1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 11:36:13 +01:00
CommandStation-EX/Release_Notes/NeoPixel.md

77 lines
4.2 KiB
Markdown
Raw Normal View History

NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
NeoPixel support
The IO_NeoPixel.h driver supports the adafruit neopixel seesaw board. It turns each pixel into an individual VPIN which can be given a colour and turned on or off using the new <o> command or the NEOPIXEL Exrail macro. Exrail SIGNALS can also drive a single pixel signal or multiple separate pixels.
1. Defining the hardware driver:
Add a driver definition in myAutomation.h for each adafruit I2C driver.
HAL(neoPixel, firstVpin, numberOfPixels [, mode [, i2caddress])
Where mode is selected from the various pixel string types which have varying
colour order or refresh frequency. For MOST strings this mode will be NEO_GRB but for others refer to the comments in IO_NeoPixel.h
If omitted the node and i2caddress default to NEO_GRB, 0x60.
HAL(NeoPixel,1000,20)
This is a NeoPixel driver defaulting to I2C aqddress 0x60 for a GRB pixel string. Pixels are given vpin numbers from 1000 to 1019.
HAL(NeoPixel,1020,20,NEO_GRB,0x61)
This is a NeoPixel driver on i2c address 0x61
2. Setting pixels from the < > commands.
By default, each pixel in the string is created as white but switched off.
Each pixel has a vpin starting from the first vpin in the HAL definitions.
<o vpin> switches pixel on (same as <z vpin>) e.g. <o 1005>
<o -vpin> switches pixel off (same as <z -vpin>) e.g. <o -1003>
(the z commands work on pixels the same as other gpio pins.)
<o [-]vpin count> switches on/off count pixels starting at vpin. e.g <o 1000 5>
Note: it IS acceptable to switch across 2 strings of pixels if they are contiguous vpin ranges. It is also interesting that this command doesnt care if the vpins are NeoPixel or any other type, so it can be used to switch a range of other pin types.
<o [-]vpin red green blue [count]> sets the colour and on/off status of a pin or pins. Each colour is 0..255 e.g. <o 1005 255 255 0> sets pin 1005 to bright yellow and ON, <0 -1006 0 0 255 10> sets pins 1006 to 1015 (10 pins) to bright blue but OFF.
Note: If you set a pin to a colour, you can turn it on and off without having to reset the colour every time. This is something the adafruit seesaw library can't do and is just one of several reasons why we dont use it.
3. Setting pixels from EXRAIL
The new NEOPIXEL macro provides the same functionality as the <o [-]vpin red green blue [count]> command above.
NEOPIXEL([-]vpin, red, green, blue [,count])
Setting pixels on or off (without colour change) can be done with SET/RESET [currently there is no set range facility but that may be added as a general exrail thing... watch this space]
Because the pixels obey set/reset, the BLINK command can also be used to control blinking a pixel.
4. EXRAIL pixel signals.
There are two types possible, a mast with separate fixed colour pixels for each aspect, or a mast with one multiple colour pixel for all aspects.
For separate pixels, the colours should be established at startup and a normal SIGNALH macro used.
AUTOSTART
SIGNALH(1010,1011,1012)
NEOPIXEL(1010,255,0,0)
NEOPIXEL(1011,128,128,0)
NEOPIXEL(1012,0,255,0)
RED(1010) // force signal state otherwise all 3 lights will be on
DONE
For signals with 1 pixel, the NEOPIXEL_SIGNAL macro will create a signal
NEOPIXEL_SIGNAL(vpin,redfx,amberfx,greenfx)
** Changed... ****
The fx values above can be created by the NeoRGB macro so a bright red would be NeoRGB(255,0,0) bright green NeoRGB(0,255,0) and amber something like NeoRGB(255,100,0)
NeoRGB creates a single int32_t value so it can be used in several ways as convenient.
// create 1-lamp signal with NeoRGB colours
NEOPIXEL_SIGNAL(1000,NeoRGB(255,0,0),NeoRGB(255,100,0),NeoRGB(0,255,0))
// Create 1-lamp signal with named colours.
// This is better if you have multiple signals.
// (Note: ALIAS is not suitable due to word length defaults)
#define REDLAMP NeoRGB(255,0,0)
#define AMBERLAMP NeoRGB(255,100,0)
#define GREENLAMP NeoRGB(0,255,0)
NEOPIXEL_SIGNAL(1001,REDLAMP,AMBERLAMP,GREENLAMP)
// Create 1-lamp signal with web type RGB colours
// (Using blue for the amber signal , just testing)
NEOPIXEL_SIGNAL(1002,0xFF0000,0x0000FF,0x00FF00)