+ 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
+ }
+
+ // TODO: maybe use these values instead of 10-bit?
+ byte_fast = fast_10bit >> 2;
+ byte_slow = slow_10bit >> 2;
+
+ if (byte_slow > byte_fast) {
+ drop = byte_slow - byte_fast;
+ if (drop > ambient_drop)
+ ambient_drop = drop;
+ }
+
+ if (ambient_min > byte_slow)
+ ambient_min = byte_slow;
+
+ if (ambient_max < byte_slow)
+ ambient_max = byte_slow;
+
+ if (new_zone != ambient_zone) {
+ ambient_zone = new_zone;