Skip to content

Commit

Permalink
Merge pull request letscontrolit#5113 from tonhuisman/feature/P165-ne…
Browse files Browse the repository at this point in the history
…opixel-7segment-display

[P165] Add plugin Display - NeoPixel (7-segment)
  • Loading branch information
TD-er authored Sep 28, 2024
2 parents 6d0e93d + c60cfe6 commit 789ade8
Show file tree
Hide file tree
Showing 95 changed files with 8,700 additions and 516 deletions.
250 changes: 250 additions & 0 deletions docs/source/Plugin/P165.rst

Large diffs are not rendered by default.

Binary file added docs/source/Plugin/P165_DeviceConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_DisplayOutputOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_FontsetOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_StripTypeOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions docs/source/Plugin/P165_commands.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
.. csv-table::
:header: "Command Syntax", "Extra information"
:widths: 20, 30

"
``7don``
","
Turn the display on, if it was turned off before using the ``7doff`` command. (Not implemented yet)
"
"
``7doff``
","
Turn the display off, can later be turned on again by using the ``7don`` command. (Not implemented yet)
"
"
``7db,<brightness>``

``<brightness>``: Set the brightness between 0 and 255. Will be limited to the max. value configured in **Maximum allowed brightness** setting.
","
Changes the **Initial brightness** config setting, and the brightness of the strip. The setting is not saved unless the ``save`` command is used.
"
"
``7output,<output option>``
","
Change the Display Output setting, available options:

* 0 - Manual
* 1 - Clock 24h - Blink
* 2 - Clock 24h - No Blink
* 3 - Clock 12h - Blink
* 4 - Clock 12h - No Blink
* 5 - Date
"
"
``7dfont,<font>``

","
Select a different font, either by name: ``Default`` or ``7dgt`` for the original font (0), ``Siekoo`` for standard Siekoo font (1), ``Siekoo_Upper`` for the Siekoo font with uppercase 'CHNORUX' characters (2), and ``dSEG7`` for the dSEG7 font (3). Numbers can also be used, 0, 1, 2, or 3 as noted. Fontnames are not case-sensitive.
"
"
``7dtext,<text>``

Examples:

``7dtext,OUT [BLK#Temperature#d2.1]^``

``7dtext,HU. [BLK#Humidity#d2.1]^o`` Will result in 'HU. 57.2°o' being displayed
","
To display a text on the display. Any variable can be used. Unsupported characters (like accented letters) will show as a space (empty digit).

With the Scroll Text option disabled, the first n characters the display can show are displayed, if the Scroll Text option is enabled, longer texts will scroll from right to left across the display, at the set speed.
"
"
``7digit,<grp>,<dgt>,<char>[.]``
","
Draw a single character in the exact group & digit. When followed by a period, the decimal point will also be used.
"
"
``7dbin,<byte>,...``

Example:

``7dbin,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x80``
","
To display any bit pattern on the display.

The example shows each digit with a different segment on, including the dot/colon, and assuming an 8 digit configuration, or Scroll Text enabled.

See explanation on how the bits map to segments, below.
"
"
``7dgroup,<group>``

``<group>`` Range 0..<number of configured groups>
","
Set the default group any command should be applied to. Group 0 is the entire display, and the default.
"
"
``7color,<fg_r>,<fg_g>,<fg_b>[,<fg_w>],<bg_r>,<bg_g>,<bg_b>[,<bg_w>]``
","
Set the foreground, and/or background colors for the entire display. When a GRBW strip is configured, the brightness/white values have to be provided too. For only setting the background colors, leave out values for the foreground colors, but keep the commas.

Color values can be in range 0..255.

When group or digit colors are configured, then those will get priority.
"
"
``7digitcolor,<grp>,<dgt>,<fg_r>,<fg_g>,<fg_b>[,<fg_w>],<bg_r>,<bg_g>,<bg_b>[,<bg_w>]``
","
Set the foreground, and/or background colors for a specific digit of a group. When a GRBW strip is configured, the brightness/white values have to be provided too. For only setting the background colors, leave out values for the foreground colors, but keep the commas.

Both <grp> (group) and <dgt> (digit) are required, and must be in range 1..<available groups/digits for that group>.

Color values can be in range 0..255.

To clear a digit color, to use the group or global defaults, provide ``-`` instead of the <fg_r> value. The rest of the arguments will then be ignored.

Digit colors have highest priority.
"
"
``7groupcolor,<grp>,<fg_r>,<fg_g>,<fg_b>[,<fg_w>],<bg_r>,<bg_g>,<bg_b>[,<bg_w>]``
","
Set the foreground, and/or background colors for a all digits of a group. When a GRBW strip is configured, the brightness/white values have to be provided too. For only setting the background colors, leave out values for the foreground colors, but keep the commas.

Group <grp> is required, and must be in range 1..<available groups>.

Color values can be in range 0..255.

To clear a group color, to use the global defaults, provide ``-`` instead of the <fg_r> value. The rest of the arguments will then be ignored.

Group color will be overridden by a digit color, when set.
"
"
``7dextra,<grp>,<state>[,<r>,<g>,<b>[,<w>]]``

``7dbefore,<grp>,<state>[,<r>,<g>,<b>[,<w>]]``

``<state>`` : 0, 1, 2, 3, 4 or 5
","
Set the extra pixels after or before the digit On or Off, according to the state. The optionally supplied color will be used for the state. If not used, the the global background color will be used for Off, and the global foreground color for On.

State:

* ``0`` : All Off

* ``1`` : All On

* ``2`` : Low-numbered half of pixels Off

* ``3`` : Low-numbered half of pixels On

* ``4`` : High-numbered half of pixels Off

* ``5`` : High-numbered half of pixels On
"
16 changes: 16 additions & 0 deletions docs/source/Plugin/P165_example1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Example 1
^^^^^^^^^

For displaying the time in a 24 hour format, and an optionally blinking colon as the hours/minutes separator, you can define this Group/Digit setup:

.. image:: P165_example1_config.png
:height: 75pc

This defines 2 Groups of each 2 Digits. The height and width of the segments can be configured as preferred, this example uses 3 pixels for both. When using more pixels per segment, like 5, 6 or 7, it is probably better to define a larger decimal point, if that is to be used, 3 seems appropriate in that case, and also the extra pixels, used to add the colon separator, could have 4 to 8 pixels to get a matching size with the large segments.

The number-plan for this layout is presented like this:

.. image:: P165_example1_number.png
:height: 75pc

Binary file added docs/source/Plugin/P165_example1_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_example1_number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions docs/source/Plugin/P165_example2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Example 2
^^^^^^^^^

For displaying the time in a 12 hour format, and an optionally blinking colon as the hours/minutes separator, you can define this Group/Digit setup:

.. image:: P165_example2_config.png
:height: 75pc

The option to suppress the leading 0 on day/hour option is enabled now, so the left-most digit will be empty most of the time.

We have defined 2 Groups of each 2 Digits, but effectively use only 3 1/2 digit. The height and width of the segments can be configured as preferred, this example uses 3 pixels for both. When using more pixels per segment, like 5, 6 or 7, it is probably better to define a larger decimal point, if that is to be used, 3 seems appropriate in that case, and also the extra pixels, used to add the colon separator, could have 4 to 8 pixels to get a matching size with the large segments.

.. note:: This layout is presented in reverse order, as all groups use the **Right to Left digits** option. The actual positioning is still with Group 1 as the left-most group, and then using the numerically next group(s). This layout is needed to make the number-plan work from right to left.

The number-plan for this layout is presented like this:

.. image:: P165_example2_number.png
:height: 75pc

The number-plan starts at the Right-Top pixel, instead of the Left-Top pixel, so the a-segment for the left-most digit can be excluded.

To save space and a few pixels, or create a larger display with a standard strip-length, the marked numbers (76..90) can be excluded from the build, as for a 12 hour clock the left-most digit is 0 most of the time, and that 0 is being suppressed, so no pixels will light up.

.. image:: P165_example2a_number.png
:height: 75pc

This shows an increased layout, using 4-pixel segments and a 4-pixel colon, that can be built from exactly 100 pixels, 2 50-pixel wired-pixelchains as available from EBay, Aliexpress etc.

Again, the marked pixels (101..120) can be excluded.
Binary file added docs/source/Plugin/P165_example2_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_example2_number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_example2a_number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions docs/source/Plugin/P165_example3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

Example 3
^^^^^^^^^

For displaying a game score, with an indicator of the active player by using a half of the extra pixels, you can define this Group/Digit setup:

.. image:: P165_example3_config.png
:height: 75pc

We have defined 2 Groups of each 2 Digits, and enabled the Corners Overlap option to have a more explicitly defined digit. The height and width of the segments can be configured as preferred, this example uses 3 pixels for both. When using more pixels per segment, like 5, 6 or 7, the extra pixels, used to add the left/right player indicator, could have 4 to 8 pixels to get a matching size with the large segments.

The number-plan for this layout is presented like this:

.. image:: P165_example3_number.png
:height: 75pc

The number-plan starts at the Left-Top pixel.

For mounting the middle segment easier/more efficient, this segment can be split in a left and right half, by checking the Split g-segment pixels. The number-plan then looks like this:

.. image:: P165_example3a_number.png
:height: 75pc

The right half of the g-segment is placed between the b and c segments, and the left half of the g-segment between the e and f segments.


To control the player-indicator, the extra pixels 41 and 42 should be placed to indicate the digits from Group 1 being the active player score, and extra pixels 43 and 44 placed to indicate the digits from Group 2 for the other player.

These rules can be added to use 2 buttons (PlayerA and PlayerB) to select the active player:

.. code:: text
On PlayerA#State=0 Do
7dextra,0,4 // Player B Off
7dextra,0,3 // Player A On
Endon
On PlayerB#State=0 Do
7dextra,0,2 // Player A Off
7dextra,0,5 // Player B On
Endon
Binary file added docs/source/Plugin/P165_example3_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_example3_number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P165_example3a_number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/Plugin/_Plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ There are different released versions of ESP Easy:
":ref:`P162_page`","|P162_status|","P162"
":ref:`P163_page`","|P163_status|","P163"
":ref:`P164_page`","|P164_status|","P164"
":ref:`P165_page`","|P165_status|","P165"
":ref:`P166_page`","|P166_status|","P166"
":ref:`P167_page`","|P167_status|","P167"
":ref:`P168_page`","|P168_status|","P168"
Expand Down
13 changes: 13 additions & 0 deletions docs/source/Plugin/_plugin_substitutions_p16x.repl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
.. |P164_compileinfo| replace:: `.`
.. |P164_usedlibraries| replace:: `I2C`

.. |P165_name| replace:: :cyan:`NeoPixel (7-Segment)`
.. |P165_type| replace:: :cyan:`Display`
.. |P165_typename| replace:: :cyan:`Display - NeoPixel (7-Segment)`
.. |P165_porttype| replace:: `.`
.. |P165_status| replace:: :yellow:`DISPLAY` :yellow:`NEOPIXEL`
.. |P165_github| replace:: P165_7SegNeopixel.ino
.. _P165_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P165_7SegNeopixel.ino
.. |P165_usedby| replace:: `.`
.. |P165_shortinfo| replace:: `NeoPixel 7-Segment display`
.. |P165_maintainer| replace:: `tonhuisman`
.. |P165_compileinfo| replace:: `.`
.. |P165_usedlibraries| replace:: `Noiasca NeopixelDisplay (modified)`

.. |P166_name| replace:: :cyan:`GP8403 Dual channel DAC 0-10V`
.. |P166_type| replace:: :cyan:`Output`
.. |P166_typename| replace:: :cyan:`Output - GP8403 Dual channel DAC 0-10V`
Expand Down
8 changes: 7 additions & 1 deletion lib/NeoPixelBus_wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**NeoPixelBus_wrapper**: A minimal wrapper to replace Adafruit_NeoPixel API to use Makuna's NeoPixelBus API.

(c) 2023, Ton Huisman for [ESPEasy](https://github.com/letscontrolit/ESPEasy).
(c) 2023..2024, Ton Huisman for [ESPEasy](https://github.com/letscontrolit/ESPEasy).

### How to use

Expand All @@ -18,6 +18,12 @@
- Currently only supports the most commonly used NeoPixel stripes `NEO_GRB` and `NEO_GRBW`, and the default `NEO_KHZ800` method. (That's all what is used in ESPEasy...)
- When using an ESP8266 and the used GPIO pin is *not* `GPIO2`, you can enable `# define NEOPIXEL_WRAPPER_USE_ADAFRUIT` in `NeoPixelBus_wrapper.h`, but you'll then be using the Adafruit_NeoPixel library again, as that does allow to select the GPIO pin. The `Adafruit_NeoPixel` library then has to be available for compilation!

### Changelog

- 2024-08-04 tonhuisman: Add support for `fill()` method.
- 2024-01-31 tonhuisman: Add use of Adafruit_NeoPixel library for ESP8266 to restore configurable GPIO pin usage.
- 2023-10-29 tonhuisman: Initial version, wrapper for minimal use. Only what's used from Adafruit_NeoPixel to use NeoPixelBus library

### Support

For questions and improvement requests, please use the Github Issues system.
Expand Down
11 changes: 11 additions & 0 deletions lib/NeoPixelBus_wrapper/src/NeoPixelBus_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,16 @@ uint32_t NeoPixelBus_wrapper::getPixelColor(uint16_t n) {
return 0u; // Fall-through value...
}

void NeoPixelBus_wrapper::fill(uint32_t c,
uint16_t first,
uint16_t count) {
if (nullptr != neopixels_grb) {
neopixels_grb->ClearTo(RgbColor((c >> 16) & 0xFF, (c >> 8) & 0xFF, c & 0xFF), first, first + count); // Unfold the Color(r,g,b,w) static
} else
if (nullptr != neopixels_grbw) {
neopixels_grbw->ClearTo(RgbwColor((c >> 16) & 0xFF, (c >> 8) & 0xFF, c & 0xFF, (c >> 24) & 0xFF), first, first + count);
}
}

#endif // ifndef NEOPIXEL_WRAPPER_USE_ADAFRUIT
#endif // ifndef _NEOPIXELBUS_WRAPPER_CPP
4 changes: 4 additions & 0 deletions lib/NeoPixelBus_wrapper/src/NeoPixelBus_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ struct NeoPixelBus_wrapper
return numLEDs;
}

void fill(uint32_t c = 0,
uint16_t first = 0,
uint16_t count = 0);

static uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0) {
return static_cast<uint32_t>(w) << 24 |
static_cast<uint32_t>(r) << 16 |
Expand Down
1 change: 1 addition & 0 deletions lib/NoiascaNeopixelDisplay/.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
just to remove write protection for this folder/library
17 changes: 17 additions & 0 deletions lib/NoiascaNeopixelDisplay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NoiascaNeopixelDisplay
==========
NoiascaNeopixelDisplay is an [Arduino](http://arduino.cc) library for WS2812 LED display drivers.

Documentation
-------------
-

Download
--------
The lastest binary version of the Library is always available from the
[NoiascaLedControl Release Page]http://werner.rothschopf.net/


Install
-------
Unzip the content to your Arduino Library Folder
57 changes: 57 additions & 0 deletions lib/NoiascaNeopixelDisplay/docs/html/annotated.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added lib/NoiascaNeopixelDisplay/docs/html/bc_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/NoiascaNeopixelDisplay/docs/html/bdwn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 789ade8

Please sign in to comment.