Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter to set delay time in readPicture() #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Adafruit_VC0706.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ uint8_t Adafruit_VC0706::available(void) { return bufferLen; }
@returns Pointer to buffer containing n bytes of picture data
*/
/**************************************************************************/
uint8_t *Adafruit_VC0706::readPicture(uint8_t n) {
uint8_t *Adafruit_VC0706::readPicture(uint8_t n, uint32_t delay_time) {
uint8_t args[] = {0x0C,
0x0,
0x0A,
Expand All @@ -556,14 +556,17 @@ uint8_t *Adafruit_VC0706::readPicture(uint8_t n) {
0,
0,
n,
CAMERADELAY >> 8,
CAMERADELAY & 0xFF};
delay_time >> 8,
delay_time & 0xFF};

if (!runCommand(VC0706_READ_FBUF, args, sizeof(args), 5, false))
{
Serial.println("VC0706: Read fbuf failed - delay time too small?");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the error condition that the code hits when the delay time is too small, so let the user know what the possible cause is.

return 0;
}

// read into the buffer PACKETLEN!
if (readResponse(n + 5, CAMERADELAY) == 0)
if (readResponse(n + 5, delay_time) == 0)
return 0;

frameptr += n;
Expand Down
2 changes: 1 addition & 1 deletion Adafruit_VC0706.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Adafruit_VC0706 {
boolean TVon(void);
boolean TVoff(void);
boolean takePicture(void);
uint8_t *readPicture(uint8_t n);
uint8_t *readPicture(uint8_t n, uint32_t delay_time = CAMERADELAY);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CAMERADELAY as the default so that everything works normally if no delay_time value is given.

boolean resumeVideo(void);
uint32_t frameLength(void);
char *getVersion(void);
Expand Down
Loading