Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P165] Add plugin Display - NeoPixel (7-segment) #5113

Open
wants to merge 26 commits into
base: mega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b48416a
[P165] Add plugin Display - NeoPixel (7-segment)
tonhuisman Aug 25, 2024
9adea94
[P165] Add code from #4977
tonhuisman Aug 25, 2024
f8f006d
[P165] Add code from #5091
tonhuisman Aug 25, 2024
6f741ce
[AdaGFX] Add rgb565/rgb888 color conversions
tonhuisman Aug 25, 2024
f296d62
[P165] Add Clear display on exit, add manual g-segment split, rework …
tonhuisman Aug 26, 2024
913f54e
[P165] Breaking Settings change! (delete & re-add) Allow 7 pixels/seg…
tonhuisman Aug 27, 2024
95f0137
[P165] Add digitmapping for having all RTL groups, UI improvements an…
tonhuisman Aug 28, 2024
01c98bb
[P165] Add counter-clockwise numbering, enable digit/group color comm…
tonhuisman Aug 29, 2024
cf3962d
[DeviceStruct] Add PinDirection flag for PIN1..PIN3
tonhuisman Aug 31, 2024
7c4bf21
[P165] Apply PinXDirection feature
tonhuisman Aug 31, 2024
93061ab
[P165] Add new commands to EasyColorCode (some are defined for P073)
tonhuisman Aug 31, 2024
500e18b
[P165] Add documentation and a few configuration examples
tonhuisman Aug 31, 2024
4dd4c6b
[EasyColorCode] Command Reset is renamed to FactoryReset
tonhuisman Sep 1, 2024
a237603
[P165] Add more code from #5091
tonhuisman Sep 1, 2024
84d8b22
[P165] Fix some bugs found during testing
tonhuisman Sep 1, 2024
12f4c07
[EasyColorCode] Also update minified js file
tonhuisman Sep 1, 2024
ab5c49b
[P165] Add more code from #5091
tonhuisman Sep 2, 2024
55af316
[P165] Disable periods handling if no decimal dot pixels defined
tonhuisman Sep 5, 2024
0c91766
[P165] Small bugfix
tonhuisman Sep 11, 2024
6c55b8f
[P165] Bugfixes and javascript optimizations
tonhuisman Sep 15, 2024
044dd43
[P165] Bugfixes and javascript optimizations
tonhuisman Sep 15, 2024
cdcbee5
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Sep 15, 2024
647c719
[UI] Fix disabled-checked Checkbox styling, and allow to enable/disab…
tonhuisman Sep 18, 2024
bf50395
[P165] Add option to start numbering at g-segment
tonhuisman Sep 18, 2024
d4c2360
[P165] Add option to use decimal dot for blinking time indicator
tonhuisman Sep 19, 2024
b2213d3
[P165] Fix initialization of output mode
tonhuisman Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/_P165_7SegNeopixel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// #######################################################################################################

/** Changelog:
* 2024-09-01 tonhuisman: Fixing some bugs/typos: g-split was enabled for width-pixels > 1, P073 font characters must have 7 bits reverted.
* 7groupcolor wasn't handling arguments correctly. Restoring groupcolor after digitcolor fixed.
* 2024-08-31 tonhuisman: Apply Device[].PinXDirection feature so only an output-capable GPIO can be selected for the Strip
* 2024-08-29 tonhuisman: Add Counter-clockwise numbering option pe group. Enable GroupColor and DigitColor features also fog
* LIMIT_BUILD_SIZE builds, as the ESP8266 NeoPixel builds still have enough space available.
Expand Down
14 changes: 14 additions & 0 deletions src/src/PluginStructs/P073_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ void P073_font_selector(const __FlashStringHelper *id, int16_t value) {

# endif // ifdef P073_EXTRA_FONTS

/**
* This function reverts the 7 databits/segmentbits so TM1637 and 74HC595 displays work with fonts designed for MAX7219.
* Dot/colon bit is still bit 8
*/
uint8_t P073_revert7bits(uint8_t character) {
uint8_t newCharacter = character & 0x80; // Keep dot-bit if passed in
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved

for (int b = 0; b < 7; ++b) {
if (character & (0x01 << b)) {
newCharacter |= (0x40 >> b);
}
}
return newCharacter;
}
// FIXME End of part to merge from PR #5091

void P073_data_struct::init(struct EventStruct *event)
Expand Down
1 change: 1 addition & 0 deletions src/src/PluginStructs/P073_data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void P073_display_output_selector(const __FlashStringHelper *id,
void P073_font_selector(const __FlashStringHelper *id,
int16_t value);
# endif // ifdef P073_EXTRA_FONTS
uint8_t P073_revert7bits(uint8_t character);
// FIXME End of part to merge from PR #5091

struct P073_data_struct : public PluginTaskData_base {
Expand Down
25 changes: 15 additions & 10 deletions src/src/PluginStructs/P165_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ void P165_data_struct::fillSegmentBitmap(const uint8_t grp,
const uint8_t hpx = pixCfg.wpix + (pixCfg.crnr ? 2 : 0); // Overlapping pixels checked on horizontal segments
const uint8_t vpx = pixCfg.hpix; // Vertical pixels = height pixels
// smap: Determine the segment(part) order
const uint8_t smap = (pixCfg.strt ? 2 : 0) + (pixCfg.dend ? 1 : 0) + (pixCfg.wpix > pixCfg.splt ? 4 : 0) + (pixCfg.cclkw ? 8 : 0);
const uint8_t smap = (pixCfg.strt ? 2 : 0) + (pixCfg.dend ? 1 : 0) + (pixCfg.splt ? 4 : 0) + (pixCfg.cclkw ? 8 : 0);
const uint8_t rh = hpx / 2; // Horizontal half part, right
const uint8_t lh = hpx - rh; // Horizontal half part, left

Expand Down Expand Up @@ -1416,7 +1416,7 @@ bool P165_data_struct::plugin_write(struct EventStruct *event,
case p165_commands_e::c7digitcolor: // 7digitcolor,grp,dgt,[-|fg_r,fg_g,fg_b[,fg_w][,bg_r,bg_g,bg_b[,bg_w]]]
# endif // if P165_FEATURE_DIGITCOLOR
# if P165_FEATURE_GROUPCOLOR
case p165_commands_e::c7groupcolor: // 7digitcolor,grp,[-|fg_r,fg_g,fg_b[,fg_w][,bg_r,bg_g,bg_b[,bg_w]]]
case p165_commands_e::c7groupcolor: // 7groupcolor,grp,[-|fg_r,fg_g,fg_b[,fg_w][,bg_r,bg_g,bg_b[,bg_w]]]
# endif // if P165_FEATURE_GROUPCOLOR
# if P165_FEATURE_DIGITCOLOR || P165_FEATURE_GROUPCOLOR
{
Expand All @@ -1439,7 +1439,7 @@ bool P165_data_struct::plugin_write(struct EventStruct *event,
grp = event->Par1;
}

if ((grp > 0) && (grpColor || ((event->Par2 > 0) && (event->Par2 <= _pixelGroupCfg[grp - 1].dgts)))) {
if ((grp > 0) && !grpColor && ((event->Par2 > 0) && (event->Par2 <= _pixelGroupCfg[grp - 1].dgts))) {
dgt = event->Par2;
}

Expand All @@ -1451,7 +1451,8 @@ bool P165_data_struct::plugin_write(struct EventStruct *event,
const uint16_t grp200dgt = 0x200 + (grp << 4) + (dgt - 1);
const uint16_t grp300 = 0x300 + (grp << 4);
const uint16_t grp400 = 0x400 + (grp << 4);
const String par4 = parseString(string, 4);
const uint8_t parIdx = grpColor ? 3 : 4;
const String par4 = parseString(string, parIdx);

// Next argument: delete digit/groupcolor?
if (equals(par4, F("-"))) { // use dash to remove a digit/group color setting
Expand All @@ -1467,7 +1468,7 @@ bool P165_data_struct::plugin_write(struct EventStruct *event,
}
success = true;
} else
if (parseRGBWColors(parseStringToEnd(string, 4), rgbW, fgColor, bgColor, fgSet, bgSet)) {
if (parseRGBWColors(parseStringToEnd(string, parIdx), rgbW, fgColor, bgColor, fgSet, bgSet)) {
if (fgSet) {
auto it = digitColors.find(grpColor ? grp300 : grp100dgt); // fg color

Expand Down Expand Up @@ -1935,7 +1936,7 @@ void P165_data_struct::writeCharacterToDisplay(uint8_t group, uint8_t digit, uin
# endif // if P165_FEATURE_P073
character
# if P165_FEATURE_P073 // Use P073 7-segment fonts and buffer content when available
: P073_getFontChar(character, _fontset)
: P073_revert7bits(P073_getFontChar(character, _fontset))
# endif // if P165_FEATURE_P073
;

Expand Down Expand Up @@ -1969,6 +1970,8 @@ void P165_data_struct::writeBufferToDisplay(uint8_t group) {
# endif // if P165_DEBUG_DEBUG

for (uint8_t grp = from; grp < to; ++grp) {
uint32_t fgColor = AdaGFXrgb565ToRgb888(_fgColor);
uint32_t bgColor = AdaGFXrgb565ToRgb888(_bgColor);
# if P165_FEATURE_GROUPCOLOR
bool fgColorGrp = false;
bool bgColorGrp = false;
Expand All @@ -1977,13 +1980,15 @@ void P165_data_struct::writeBufferToDisplay(uint8_t group) {
auto itgrp = digitColors.find(grp300); // fg color

if (itgrp != digitColors.end()) {
display[grp]->setColorFont(itgrp->second);
fgColor = itgrp->second;
display[grp]->setColorFont(fgColor);
fgColorGrp = true;
}
itgrp = digitColors.find(grp400); // bg color

if (itgrp != digitColors.end()) {
display[grp]->setColorBack(itgrp->second);
bgColor = itgrp->second;
display[grp]->setColorBack(bgColor);
bgColorGrp = true;
}
# endif // if P165_FEATURE_GROUPCOLOR
Expand Down Expand Up @@ -2022,11 +2027,11 @@ void P165_data_struct::writeBufferToDisplay(uint8_t group) {

// Restore global colors
if (fgColorSet) {
display[grp]->setColorFont(AdaGFXrgb565ToRgb888(_fgColor));
display[grp]->setColorFont(fgColor);
}

if (bgColorSet) {
display[grp]->setColorBack(AdaGFXrgb565ToRgb888(_bgColor));
display[grp]->setColorBack(bgColor);
}
# endif // if P165_FEATURE_DIGITCOLOR

Expand Down
4 changes: 2 additions & 2 deletions static/espeasy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
var commonAtoms = ["And", "Or"];
var commonKeywords = ["If", "Else", "Elseif", "Endif"];
var commonCommands = ["AccessInfo", "Background", "Build", "ClearAccessBlock", "ClearRTCam", "Config", "ControllerDisable",
"ControllerEnable", "DateTime", "Debug", "Dec", "DeepSleep", "DisablePriorityTask", "DNS", "DST", "EraseSDKWiFi", "ExecuteRules", "Gateway", "I2Cscanner", "Inc",
"ControllerEnable", "DateTime", "Debug", "Dec", "DeepSleep", "DisablePriorityTask", "DNS", "DST", "EraseSDKWiFi", "ExecuteRules", "FactoryReset", "Gateway", "I2Cscanner", "Inc",
"IP", "Let", "Load", "LogEntry", "LogPortStatus", "LoopTimerSet", "LoopTimerSet_ms", "MemInfo", "MemInfoDetail", "Name", "Password", "PostToHTTP", "Publish", "PublishR",
"Reboot", "Reset", "Save", "SendTo", "SendToHTTP", "SendToUDP", "Settings", "Subnet", "Subscribe", "TaskClear", "TaskClearAll",
"Reboot", "Save", "SendTo", "SendToHTTP", "SendToUDP", "Settings", "Subnet", "Subscribe", "TaskClear", "TaskClearAll",
"TaskDisable", "TaskEnable", "TaskRun", "TaskValueSet", "TaskValueSetAndRun", "TimerPause", "TimerResume", "TimerSet", "TimerSet_ms", "TimeZone",
"UdpPort", "UdpTest", "Unit", "UseNTP", "WdConfig", "WdRead", "WiFi", "WiFiAllowAP", "WiFiAPMode", "WiFiConnect", "WiFiDisconnect", "WiFiKey",
"WiFiKey2", "WiFiMode", "WiFiScan", "WiFiSSID", "WiFiSSID2", "WiFiSTAMode",
Expand Down