mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-19 11:01:46 +02:00
Integrate RGB LEDs into power management
This commit is contained in:
parent
4bfae98f6b
commit
8a93e0ca93
@ -5,6 +5,9 @@ MultiColorLight::MultiColorLight():rgbLeds(ledAmount,ledPin){
|
|||||||
};
|
};
|
||||||
|
|
||||||
void MultiColorLight::begin(void){
|
void MultiColorLight::begin(void){
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_TOP_LEFT, PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_TOP_RIGHT, PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_BOTTOM, PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
rgbLeds.begin();
|
rgbLeds.begin();
|
||||||
this->turnOffLed();
|
this->turnOffLed();
|
||||||
};
|
};
|
||||||
@ -13,7 +16,26 @@ void MultiColorLight::setLed(uint8_t index , uint32_t color){
|
|||||||
if (index > ledAmount-1){
|
if (index > ledAmount-1){
|
||||||
//TODO: logging
|
//TODO: logging
|
||||||
}
|
}
|
||||||
rgbLeds.setPixelColor(index, normalizeColor(color));
|
uint32_t normalizedColor = normalizeColor(color);
|
||||||
|
uint16_t colorComponentRed = (normalizedColor & 0x00FF0000) >> 16;
|
||||||
|
uint16_t colorComponentGreen = (normalizedColor & 0x0000FF00) >> 8;
|
||||||
|
uint16_t colorComponentBlue = (normalizedColor & 0x000000FF);
|
||||||
|
float redChannelConsumption = (colorComponentRed/255.0) * PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_CHAN_T_ON;
|
||||||
|
float greenChannelConsumption = (colorComponentGreen/255.0) * PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_CHAN_T_ON;
|
||||||
|
float blueChannelConsumption = (colorComponentBlue/255.0) * PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_CHAN_T_ON;
|
||||||
|
float totalConsumption = redChannelConsumption + greenChannelConsumption + blueChannelConsumption + PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE;
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_TOP_RIGHT, totalConsumption, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_TOP_LEFT, totalConsumption, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::LED_RGB_BOTTOM, totalConsumption, MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rgbLeds.setPixelColor(index, normalizedColor);
|
||||||
rgbLeds.show();
|
rgbLeds.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#define MultiColorLight_h
|
#define MultiColorLight_h
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include "ColorConstants.h"
|
#include "ColorConstants.h"
|
||||||
|
#include "../power/Power.h"
|
||||||
|
|
||||||
|
#define MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS 20
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Describes combinations of leds on the Dezibot.
|
* @brief Describes combinations of leds on the Dezibot.
|
||||||
* With the Robot in Front of you, when the robot drives away from you, the left LED is TOP_LEFT
|
* With the Robot in Front of you, when the robot drives away from you, the left LED is TOP_LEFT
|
||||||
@ -31,6 +35,7 @@ protected:
|
|||||||
static const int16_t ledPin = 48;
|
static const int16_t ledPin = 48;
|
||||||
static const uint8_t maxBrightness = 150;
|
static const uint8_t maxBrightness = 150;
|
||||||
Adafruit_NeoPixel rgbLeds;
|
Adafruit_NeoPixel rgbLeds;
|
||||||
|
static constexpr int maximumExecutionDelayMs = 10;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MultiColorLight();
|
MultiColorLight();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user