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

Speed improvements for discussion #4138

Open
wants to merge 40 commits into
base: 0_15
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c3f472f
some improvements to consider
DedeHai Sep 11, 2024
9341768
more improvements to color_scale() now even faster.
DedeHai Sep 12, 2024
feac45f
improvement in color_add
DedeHai Sep 12, 2024
992d11b
Improvements in get/set PixelColor()
DedeHai Sep 12, 2024
b07658b
improved Segment::setPixelColorXY a tiny bit
DedeHai Sep 12, 2024
09428dc
inlined getMappedPixelIndex, improved color_add, bugfix in colorFromP…
DedeHai Sep 12, 2024
ec938f2
removed old code
DedeHai Sep 12, 2024
d45b4ad
fixes and consistency
DedeHai Sep 13, 2024
2afff05
minor tweak (break instead of continue in setPixelColorXY)
DedeHai Sep 14, 2024
6a37f25
memory improvement: dropped static gamma table
DedeHai Sep 14, 2024
0e5bd4e
remove test printout
DedeHai Sep 14, 2024
f3137eb
updated Segment::color_from_palette
DedeHai Sep 14, 2024
686866c
Merge remote-tracking branch 'upstream/0_15' into 0_15__speed_improve…
DedeHai Sep 18, 2024
6962905
cleanup and improved color_add()
DedeHai Sep 18, 2024
a88436c
revert removal of adding with saturation, renamed 'fast' to 'saturate'
DedeHai Sep 19, 2024
17d59d3
adding initialization to vStrip, added comment on padding bytes
DedeHai Sep 22, 2024
0a54002
removed IRAM_ATTR from inlined function
DedeHai Sep 22, 2024
33cf82a
Indentations and a few optimisations
blazoncek Sep 23, 2024
906f8fc
Fix C3 compiler issue.
blazoncek Sep 25, 2024
bef1ac2
Added HSV2RGB and RGB2HSV functions for higher accuracy conversions
DedeHai Sep 25, 2024
c44b9f8
Merge remote-tracking branch 'upstream/0_15' into 0_15__speed_improve…
DedeHai Sep 26, 2024
b404458
fixed one forgotten replacement of rgb2hsv_approximate
DedeHai Sep 26, 2024
a76a895
bugfix
DedeHai Sep 27, 2024
7c0fe12
updated setPixelColor() and getPixelColor() functions
DedeHai Sep 28, 2024
202901b
bugfix, ESP32 compiler requires the color order to be identical
DedeHai Sep 28, 2024
c842994
Pre-calculate virtual
blazoncek Sep 28, 2024
9114867
Fix compiler error
blazoncek Sep 28, 2024
ffbc8c5
Reverting addition of `bool unScale`, added new improvements and fixes
DedeHai Sep 29, 2024
336da25
Private global _colorScaled
blazoncek Sep 29, 2024
8e78fb4
Merge branch '0_15' into 0_15__speed_improvements
blazoncek Sep 29, 2024
0ae7329
Update comment
blazoncek Sep 29, 2024
ee380c5
Replace uint16_t with unsigned for segment data
blazoncek Sep 30, 2024
ba3a61f
Reduced code size by:
blazoncek Oct 2, 2024
a15c391
Improvement to `setPixelColorXY` and some flash optimisations
DedeHai Oct 3, 2024
ca06214
removed todo.
DedeHai Oct 3, 2024
eb5ad23
Minor tweaks and whitespace
blazoncek Oct 5, 2024
be64930
Indentation and shadowed variable.
blazoncek Oct 7, 2024
210191b
Fix for realtime drawing on main segment
blazoncek Oct 7, 2024
ef1e24c
Bugfix & code reduction
blazoncek Nov 9, 2024
5c2bac4
Merge branch '0_15' into 0_15__speed_improvements
blazoncek Nov 9, 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: 1 addition & 1 deletion usermods/smartnest/usermod_smartnest.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Smartnest : public Usermod

void setColor(int r, int g, int b)
{
strip.setColor(0, r, g, b);
strip.getMainSegment().setColor(0, RGBW32(r, g, b, 0));
stateUpdated(CALL_MODE_DIRECT_CHANGE);
char msg[18] {};
sprintf(msg, "rgb(%d,%d,%d)", r, g, b);
Expand Down
128 changes: 64 additions & 64 deletions usermods/word-clock-matrix/usermod_word_clock_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class WordClockMatrix : public Usermod
//strip.getSegment(1).setOption(SEG_OPTION_SELECTED, true);

//select first two segments (background color + FX settable)
WS2812FX::Segment &seg = strip.getSegment(0);
Segment &seg = strip.getSegment(0);
seg.colors[0] = ((0 << 24) | ((0 & 0xFF) << 16) | ((0 & 0xFF) << 8) | ((0 & 0xFF)));
strip.getSegment(0).setOption(0, false);
strip.getSegment(0).setOption(2, false);
//other segments are text
for (int i = 1; i < 10; i++)
{
WS2812FX::Segment &seg = strip.getSegment(i);
Segment &seg = strip.getSegment(i);
seg.colors[0] = ((0 << 24) | ((0 & 0xFF) << 16) | ((190 & 0xFF) << 8) | ((180 & 0xFF)));
strip.getSegment(i).setOption(0, true);
strip.setBrightness(64);
Expand Down Expand Up @@ -80,61 +80,61 @@ class WordClockMatrix : public Usermod
void displayTime(byte hour, byte minute)
{
bool isToHour = false; //true if minute > 30
strip.setSegment(0, 0, 64); // background
strip.setSegment(1, 0, 2); //It is
strip.getSegment(0).setGeometry(0, 64); // background
strip.getSegment(1).setGeometry(0, 2); //It is

strip.setSegment(2, 0, 0);
strip.setSegment(3, 0, 0); //disable minutes
strip.setSegment(4, 0, 0); //past
strip.setSegment(6, 0, 0); //to
strip.setSegment(8, 0, 0); //disable o'clock
strip.getSegment(2).setGeometry(0, 0);
strip.getSegment(3).setGeometry(0, 0); //disable minutes
strip.getSegment(4).setGeometry(0, 0); //past
strip.getSegment(6).setGeometry(0, 0); //to
strip.getSegment(8).setGeometry(0, 0); //disable o'clock

if (hour < 24) //valid time, display
{
if (minute == 30)
{
strip.setSegment(2, 3, 6); //half
strip.setSegment(3, 0, 0); //minutes
strip.getSegment(2).setGeometry(3, 6); //half
strip.getSegment(3).setGeometry(0, 0); //minutes
}
else if (minute == 15 || minute == 45)
{
strip.setSegment(3, 0, 0); //minutes
strip.getSegment(3).setGeometry(0, 0); //minutes
}
else if (minute == 10)
{
//strip.setSegment(5, 6, 8); //ten
//strip.getSegment(5).setGeometry(6, 8); //ten
}
else if (minute == 5)
{
//strip.setSegment(5, 16, 18); //five
//strip.getSegment(5).setGeometry(16, 18); //five
}
else if (minute == 0)
{
strip.setSegment(3, 0, 0); //minutes
strip.getSegment(3).setGeometry(0, 0); //minutes
//hourChime();
}
else
{
strip.setSegment(3, 18, 22); //minutes
strip.getSegment(3).setGeometry(18, 22); //minutes
}

//past or to?
if (minute == 0)
{ //full hour
strip.setSegment(3, 0, 0); //disable minutes
strip.setSegment(4, 0, 0); //disable past
strip.setSegment(6, 0, 0); //disable to
strip.setSegment(8, 60, 64); //o'clock
strip.getSegment(3).setGeometry(0, 0); //disable minutes
strip.getSegment(4).setGeometry(0, 0); //disable past
strip.getSegment(6).setGeometry(0, 0); //disable to
strip.getSegment(8).setGeometry(60, 64); //o'clock
}
else if (minute > 34)
{
//strip.setSegment(6, 22, 24); //to
//strip.getSegment(6).setGeometry(22, 24); //to
//minute = 60 - minute;
isToHour = true;
}
else
{
//strip.setSegment(4, 24, 27); //past
//strip.getSegment(4).setGeometry(24, 27); //past
//isToHour = false;
}
}
Expand All @@ -143,68 +143,68 @@ class WordClockMatrix : public Usermod

if (minute <= 4)
{
strip.setSegment(3, 0, 0); //nothing
strip.setSegment(5, 0, 0); //nothing
strip.setSegment(6, 0, 0); //nothing
strip.setSegment(8, 60, 64); //o'clock
strip.getSegment(3).setGeometry(0, 0); //nothing
strip.getSegment(5).setGeometry(0, 0); //nothing
strip.getSegment(6).setGeometry(0, 0); //nothing
strip.getSegment(8).setGeometry(60, 64); //o'clock
}
else if (minute <= 9)
{
strip.setSegment(5, 16, 18); // five past
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(16, 18); // five past
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 14)
{
strip.setSegment(5, 6, 8); // ten past
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(6, 8); // ten past
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 19)
{
strip.setSegment(5, 8, 12); // quarter past
strip.setSegment(3, 0, 0); //minutes
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(8, 12); // quarter past
strip.getSegment(3).setGeometry(0, 0); //minutes
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 24)
{
strip.setSegment(5, 12, 16); // twenty past
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(12, 16); // twenty past
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 29)
{
strip.setSegment(5, 12, 18); // twenty-five past
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(12, 18); // twenty-five past
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 34)
{
strip.setSegment(5, 3, 6); // half past
strip.setSegment(3, 0, 0); //minutes
strip.setSegment(4, 24, 27); //past
strip.getSegment(5).setGeometry(3, 6); // half past
strip.getSegment(3).setGeometry(0, 0); //minutes
strip.getSegment(4).setGeometry(24, 27); //past
}
else if (minute <= 39)
{
strip.setSegment(5, 12, 18); // twenty-five to
strip.setSegment(6, 22, 24); //to
strip.getSegment(5).setGeometry(12, 18); // twenty-five to
strip.getSegment(6).setGeometry(22, 24); //to
}
else if (minute <= 44)
{
strip.setSegment(5, 12, 16); // twenty to
strip.setSegment(6, 22, 24); //to
strip.getSegment(5).setGeometry(12, 16); // twenty to
strip.getSegment(6).setGeometry(22, 24); //to
}
else if (minute <= 49)
{
strip.setSegment(5, 8, 12); // quarter to
strip.setSegment(3, 0, 0); //minutes
strip.setSegment(6, 22, 24); //to
strip.getSegment(5).setGeometry(8, 12); // quarter to
strip.getSegment(3).setGeometry(0, 0); //minutes
strip.getSegment(6).setGeometry(22, 24); //to
}
else if (minute <= 54)
{
strip.setSegment(5, 6, 8); // ten to
strip.setSegment(6, 22, 24); //to
strip.getSegment(5).setGeometry(6, 8); // ten to
strip.getSegment(6).setGeometry(22, 24); //to
}
else if (minute <= 59)
{
strip.setSegment(5, 16, 18); // five to
strip.setSegment(6, 22, 24); //to
strip.getSegment(5).setGeometry(16, 18); // five to
strip.getSegment(6).setGeometry(22, 24); //to
}

//hours
Expand All @@ -220,45 +220,45 @@ class WordClockMatrix : public Usermod
switch (hour)
{
case 1:
strip.setSegment(7, 27, 29);
strip.getSegment(7).setGeometry(27, 29);
break; //one
case 2:
strip.setSegment(7, 35, 37);
strip.getSegment(7).setGeometry(35, 37);
break; //two
case 3:
strip.setSegment(7, 29, 32);
strip.getSegment(7).setGeometry(29, 32);
break; //three
case 4:
strip.setSegment(7, 32, 35);
strip.getSegment(7).setGeometry(32, 35);
break; //four
case 5:
strip.setSegment(7, 37, 40);
strip.getSegment(7).setGeometry(37, 40);
break; //five
case 6:
strip.setSegment(7, 43, 45);
strip.getSegment(7).setGeometry(43, 45);
break; //six
case 7:
strip.setSegment(7, 40, 43);
strip.getSegment(7).setGeometry(40, 43);
break; //seven
case 8:
strip.setSegment(7, 45, 48);
strip.getSegment(7).setGeometry(45, 48);
break; //eight
case 9:
strip.setSegment(7, 48, 50);
strip.getSegment(7).setGeometry(48, 50);
break; //nine
case 10:
strip.setSegment(7, 54, 56);
strip.getSegment(7).setGeometry(54, 56);
break; //ten
case 11:
strip.setSegment(7, 50, 54);
strip.getSegment(7).setGeometry(50, 54);
break; //eleven
case 12:
strip.setSegment(7, 56, 60);
strip.getSegment(7).setGeometry(56, 60);
break; //twelve
}

selectWordSegments(true);
applyMacro(1);
applyPreset(1);
}

void timeOfDay()
Expand Down
Loading