Changed error flash routine

Need to add other features that involve flashing the error code lights, so made it possible to do this with different colors and without interfering with running programs
This commit is contained in:
true 2023-11-01 06:05:40 -07:00
parent 418fdafe56
commit ad383a76ac
2 changed files with 24 additions and 17 deletions

View File

@ -8,9 +8,14 @@
#define _INC_RGBPROG_H
#include <stdint.h>
void rgbprog_run();
void rgbprog_error_flasher(uint8_t r, uint8_t g, uint8_t b);
#endif /* _INC_RGBPROG_H */

View File

@ -23,6 +23,8 @@
*/
#include "rgbprog.h"
#include "led.h"
#include "hsv2rgb.h"
#include "rand.h"
@ -43,8 +45,6 @@ void rgbprog_randcolor(uint8_t k0);
void rgbprog_randcolorfadeinout(uint8_t k0);
void rgbprog_prog7(uint8_t k0);
void rgbprog_set1_error();
static void (*proglist[8])(uint8_t) = {
rgbprog_rainbow,
rgbprog_rainbow_offset,
@ -117,7 +117,7 @@ void rgbprog_run()
// if SET1 is out of range, indicate that instead of
// running the normal program
if (userio_get_set1_limit()) {
rgbprog_set1_error();
rgbprog_error_flasher(120, 0, 0);
return;
}
@ -405,20 +405,22 @@ void rgbprog_prog7(uint8_t k0)
*
* flashes LEDs, indicating a SET1 knob error.
*/
void rgbprog_set1_error()
static uint8_t err_ctr;
static uint8_t err_tog = 0;
void rgbprog_error_flasher(uint8_t r, uint8_t g, uint8_t b)
{
hsv[1].s++;
if (!hsv[1].s) {
hsv[1].v++;
hsv[1].v &= 1;
hsv[0].v = hsv[1].v ^ 1;
err_ctr++;
if (!err_ctr) {
err_tog ^= 1;
}
rgb[0].r = 255;
rgb[0].g = 0;
rgb[0].b = 0;
rgb_setled(hsv[1].v, &rgb[0]);
rgb[0].r = r;
rgb[0].g = g;
rgb[0].b = b;
rgb_setled(err_tog, &rgb[0]);
rgb[0].r = 0;
rgb_setled(hsv[0].v, &rgb[0]);
}
rgb[0].g = 0;
rgb[0].b = 0;
rgb_setled(err_tog ^ 1, &rgb[0]);
}