01234567890123456789012345678901234567890123456789012345678901234567890123456789
622762286229623062316232623362346235623662376238623962406241624262436244624562466247 62486249625062516252625362546255625662576258625962606261626262636264626562666267 |
<----SKIPPED LINES---->
def CheckTemperature(configuration, last_logged=0):
"""Turn on fan if temperature exceeds threshold.
Args:
configuration: dictionary of configuration settings.
last_logged: epoch at which temperature was last logged.
Returns:
Epoch at which temperature was last logged.
"""
if RASPBERRY_PI:
temperature = gpiozero.CPUTemperature().temperature
if temperature > TEMP_FAN_TURN_ON_CELSIUS:
UpdateStatusLight(GPIO_FAN, True, 'Temperature: %.1f' % temperature)
elif temperature < TEMP_FAN_TURN_OFF_CELSIUS:
UpdateStatusLight(GPIO_FAN, False)
now = time.time()
if (configuration.get('log_temperature') and
now - last_logged > TEMPERATURE_LOG_FREQUENCY_SECONDS):
line = ','.join([str(now), str(temperature)])
with open(TEMPERATURE_LOG, 'a') as f:
f.write('%s\n' % line)
last_logged = now
return last_logged
pin_values = {} # caches last set value
def SetPinMode():
"""Initialize output GPIO pins for output on Raspberry Pi."""
global pin_values
if RASPBERRY_PI:
RPi.GPIO.setmode(RPi.GPIO.BCM)
pins = (
GPIO_ERROR_VESTABOARD_CONNECTION, GPIO_ERROR_FLIGHT_AWARE_CONNECTION,
GPIO_ERROR_ARDUINO_SERVO_CONNECTION, GPIO_ERROR_ARDUINO_REMOTE_CONNECTION,
GPIO_ERROR_BATTERY_CHARGE, GPIO_FAN, GPIO_UNUSED_1, GPIO_UNUSED_2)
for pin in pins:
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271 |
<----SKIPPED LINES---->
def CheckTemperature(configuration, last_logged=0):
"""Turn on fan if temperature exceeds threshold.
Args:
configuration: dictionary of configuration settings.
last_logged: epoch at which temperature was last logged.
Returns:
Epoch at which temperature was last logged.
"""
if RASPBERRY_PI:
temperature = gpiozero.CPUTemperature().temperature
if temperature > TEMP_FAN_TURN_ON_CELSIUS:
UpdateStatusLight(GPIO_FAN, True, 'Temperature: %.1f' % temperature)
elif temperature < TEMP_FAN_TURN_OFF_CELSIUS:
UpdateStatusLight(GPIO_FAN, False)
now = time.time()
if (configuration.get('log_temperature') and
now - last_logged > TEMPERATURE_LOG_FREQUENCY_SECONDS):
line = ','.join([
str(now),
EpochDisplayTime(now, '%Y-%m-%d'),
EpochDisplayTime(now, '%H:%M:%S%z'),
str(temperature)])
with open(TEMPERATURE_LOG, 'a') as f:
f.write('%s\n' % line)
last_logged = now
return last_logged
pin_values = {} # caches last set value
def SetPinMode():
"""Initialize output GPIO pins for output on Raspberry Pi."""
global pin_values
if RASPBERRY_PI:
RPi.GPIO.setmode(RPi.GPIO.BCM)
pins = (
GPIO_ERROR_VESTABOARD_CONNECTION, GPIO_ERROR_FLIGHT_AWARE_CONNECTION,
GPIO_ERROR_ARDUINO_SERVO_CONNECTION, GPIO_ERROR_ARDUINO_REMOTE_CONNECTION,
GPIO_ERROR_BATTERY_CHARGE, GPIO_FAN, GPIO_UNUSED_1, GPIO_UNUSED_2)
for pin in pins:
<----SKIPPED LINES---->
|