X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fambient.c;h=f6f52202f35a5738a60e7a70d1308539618cf399;hb=ee55592455c9628ca21142449d4b5918a59151fe;hp=cbbef9e02a78d902ef606dad286ffa8cb90358da;hpb=f956c1fa7f47b0e8b8afe323c2eff1b6c2607c2a;p=bike-lights.git diff --git a/firmware/ambient.c b/firmware/ambient.c index cbbef9e..f6f5220 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[] = { - 0x10, 0x18, 0x20, 0x40, 0x100, 0x400, 0x1000, 0x4000, 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,10 @@ void ambient_init() void ambient_zone_changed() { - log_byte(0xCC); + log_byte(0xab); log_byte(ambient_zone); log_word(ambient_val); + log_flush(); } void ambient_adc(uint16_t adcval) @@ -39,6 +40,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;