+ // are we entering the shadow?
+ if (!user_zone && new_zone < ambient_zone
+ && ambient_zone >= 2 && slow_10bit > fast_10bit
+ && slow_10bit - fast_10bit >= SHADOW_DROP_LIMIT) {
+ // we are entering the shadow
+ new_shadow = 0x30;
+ }
+
+ if (ambient_shadow) {
+ if (new_shadow) {
+ new_zone = ambient_zone; // don't change while entering shadow
+ ambient_shadow = new_shadow; // update the timeout
+ } else {
+ ambient_shadow--;
+ if (!ambient_shadow) { // leaving the shadow
+ ambient_zone_changed();
+ }
+ }
+ } else if (new_shadow) {
+ ambient_shadow = new_shadow; // set up the timeout
+ new_zone = ambient_zone; // don't change while entering shadow
+ ambient_zone_changed(); // notify others the first time
+ }
+