From f7dc36a58fd8dfb4fb5fb3115016d5a1e9ff644c Mon Sep 17 00:00:00 2001 From: Orhan-Timo Altan <timo.altan@th-koeln.de> Date: Wed, 30 Nov 2022 21:14:28 +0100 Subject: [PATCH] added 2 functions: set_brightness, get_pixel_color --- thk_ledstrip_controller.cpp | 10 +++++++++- thk_ledstrip_controller.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/thk_ledstrip_controller.cpp b/thk_ledstrip_controller.cpp index 6f441f1..6ac5fc0 100644 --- a/thk_ledstrip_controller.cpp +++ b/thk_ledstrip_controller.cpp @@ -10,6 +10,10 @@ void thk_LedStripController::init() { show(); } +void thk_LedStripController::set_brightness(uint8_t brightness) { + ptrStrip->setBrightness(brightness); +} + void thk_LedStripController::clear() { ptrStrip->clear(); } @@ -27,6 +31,11 @@ void thk_LedStripController::set_pixel_color(uint16_t start_index, uint16_t amou ptrStrip->fill(color, start_index, amount); } +uint32_t thk_LedStripController::get_pixel_color(uint16_t index) { + uint32_t pixel_color = ptrStrip->getPixelColor(index); + return pixel_color; +} + void thk_LedStripController::show() { ptrStrip->show(); } @@ -120,7 +129,6 @@ void thk_LedStripController::running_light(unsigned long wait_time, uint8_t leng ptrStrip->show(); // Send the updated pixel colors to the hardware. delay(wait_time); // Pause before next pass through loop - Serial.println(last_pixel); } clear(); show(); diff --git a/thk_ledstrip_controller.h b/thk_ledstrip_controller.h index eb8f6c1..9db21be 100644 --- a/thk_ledstrip_controller.h +++ b/thk_ledstrip_controller.h @@ -22,10 +22,12 @@ class thk_LedStripController { thk_LedStripController(const uint16_t MAX_LED_NUMBER, const uint16_t DATA_PIN, uint8_t brightness = 64); void init(); void clear(); + void set_brightness(uint8_t brightness); static uint32_t Color(uint8_t red, uint8_t green, uint8_t blue) { return Adafruit_NeoPixel::Color(red, green, blue);}; void set_pixel_color(uint32_t color); void set_pixel_color(uint16_t index, uint32_t color); void set_pixel_color(uint16_t index, uint16_t amount, uint32_t color); + uint32_t get_pixel_color(uint16_t index); void show(); uint32_t color_hsv(int pixelHue); uint32_t gamma(int pixelHue); -- GitLab