Skip to content

Commit 192c3c0

Browse files
committed
Added a delay method on Scout to allow the system to continue performing system tasks
Added Scout.delay() - this will handle when the millis rolls over (~ every 52 days of hardware uptime) Updated the examples to use this feature. Also updated the BlinkRGB to show using specified blink delay values and using the default (500ms)
1 parent 2bba333 commit 192c3c0

File tree

7 files changed

+23
-10
lines changed

7 files changed

+23
-10
lines changed

Scout.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ void PinoccioScout::loop() {
7878
}
7979
}
8080

81+
void PinoccioScout::delay(unsigned long ms) {
82+
unsigned long target = millis() + ms;
83+
while ((long)(millis() - target) < 0) {
84+
loop();
85+
}
86+
}
87+
8188
bool PinoccioScout::isBatteryCharging() {
8289
return isBattCharging;
8390
}

Scout.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PinoccioScout : public PinoccioClass {
2424

2525
void setup(bool isForcedLeadScout=false);
2626
void loop();
27+
void delay(unsigned long ms);
2728

2829
bool isBatteryCharging();
2930
int getBatteryPercentage();

examples/Peripherals/BlinkRGB/BlinkRGB.ino

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ void setup() {
99
void loop() {
1010
Scout.loop();
1111

12-
RgbLed.blinkRed();
13-
delay(1000);
12+
// blink once for 250ms
13+
RgbLed.blinkRed(250);
14+
Scout.delay(1000);
15+
16+
// blink once using the default (500ms)
1417
RgbLed.blinkGreen();
15-
delay(1000);
16-
RgbLed.blinkBlue();
17-
delay(1000);
18+
Scout.delay(1000);
19+
20+
// blink once using 750ms
21+
RgbLed.blinkBlue(750);
22+
Scout.delay(1000);
1823
}

examples/Peripherals/Temperature/Temperature.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ void loop() {
1212
Serial.print("Temperature: ");
1313
Serial.println(Scout.getTemperature());
1414

15-
delay(1000);
15+
Scout.delay(1000);
1616
}

examples/Peripherals/TrueRandomNumber/TrueRandomNumber.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ void loop() {
1212
Serial.print("Random Number: ");
1313
Serial.println(Scout.getRandomNumber());
1414

15-
delay(1000);
15+
Scout.delay(1000);
1616
}

examples/Power/BackpackPower/BackpackPower.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ void loop() {
1111

1212
Scout.enableBackpackVcc();
1313
Serial.println("Backpack VCC is on.");
14-
delay(3000);
14+
Scout.delay(3000);
1515

1616
Scout.disableBackpackVcc();
1717
Serial.println("Backpack VCC is off.");
18-
delay(3000);
18+
Scout.delay(3000);
1919
}

examples/Power/BatteryStatus/BatteryStatus.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ void loop() {
2323
}
2424

2525
Serial.println("");
26-
delay(3000);
26+
Scout.delay(3000);
2727
}

0 commit comments

Comments
 (0)