Used rgbled_set_color() for CO2 value indication

This commit is contained in:
Your Name 2021-11-13 21:49:02 +01:00
parent 235ca259f1
commit 852de86755
3 changed files with 27 additions and 19 deletions

View File

@ -19,9 +19,25 @@
#define RGBLED_ERROR -1 // generic error
#define RGBLED_WRONG_CHANNEL -2 // channel number not in {1,2,3,4}
/*
* Defaults used for LL timer (PWM) initialization
*/
#define RGBLED_PRESCALER 0
#define RGBLED_PERIOD 255
/*
* Shorthands for colors
*/
#define RGBLED_RED 255,0,0
#define RGBLED_GREEN 0,255,0
#define RGBLED_BLUE 0,0,255
#define RGBLED_WHITE 255,255,255
#define RGBLED_YELLOW 255,255,0
#define RGBLED_OFF 0,0,0
#define RGBLED_MAGENTA 255,0,255
/*
* Type definitions
*/

View File

@ -225,7 +225,7 @@ int main(void)
rgbled_context.channel.B = 1;
rgbled_init(&rgbled_context);
rgbled_set_color(50, 50, 0);
rgbled_set_color(RGBLED_WHITE);
LL_mDelay(2000);
@ -343,33 +343,25 @@ int main(void)
if (co2_valid == 1) {
if (CO2 <= sensor_config.led_co2_alert_limit1) {
/* CO2 is OK -> GREEN */
// LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
// LL_GPIO_ResetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
// LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
rgbled_set_color(RGBLED_GREEN);
} else if ((sensor_config.led_co2_alert_limit1 < CO2) && (CO2 <= sensor_config.led_co2_alert_limit2)) {
// /* CO2 is NOT OK -> YELLOW */
// LL_GPIO_ResetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
// LL_GPIO_ResetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
// LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
/* CO2 is NOT OK -> YELLOW */
rgbled_set_color(RGBLED_YELLOW);
} else if (sensor_config.led_co2_alert_limit2 < CO2) {
/* CO2 is CRITICAL -> RED */
// LL_GPIO_ResetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
// LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
// LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
rgbled_set_color(RGBLED_RED);
}
} else {
// LL_GPIO_ResetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
// LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
// LL_GPIO_ResetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
/* CO2 invalid */
rgbled_set_color(RGBLED_MAGENTA);
}
} else {
// LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
// LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
// LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
/* LED disabled by user */
rgbled_set_color(RGBLED_OFF);
}
/* USER CODE END WHILE */

View File

@ -57,5 +57,5 @@ int8_t rgbled_set_color(uint8_t R, uint8_t G, uint8_t B)
int8_t rgbled_off(void)
{
rgbled_set_color(RGBLED_OFF);
}