]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/ambient.c
ambient light: make three measurements
[bike-lights.git] / firmware / ambient.c
index c6c6a654ab67e1bd974366feefd575e98af95f55..735f80e968a940c7a77dc210bb73d07c0ee16ace 100644 (file)
@@ -15,8 +15,8 @@ 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 },
+       { 0x0000, 0x3400 }, // dark
+       { 0x3300, 0x5000 },
        { 0x4c00, 0x8000 },
        { 0x7800, 0xffff }
 };
@@ -46,7 +46,7 @@ void ambient_adc(uint16_t adcval)
 {
        unsigned char old_zone = ambient_zone;
 
-       ambient_val += adcval - (ambient_val >> 6);
+       ambient_val += adcval - (ambient_val >> 3);
 
        while (ambient_zones[ambient_zone].lo > ambient_val)
                ambient_zone--;