]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/ambient.c
ambient.c: settings for my wife's bike
[bike-lights.git] / firmware / ambient.c
index 7352f6d5779359c2b1b2471091618e0a07641c78..9dbf600ea6f9c0bae7dbcccdc91b0c87b4477641 100644 (file)
@@ -26,10 +26,17 @@ typedef struct {
  * and having small overlaps in order to provide a bit of hysteresis.
  */
 static ambient_zone_t ambient_zones[N_AMBIENT_ZONES] = {
+#ifdef PAVLINA
+       { 0x0000, 0x0290 }, // dark
+       { 0x0278, 0x02f8 }, // evening
+       { 0x02d8, 0x0310 }, // dawn
+       { 0x0308, 0xffff }, // day
+#else
        { 0x0000, 0x0250 }, // dark
        { 0x0240, 0x02e0 }, // evening
        { 0x02c0, 0x0300 }, // dawn
        { 0x02f8, 0xffff }, // day
+#endif
 };
 
 #define SHADOW_DROP_LIMIT      0x20 // in ADC units (0..0x3ff)
@@ -65,7 +72,7 @@ void susp_ambient()
 void ambient_log_min_max()
 {
        if (ambient_log_offset >= AMBIENT_LOG_SIZE - 1)
-               return;
+               ambient_log_offset = 0; // start over
 
        ambient_max -= ambient_min;
        // ambient_max >>= 2;
@@ -123,7 +130,7 @@ void ambient_adc(uint16_t adcval)
        slow_10bit = ambient_slow >> AMBIENT_SLOW_SHIFT;
 
        if (new_zone > 1 && (
-               new_zone == ambient_zone-1 || new_zone == ambient_zone+1)) {
+               new_zone == ambient_zone-1 || new_zone > ambient_zone)) {
                // but change to the neighbouring zone is governed by _slow,
                // except to the darkest zone, where we want fast reaction.
                new_zone = val_to_zone(slow_10bit);