@@ -55,7 +55,7 @@ def handle_quiet_mode(new_voltage):
55
55
f .close ()
56
56
print ('QUIET MODE DATA - new voltage:{}, last_voltage:{}' .format (new_voltage , last_voltage ))
57
57
if (new_voltage > float (last_voltage ) + VOLT_DIFF_FOR_CHARGE ):
58
- fade_up_status (50 , 0 , 128 , 3 , 2 )
58
+ fade_up_status (128 , 128 , 128 , 4 , 1 )
59
59
print ("QUIET MODE ENDED - battery is charging. Unit must be plugged in" )
60
60
print ("Clearing battery.txt and quiet.txt" )
61
61
# Higher voltage even with some offset! We're plugged in
@@ -71,14 +71,14 @@ def handle_quiet_mode(new_voltage):
71
71
print ("QUIET MODE: overwriting battery.txt low water mark" )
72
72
with open ('battery.txt' , "w" ) as bf :
73
73
bf .write ('{}\n ' .format (new_voltage ))
74
- fade_status ( 50 , 0 , 128 , 3 , 2 )
74
+ flash_status ( 80 , 0 , 128 , 2 , 1 )
75
75
print ("QUIET MODE: Sleeping for " + str (QUIET_MODE_SLEEP_LENGTH / 60 ) + " min" )
76
76
deep_sleep (QUIET_MODE_SLEEP_LENGTH )
77
77
else :
78
78
print ("QUIET MODE: writing new battery.txt" )
79
79
with open ('battery.txt' , "w" ) as bf :
80
80
bf .write ('{}\n ' .format (new_voltage ))
81
- fade_status ( 50 , 0 , 128 , 3 , 2 )
81
+ flash_status ( 80 , 0 , 128 , 2 , 1 )
82
82
print ("QUIET MODE: Sleeping for " + str (QUIET_MODE_SLEEP_LENGTH / 60 ) + " min" )
83
83
deep_sleep (QUIET_MODE_SLEEP_LENGTH )
84
84
@@ -141,18 +141,19 @@ def flash_warning(red=128, green=0, blue=0, red2=128, green2=128, blue2=0,flash_
141
141
time .sleep (flash_length )
142
142
pixels .fill ((0 , 0 , 0 ))
143
143
144
- def fade_status (red = 0 , green = 0 , blue = 128 , fade_length = 3 , repeat = 1 ):
144
+
145
+ def fade_status (red = 0 , green = 0 , blue = 128 , fade_length = 2 , repeat = 1 ):
145
146
for x in range (0 , repeat ):
146
- for y in range (1 , fade_length * 100 ):
147
- pixels .fill ((int (red / y ) , int (green / y ) , int (blue / y )))
147
+ for y in range (100 , 1 , - 1 ):
148
+ pixels .fill ((int (pow ( red , y / 100 )) , int (pow ( green , y / 100 )) , int (pow ( blue , y / 100 ) )))
148
149
time .sleep (fade_length / 100 )
149
150
pixels .fill ((0 , 0 , 0 ))
150
151
151
152
152
- def fade_up_status (red = 128 , green = 128 , blue = 128 , fade_length = 3 , repeat = 1 ):
153
+ def fade_up_status (red = 128 , green = 128 , blue = 128 , fade_length = 2 , repeat = 1 ):
153
154
for x in range (0 , repeat ):
154
- for y in range (fade_length * 100 , 1 ):
155
- pixels .fill ((int (red / y ) , int (green / y ) , int (blue / y )))
155
+ for y in range (1 , 100 ):
156
+ pixels .fill ((int (pow ( red , y / 100 )) , int (pow ( green , y / 100 )) , int (pow ( blue , y / 100 ) )))
156
157
time .sleep (fade_length / 100 )
157
158
pixels .fill ((0 , 0 , 0 ))
158
159
@@ -197,11 +198,11 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=3, repeat=1):
197
198
sensor = adafruit_ahtx0 .AHTx0 (i2c )
198
199
# If the sensor is connected, go to read only mode so we can write temperatures
199
200
print ("\n SENSOR DETECTED, attempting to writing to temperatures.txt, CIRCUITPY is read-only by computer" )
200
- flash_status (0 ,128 ,0 ,0.5 ,1 )
201
+ flash_status (0 ,128 ,0 ,1 ,1 )
201
202
# storage.remount("", switch.value)
202
203
except ValueError :
203
204
print ("\n NO SENSOR, not writing to temperatures.txt CIRCUITPY is writeable by computer" )
204
- flash_status (0 ,0 ,128 ,0.5 ,1 )
205
+ flash_status (0 ,0 ,128 ,1 ,1 )
205
206
206
207
reading_interval = int (secrets ["reading_interval" ])
207
208
net_connected = False
@@ -220,7 +221,7 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=3, repeat=1):
220
221
pool = socketpool .SocketPool (wifi .radio )
221
222
requests = adafruit_requests .Session (pool , ssl .create_default_context ())
222
223
net_connected = True
223
- flash_status (0 ,128 ,0 ,1 ,2 )
224
+ flash_status (0 ,128 ,0 ,0.5 ,2 )
224
225
except :
225
226
print ("Connecting to fallback network %s" % secrets ["heatseek_wifi_ssid" ])
226
227
wifi .radio .connect (secrets ["heatseek_wifi_ssid" ], secrets ["heatseek_wifi_password" ])
@@ -230,12 +231,12 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=3, repeat=1):
230
231
pool = socketpool .SocketPool (wifi .radio )
231
232
requests = adafruit_requests .Session (pool , ssl .create_default_context ())
232
233
net_connected = True
233
- flash_status (0 ,128 ,0 ,1 ,2 )
234
+ flash_status (0 ,128 ,0 ,0.5 ,2 )
234
235
235
236
## Set the time if this is a cold boot
236
237
if not alarm .wake_alarm :
237
238
print ("Cold boot. Fetching updated time and setting realtime clock" )
238
-
239
+ fade_up_status ( 0 , 128 , 0 , 3 , 1 )
239
240
response = requests .get ("http://worldtimeapi.org/api/timezone/America/New_York" )
240
241
if response .status_code == 200 :
241
242
r .datetime = time .localtime (response .json ()['unixtime' ])
0 commit comments