From e40fafa074e27773137a23de4f0deac8ff7ef2d3 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Tue, 21 Feb 2023 23:51:41 +0900 Subject: [PATCH 01/29] del trailing spaces and add last line --- ESP32_BadApple.ino | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 3c34271..64a6c89 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -4,7 +4,7 @@ #include "SSD1306.h" #include "heatshrink_decoder.h" -// Hints: +// Hints: // * Adjust the display pins below // * After uploading to ESP32, also do "ESP32 Sketch Data Upload" from Arduino @@ -17,7 +17,7 @@ SSD1306 display (0x3c, 4, 15); // For Heltec static heatshrink_decoder hsd; -// global storage for putPixels +// global storage for putPixels int16_t curr_x = 0; int16_t curr_y = 0; @@ -64,9 +64,9 @@ void putPixels(uint8_t c, int32_t len) { b = 128; for(int i=0; i<8; i++) { if(c & b) { - display.setColor(WHITE); + display.setColor(WHITE); } else { - display.setColor(BLACK); + display.setColor(BLACK); } b >>= 1; display.setPixel(curr_x, curr_y); @@ -116,8 +116,8 @@ void decodeRLE(uint8_t c) { } else { putPixels(255, runlength); } - c_to_dup = -1; - runlength = -1; + c_to_dup = -1; + runlength = -1; } } } @@ -127,12 +127,12 @@ void decodeRLE(uint8_t c) { void readFile(fs::FS &fs, const char * path){ static uint8_t rle_buf[RLEBUFSIZE]; size_t rle_bufhead = 0; - size_t rle_size = 0; - + size_t rle_size = 0; + size_t filelen = 0; size_t filesize; static uint8_t compbuf[READBUFSIZE]; - + Serial.printf("Reading file: %s\n", path); File file = fs.open(path); if(!file || file.isDirectory()){ @@ -150,8 +150,8 @@ void readFile(fs::FS &fs, const char * path){ curr_x = 0; curr_y = 0; runlength = -1; - c_to_dup = -1; - lastRefresh = millis(); + c_to_dup = -1; + lastRefresh = millis(); // init decoder heatshrink_decoder_reset(&hsd); @@ -160,7 +160,7 @@ void readFile(fs::FS &fs, const char * path){ size_t toRead; size_t toSink = 0; uint32_t sinkHead = 0; - + // Go through file... while(filelen) { @@ -177,14 +177,14 @@ void readFile(fs::FS &fs, const char * path){ HSD_sink_res sres; sres = heatshrink_decoder_sink(&hsd, &compbuf[sinkHead], toSink, &count); //Serial.print("^^ sinked "); - //Serial.println(count); + //Serial.println(count); toSink -= count; - sinkHead = count; + sinkHead = count; sunk += count; if (sunk == filesize) { heatshrink_decoder_finish(&hsd); } - + HSD_poll_res pres; do { rle_size = 0; @@ -225,7 +225,7 @@ void setup(){ display.setFont(ArialMT_Plain_10); display.setColor(WHITE); display.drawString(0, 0, "Mounting SPIFFS... "); - display.display(); + display.display(); if(!SPIFFS.begin()){ Serial.println("SPIFFS mount failed"); display.drawStringMaxWidth(0, 10, 128, "SPIFFS mount failed. Upload video.hs using ESP32 Sketch Upload."); display.display(); @@ -252,4 +252,5 @@ void setup(){ void loop(){ -} +} + From d76023401bc675fd5c6eb35f52aac7265b5c94a3 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Wed, 22 Feb 2023 23:33:37 +0900 Subject: [PATCH 02/29] SSD1306 display I2C bus For Wemos Lolin32 ESP32 --- ESP32_BadApple.ino | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 64a6c89..e18f191 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -8,8 +8,17 @@ // * Adjust the display pins below // * After uploading to ESP32, also do "ESP32 Sketch Data Upload" from Arduino -SSD1306 display (0x3c, 4, 15); // For Heltec -//SSD1306 display (0x3c, 5, 4); +// SSD1306 display I2C bus +// For Heltec +// #define I2C_SCL 15 +// #define I2C_SDA 4 +// #define RESET_OLED 16 + +// For Wemos Lolin32 ESP32 +#define I2C_SCL 4 +#define I2C_SDA 5 + +SSD1306 display (0x3c, I2C_SDA, I2C_SCL); #if HEATSHRINK_DYNAMIC_ALLOC #error HEATSHRINK_DYNAMIC_ALLOC must be false for static allocation test suite. @@ -216,8 +225,10 @@ void readFile(fs::FS &fs, const char * path){ void setup(){ Serial.begin(115200); +#ifdef RESET_OLED // Reset for some displays - pinMode(16,OUTPUT); digitalWrite(16, LOW); delay(50); digitalWrite(16, HIGH); + pinMode(RESET_OLED, OUTPUT); digitalWrite(RESET_OLED, LOW); delay(50); digitalWrite(RESET_OLED, HIGH); +#endif display.init(); display.flipScreenVertically (); display.clear(); From 63d5239a761fd879e50b2694b8535b4e9c523e25 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Wed, 22 Feb 2023 23:56:14 +0900 Subject: [PATCH 03/29] mod Difine OLED setBrightness --- ESP32_BadApple.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index e18f191..7189435 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -18,6 +18,8 @@ #define I2C_SCL 4 #define I2C_SDA 5 +#define OLED_BRIGHTNESS 16 + SSD1306 display (0x3c, I2C_SDA, I2C_SCL); #if HEATSHRINK_DYNAMIC_ALLOC @@ -230,6 +232,9 @@ void setup(){ pinMode(RESET_OLED, OUTPUT); digitalWrite(RESET_OLED, LOW); delay(50); digitalWrite(RESET_OLED, HIGH); #endif display.init(); +#ifdef OLED_BRIGHTNESS + display.setBrightness(OLED_BRIGHTNESS); +#endif display.flipScreenVertically (); display.clear(); display.setTextAlignment (TEXT_ALIGN_LEFT); From d880588818d6c3ae4e4840abf524d54bd92eaecf Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Wed, 22 Feb 2023 23:57:51 +0900 Subject: [PATCH 04/29] mod Difine Board Boot SW GPIO 0 --- ESP32_BadApple.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 7189435..4eb6047 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -4,6 +4,9 @@ #include "SSD1306.h" #include "heatshrink_decoder.h" +// Board Boot SW GPIO 0 +#define BOOT_SW 0 + // Hints: // * Adjust the display pins below // * After uploading to ESP32, also do "ESP32 Sketch Data Upload" from Arduino @@ -90,7 +93,7 @@ void putPixels(uint8_t c, int32_t len) { display.display(); //display.clear(); // 30 fps target rate - if(digitalRead(0)) while((millis() - lastRefresh) < 33) ; + if(digitalRead(BOOT_SW)) while((millis() - lastRefresh) < 33) ; lastRefresh = millis(); } } @@ -248,7 +251,7 @@ void setup(){ return; } - pinMode(0, INPUT_PULLUP); + pinMode(BOOT_SW, INPUT_PULLUP); Serial.print("totalBytes(): "); Serial.println(SPIFFS.totalBytes()); Serial.print("usedBytes(): "); From a6f330cbc9ecb95ae023894e1cdaae098ca69a80 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Wed, 22 Feb 2023 23:58:25 +0900 Subject: [PATCH 05/29] mod Add Reset to Infinite Loop Demo ! --- ESP32_BadApple.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 4eb6047..7bdbe82 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -224,6 +224,11 @@ void readFile(fs::FS &fs, const char * path){ } file.close(); Serial.println("Done."); + + // 10 sec + delay(10000); + // Reset to Infinite Loop Demo ! + ESP.restart(); } From dedd45f6c43eaf9b8bf4342e965009c5f972e17b Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:16:07 +0900 Subject: [PATCH 06/29] mod More Accurate frame rate --- ESP32_BadApple.ino | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 7bdbe82..a2b30c1 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -70,7 +70,9 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ } } -uint32_t lastRefresh = 0; +unsigned long lastRefresh = 0; +// 30 fps target rate = 33.333us +#define FRAME_DERAY_US 33333UL void putPixels(uint8_t c, int32_t len) { uint8_t b = 0; @@ -90,11 +92,14 @@ void putPixels(uint8_t c, int32_t len) { curr_y++; if(curr_y >= 64) { curr_y = 0; + + // Update Display frame display.display(); //display.clear(); - // 30 fps target rate - if(digitalRead(BOOT_SW)) while((millis() - lastRefresh) < 33) ; - lastRefresh = millis(); + + // 30 fps target rate = 33.333us + lastRefresh += FRAME_DERAY_US; + if(digitalRead(BOOT_SW)) while(micros() < lastRefresh) ; } } } @@ -165,7 +170,6 @@ void readFile(fs::FS &fs, const char * path){ curr_y = 0; runlength = -1; c_to_dup = -1; - lastRefresh = millis(); // init decoder heatshrink_decoder_reset(&hsd); @@ -175,6 +179,7 @@ void readFile(fs::FS &fs, const char * path){ size_t toSink = 0; uint32_t sinkHead = 0; + lastRefresh = micros(); // Go through file... while(filelen) { From e5bf0367c4076d800307d708d0412447ee702a40 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:17:21 +0900 Subject: [PATCH 07/29] fix No wait mode delay Bug and Optimize Button handring --- ESP32_BadApple.ino | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index a2b30c1..9d7319a 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -70,10 +70,17 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ } } -unsigned long lastRefresh = 0; +volatile unsigned long lastRefresh = 0; // 30 fps target rate = 33.333us #define FRAME_DERAY_US 33333UL +volatile bool isButtonPressing = false; + +void ARDUINO_ISR_ATTR isr() { + lastRefresh = micros(); + isButtonPressing = (digitalRead(BOOT_SW) == LOW); +} + void putPixels(uint8_t c, int32_t len) { uint8_t b = 0; while(len--) { @@ -97,9 +104,11 @@ void putPixels(uint8_t c, int32_t len) { display.display(); //display.clear(); - // 30 fps target rate = 33.333us - lastRefresh += FRAME_DERAY_US; - if(digitalRead(BOOT_SW)) while(micros() < lastRefresh) ; + if(!isButtonPressing) { + // 30 fps target rate = 33.333us + lastRefresh += FRAME_DERAY_US; + while(micros() < lastRefresh) ; + } } } } @@ -262,6 +271,7 @@ void setup(){ } pinMode(BOOT_SW, INPUT_PULLUP); + attachInterrupt(BOOT_SW, isr, CHANGE); Serial.print("totalBytes(): "); Serial.println(SPIFFS.totalBytes()); Serial.print("usedBytes(): "); From 1974d0509912a07bed7b81d0cf472700648180c0 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:18:24 +0900 Subject: [PATCH 08/29] mod Add Frame counter and More Accurate frame rate --- ESP32_BadApple.ino | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 9d7319a..09790b7 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -7,6 +7,9 @@ // Board Boot SW GPIO 0 #define BOOT_SW 0 +// Frame counter +#define ENABLE_FRAME_COUNTER + // Hints: // * Adjust the display pins below // * After uploading to ESP32, also do "ESP32 Sketch Data Upload" from Arduino @@ -73,6 +76,9 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ volatile unsigned long lastRefresh = 0; // 30 fps target rate = 33.333us #define FRAME_DERAY_US 33333UL +#ifdef ENABLE_FRAME_COUNTER +int32_t frame = 0; +#endif volatile bool isButtonPressing = false; @@ -107,6 +113,10 @@ void putPixels(uint8_t c, int32_t len) { if(!isButtonPressing) { // 30 fps target rate = 33.333us lastRefresh += FRAME_DERAY_US; +#ifdef ENABLE_FRAME_COUNTER + // Adjust 33.334us every 3 frame + if ((++frame % 3) == 0) lastRefresh++; +#endif while(micros() < lastRefresh) ; } } @@ -237,7 +247,12 @@ void readFile(fs::FS &fs, const char * path){ } while (pres == HSDR_POLL_MORE); } file.close(); +#ifdef ENABLE_FRAME_COUNTER + Serial.print("Done. "); + Serial.println(frame); +#else Serial.println("Done."); +#endif // 10 sec delay(10000); From 6d3a0d075886192780af8b293d724a326aae2fca Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 19:09:07 +0900 Subject: [PATCH 09/29] mod Disable heatshrink error checking --- ESP32_BadApple.ino | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 09790b7..4f9b36c 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -10,6 +10,9 @@ // Frame counter #define ENABLE_FRAME_COUNTER +// Disable heatshrink error checking +#define DISABLE_HS_ERROR + // Hints: // * Adjust the display pins below // * After uploading to ESP32, also do "ESP32 Sketch Data Upload" from Arduino @@ -229,19 +232,23 @@ void readFile(fs::FS &fs, const char * path){ pres = heatshrink_decoder_poll(&hsd, rle_buf, RLEBUFSIZE, &rle_size); //Serial.print("^^ polled "); //Serial.println(rle_size); +#ifndef DISABLE_HS_ERROR if(pres < 0) { Serial.print("POLL ERR! "); Serial.println(pres); return; } +#endif rle_bufhead = 0; while(rle_size) { rle_size--; +#ifndef DISABLE_HS_ERROR if(rle_bufhead >= RLEBUFSIZE) { Serial.println("RLE_SIZE ERR!"); return; } +#endif decodeRLE(rle_buf[rle_bufhead++]); } } while (pres == HSDR_POLL_MORE); From f60d4ea70ec912ed5b30b8c11f66416176994068 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 00:05:46 +0900 Subject: [PATCH 10/29] mod Optimize readFile display.resetDisplay() --- ESP32_BadApple.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 4f9b36c..c43fcc8 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -186,8 +186,7 @@ void readFile(fs::FS &fs, const char * path){ Serial.printf("File size: %d\n", filelen); // init display, putPixels and decodeRLE - display.clear(); - display.display(); + display.resetDisplay(); curr_x = 0; curr_y = 0; runlength = -1; From fc772eb9243bbfec03c2a006acdd333fb5971bb6 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 00:06:12 +0900 Subject: [PATCH 11/29] mod Optimize readFile file.read --- ESP32_BadApple.ino | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index c43fcc8..5761cd1 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -196,7 +196,6 @@ void readFile(fs::FS &fs, const char * path){ heatshrink_decoder_reset(&hsd); size_t count = 0; uint32_t sunk = 0; - size_t toRead; size_t toSink = 0; uint32_t sinkHead = 0; @@ -205,11 +204,8 @@ void readFile(fs::FS &fs, const char * path){ // Go through file... while(filelen) { if(toSink == 0) { - toRead = filelen; - if(toRead > READBUFSIZE) toRead = READBUFSIZE; - file.read(compbuf, toRead); - filelen -= toRead; - toSink = toRead; + toSink = file.read(compbuf, READBUFSIZE); + filelen -= toSink; sinkHead = 0; } From 87a7075e4d8c429f4cb58bee4ecdcbe05e51d730 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 00:06:40 +0900 Subject: [PATCH 12/29] mod Optimize readFile delete Unused HSD_sink_res --- ESP32_BadApple.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 5761cd1..1d61f96 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -210,8 +210,7 @@ void readFile(fs::FS &fs, const char * path){ } // uncompress buffer - HSD_sink_res sres; - sres = heatshrink_decoder_sink(&hsd, &compbuf[sinkHead], toSink, &count); + heatshrink_decoder_sink(&hsd, &compbuf[sinkHead], toSink, &count); //Serial.print("^^ sinked "); //Serial.println(count); toSink -= count; From 20d1711a4f958e90bba682902eac7b37f9296c2b Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 00:07:13 +0900 Subject: [PATCH 13/29] mod Optimize readFile decodeRLE rle_buf --- ESP32_BadApple.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 1d61f96..daeb558 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -167,7 +167,7 @@ void decodeRLE(uint8_t c) { #define READBUFSIZE 2048 void readFile(fs::FS &fs, const char * path){ static uint8_t rle_buf[RLEBUFSIZE]; - size_t rle_bufhead = 0; + uint8_t* p_rle_buf; size_t rle_size = 0; size_t filelen = 0; @@ -234,7 +234,7 @@ void readFile(fs::FS &fs, const char * path){ } #endif - rle_bufhead = 0; + p_rle_buf = rle_buf; while(rle_size) { rle_size--; #ifndef DISABLE_HS_ERROR @@ -243,7 +243,7 @@ void readFile(fs::FS &fs, const char * path){ return; } #endif - decodeRLE(rle_buf[rle_bufhead++]); + decodeRLE(*(p_rle_buf++)); } } while (pres == HSDR_POLL_MORE); } From 0fb001b2e9a48985ed813ab524de93521a4f777a Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:21:00 +0900 Subject: [PATCH 14/29] mod Optimize int16_t to int32_t for Reduse Program size 12 byte (323437 bytes to 323425 bytes) --- ESP32_BadApple.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index daeb558..06e21d0 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -38,8 +38,8 @@ SSD1306 display (0x3c, I2C_SDA, I2C_SCL); static heatshrink_decoder hsd; // global storage for putPixels -int16_t curr_x = 0; -int16_t curr_y = 0; +int32_t curr_x = 0; +int32_t curr_y = 0; // global storage for decodeRLE int32_t runlength = -1; From c33224c48ebb17a068a2d9da65b414b71a69b322 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:21:48 +0900 Subject: [PATCH 15/29] mod Optimize int16_t to int32_t for Reduse Program size 24 byte (323425 bytes to 323401 bytes) --- ESP32_BadApple.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 06e21d0..1366c39 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -90,8 +90,8 @@ void ARDUINO_ISR_ATTR isr() { isButtonPressing = (digitalRead(BOOT_SW) == LOW); } -void putPixels(uint8_t c, int32_t len) { - uint8_t b = 0; +void putPixels(uint32_t c, int32_t len) { + uint32_t b = 0; while(len--) { b = 128; for(int i=0; i<8; i++) { @@ -128,7 +128,7 @@ void putPixels(uint8_t c, int32_t len) { } } -void decodeRLE(uint8_t c) { +void decodeRLE(uint32_t c) { if(c_to_dup == -1) { if((c == 0x55) || (c == 0xaa)) { c_to_dup = c; From fab9458897799459870bfababf3b3ce429da2178 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Mon, 27 Feb 2023 14:41:36 +0900 Subject: [PATCH 16/29] mod I2C SCLK 700kHz to 4MHz (However, Actual measured value is 892 kHz) --- ESP32_BadApple.ino | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 1366c39..c904a45 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -29,7 +29,15 @@ #define OLED_BRIGHTNESS 16 +// MAX freq for SCL is 4 MHz, However, Actual measured value is 892 kHz . (ESP32-D0WDQ6 (revision 1)) +// see Inter-Integrated Circuit (I2C) +// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2c.html +#define I2C_SCLK_FREQ 4000000 +#ifdef I2C_SCLK_FREQ +SSD1306 display (0x3c, I2C_SDA, I2C_SCL, GEOMETRY_128_64, I2C_ONE, I2C_SCLK_FREQ); +#else SSD1306 display (0x3c, I2C_SDA, I2C_SCL); +#endif #if HEATSHRINK_DYNAMIC_ALLOC #error HEATSHRINK_DYNAMIC_ALLOC must be false for static allocation test suite. From 1b53b91cc557993d207c0cb07e30d9a49793fdd0 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Mon, 27 Feb 2023 14:44:51 +0900 Subject: [PATCH 17/29] mod Add Enable I2C Clock up 892kHz to 1.31MHz (It Actual measured value) --- ESP32_BadApple.ino | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index c904a45..ddb0e3b 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -39,6 +39,9 @@ SSD1306 display (0x3c, I2C_SDA, I2C_SCL, GEOMETRY_128_64, I2C_ONE, I2C_SCLK_FREQ SSD1306 display (0x3c, I2C_SDA, I2C_SCL); #endif +// Enable I2C Clock up 892kHz to 1.31MHz (It Actual measured value with ESP32-D0WDQ6 (revision 1)) +// #define ENABLE_EXTRA_I2C_CLOCK_UP + #if HEATSHRINK_DYNAMIC_ALLOC #error HEATSHRINK_DYNAMIC_ALLOC must be false for static allocation test suite. #endif @@ -301,6 +304,21 @@ void setup(){ Serial.print("usedBytes(): "); Serial.println(SPIFFS.usedBytes()); listDir(SPIFFS, "/", 0); + +#ifdef ENABLE_EXTRA_I2C_CLOCK_UP + // Direct Access I2C SCL frequency setting value + // It Tested ESP32-D0WDQ6 (revision 1) + uint32_t* ptr; + ptr = (uint32_t*)0x3FF53000; // I2C_SCL_LOW_PERIOD_REG + // *ptr = 30; // Don't work + // *ptr = 31; // Sometime Stop Frame drawing + // *ptr = 32; // Works + *ptr = 35; // Safety value + ptr = (uint32_t*)0x3FF53038; // I2C_SCL_HIGH_PERIOD_REG + // *ptr = 0; // Works + *ptr = 2; // Safety value +#endif + readFile(SPIFFS, "/video.hs"); //Serial.print("Format SPIFSS? (enter y for yes): "); From dbcd6fe269458c6afc99214acd019e28443d378c Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Mon, 27 Feb 2023 14:45:31 +0900 Subject: [PATCH 18/29] mod Optimize Direct Draw OLED buffer --- ESP32_BadApple.ino | 54 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index ddb0e3b..b11cd72 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -93,6 +93,8 @@ volatile unsigned long lastRefresh = 0; #ifdef ENABLE_FRAME_COUNTER int32_t frame = 0; #endif +uint8_t* pImage; +uint32_t b = 0x01; volatile bool isButtonPressing = false; @@ -102,23 +104,46 @@ void ARDUINO_ISR_ATTR isr() { } void putPixels(uint32_t c, int32_t len) { - uint32_t b = 0; while(len--) { - b = 128; - for(int i=0; i<8; i++) { - if(c & b) { - display.setColor(WHITE); - } else { - display.setColor(BLACK); - } - b >>= 1; - display.setPixel(curr_x, curr_y); - curr_x++; - if(curr_x >= 128) { - curr_x = 0; + // Direct Draw OLED buffer + // OLED Buffer Image Rotate 90 Convert X-Y and Byte structure + if (b == 0x01) { + *(pImage++) = (c & 0x80) ? b : 0; + *(pImage++) = (c & 0x40) ? b : 0; + *(pImage++) = (c & 0x20) ? b : 0; + *(pImage++) = (c & 0x10) ? b : 0; + + *(pImage++) = (c & 0x08) ? b : 0; + *(pImage++) = (c & 0x04) ? b : 0; + *(pImage++) = (c & 0x02) ? b : 0; + *(pImage++) = (c & 0x01) ? b : 0; + } else { + *(pImage++) |= (c & 0x80) ? b : 0; + *(pImage++) |= (c & 0x40) ? b : 0; + *(pImage++) |= (c & 0x20) ? b : 0; + *(pImage++) |= (c & 0x10) ? b : 0; + + *(pImage++) |= (c & 0x08) ? b : 0; + *(pImage++) |= (c & 0x04) ? b : 0; + *(pImage++) |= (c & 0x02) ? b : 0; + *(pImage++) |= (c & 0x01) ? b : 0; + } + + curr_x++; + if(curr_x == 128/8) { + curr_x = 0; + pImage -= 128; + + b <<= 1; + if(b == 0x100) { + // Next Page + pImage += 128; + b = 0x01; + curr_y++; - if(curr_y >= 64) { + if(curr_y == 8) { curr_y = 0; + pImage = display.buffer; // Update Display frame display.display(); @@ -200,6 +225,7 @@ void readFile(fs::FS &fs, const char * path){ display.resetDisplay(); curr_x = 0; curr_y = 0; + pImage = display.buffer; runlength = -1; c_to_dup = -1; From d83deb95d5b6352f950aba447022c46381e3f0f6 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 02:31:30 +0900 Subject: [PATCH 19/29] mod More Optimize Direct Draw OLED buffer --- ESP32_BadApple.ino | 54 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index b11cd72..9f91359 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -108,16 +108,48 @@ void putPixels(uint32_t c, int32_t len) { // Direct Draw OLED buffer // OLED Buffer Image Rotate 90 Convert X-Y and Byte structure if (b == 0x01) { - *(pImage++) = (c & 0x80) ? b : 0; - *(pImage++) = (c & 0x40) ? b : 0; - *(pImage++) = (c & 0x20) ? b : 0; - *(pImage++) = (c & 0x10) ? b : 0; - - *(pImage++) = (c & 0x08) ? b : 0; - *(pImage++) = (c & 0x04) ? b : 0; - *(pImage++) = (c & 0x02) ? b : 0; - *(pImage++) = (c & 0x01) ? b : 0; - } else { + if (c == 0xff) { + *(pImage++) = b; + *(pImage++) = b; + *(pImage++) = b; + *(pImage++) = b; + + *(pImage++) = b; + *(pImage++) = b; + *(pImage++) = b; + *(pImage++) = b; + } else if (c != 0x00) { + *(pImage++) = (c & 0x80) ? b : 0; + *(pImage++) = (c & 0x40) ? b : 0; + *(pImage++) = (c & 0x20) ? b : 0; + *(pImage++) = (c & 0x10) ? b : 0; + + *(pImage++) = (c & 0x08) ? b : 0; + *(pImage++) = (c & 0x04) ? b : 0; + *(pImage++) = (c & 0x02) ? b : 0; + *(pImage++) = (c & 0x01) ? b : 0; + } else { + *(pImage++) = 0; + *(pImage++) = 0; + *(pImage++) = 0; + *(pImage++) = 0; + + *(pImage++) = 0; + *(pImage++) = 0; + *(pImage++) = 0; + *(pImage++) = 0; + } + } else if (c == 0xff) { + *(pImage++) |= b; + *(pImage++) |= b; + *(pImage++) |= b; + *(pImage++) |= b; + + *(pImage++) |= b; + *(pImage++) |= b; + *(pImage++) |= b; + *(pImage++) |= b; + } else if (c != 0x00) { *(pImage++) |= (c & 0x80) ? b : 0; *(pImage++) |= (c & 0x40) ? b : 0; *(pImage++) |= (c & 0x20) ? b : 0; @@ -127,6 +159,8 @@ void putPixels(uint32_t c, int32_t len) { *(pImage++) |= (c & 0x04) ? b : 0; *(pImage++) |= (c & 0x02) ? b : 0; *(pImage++) |= (c & 0x01) ? b : 0; + } else { + pImage += 8; } curr_x++; From a000af96a9edf2d698eede158fe45f4585dbb472 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 22:24:30 +0900 Subject: [PATCH 20/29] mod More Optimize Direct Draw OLED buffer Write 4 dot --- ESP32_BadApple.ino | 84 +++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 9f91359..b8cc40e 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -104,63 +104,47 @@ void ARDUINO_ISR_ATTR isr() { } void putPixels(uint32_t c, int32_t len) { + uint32_t d1; + uint32_t d2; + while(len--) { // Direct Draw OLED buffer // OLED Buffer Image Rotate 90 Convert X-Y and Byte structure - if (b == 0x01) { + { + // 4 dot(Direct Access 4 byte, 32 bit) + d1 = 0; + d2 = 0; if (c == 0xff) { - *(pImage++) = b; - *(pImage++) = b; - *(pImage++) = b; - *(pImage++) = b; - - *(pImage++) = b; - *(pImage++) = b; - *(pImage++) = b; - *(pImage++) = b; + d1 = b; d1 <<= 8; + d1 |= b; d1 <<= 8; + d1 |= b; d1 <<= 8; + d1 |= b; + + d2 = d1; + } else if (c != 0x00) { + d1 = (c & 0x10) ? b : 0; d1 <<= 8; + d1 |= (c & 0x20) ? b : 0; d1 <<= 8; + d1 |= (c & 0x40) ? b : 0; d1 <<= 8; + d1 |= (c & 0x80) ? b : 0; + + d2 = (c & 0x01) ? b : 0; d2 <<= 8; + d2 |= (c & 0x02) ? b : 0; d2 <<= 8; + d2 |= (c & 0x04) ? b : 0; d2 <<= 8; + d2 |= (c & 0x08) ? b : 0; + } + + if (b == 0x01) { + *(uint32_t*)pImage = d1; + pImage += 4; + *(uint32_t*)pImage = d2; } else if (c != 0x00) { - *(pImage++) = (c & 0x80) ? b : 0; - *(pImage++) = (c & 0x40) ? b : 0; - *(pImage++) = (c & 0x20) ? b : 0; - *(pImage++) = (c & 0x10) ? b : 0; - - *(pImage++) = (c & 0x08) ? b : 0; - *(pImage++) = (c & 0x04) ? b : 0; - *(pImage++) = (c & 0x02) ? b : 0; - *(pImage++) = (c & 0x01) ? b : 0; + *(uint32_t*)pImage |= d1; + pImage += 4; + *(uint32_t*)pImage |= d2; } else { - *(pImage++) = 0; - *(pImage++) = 0; - *(pImage++) = 0; - *(pImage++) = 0; - - *(pImage++) = 0; - *(pImage++) = 0; - *(pImage++) = 0; - *(pImage++) = 0; + pImage += 4; } - } else if (c == 0xff) { - *(pImage++) |= b; - *(pImage++) |= b; - *(pImage++) |= b; - *(pImage++) |= b; - - *(pImage++) |= b; - *(pImage++) |= b; - *(pImage++) |= b; - *(pImage++) |= b; - } else if (c != 0x00) { - *(pImage++) |= (c & 0x80) ? b : 0; - *(pImage++) |= (c & 0x40) ? b : 0; - *(pImage++) |= (c & 0x20) ? b : 0; - *(pImage++) |= (c & 0x10) ? b : 0; - - *(pImage++) |= (c & 0x08) ? b : 0; - *(pImage++) |= (c & 0x04) ? b : 0; - *(pImage++) |= (c & 0x02) ? b : 0; - *(pImage++) |= (c & 0x01) ? b : 0; - } else { - pImage += 8; + pImage += 4; } curr_x++; From 416ffac4bc29b8947186817e25e629f4396703ed Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 11:52:30 +0900 Subject: [PATCH 21/29] mod Change pImage uint8_t* to uint32_t* --- ESP32_BadApple.ino | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index b8cc40e..bfed29f 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -93,7 +93,7 @@ volatile unsigned long lastRefresh = 0; #ifdef ENABLE_FRAME_COUNTER int32_t frame = 0; #endif -uint8_t* pImage; +uint32_t* pImage; uint32_t b = 0x01; volatile bool isButtonPressing = false; @@ -134,34 +134,32 @@ void putPixels(uint32_t c, int32_t len) { } if (b == 0x01) { - *(uint32_t*)pImage = d1; - pImage += 4; - *(uint32_t*)pImage = d2; + *pImage++ = d1; + *pImage = d2; } else if (c != 0x00) { - *(uint32_t*)pImage |= d1; - pImage += 4; - *(uint32_t*)pImage |= d2; + *pImage++ |= d1; + *pImage |= d2; } else { - pImage += 4; + pImage++; } - pImage += 4; + pImage++; } curr_x++; if(curr_x == 128/8) { curr_x = 0; - pImage -= 128; + pImage -= 128/4; b <<= 1; if(b == 0x100) { // Next Page - pImage += 128; + pImage += 128/4; b = 0x01; curr_y++; if(curr_y == 8) { curr_y = 0; - pImage = display.buffer; + pImage = (uint32_t*)display.buffer; // Update Display frame display.display(); @@ -243,7 +241,7 @@ void readFile(fs::FS &fs, const char * path){ display.resetDisplay(); curr_x = 0; curr_y = 0; - pImage = display.buffer; + pImage = (uint32_t*)display.buffer; runlength = -1; c_to_dup = -1; From d6e9927dcfa08cba77be2785412fd43a79a9177d Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Thu, 23 Feb 2023 11:53:17 +0900 Subject: [PATCH 22/29] mod More Optimize Direct Draw OLED buffer Skip black --- ESP32_BadApple.ino | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index bfed29f..db8f9cb 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -122,15 +122,19 @@ void putPixels(uint32_t c, int32_t len) { d2 = d1; } else if (c != 0x00) { - d1 = (c & 0x10) ? b : 0; d1 <<= 8; - d1 |= (c & 0x20) ? b : 0; d1 <<= 8; - d1 |= (c & 0x40) ? b : 0; d1 <<= 8; - d1 |= (c & 0x80) ? b : 0; - - d2 = (c & 0x01) ? b : 0; d2 <<= 8; - d2 |= (c & 0x02) ? b : 0; d2 <<= 8; - d2 |= (c & 0x04) ? b : 0; d2 <<= 8; - d2 |= (c & 0x08) ? b : 0; + if ((c & 0xF0) != 0x00) { + d1 = (c & 0x10) ? b : 0; d1 <<= 8; + d1 |= (c & 0x20) ? b : 0; d1 <<= 8; + d1 |= (c & 0x40) ? b : 0; d1 <<= 8; + d1 |= (c & 0x80) ? b : 0; + } + + if ((c & 0x0F) != 0x00) { + d2 = (c & 0x01) ? b : 0; d2 <<= 8; + d2 |= (c & 0x02) ? b : 0; d2 <<= 8; + d2 |= (c & 0x04) ? b : 0; d2 <<= 8; + d2 |= (c & 0x08) ? b : 0; + } } if (b == 0x01) { From 0d8c4d5a16f39f2185a2e235b9a85ab16e6cd247 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:26:44 +0900 Subject: [PATCH 23/29] mod More Optimize bit operation Reduse Program size 8 byte (323437 bytes to 323429 bytes) --- ESP32_BadApple.ino | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index db8f9cb..6a4b172 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -123,17 +123,17 @@ void putPixels(uint32_t c, int32_t len) { d2 = d1; } else if (c != 0x00) { if ((c & 0xF0) != 0x00) { - d1 = (c & 0x10) ? b : 0; d1 <<= 8; - d1 |= (c & 0x20) ? b : 0; d1 <<= 8; - d1 |= (c & 0x40) ? b : 0; d1 <<= 8; - d1 |= (c & 0x80) ? b : 0; + d1 = (c & 0x10) ? b<<24 : 0; + d1 |= (c & 0x20) ? b<<16 : 0; + d1 |= (c & 0x40) ? b<< 8 : 0; + d1 |= (c & 0x80) ? b : 0; } if ((c & 0x0F) != 0x00) { - d2 = (c & 0x01) ? b : 0; d2 <<= 8; - d2 |= (c & 0x02) ? b : 0; d2 <<= 8; - d2 |= (c & 0x04) ? b : 0; d2 <<= 8; - d2 |= (c & 0x08) ? b : 0; + d2 = (c & 0x01) ? b<<24 : 0; + d2 |= (c & 0x02) ? b<<16 : 0; + d2 |= (c & 0x04) ? b<< 8 : 0; + d2 |= (c & 0x08) ? b : 0; } } From fac4c486ca3108ce99fd79cd6a5d006d57d4757f Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 14:27:43 +0900 Subject: [PATCH 24/29] mod More Optimize bit operation Reduse Program size 32 byte (323429 bytes to 323397 bytes) --- ESP32_BadApple.ino | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 6a4b172..7a1e013 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -123,17 +123,17 @@ void putPixels(uint32_t c, int32_t len) { d2 = d1; } else if (c != 0x00) { if ((c & 0xF0) != 0x00) { - d1 = (c & 0x10) ? b<<24 : 0; - d1 |= (c & 0x20) ? b<<16 : 0; - d1 |= (c & 0x40) ? b<< 8 : 0; - d1 |= (c & 0x80) ? b : 0; + if (c & 0x10) d1 = b<<24; + if (c & 0x20) d1 |= b<<16; + if (c & 0x40) d1 |= b<< 8; + if (c & 0x80) d1 |= b; } if ((c & 0x0F) != 0x00) { - d2 = (c & 0x01) ? b<<24 : 0; - d2 |= (c & 0x02) ? b<<16 : 0; - d2 |= (c & 0x04) ? b<< 8 : 0; - d2 |= (c & 0x08) ? b : 0; + if (c & 0x01) d2 = b<<24; + if (c & 0x02) d2 |= b<<16; + if (c & 0x04) d2 |= b<< 8; + if (c & 0x08) d2 |= b; } } From be53378f8a342c6b95deecc519bd843169e5f6d9 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Mon, 27 Feb 2023 14:46:48 +0900 Subject: [PATCH 25/29] Revert Skip black Reduse Program size 16 byte (323397 bytes to 323381 bytes) --- ESP32_BadApple.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 7a1e013..67394e4 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -122,19 +122,19 @@ void putPixels(uint32_t c, int32_t len) { d2 = d1; } else if (c != 0x00) { - if ((c & 0xF0) != 0x00) { + // if ((c & 0xF0) != 0x00) { if (c & 0x10) d1 = b<<24; if (c & 0x20) d1 |= b<<16; if (c & 0x40) d1 |= b<< 8; if (c & 0x80) d1 |= b; - } + // } - if ((c & 0x0F) != 0x00) { + // if ((c & 0x0F) != 0x00) { if (c & 0x01) d2 = b<<24; if (c & 0x02) d2 |= b<<16; if (c & 0x04) d2 |= b<< 8; if (c & 0x08) d2 |= b; - } + // } } if (b == 0x01) { From 9e8dc2f13306f44ed64508dfdf2ec59693b0fc0c Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 19:15:13 +0900 Subject: [PATCH 26/29] mod Combine XY variable Reduse Program size 16 byte (323385 bytes to 323369 bytes) --- ESP32_BadApple.ino | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 67394e4..97f8d38 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -49,8 +49,7 @@ SSD1306 display (0x3c, I2C_SDA, I2C_SCL); static heatshrink_decoder hsd; // global storage for putPixels -int32_t curr_x = 0; -int32_t curr_y = 0; +int32_t curr_xy = 0; // global storage for decodeRLE int32_t runlength = -1; @@ -149,9 +148,9 @@ void putPixels(uint32_t c, int32_t len) { pImage++; } - curr_x++; - if(curr_x == 128/8) { - curr_x = 0; + // oyy_ybbb_xxxx X=0-15(4 bit), Bit=0-7(3 bit),Y=0-7(3 bit) + curr_xy++; + if((curr_xy & 0x0f) == 0) { pImage -= 128/4; b <<= 1; @@ -160,9 +159,10 @@ void putPixels(uint32_t c, int32_t len) { pImage += 128/4; b = 0x01; - curr_y++; - if(curr_y == 8) { - curr_y = 0; + // oyy_ybbb_xxxx X=0-15(4 bit), Bit=0-7(3 bit),Y=0-7(3 bit) + // Check Overflow bit + if((curr_xy & 0x400) != 0) { + curr_xy = 0; pImage = (uint32_t*)display.buffer; // Update Display frame @@ -243,8 +243,7 @@ void readFile(fs::FS &fs, const char * path){ // init display, putPixels and decodeRLE display.resetDisplay(); - curr_x = 0; - curr_y = 0; + curr_xy = 0; pImage = (uint32_t*)display.buffer; runlength = -1; c_to_dup = -1; From 62f9c22cd716b39aeb91fa1abe73d9e872ecd957 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 19:23:38 +0900 Subject: [PATCH 27/29] mod Change Compare logic --- ESP32_BadApple.ino | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index 97f8d38..dc04937 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -160,9 +160,8 @@ void putPixels(uint32_t c, int32_t len) { b = 0x01; // oyy_ybbb_xxxx X=0-15(4 bit), Bit=0-7(3 bit),Y=0-7(3 bit) - // Check Overflow bit - if((curr_xy & 0x400) != 0) { - curr_xy = 0; + // Check Overflow bit, It equivalent if((curr_xy & 0x400) != 0) + if((curr_xy & 0x3ff) == 0) { pImage = (uint32_t*)display.buffer; // Update Display frame From cf0e3c3e13fd0f87539960ffdc49e72e48bac4f1 Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Sat, 25 Feb 2023 12:43:45 +0900 Subject: [PATCH 28/29] mod Del unnecessary Initialize variable Reduse Program size 28 byte (323369 bytes to 323341 bytes) --- ESP32_BadApple.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index dc04937..e55865c 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -86,7 +86,7 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ } } -volatile unsigned long lastRefresh = 0; +volatile unsigned long lastRefresh; // 30 fps target rate = 33.333us #define FRAME_DERAY_US 33333UL #ifdef ENABLE_FRAME_COUNTER @@ -223,9 +223,9 @@ void decodeRLE(uint32_t c) { void readFile(fs::FS &fs, const char * path){ static uint8_t rle_buf[RLEBUFSIZE]; uint8_t* p_rle_buf; - size_t rle_size = 0; + size_t rle_size; - size_t filelen = 0; + size_t filelen; size_t filesize; static uint8_t compbuf[READBUFSIZE]; @@ -242,10 +242,10 @@ void readFile(fs::FS &fs, const char * path){ // init display, putPixels and decodeRLE display.resetDisplay(); - curr_xy = 0; + // curr_xy = 0; pImage = (uint32_t*)display.buffer; - runlength = -1; - c_to_dup = -1; + // runlength = -1; + // c_to_dup = -1; // init decoder heatshrink_decoder_reset(&hsd); @@ -277,7 +277,7 @@ void readFile(fs::FS &fs, const char * path){ HSD_poll_res pres; do { - rle_size = 0; + // rle_size = 0; pres = heatshrink_decoder_poll(&hsd, rle_buf, RLEBUFSIZE, &rle_size); //Serial.print("^^ polled "); //Serial.println(rle_size); From fad1689b7ba01d602ff22c9eb14f3d53772ea34e Mon Sep 17 00:00:00 2001 From: FREEWING-JP Date: Fri, 24 Feb 2023 19:25:32 +0900 Subject: [PATCH 29/29] mod Add Ending Message --- ESP32_BadApple.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ESP32_BadApple.ino b/ESP32_BadApple.ino index e55865c..3308af7 100644 --- a/ESP32_BadApple.ino +++ b/ESP32_BadApple.ino @@ -312,6 +312,10 @@ void readFile(fs::FS &fs, const char * path){ // 10 sec delay(10000); + display.resetDisplay(); + display.drawStringMaxWidth(0, 0, 128, "Optimize OLED Draw Performance version. modded By FREE WING"); + display.drawStringMaxWidth(0, 40, 128, "http://www.neko.ne.jp/~freewing/"); display.display(); + delay(10000); // Reset to Infinite Loop Demo ! ESP.restart(); }