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

Check for update and return boolean #2

Open
rlightner opened this issue Jul 2, 2019 · 1 comment
Open

Check for update and return boolean #2

rlightner opened this issue Jul 2, 2019 · 1 comment

Comments

@rlightner
Copy link

I'd like to check for an update, update my display, and the preform the update so the user knows what's happening, but I can't seem to do this currently.

@AlexArGC
Copy link

I'd like to check for an update, update my display, and the preform the update so the user knows what's happening, but I can't seem to do this currently.

It's possible! Because the Updater.cpp library already has a callback function.
For example, create your own callback function (here using serial and LCD):

void OnProgress(int progress, int totalt)
{
   static int last = 0;
   int progressPercent = (100 * progress) / totalt;
   Serial.print(".");
   if (last != progressPercent && progressPercent % 5 == 0)
   {
     // print to 5%
     Serial.println(progressPercent);
     lcd.setCursor(progressPercent / 5 - 1, 2);
     lcd.print(char(255));
   }
   last = progressPercent;
}

And before running updater.CheckAndUpdate(); run the code:

// set update callback function
Update.onProgress(OnProgress);
updater.CheckAndUpdate();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants