From 2e1d18f42d4db1d56ac411319f0274616f4cd504 Mon Sep 17 00:00:00 2001 From: Patrick Ecord Date: Fri, 21 Jul 2017 19:03:36 -0500 Subject: [PATCH 1/2] Fixes compile error for wifi --- BadgeCode/BadgeCode.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BadgeCode/BadgeCode.ino b/BadgeCode/BadgeCode.ino index c307c2c..a61bd1d 100644 --- a/BadgeCode/BadgeCode.ino +++ b/BadgeCode/BadgeCode.ino @@ -411,7 +411,7 @@ void wifiOn(){ oled.putString ("Wifi ON"); oled.setTextXY (2,2); oled.putString (ssid); - WiFi.softAP(ssid, NULL, 1, 0, 1); + WiFi.softAP(ssid, NULL, 1, 0); wifiStatus = 1; delay (2000); settingsMenu(); From 823027bc4413a459297d988bcc6c3faf28b22837 Mon Sep 17 00:00:00 2001 From: Patrick Ecord Date: Fri, 21 Jul 2017 21:06:50 -0500 Subject: [PATCH 2/2] cleaned up the bling function * put images in an array `bitmaps` * made `repeat` a boolean * changed `imageTimer` to `currentTime` * added `transitionTime` * it is two seconds ahead of the current time * added code to handle exiting to main menu --- BadgeCode/BadgeCode.ino | 45 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/BadgeCode/BadgeCode.ino b/BadgeCode/BadgeCode.ino index a61bd1d..c425b52 100644 --- a/BadgeCode/BadgeCode.ino +++ b/BadgeCode/BadgeCode.ino @@ -201,26 +201,37 @@ void drawBling() if (debug == 1){ Serial.println ("Draw Bling Called"); } - int repeat = 1; - long imageTimer = millis(); + bool repeat = true; + unsigned long currentTime = millis(); + long transitionTime = millis() + 2000L; //cycle in two secs digitalWrite(ledPin, LOW); //LED is OFF oled.clearDisplay(); // clear the display SecKC DefCon Bitmap - while (repeat > 0) { - if(millis() - imageTimer <= 2000) - { - oled.drawBitmap(SecKCFuzzy,1024); + //array of bitmaps + unsigned char* bitmaps[] = {SecKCFuzzy, BobSmall, DCXXV, DCP}; + // take the total size of the array, divide by the size of an array element + // then subtract one to convert it to a zero-based index + int numBitmaps = (sizeof(bitmaps) / sizeof(unsigned char*)) -1; + int bitmapIndex = 0; + while (repeat) { // todo - exit on button press + if (currentTime <= transitionTime) { // we got time to burn + currentTime = millis(); + oled.drawBitmap(bitmaps[bitmapIndex], 1024); //re-draw the image + } else { // time to change the image + currentTime = millis(); + transitionTime = millis() + 2000L; + if (bitmapIndex < numBitmaps) { + bitmapIndex = bitmapIndex + 1; + } else { + bitmapIndex = 0; // reset the index + } + oled.drawBitmap(bitmaps[bitmapIndex], 1024); } - if((millis() - imageTimer >= 2001) && (millis() - imageTimer <= 4000)){ - oled.drawBitmap(BobSmall,1024); - } - if((millis() - imageTimer >= 4001) && (millis() - imageTimer <= 6000)){ - oled.drawBitmap(DCXXV,1024); - } - if((millis() - imageTimer >= 6001) && (millis() - imageTimer <= 8000)){ - oled.drawBitmap(DCP,1024); - } - if(millis() - imageTimer >= 8001){ - imageTimer = millis(); + // check for button press to exit to main menu + debounceButtonLeft.update(); + debounceButtonLeft.read(); + if (debounceButtonLeft.fell()) { + repeat = false; + returnToMenu(1); } } }