Commit Graph

35 Commits

Author SHA1 Message Date
Gregor Hartmann 42ec384478
add ws2812 4 channels for RGBW strips + diagnostic output (#3637) 2024-02-18 10:58:41 +01:00
Gregor Hartmann e96078e6db
Handle impact of excluding pixbuf from build (#3398) 2021-02-14 08:41:17 +01:00
Nathaniel Wesley Filardo 109f500be7
More LED fixes (#3368)
* apa102: remove dead code

We can't store strings of hundreds of thousands of characters in RAM, so
this can't possibly have fired, historically.  Pixbufs are still RAM
objects, so that's still out.  With LFS, it would take a pathological
example to hit the required 400KB TSTRING.

* Add IRQ management functions

* ws2812: fill UART FIFOs with IRQs off

Refactor code to make the use of two fill loops less gross.
2021-01-10 17:19:10 +00:00
Nathaniel Wesley Filardo 85df6b588d
LED strip refactor (#3158)
`ws2812` buffer extracted to new `pixbuf` module.

* The new pixbuf module has more functionality than the `ws2812`-specific buffer it replaces.
* This is work in progress towards https://github.com/nodemcu/nodemcu-firmware/issues/2916
* The LED driver modules `ws2812`, `ws2801`, `apa102`, and `tm1829` have sprouted `pixbuf` support.
* `NTest` tests for `pixbuf` now exist.

While here, document the ws2812 UART-based overlapping with mainline
execution.  Fixes https://github.com/nodemcu/nodemcu-firmware/issues/3140

Co-authored-by: Gregor Hartmann <HHHartmann@users.noreply.github.com>
2021-01-06 23:35:34 +00:00
Philip Gladstone 606f91664b
First phase of number to integer conversion (#3221) 2020-08-29 17:48:24 +01:00
Firenox89 0555a4c689 fix a memory leak in ws2812_buffer_shift by freeing the same amount of bytes we allocated before 2020-06-12 18:23:36 +01:00
Terry Ellison bbeb09b695 Squashed updates do get Lua51 and Lua53 working (#3075)
-  Lots of minor but nasty bugfixes to get all tests to run clean
-  core lua and test suite fixes to allow luac -F to run cleanly against test suite
-  next tranch to get LFS working
-  luac.cross -a options plus fixes from feedback
-  UART fixes and lua.c merge
-  commit of wip prior to rebaselining against current dev
-  more tweaks
2020-06-09 22:26:52 +02:00
Gregor Hartmann d4b5b0cbaf Fixes for `ws2812` and `ws2812_effects` (#2953)
* clean effects library
* Fix several issues in ws2812 and effects
* Implement working way of calling shift from callback
2020-06-09 22:26:06 +02:00
Johny Mattsson 526d21dab4 Major cleanup - c_whatever is finally history. (#2838)
The PR removed the bulk of non-newlib headers from the NodeMCU source base.  
app/libc has now been cut down to the bare minimum overrides to shadow the 
corresponding functions in the SDK's libc. The old c_xyz.h headerfiles have been 
nuked in favour of the standard <xyz.h> headers, with a few exceptions over in 
sdk-overrides. Again, shipping a libc.a without headers is a terrible thing to do. We're 
still living on a prayer that libc was configured the same was as a default-configured
xtensa gcc toolchain assumes it is. That part I cannot do anything about, unfortunately, 
but it's no worse than it has been before.

This enables our source files to compile successfully using the standard header files, 
and use the typical malloc()/calloc()/realloc()/free(), the strwhatever()s and 
memwhatever()s. These end up, through macro and linker magic, mapped to the 
appropriate SDK or ROM functions.
2019-07-22 00:58:21 +03:00
Gregor bd0549ac4a fix rounding in ws2812:buffer:mix 2019-07-14 21:48:07 +02:00
Terry Ellison 1990f95740
Updated ROTables 1st tranch (#2742)
Updated ROTables
2019-05-08 14:08:20 +03:00
Konrad Hübner ed56d949ee ws2812 effects library (#2215)
* ws2812 effects and color utils modules added

* Added documentation for new modules to mkdocs.yml

* changed mode option to string, documentation, default modules fixed

* updated user_modules.h
2018-01-23 21:05:04 +01:00
Nathaniel Wesley Filardo 5c8619eb4d ws2812 mix: add all, then divide (#2032)
This achieves rounding between multiple summed frame buffers
2017-10-22 19:20:45 +02:00
Arnim Läuger 8931f09ce4 Fix missing return code for ws2812_init() (#1816) 2017-02-24 21:20:09 +01:00
Philip Gladstone 77b2e85d09 Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
2016-11-05 13:53:42 +01:00
Thomas Soëte 8866297c6d Remove buffer:write() as ws2812.write() handles buffers (#1408) 2016-07-20 23:04:33 +02:00
Thomas Soëte 854ad7c80f Handle two WS2812 strips in parallel using the two UARTs through GPIO2 and TXD0 (#1310) 2016-07-20 22:28:47 +02:00
Konrad Hübner 500bbceded added fadeIn, faceOut and shift to ws2812 module (#1343)
* added fadeIn, faceOut and shift to ws2812 module

* improvements to rotate, unified fade method

shift renamed to rotate and usage of more efficient memory operations.
fadeIn and fadeOut unified into fade method with optional parameter for direction.

* rename method to "shift" with optional mode parameter
2016-06-10 22:23:37 +02:00
Thomas Soëte 0577c8af0f Finalize work on ws2812 module
* Fix bug on first write
	Pin is 'HIGH' at reset, so we need to pull it down and generate a
	reset.

* Move init code to flash section, not needed to be in iram.

* Remove pin choice in API

* Remove lock in ws2812_buffer_write

* Remove naked malloc

* Drop ws2812_writergb

* Drop support of ws2812.buffers to ws2812_writegrb should use ws2812.buffers:write

* Add support for <>3 colors per leds strips (RGBW)

* Remove ICACHE_FLASH_ATTR

* Add static const on _uartData to avoid initialization penalty
2016-05-09 07:21:50 +02:00
Thomas Soëte 47b44229bf ws2812 data buffer
To create a size led long buffer:
buffer = ws2812.newBuffer(size);

To fill the buffer:
buffer:fill(g, r, b)

To get a particular led color:
g, r, b = buffer:get(index)

To set a particular led color:
buffer:set(index, g, r, b);

To send the buffer:
buffer:write(pin);
2016-01-18 17:21:08 +01:00
Thomas Soëte 51bb8a50ba Rewrite code to use UART1 instead of bit-banging.
It allows keeping interrupts enabled but force to use GPIO2.
2016-01-18 17:16:18 +01:00
Johny Mattsson 4e8ef87d03 Reworked module registration, removed modules.h
Module creation & registration now made a lot simpler. In essence,
each module file is now self-contained and only needs a

  NODEMCU_MODULE(MYNAME, "myname", myname_map, luaopen_myname);

line to both be automatically recognised by the Lua initialization
as well as honor the LUA_USE_MODULES_MYNAME #define.
2015-12-16 16:09:16 +11:00
Johny Mattsson 6b6456be47 Major cleanup of module registration.
As per #810 & #796, only LUA_OPTIMIZE_MEMORY=2 & MIN_OPT_LEVEL=2 are
supported when building. This commit effects that limitation.

With this change modules/auxmods.h no longer needs to be updated for
every new module, nor do module writers need to cater for a hypothetical
LUA_OPTIMIZE_MEMORY < 2 scenario.
2015-12-12 15:03:40 +11:00
Thomas Soëte 4fd552fcaf Better timings for 160MHz too.
Values measured:
@80MHz:
	T0H: 337ns, Period: 1.274us
	T1H: 687ns, Period: 1.25us

@160MHz:
	T0H: 349ns, Period: 1.262us
	T1H: 700ns, Period: 1.276us
2015-11-10 22:34:44 +01:00
Thomas Soëte c2f12a3b05 Better timings for WS2812 (measured 345ns/695ns, instead of 340ns/600ns) 2015-11-08 22:45:12 +01:00
Johny Mattsson d2ac5f1712 Changed os_intr_xxx to ets_intr_xxx.
The os_intr_xxx macros no longer exist in the SDK.
2015-10-12 13:26:04 +11:00
Konrad Beckmann 6538d22d1f Improved ws2812 implementation
- Fixes the "first led problem" (#534 #487).
- Adds support for 160MHz mode.
- Optimized timings. Time to write pixels is reduced by about 25%
  This is useful when having a large amount of chained LEDs (>500).
2015-07-12 13:43:33 +02:00
vowstar 3430e5f826 Add __attribute__((optimize("O2"))) to ws2812 module. 2015-06-20 01:40:45 +08:00
makefu c29edf7a22 app/modules/ws2812.c: re-add ws2812.write()
Add the original ws2812.write() function which does not scramble the
buffer while preserving the 'new' ws2812.writergb.

With this everybody should be happy again
2015-05-26 23:12:38 +02:00
Wolfram Ladurner ff85cf4371 fixes issue #321 "ws2812.writergb scrambles buffer" reported by makefu.
Don't modify Lua-internal lstring - use a copy instead.
2015-04-05 15:49:32 +02:00
Markus Gritsch 8432e8c8be Changed the ws2812 byte order from GRB to RGB
There seems to be interest in using the more intuitive RGB byte order to
specify the LED color. Also fixed the documentation.
2015-03-03 10:20:02 +01:00
Till Klocke 0bbaedac89 Renamed lgpio_ws2812 to match lua method name and fixed formatting 2015-02-07 07:05:41 +01:00
Till Klocke 284ee8c46e Added attribution and fixed documentation in comments 2015-02-05 18:47:08 +01:00
Till Klocke c30002b8df Fixed typo in method name 2015-02-05 18:43:29 +01:00
Till Klocke 0950e48925 Added support for WS2812 LEDs as a new module 2015-02-05 18:40:46 +01:00