X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=firmware%2Fambient.c;h=025b0c4bd6dcb6839395a36f91a8fedd4dc97e73;hp=ab28a20faf1ce95719cdd8ff4386ef9b90790af2;hb=647f353f4d8c87c5cf18cae905e9d600cd0e6bcb;hpb=acd7fc45b8751444605da3c464e49ab16148e9c1 diff --git a/firmware/ambient.c b/firmware/ambient.c index ab28a20..025b0c4 100644 --- a/firmware/ambient.c +++ b/firmware/ambient.c @@ -7,11 +7,11 @@ volatile unsigned char ambient_zone; static unsigned char ambient_zone_set; static uint16_t ambient_zones[] = { - 0x60, 0x68, 0x70, 0xa0, 0x100, 0x1c0, 0x270, 0x290, 0xffff + 0x0c00, 0x0d00, 0x1000, 0x1800, 0x2800, 0x2f80, 0xffff }; #define N_AMBIENT_ZONES (sizeof(ambient_zones)/sizeof(ambient_zones[0])) -void ambient_init() +void init_ambient() { ambient_val = 0; ambient_zone = 0; @@ -20,9 +20,12 @@ void ambient_init() void ambient_zone_changed() { - log_byte(0xCC); + log_byte(0xab); log_byte(ambient_zone); log_word(ambient_val); + log_flush(); + + pattern_reload(); } void ambient_adc(uint16_t adcval) @@ -39,6 +42,7 @@ void ambient_adc(uint16_t adcval) && ambient_zones[newzone] < ambient_val) newzone++; + // TODO: implement hysteresis? if (!ambient_zone_set || newzone != ambient_zone) { ambient_zone = newzone; ambient_zone_set = 1;