Skip to content

Commit

Permalink
Fixed pressed color for LEDs
Browse files Browse the repository at this point in the history
  • Loading branch information
thnikk committed Oct 7, 2022
1 parent 6b0b32c commit 0159beb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ build_flags = -Dnumkeys=6 -Dnumleds=1 -Dneopin=PIN_NEOPIXEL -DTOUCH -DQTPY
## New xiao based models
[env:mini-xiao]
board = seeed_xiao
build_flags = -Dnumkeys=2 -Dnumleds=2 -Dneopin=10 -DTOUCH -DXIAO -DLED_TYPE=NEO_RGB

[env:mini-xiao-w]
board = seeed_xiao
build_flags = -Dnumkeys=2 -Dnumleds=2 -Dneopin=10 -DTOUCH -DXIAO -DLED_TYPE=NEO_RGBW

[env:mega-xiao]
board = seeed_xiao
build_flags = -Dnumkeys=4 -Dnumleds=2 -Dneopin=10 -DTOUCH -DXIAO -DLED_TYPE=NEO_GRB

[env:mega-xiao-w]
board = seeed_xiao
build_flags = -Dnumkeys=4 -Dnumleds=2 -Dneopin=10 -DTOUCH -DXIAO -DLED_TYPE=NEO_GRBW

[env:4k-mega-xiao]
Expand Down
14 changes: 7 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ void wheel(){
static uint8_t hue;
#if numleds == 1
if (anyPressed == 0) pixels.setPixelColor(0, pixels.ColorHSV(hue*hsv_mult, 255, b));
else pixels.setPixelColor(0, pixels.Color(255, 255, b));
else pixels.setPixelColor(0, pixels.ColorHSV(255, 0, b));
#else
for(uint8_t i = 0; i < numleds; i++) {
if (pressed[i]) pixels.setPixelColor(i, pixels.ColorHSV((hue+(i*20))*hsv_mult, 255, b));
else pixels.setPixelColor(i, pixels.Color(255, 255, b));
else pixels.setPixelColor(i, pixels.ColorHSV(255, 0, b));
}
#endif
hue--;
Expand All @@ -294,7 +294,7 @@ void highlightSelected(){
uint8_t hue = (255/numkeys);
for(uint8_t i = 0; i < numkeys; i++) {
pixels.setPixelColor(i, pixels.ColorHSV(hue*hsv_mult, 255, b));
if (i == selected) pixels.setPixelColor(i, pixels.Color(255, 255, b));
if (i == selected) pixels.setPixelColor(i, pixels.ColorHSV(255, 0, b));
}
#if numleds == 1
if (anyPressed == 0) pixels.setPixelColor(0, pixels.ColorHSV(hue*hsv_mult, 255, b));
Expand Down Expand Up @@ -345,11 +345,11 @@ void custom(){
for(int i = 0; i < numkeys; i++) {
// adjust LED order for special keypads
if (pressed[i]) pixels.setPixelColor(i, pixels.ColorHSV(custColor[i]*hsv_mult, 255, b));
else pixels.setPixelColor(i, pixels.Color(255, 255, 255));
else pixels.setPixelColor(i, pixels.ColorHSV(255, 0, b));
}
#if numleds == 1
if (anyPressed == 0) pixels.setPixelColor(0, pixels.ColorHSV(custColor[0]*hsv_mult, 255, b));
else pixels.setPixelColor(0, pixels.Color(255, 255, 255));
else pixels.setPixelColor(0, pixels.ColorHSV(255, 0, b));
#endif
pixels.show();
}
Expand Down Expand Up @@ -382,11 +382,11 @@ void bps(){

for(int i = 0; i < numleds; i++) {
if (pressed[i]) pixels.setPixelColor(i, pixels.ColorHSV((finalColor+100)*hsv_mult, 255, b));
else pixels.setPixelColor(i, pixels.Color(255, 255, b));
else pixels.setPixelColor(i, pixels.ColorHSV(255, 0, b));
}
#if numleds == 1
if (anyPressed == 0) pixels.setPixelColor(0, pixels.ColorHSV((finalColor+100)*hsv_mult, 255, b));
else pixels.setPixelColor(0, pixels.Color(255, 255, b));
else pixels.setPixelColor(0, pixels.ColorHSV(255, 0, b));
#endif
//FastLED.show();
pixels.show();
Expand Down

0 comments on commit 0159beb

Please sign in to comment.