X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=firmware%2Fambient.c;h=5627dba2a88ab3b5ec1fd246793cd699e7e1c726;hp=7352f6d5779359c2b1b2471091618e0a07641c78;hb=bd8e93c9a8a74602aa856a2d7c53dfbc2522af07;hpb=60f1349e85769a3fe43843b46b4232168c08ca98 diff --git a/firmware/ambient.c b/firmware/ambient.c index 7352f6d..5627dba 100644 --- a/firmware/ambient.c +++ b/firmware/ambient.c @@ -11,7 +11,7 @@ volatile unsigned char ambient_zone, ambient_shadow; static unsigned char ambient_min, ambient_max, ambient_drop; /* logging */ -#define AMBIENT_LOG_SIZE 128 +#define AMBIENT_LOG_SIZE 256 static unsigned char ambient_log_offset_stored EEMEM; static unsigned char ambient_log_offset; static unsigned char ambient_log[AMBIENT_LOG_SIZE] EEMEM; @@ -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] = { - { 0x0000, 0x0250 }, // dark - { 0x0240, 0x02e0 }, // evening - { 0x02c0, 0x0300 }, // dawn - { 0x02f8, 0xffff }, // day +#ifdef PAVLINA + { 0x0000, 0x02b0 }, // dark + { 0x0298, 0x0308 }, // evening + { 0x02e8, 0x0320 }, // dawn + { 0x0318, 0xffff }, // day +#else + { 0x0000, 0x0240 }, // dark + { 0x0230, 0x02e0 }, // evening + { 0x02c0, 0x0304 }, // dawn + { 0x02fc, 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);