looking for temp sensor. if available use it
This commit is contained in:
parent
dae60ef496
commit
2ea0184553
39
rasp_grid.py
39
rasp_grid.py
@ -174,7 +174,11 @@ def main():
|
|||||||
file = os.path.join(path, 'traces-grid1.raw')
|
file = os.path.join(path, 'traces-grid1.raw')
|
||||||
temp_file = os.path.join(path, 'temp_file.txt')
|
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')
|
f = open(file, 'wb')
|
||||||
temp_f = open(temp_file, 'w')
|
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)
|
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
|
# DAQ setup
|
||||||
if True:
|
if True:
|
||||||
# channels = 16
|
# channels = 16
|
||||||
@ -277,6 +284,7 @@ def main():
|
|||||||
emergency_LED_t = time()
|
emergency_LED_t = time()
|
||||||
emergency_LED_interval = 0.5
|
emergency_LED_interval = 0.5
|
||||||
|
|
||||||
|
|
||||||
LED_t = time()
|
LED_t = time()
|
||||||
LED_t_interval = 2
|
LED_t_interval = 2
|
||||||
|
|
||||||
@ -287,18 +295,19 @@ def main():
|
|||||||
disp_eth_power = True
|
disp_eth_power = True
|
||||||
|
|
||||||
while GPIO.input(Button1_pin) == GPIO.LOW:
|
while GPIO.input(Button1_pin) == GPIO.LOW:
|
||||||
if time() - temp_t0 > next_temp_t:
|
if record_temp == True:
|
||||||
w1_f = open(w1_bus_path, 'r')
|
if time() - temp_t0 > next_temp_t:
|
||||||
w1_file = w1_f.readlines()
|
w1_f = open(w1_bus_path, 'r')
|
||||||
for line in w1_file:
|
w1_file = w1_f.readlines()
|
||||||
if 't=' in line:
|
for line in w1_file:
|
||||||
temp = float((line.split('=')[-1].strip())) / 1000
|
if 't=' in line:
|
||||||
temp_f.write('sec: %.0f; %.3f\n' % (next_temp_t, temp))
|
temp = float((line.split('=')[-1].strip())) / 1000
|
||||||
temp_f.flush()
|
temp_f.write('sec: %.0f; %.3f\n' % (next_temp_t, temp))
|
||||||
break
|
temp_f.flush()
|
||||||
|
break
|
||||||
w1_f.close()
|
|
||||||
next_temp_t += temp_interval
|
w1_f.close()
|
||||||
|
next_temp_t += temp_interval
|
||||||
|
|
||||||
# blinking LED
|
# blinking LED
|
||||||
if GPIO.input(power_controll_pin) == GPIO.HIGH:
|
if GPIO.input(power_controll_pin) == GPIO.HIGH:
|
||||||
@ -334,12 +343,13 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
# dist & eth0 controll
|
# 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:
|
if disp_eth_power == True:
|
||||||
subprocess.run(['tvservice', '-o'])
|
subprocess.run(['tvservice', '-o'])
|
||||||
subprocess.run(['vcgencmd', 'display_power', '0'])
|
subprocess.run(['vcgencmd', 'display_power', '0'])
|
||||||
|
|
||||||
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'down'])
|
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'down'])
|
||||||
|
GPIO.output(LED2_pin, GPIO.LOW)
|
||||||
disp_eth_power = False
|
disp_eth_power = False
|
||||||
|
|
||||||
elif disp_eth_power == False:
|
elif disp_eth_power == False:
|
||||||
@ -349,6 +359,7 @@ def main():
|
|||||||
subprocess.run(['sudo', '/bin/chvt', '7'])
|
subprocess.run(['sudo', '/bin/chvt', '7'])
|
||||||
|
|
||||||
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'up'])
|
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'up'])
|
||||||
|
GPIO.output(LED2_pin, GPIO.HIGH)
|
||||||
disp_eth_power = True
|
disp_eth_power = True
|
||||||
|
|
||||||
# Get the status of the background operation
|
# Get the status of the background operation
|
||||||
|
Loading…
Reference in New Issue
Block a user