Skip to content

Commit bdb1c6d

Browse files
committed
Unify data type for time variables
The three variables used in the main loop were all different data types, which would likely cause roll-over issues at ~25 or ~50 days of run time. This fix changes the api_mtbs and api_lasttime to match the unsigned long type used by the millis() function and tweaks the main loop comparison.
1 parent 18eee39 commit bdb1c6d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/ESP8266/ChannelStatistics/ChannelStatistics.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ char password[] = "yyyy"; // your network key
2323
WiFiClientSecure client;
2424
YoutubeApi api(API_KEY, client);
2525

26-
int api_mtbs = 60000; //mean time between api requests
27-
long api_lasttime; //last time api request has been done
26+
unsigned long api_mtbs = 60000; //mean time between api requests
27+
unsigned long api_lasttime; //last time api request has been done
2828

2929
long subs = 0;
3030

@@ -57,7 +57,7 @@ void setup() {
5757

5858
void loop() {
5959

60-
if (millis() > api_lasttime + api_mtbs) {
60+
if (millis() - api_lasttime > api_mtbs) {
6161
if(api.getChannelStatistics(CHANNEL_ID))
6262
{
6363
Serial.println("---------Stats---------");

0 commit comments

Comments
 (0)