Add error mode indicator when SET1 is set above max

This commit is contained in:
true 2023-10-31 08:22:27 -07:00
parent cfd9715023
commit f2d4afce1c
3 changed files with 48 additions and 1 deletions

View File

@ -32,6 +32,8 @@ void userio_parse();
uint8_t userio_get_mode();
int16_t userio_get_btn();
uint8_t userio_get_set1_limit();
#endif /* _INC_USERIO_H */

View File

@ -43,6 +43,8 @@ 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,
@ -111,6 +113,13 @@ void rgbprog_run()
brite++;
brite &= 0x3;
}
// if SET1 is out of range, indicate that instead of
// running the normal program
if (userio_get_set1_limit()) {
rgbprog_set1_error();
return;
}
// which program to run?
j = 0;
@ -389,4 +398,27 @@ void rgbprog_prog7(uint8_t k0)
rgb[0].r = rgb[0].g = rgb[0].b = 0;
rgb_setled(0, &rgb[0]);
rgb_setled(1, &rgb[0]);
}
/*
* internal program:
*
* flashes LEDs, indicating a SET1 knob error.
*/
void rgbprog_set1_error()
{
hsv[1].s++;
if (!hsv[1].s) {
hsv[1].v++;
hsv[1].v &= 1;
hsv[0].v = hsv[1].v ^ 1;
rgb[0].r = 255;
rgb[0].g = 0;
rgb[0].b = 0;
rgb_setled(hsv[1].v, &rgb[0]);
rgb[0].r = 0;
rgb_setled(hsv[0].v, &rgb[0]);
}
}

View File

@ -42,7 +42,7 @@
#ifdef TESTO_REV1
#define SET1_MAX 2047 // 3V net feeding into 1V24 via body diode above this
#define SET1_MAX 2199 // 3V net feeding into 1V24 via body diode above this
#else
#define SET1_MAX 1539 // 1.24Vref
#endif
@ -174,5 +174,18 @@ int16_t userio_get_btn()
}
}
return 0;
}
/*
* returns true if the right knob is beyond maximum range.
* always returns false on REV2 or later boards.
*/
uint8_t userio_get_set1_limit()
{
#ifdef TESTO_REV1
if (adc_avg[ADC_SET1] > SET1_MAX) return 1;
#endif
return 0;
}