X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fambient.c;h=f62620862df49538a5a5ab282fb01d1168ec6f9e;hb=442a8e127061e8bc51119fde3346cf88477b355f;hp=f6e8ae5f5be088eba62d2efc6533b495e5a254bd;hpb=9e483c6969d2cdce60f6dcc3d167fec889a48993;p=bike-lights.git diff --git a/firmware/ambient.c b/firmware/ambient.c index f6e8ae5..f626208 100644 --- a/firmware/ambient.c +++ b/firmware/ambient.c @@ -2,6 +2,7 @@ #include "lights.h" +#define AMBIENT_VAL_SHIFT 3 static uint16_t ambient_val; volatile unsigned char ambient_zone; @@ -15,10 +16,10 @@ typedef struct { * and having small overlaps in order to provide a bit of hysteresis. */ static ambient_zone_t ambient_zones[] = { - { 0x0000, 0xb000 }, // dark - { 0xa800, 0xc700 }, - { 0xc600, 0xcb00 }, - { 0xca80, 0xffff } + { 0x0000 , 0x0290<> 3); + ambient_val += adcval - (ambient_val + >> (AMBIENT_VAL_SHIFT - AMBIENT_ADC_SHIFT)); while (ambient_zones[ambient_zone].lo > ambient_val) ambient_zone--;