Changeset - e12ecbf1cb9f
[Not reviewed]
default
0 1 0
Dennis Fink - 6 years ago 2018-02-06 20:46:20
dennis.fink@c3l.lu
Save 8 bytes, by calling millis twice and not storing it an variable
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Neopixel_Goggles.ino
Show inline comments
 
@@ -300,10 +300,16 @@ void setup() {
 

	
 
void loop() {
 
  Rings.Update();
 
  uint32_t t = millis();
 
  if ((t - prev_time) >= MODE_CHANGE_TIME) {
 
  /*
 
   * We could store the return of the first millis call in a variable.
 
   * But this routine is fast, so we only loose some milliseconds (if even)
 
   * and we are not that time critical, that the MODE changes extacly after
 
   * MODE_CHANGE_TIME. Calling millis twice, saves us 8 bytes, which is critical
 
   * for the small storage space we have.
 
   */
 
  if ((millis() - prev_time) >= MODE_CHANGE_TIME) {
 
    mode = random(0, 9);
 
    prev_time = t;
 
    prev_time = millis();
 
  }
 
}
 

	
0 comments (0 inline, 0 general)