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;
*/
static ambient_zone_t ambient_zones[N_AMBIENT_ZONES] = {
#ifdef PAVLINA
- { 0x0000, 0x0290 }, // dark
- { 0x0278, 0x02f8 }, // evening
- { 0x02d8, 0x0310 }, // dawn
- { 0x0308, 0xffff }, // day
+ { 0x0000, 0x02d0 }, // dark
+ { 0x02b0, 0x0318 }, // evening
+ { 0x0308, 0x032c }, // dawn
+ { 0x0324, 0xffff }, // day
#else
{ 0x0000, 0x0250 }, // dark
- { 0x0240, 0x02e0 }, // evening
- { 0x02c0, 0x0300 }, // dawn
- { 0x02f8, 0xffff }, // day
+ { 0x0230, 0x02e8 }, // evening
+ { 0x02d0, 0x0302 }, // dawn
+ { 0x02fc, 0xffff }, // day
#endif
};
{
unsigned char new_zone = ambient_zone;
+ if (new_zone >= N_AMBIENT_ZONES)
+ new_zone = N_AMBIENT_ZONES-1;
+
while (ambient_zones[new_zone].lo > ambient_val)
new_zone--;
slow_10bit = ambient_slow >> AMBIENT_SLOW_SHIFT;
- if (new_zone > 1 && (
- new_zone == ambient_zone-1 || new_zone > ambient_zone)) {
+ if ((new_zone > ambient_zone)
+ || (new_zone > 1 && new_zone == ambient_zone - 1)) {
// 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);
if ((user_zone = get_user_param(0)) > 0)
new_zone = user_zone - 1;
+#if 0 // ignore shadow-entering code altogether for now
// are we entering the shadow?
if (!user_zone && new_zone < ambient_zone
&& ambient_zone >= 2 && slow_10bit > fast_10bit
new_zone = ambient_zone; // don't change while entering shadow
ambient_zone_changed(); // notify others the first time
}
+#endif
// TODO: maybe use these values instead of 10-bit?
byte_fast = fast_10bit >> 2;