looking for temp sensor. if available use it
This commit is contained in:
parent
dae60ef496
commit
2ea0184553
15
rasp_grid.py
15
rasp_grid.py
@ -174,7 +174,11 @@ def main():
|
||||
file = os.path.join(path, 'traces-grid1.raw')
|
||||
temp_file = os.path.join(path, 'temp_file.txt')
|
||||
|
||||
w1_bus_path = '/sys/bus/w1/devices/28-00000aee438d/w1_slave'
|
||||
record_temp = False
|
||||
w1_bus_path = glob.glob('/sys/bus/w1/devices/28*/w1_slave')
|
||||
if len(w1_bus_path) > 0:
|
||||
w1_bus_path = w1_bus_path[0]
|
||||
record_temp = True
|
||||
f = open(file, 'wb')
|
||||
temp_f = open(temp_file, 'w')
|
||||
|
||||
@ -188,6 +192,9 @@ def main():
|
||||
|
||||
LED_status = GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin, power_controll_pin)
|
||||
|
||||
last_button_1_t = time()
|
||||
last_button_2_t = time()
|
||||
|
||||
# DAQ setup
|
||||
if True:
|
||||
# channels = 16
|
||||
@ -277,6 +284,7 @@ def main():
|
||||
emergency_LED_t = time()
|
||||
emergency_LED_interval = 0.5
|
||||
|
||||
|
||||
LED_t = time()
|
||||
LED_t_interval = 2
|
||||
|
||||
@ -287,6 +295,7 @@ def main():
|
||||
disp_eth_power = True
|
||||
|
||||
while GPIO.input(Button1_pin) == GPIO.LOW:
|
||||
if record_temp == True:
|
||||
if time() - temp_t0 > next_temp_t:
|
||||
w1_f = open(w1_bus_path, 'r')
|
||||
w1_file = w1_f.readlines()
|
||||
@ -334,12 +343,13 @@ def main():
|
||||
|
||||
|
||||
# dist & eth0 controll
|
||||
if GPIO.input(Button2_pin) == GPIO.HIGH:
|
||||
if GPIO.input(Button2_pin) == GPIO.HIGH and (time() - last_button_2_t) > 5:
|
||||
if disp_eth_power == True:
|
||||
subprocess.run(['tvservice', '-o'])
|
||||
subprocess.run(['vcgencmd', 'display_power', '0'])
|
||||
|
||||
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'down'])
|
||||
GPIO.output(LED2_pin, GPIO.LOW)
|
||||
disp_eth_power = False
|
||||
|
||||
elif disp_eth_power == False:
|
||||
@ -349,6 +359,7 @@ def main():
|
||||
subprocess.run(['sudo', '/bin/chvt', '7'])
|
||||
|
||||
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'up'])
|
||||
GPIO.output(LED2_pin, GPIO.HIGH)
|
||||
disp_eth_power = True
|
||||
|
||||
# Get the status of the background operation
|
||||
|
Loading…
Reference in New Issue
Block a user