From bfb4b7992279837296ba49396120cdfc4e8b24d3 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 17 Jan 2020 23:23:27 -0800 Subject: [PATCH 01/11] Specify library dependencies in library.properties Specifying the library dependencies in the depends field of library.properties causes the Arduino Library Manager (Arduino IDE 1.8.10 and newer) to offer to install any missing dependencies during installation of this library. "arduino-cli lib install" will automatically install the dependencies (arduino-cli 0.7.0 and newer). --- library.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/library.properties b/library.properties index 8228aad..aaec943 100644 --- a/library.properties +++ b/library.properties @@ -8,3 +8,4 @@ category=Device Control url=https://github.com/m5stack/M5Atom architectures=esp32 includes=M5Atom.h +depends=FastLED From 705a1d9d621d75ff34a8317baebf36677ea5bb32 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 22:40:01 +0800 Subject: [PATCH 02/11] Update and rename Display.cpp, removing the extraneous and blocking xSemaphoreTake/Give and correcting some typos The xSemaphoreTake(_xSemaphore, portMAX_DELAY); in LED_Display::displaybuff was taking a second time the _xSemaphore that had already been taken in LED_Display::run() in the same execution flow and was halting the execution of the program xSemaphoreGive(_xSemaphore); in LED_Display::displaybuff has also been removed To keep things consistent, the FastLED.setBrightness(20); has been put after FastLED.show(); in LED_Display::run Some english typo were also corrected --- src/utility/{LED_DisPlay.cpp => LED_Display.cpp} | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) rename src/utility/{LED_DisPlay.cpp => LED_Display.cpp} (92%) diff --git a/src/utility/LED_DisPlay.cpp b/src/utility/LED_Display.cpp similarity index 92% rename from src/utility/LED_DisPlay.cpp rename to src/utility/LED_Display.cpp index 7065bd0..a45c78e 100644 --- a/src/utility/LED_DisPlay.cpp +++ b/src/utility/LED_Display.cpp @@ -1,10 +1,10 @@ #include "LED_Display.h" -LED_Display::LED_Display(uint8_t LEDNumbre) +LED_Display::LED_Display(uint8_t LEDNumber) { - FastLED.addLeds(_ledbuff, LEDNumbre); + FastLED.addLeds(_ledbuff, LEDNumber); _xSemaphore = xSemaphoreCreateMutex(); - _numberled = LEDNumbre; + _numberled = LEDNumber; } LED_Display::~LED_Display() @@ -39,7 +39,7 @@ void LED_Display::run(void *data) _count_x--; } } - if ((_am_mode & kMoveTop) || (_am_mode & kMoveButtom)) + if ((_am_mode & kMoveTop) || (_am_mode & kMoveBottom)) { if (_am_mode & kMoveTop) { @@ -70,6 +70,7 @@ void LED_Display::run(void *data) } FastLED.show(); + FastLED.setBrightness(20); } } @@ -100,7 +101,6 @@ void LED_Display::displaybuff(uint8_t *buffptr, int8_t offsetx, int8_t offsety) int8_t setdatax = (offsetx < 0) ? (-offsetx) : (xsize - offsetx); int8_t setdatay = (offsety < 0) ? (-offsety) : (ysize - offsety); - xSemaphoreTake(_xSemaphore, portMAX_DELAY); for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) @@ -110,8 +110,6 @@ void LED_Display::displaybuff(uint8_t *buffptr, int8_t offsetx, int8_t offsety) _ledbuff[x + y * 5].raw[2] = buffptr[2 + ((setdatax + x) % xsize + ((setdatay + y) % ysize) * xsize) * 3 + 2]; } } - xSemaphoreGive(_xSemaphore); - FastLED.setBrightness(20); } void LED_Display::setBrightness(uint8_t brightness) From 0835d9f1d094effd82a3e7e44a9550bba187a53a Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 22:51:14 +0800 Subject: [PATCH 03/11] Update LED_Display.h with some typo corrections and NUM_LEDS instead of numeric constant Minor typo corrections to match those of LED_Display.cpp --- src/utility/LED_Display.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utility/LED_Display.h b/src/utility/LED_Display.h index 426299e..7f5b7e0 100644 --- a/src/utility/LED_Display.h +++ b/src/utility/LED_Display.h @@ -28,20 +28,20 @@ class LED_Display : public Task enum { kStatic = 0, - kAnmiation_run, - kAnmiation_stop, + kAnimation_run, + kAnimation_stop, } Dismode; enum { kMoveRight = 0x01, kMoveLeft = 0x02, kMoveTop = 0x04, - kMoveButtom = 0x08, + kMoveBottom = 0x08, } Am_mode; /* data */ public: - LED_Display(uint8_t LEDNumbre = 25); + LED_Display(uint8_t LEDNumber = NUM_LEDS); ~LED_Display(); void run(void *data); From aeaf1cfbf9801c250976a7345c1e27434c4fc93f Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 22:53:26 +0800 Subject: [PATCH 04/11] Correct indentation --- src/utility/LED_Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index a45c78e..92d25fc 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -70,7 +70,7 @@ void LED_Display::run(void *data) } FastLED.show(); - FastLED.setBrightness(20); + FastLED.setBrightness(20); } } From 712e327957036be8512f2a9f56fa702bbe3f0347 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 22:55:22 +0800 Subject: [PATCH 05/11] Correct typo on animation --- src/utility/LED_Display.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index 92d25fc..c2afebc 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -26,7 +26,7 @@ void LED_Display::run(void *data) while (1) { xSemaphoreTake(_xSemaphore, portMAX_DELAY); - if (_mode == kAnmiation_run) + if (_mode == kAnimation_run) { if ((_am_mode & kMoveRight) || (_am_mode & kMoveLeft)) { @@ -55,7 +55,7 @@ void LED_Display::run(void *data) _am_count--; if (_am_count == 0) { - _mode = kAnmiation_stop; + _mode = kAnimation_stop; } } displaybuff(_am_buffptr, _count_x, _count_y); @@ -77,16 +77,16 @@ void LED_Display::run(void *data) void LED_Display::animation(uint8_t *buffptr, uint8_t amspeed, uint8_t ammode, int64_t amcount) { xSemaphoreTake(_xSemaphore, portMAX_DELAY); - if (_mode == kAnmiation_run) + if (_mode == kAnimation_run) { - _mode = kAnmiation_stop; + _mode = kAnimation_stop; } _am_buffptr = buffptr; _am_speed = amspeed; _am_mode = ammode; _am_count = amcount; _count_x = _count_y = 0; - _mode = kAnmiation_run; + _mode = kAnimation_run; xSemaphoreGive(_xSemaphore); } From ab2965a1ada1dfe37085119774791478a6a8a570 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 23:13:23 +0800 Subject: [PATCH 06/11] Update LED_Display.cpp to display initial state With the previous code, the initial state (_count_x,_count_y) = (0,0) was never displayed. Here the buffer is calculated before the increment/decrement. As a side effect the total animation count shall be increased by one unit to display the last line --- src/utility/LED_Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index c2afebc..1e19fdc 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -28,6 +28,7 @@ void LED_Display::run(void *data) xSemaphoreTake(_xSemaphore, portMAX_DELAY); if (_mode == kAnimation_run) { + displaybuff(_am_buffptr, _count_x, _count_y); if ((_am_mode & kMoveRight) || (_am_mode & kMoveLeft)) { if (_am_mode & kMoveRight) @@ -58,7 +59,6 @@ void LED_Display::run(void *data) _mode = kAnimation_stop; } } - displaybuff(_am_buffptr, _count_x, _count_y); delay(_am_speed); delay(10); xSemaphoreGive(_xSemaphore); From 346c39743ac76895f2ba4074a37d2595c9831307 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Sun, 3 May 2020 23:17:32 +0800 Subject: [PATCH 07/11] Update Display.ino to display the full buffer until last line Following change in LED_Display.cpp to display the initial state, another 1 count is necessary to display the M fully. --- examples/Basics/LEDDisplay/LEDDisplay.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Basics/LEDDisplay/LEDDisplay.ino b/examples/Basics/LEDDisplay/LEDDisplay.ino index b574a59..b5d8341 100644 --- a/examples/Basics/LEDDisplay/LEDDisplay.ino +++ b/examples/Basics/LEDDisplay/LEDDisplay.ino @@ -10,11 +10,11 @@ void setup() { M5.begin(true, false, true); delay(50); - M5.dis.animation((uint8_t *)AtomImageData, 200, LED_Display::kMoveLeft, 18); + M5.dis.animation((uint8_t *)AtomImageData, 200, LED_Display::kMoveLeft, 19); } void loop() { delay(500); M5.update(); -} \ No newline at end of file +} From fef1ad4a214a95aa3d6ed84fc371228b78f0b560 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Mon, 4 May 2020 15:34:46 +0800 Subject: [PATCH 08/11] Offsets int8_t type does not allow scrolling large matrixs int8_t offset limits scrolling to 127 whereas it is supposed to be able to be incremented or decremented several times the pixel size of the initial buffer --- src/utility/LED_Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index c2afebc..ad9fc48 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -90,7 +90,7 @@ void LED_Display::animation(uint8_t *buffptr, uint8_t amspeed, uint8_t ammode, i xSemaphoreGive(_xSemaphore); } -void LED_Display::displaybuff(uint8_t *buffptr, int8_t offsetx, int8_t offsety) +void LED_Display::displaybuff(uint8_t *buffptr, int32_t offsetx, int32_t offsety) { uint16_t xsize = 0, ysize = 0; xsize = buffptr[0]; From 13770c34bb09c9da12755b0f147952c71f551702 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Mon, 4 May 2020 15:41:55 +0800 Subject: [PATCH 09/11] Update LED_Display.h with int32_t offsets to allow large matrix scrolling. Also deleted unused declaration --- src/utility/LED_Display.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utility/LED_Display.h b/src/utility/LED_Display.h index 7f5b7e0..fa24c7e 100644 --- a/src/utility/LED_Display.h +++ b/src/utility/LED_Display.h @@ -46,8 +46,7 @@ class LED_Display : public Task void run(void *data); void animation(uint8_t *buffptr, uint8_t amspeed, uint8_t ammode, int64_t amcount = -1); - void displaybuff(uint8_t *buffptr, int8_t offsetx = 0, int8_t offsety = 0); - void MoveDisPlayBuff(int8_t offsetx = 0, int8_t offsety = 0); + void displaybuff(uint8_t *buffptr, int32_t offsetx = 0, int32_t offsety = 0); void setBrightness(uint8_t brightness); void drawpix(uint8_t xpos, uint8_t ypos, CRGB Color); From a45e1ed15089a951b2600200c259da374294b9e8 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Mon, 4 May 2020 15:57:37 +0800 Subject: [PATCH 10/11] Update type of setdatax and setdatay to allow display of large matrix --- src/utility/LED_Display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index ad9fc48..1ef2cbd 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -99,8 +99,8 @@ void LED_Display::displaybuff(uint8_t *buffptr, int32_t offsetx, int32_t offsety offsetx = offsetx % xsize; offsety = offsety % ysize; - int8_t setdatax = (offsetx < 0) ? (-offsetx) : (xsize - offsetx); - int8_t setdatay = (offsety < 0) ? (-offsety) : (ysize - offsety); + int16_t setdatax = (offsetx < 0) ? (-offsetx) : (xsize - offsetx); + int16_t setdatay = (offsety < 0) ? (-offsety) : (ysize - offsety); for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) From af53cb89fee1144ea1b02e32b8da512df13ec410 Mon Sep 17 00:00:00 2001 From: Brice LECOLE Date: Mon, 4 May 2020 16:13:37 +0800 Subject: [PATCH 11/11] Corrected max number of LEDs with #define NUM_LEDS value --- src/utility/LED_Display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utility/LED_Display.cpp b/src/utility/LED_Display.cpp index 1ef2cbd..d25a629 100644 --- a/src/utility/LED_Display.cpp +++ b/src/utility/LED_Display.cpp @@ -16,7 +16,7 @@ void LED_Display::run(void *data) { data = nullptr; - for (int num = 0; num < 26; num++) + for (int num = 0; num < NUM_LEDS; num++) { _ledbuff[num] = 0x000000; } @@ -144,7 +144,7 @@ void LED_Display::drawpix(uint8_t Number, CRGB Color) void LED_Display::clear() { xSemaphoreTake(_xSemaphore, portMAX_DELAY); - for (int8_t i = 0; i < 25; i++) + for (int8_t i = 0; i < NUM_LEDS; i++) { _ledbuff[i] = 0; }