Skip to content

Commit

Permalink
Merge pull request #4746 from uwekaditz/UweKaditz
Browse files Browse the repository at this point in the history
[P036] Add ticker as scroll option
  • Loading branch information
TD-er authored Sep 17, 2023
2 parents 77925a8 + 780c1b9 commit 156d79e
Show file tree
Hide file tree
Showing 9 changed files with 579 additions and 191 deletions.
14 changes: 12 additions & 2 deletions docs/source/Plugin/P036.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ Device Settings

.. image:: P036_ScrollOptions.png

* **Scroll**: Switching between pages can be "instant" or "scrolling". Please note that scrolling will need more resources of the ESP, which can have an effect on other active tasks of the node.
* **Scroll**: Switching between pages can be "instant", "scrolling" or a "ticker" band. Please note that scrolling will need more resources of the ESP, which can have an effect on other active tasks of the node.
For the ``Ticker`` there are some restrictions:
* Depending on the build used (NORMAL and CUSTOM) this option is available
* only one line is displaying the ticker string
* all line contents are parsed and combined to this ticker string, the parsing happens only at each ticker start (using the setting ``Interval``)
* the optional split token ``<|>`` is replaced by three spaces
* the gaps between the ticker items must be set by the ``line content`` (tailing spaces)
* the starting alignment (left, center, right) depends on the setting ``Align content (global)``
* the font is taken from the setting ``Modify font`` of the first line, the ``Alignment`` settings of the lines are ignored (always right aligned)
* the ticker speed depends on the length of the ticker string and the setting ``Interval`` setting
* the footer is automatically hidden

* **GPIO <- Display button**: Setting up a ``Display Button``, allows to configure a Display Timeout and wake the display on demand, either by a button, or by using some presence detection.

Expand Down Expand Up @@ -125,7 +135,7 @@ The user defined texts may also contain a split token ``<|>`` to display the lin

* **Alignment**: For each line, the alignment to be used can be selected, or the global setting can be used.

* **Interval** By default, Interval will be set to 0. If set to a non-zero value, the pre-configured content will be updated automatically using that interval (seconds).
* **Interval** By default, Interval will be set to 0. It needs to be set to a non-zero value, to switch between the frames using that interval (seconds).


General
Expand Down
Binary file modified docs/source/Plugin/P036_ScrollOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion docs/source/Plugin/P036_commands.repl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

The updated line text is not stored in the settings itself, but kept in memory.
After a reboot the stored plugin settings will be used.
The line text can also be restored from the settings by the command ``restore``.

All template notations can be used, like system variables, or reference to a task value.

Expand All @@ -50,6 +51,7 @@
This command is to display a specific frame (aka page), or the next frame. When reaching the last frame, a 'next' (0) will display the first frame.

The <framenr> parameter corresponds to the desired frame (1..<number of frames>) to display. The number of frames is determined by dividing the lines in use (at least one line in that frame with some data), by the number of Lines per Frame. So practically, the range is 1..3 when all lines are used and 4 Lines per Frame is set, or 1..12 if Line per frames is set to 1. The number of frames is updated if a frame would initially be empty, and an external source places text on a line of that frame (see above).
If scroll is set to ``ticker`` only <framenr> = 1 is supported, it starts the ticker from the beginning.

When omitting <framenr>, or providing 0, the next frame is displayed.

Expand All @@ -59,6 +61,7 @@
``oledframedcmd,linecount,<1..4>``
","
This command changes the number of lines in each frame. When the next frame is to be displayed, the frames are recalculated and the sequence is restarted at the first frame.
If scroll is set to ``ticker`` this command is not supported.

If Generate events for 'Linecount' is selected, a ``<taskname#linecount=<lines>`` event is generated on initialization of the plugin and when changing the setting.
"
Expand All @@ -85,4 +88,18 @@
Set the user defined header nr. 2 with any desired text value.

Use ``$<sysvar>$`` instead of ``%<sysvar>%`` to use system variables.
"
"
"
``oledframedcmd,restore,<line>``
","
If the <line> parameter is set to 0 all line contents will be restored from the settings.
Otherwise the <line> parameter corresponds with the same lines as the plugin configuration has,
and only the content of this line will be restored from the settings.
"
"
``oledframedcmd,scroll,<speed>``
","
The <speed> parameter corresponds with the line number of the scroll parameter of the settings (1=Very slow ... 6=Ticker).
After applying the new scroll speed the display restarts with the first page.
"

9 changes: 9 additions & 0 deletions lib/esp8266-oled-ssd1306/OLEDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ uint16_t OLEDDisplay::getStringWidth(const String& strUser) {
return width;
}

uint8_t OLEDDisplay::getCharWidth(const char c) {
uint8_t firstChar = pgm_read_byte(fontData + FIRST_CHAR_POS);
if (utf8ascii(c) == 0)
return 0;
if (c < firstChar)
return 0;
return pgm_read_byte(fontData + JUMPTABLE_START + (c- firstChar) * JUMPTABLE_BYTES + JUMPTABLE_WIDTH);
}

void OLEDDisplay::setTextAlignment(OLEDDISPLAY_TEXT_ALIGNMENT textAlignment) {
this->textAlignment = textAlignment;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/esp8266-oled-ssd1306/OLEDDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ class OLEDDisplay : public Print {
// Convencience method for the const char version
uint16_t getStringWidth(const String& text);

// Returns the width of c with the already set fontData
// returns a 0 if c is non-ascii
// in this case the next char must be converted
uint8_t getCharWidth(const char c);

// Specifies relative to which anchor point
// the text is rendered. Available constants:
// TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER_BOTH
Expand Down
1 change: 1 addition & 0 deletions src/Custom-sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = {
// #define USES_P036 // FrameOLED
// #define P036_FEATURE_DISPLAY_PREVIEW 1 // Enable Preview feature, shows on-display content on Devices overview page
// #define P036_FEATURE_ALIGN_PREVIEW 1 // Enable center/right-align feature when preview is enabled (auto-disabled for 1M builds)
// #define P036_ENABLE_TICKER 1 // Enable ticker function
// #define USES_P037 // MQTTImport
// #define P037_MAPPING_SUPPORT 1 // Enable Value mapping support
// #define P037_FILTER_SUPPORT 1 // Enable filtering support
Expand Down
Loading

0 comments on commit 156d79e

Please sign in to comment.