From 6038307bbf665fe370ced742830cc06deb8b60b5 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Sun, 18 Feb 2024 10:58:41 +0100 Subject: [PATCH] add ws2812 4 channels for RGBW strips + diagnostic output (#3637) --- app/lua/luac_cross/lflashimg.c | 1 + app/modules/ws2812.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/lua/luac_cross/lflashimg.c b/app/lua/luac_cross/lflashimg.c index 9133b8e8..f42f12d9 100644 --- a/app/lua/luac_cross/lflashimg.c +++ b/app/lua/luac_cross/lflashimg.c @@ -399,6 +399,7 @@ uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w, fh->flash_sig = FLASH_SIG + (address ? FLASH_SIG_ABSOLUTE : 0); fh->flash_size = curOffset*WORDSIZE; + printf("Image size: %d\n", fh->flash_size); if (fh->flash_size>maxSize) { fatal ("The image is too large for specfied LFS size"); } diff --git a/app/modules/ws2812.c b/app/modules/ws2812.c index d748be3d..c8dcc163 100644 --- a/app/modules/ws2812.c +++ b/app/modules/ws2812.c @@ -138,7 +138,7 @@ static int ws2812_write(lua_State* L) { else if (type == LUA_TUSERDATA) { pixbuf *buffer = pixbuf_from_lua_arg(L, 1); - luaL_argcheck(L, pixbuf_channels(buffer) == 3, 1, "Bad pixbuf format"); + luaL_argcheck(L, pixbuf_channels(buffer) == 3 || pixbuf_channels(buffer) == 4, 1, "Bad pixbuf format"); buffer1 = buffer->values; length1 = pixbuf_size(buffer); } @@ -163,7 +163,7 @@ static int ws2812_write(lua_State* L) { else if (type == LUA_TUSERDATA) { pixbuf *buffer = pixbuf_from_lua_arg(L, 2); - luaL_argcheck(L, pixbuf_channels(buffer) == 3, 2, "Bad pixbuf format"); + luaL_argcheck(L, pixbuf_channels(buffer) == 3 || pixbuf_channels(buffer) == 4, 2, "Bad pixbuf format"); buffer2 = buffer->values; length2 = pixbuf_size(buffer); }