Dezibot 4
Loading...
Searching...
No Matches
MultiColorLight.cpp
Go to the documentation of this file.
1#include "MultiColorLight.h"
2
3MultiColorLight::MultiColorLight():rgbLeds(ledAmount,ledPin){
4
5};
6
8 rgbLeds.begin();
9 this->turnOffLed();
10};
11
12void MultiColorLight::setLed(uint8_t index , uint32_t color){
13 if (index > ledAmount-1){
14 //TODO: logging
15 }
16 rgbLeds.setPixelColor(index, normalizeColor(color));
17 rgbLeds.show();
18};
19
20
22 switch (leds){
23 case TOP_LEFT:
25 case TOP_RIGHT:
27 case BOTTOM:
29 case TOP:
30 for (int index = 0; index<2; index++){
32 }break;
33 case ALL:
34 for (int index = 0; index<ledAmount; index++){
36 }break;
37 default:
38 //TODO logging
39 break;
40 }
41
42};
43
44void MultiColorLight::setLed(leds leds, uint8_t red, uint8_t green, uint8_t blue){
46};
47
48
52
53void MultiColorLight::setTopLeds(uint8_t red, uint8_t green, uint8_t blue){
55};
56
57void MultiColorLight::blink(uint16_t amount,uint32_t color, leds leds, uint32_t interval){
58 for(uint16_t index = 0; index < amount;index++){
60 vTaskDelay(interval);
62 vTaskDelay(interval);
63 }
64};
65
67 switch (leds){
68 case TOP_LEFT:
69 MultiColorLight::setLed(1,0);break;
70 case TOP_RIGHT:
71 MultiColorLight::setLed(0,0);break;
72 case BOTTOM:
73 MultiColorLight::setLed(2,0);break;
74 case TOP:
75 for (int index = 0; index<2; index++){
77 }break;
78 case ALL:
79 for (int index = 0; index<3; index++){
81 }break;
82 default:
83 //TODO logging
84 break;
85 }
86};
87
88uint32_t MultiColorLight::color(uint8_t r, uint8_t g, uint8_t b){
89 return rgbLeds.Color(r,g,b);
90};
91
92//PRIVATE
93uint32_t MultiColorLight::normalizeColor(uint32_t color,uint8_t maxBrightness){
94 uint8_t red = (color&0x00FF0000)>>16;
95 uint8_t green = (color&0x0000FF00)>>8;
96 uint8_t blue = (color&0x000000FF);
97 if (red > maxBrightness){
98 red = maxBrightness;
99 }
100 if(green > maxBrightness-70){
101 green = maxBrightness-70;
102 }
103 if(blue > maxBrightness-50){
104 blue = maxBrightness-50;
105 }
106 return MultiColorLight::color(red,green,blue);
107}
color
This component controls the ability to show multicolored light, using the RGB-LEDs.
leds
Describes combinations of leds on the Dezibot. With the Robot in Front of you, when the robot drives ...
@ TOP
@ TOP_LEFT
@ BOTTOM
@ TOP_RIGHT
@ ALL
void turnOffLed(leds leds=ALL)
turn off the given leds
void blink(uint16_t amount, uint32_t color=0x00006400, leds leds=TOP, uint32_t interval=1000)
Let LEDs blink, returns after all blinks were executed.
static const uint16_t ledAmount
void setLed(uint8_t index, uint32_t color)
Set the specified led to the passed color.
void begin(void)
initialize the multicolor component
uint32_t color(uint8_t r, uint8_t g, uint8_t b)
wrapper to calulate the used colorformat from a rgb-value
static const uint8_t maxBrightness
Adafruit_NeoPixel rgbLeds
void setTopLeds(uint32_t color)
sets the two leds on the top of the robot to the specified color