X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fambient.c;h=a44e844fb4d0bbd76ec67f78c5357b9d1880d78f;hb=9b8d044bdc4a571d5bf6c59586accdd274a85ffb;hp=c6c6a654ab67e1bd974366feefd575e98af95f55;hpb=20177f823fc0effcc9c5c389a629294c5ed367a1;p=bike-lights.git diff --git a/firmware/ambient.c b/firmware/ambient.c index c6c6a65..a44e844 100644 --- a/firmware/ambient.c +++ b/firmware/ambient.c @@ -2,6 +2,7 @@ #include "lights.h" +#define AMBIENT_VAL_SHIFT 2 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, 0x3120 }, // dark - { 0x30f0, 0x5000 }, - { 0x4c00, 0x8000 }, - { 0x7800, 0xffff } + { 0x0000 , 0x0290<> 6); + ambient_val += adcval - (ambient_val + >> (AMBIENT_VAL_SHIFT - AMBIENT_ADC_SHIFT)); while (ambient_zones[ambient_zone].lo > ambient_val) ambient_zone--;