SPI for FastLED

This commit is contained in:
norbert-walter 2024-09-13 17:41:02 +02:00
parent 185bf91a7a
commit 91f8ba0e4d
4 changed files with 27 additions and 17 deletions

View File

@ -1,6 +1,9 @@
#ifdef BOARD_OBP60S3 #ifdef BOARD_OBP60S3
#include <Arduino.h> #include <Arduino.h>
#define FASTLED_ALL_PINS_HARDWARE_SPI
#define FASTLED_ESP32_SPI_BUS HSPI
#define FASTLED_ESP32_FLASH_LOCK 1
#include <FastLED.h> // Driver for WS2812 RGB LED #include <FastLED.h> // Driver for WS2812 RGB LED
#include <PCF8574.h> // Driver for PCF8574 output modul from Horter #include <PCF8574.h> // Driver for PCF8574 output modul from Horter
#include <Wire.h> // I2C #include <Wire.h> // I2C
@ -110,6 +113,10 @@ CHSV colorMapping(String colorString){
// All defined colors see pixeltypes.h in FastLED lib // All defined colors see pixeltypes.h in FastLED lib
void setBacklightLED(uint brightness, CHSV color){ void setBacklightLED(uint brightness, CHSV color){
static uint oldbrightness;
static CHSV oldcolor;
// If changed the values then set new values
if(brightness != oldbrightness || color != oldcolor){
FastLED.setBrightness(255); // Brightness for flash LED FastLED.setBrightness(255); // Brightness for flash LED
color.value = brightness; color.value = brightness;
backlight[0] = color; // Backlight LEDs on with color backlight[0] = color; // Backlight LEDs on with color
@ -119,6 +126,9 @@ void setBacklightLED(uint brightness, CHSV color){
backlight[4] = color; backlight[4] = color;
backlight[5] = color; backlight[5] = color;
FastLED.show(); FastLED.show();
oldbrightness = brightness;
oldcolor = color;
}
} }
void toggleBacklightLED(uint brightness, CHSV color){ void toggleBacklightLED(uint brightness, CHSV color){
@ -145,9 +155,9 @@ void toggleBacklightLED(uint brightness, CHSV color){
} }
void setFlashLED(bool status){ void setFlashLED(bool status){
statusLED = status; static bool oldstatus;
FastLED.setBrightness(255); // Brightness for flash LED FastLED.setBrightness(255); // Brightness for flash LED
if(statusLED == true){ if(status == true){
fled[0] = CRGB::Red; // Flash LED on in red fled[0] = CRGB::Red; // Flash LED on in red
} }
else{ else{

View File

@ -3,6 +3,9 @@
#include <Arduino.h> #include <Arduino.h>
#include "OBP60Hardware.h" #include "OBP60Hardware.h"
#define FASTLED_ALL_PINS_HARDWARE_SPI
#define FASTLED_ESP32_SPI_BUS HSPI
#define FASTLED_ESP32_FLASH_LOCK 1
#include <FastLED.h> // Driver for WS2812 RGB LED #include <FastLED.h> // Driver for WS2812 RGB LED
#include <GxEPD2_BW.h> // E-paper lib V2 #include <GxEPD2_BW.h> // E-paper lib V2

View File

@ -262,8 +262,7 @@ public:
} }
// Update display // Update display
while(getdisplay().nextPage()); // Partial update (fast) getdisplay().nextPage(); // Partial update (fast)
while(getdisplay().nextPage()); // Partial update (fast)
}; };
}; };

View File

@ -387,9 +387,7 @@ public:
} }
// Update display // Update display
while(getdisplay().nextPage()); // Partial update (fast) getdisplay().nextPage(); // Partial update (fast)
while(getdisplay().nextPage()); // Partial update (fast)
while(getdisplay().nextPage()); // Partial update (fast)
}; };
}; };