included temperature recording
This commit is contained in:
		
							parent
							
								
									6734e26a7d
								
							
						
					
					
						commit
						dec2fc40bf
					
				
							
								
								
									
										45
									
								
								rasp_grid.py
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								rasp_grid.py
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | ||||
| from __future__ import print_function | ||||
| import os | ||||
| import glob | ||||
| import datetime | ||||
| from shutil import copyfile | ||||
| try: | ||||
| @ -29,11 +30,11 @@ def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin): | ||||
|     LED_status = [False, False] | ||||
| 
 | ||||
|     # switch controlled input | ||||
|     GPIO.setup(Button1_pin, GPIO.IN) | ||||
|     GPIO.setup(Button2_pin, GPIO.IN) | ||||
|     # GPIO.setup(Button1_pin, GPIO.IN) | ||||
|     # GPIO.setup(Button2_pin, GPIO.IN) | ||||
| 
 | ||||
|     # GPIO.setup(Button1_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||||
|     # GPIO.setup(Button2_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||||
|     GPIO.setup(Button1_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||||
|     GPIO.setup(Button2_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||||
| 
 | ||||
|     return LED_status | ||||
| 
 | ||||
| @ -171,13 +172,14 @@ def main(): | ||||
|     channels, rate = read_cfg(cfgfile, now) | ||||
| 
 | ||||
|     file = os.path.join(path, 'traces-grid1.raw') | ||||
|     temp_file = os.path.join(path, 'temp_file.txt') | ||||
| 
 | ||||
|     w1_bus_path = glob.glob('/sys/bus/w1/device/28*/w1-slave')[0] | ||||
|     f = open(file, 'wb') | ||||
|     temp_f = open(temp_file, 'w') | ||||
| 
 | ||||
|     # f.close() | ||||
| 
 | ||||
|     #embed() | ||||
|     #quit() | ||||
| 
 | ||||
|     LED1_pin = 11 | ||||
|     LED2_pin = 13 | ||||
|     Button1_pin = 16 | ||||
| @ -272,10 +274,25 @@ def main(): | ||||
|     LED_t = time() | ||||
|     LED_t_interval = 2 | ||||
| 
 | ||||
|     temp_t0 = time() | ||||
|     next_temp_t = 0 | ||||
|     temp_interval = 10  # sec --> 5 min | ||||
| 
 | ||||
|     disp_eth_power = True | ||||
| 
 | ||||
|     try: | ||||
|         while GPIO.input(Button1_pin) == GPIO.HIGH: | ||||
|     while GPIO.input(Button1_pin) == GPIO.LOW: | ||||
|         if time() - temp_t0 > next_temp_t: | ||||
|             w1_f = open(w1_bus_path, 'r') | ||||
|             w1_file = w1_f.readlines() | ||||
|             for line in w1_file: | ||||
|                 if 't=' in line: | ||||
|                     temp = float((line.split('=')[-1].strip())) / 1000 | ||||
|                     temp_f.write('sec: %.0f; %.3f\n' % (next_temp_t, temp)) | ||||
|                     break | ||||
| 
 | ||||
|             w1_f.close() | ||||
|             next_temp_t += temp_interval | ||||
| 
 | ||||
|         # blinking LED | ||||
|         if time() - LED_t < .1 and LED_status[0] == False: | ||||
|             LED_status[0] = True | ||||
| @ -294,8 +311,8 @@ def main(): | ||||
| 
 | ||||
|                 subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'down']) | ||||
|                 disp_eth_power = False | ||||
|             else: | ||||
|                 if disp_eth_power == False: | ||||
| 
 | ||||
|             elif disp_eth_power == False: | ||||
|                 subprocess.run(['tvservice', '-p']) | ||||
|                 subprocess.run(['vcgencmd', 'display_power', '1']) | ||||
|                 subprocess.run(['sudo', '/bin/chvt', '6']) | ||||
| @ -322,11 +339,11 @@ def main(): | ||||
|         else: | ||||
|             last_idx = index | ||||
| 
 | ||||
|     except KeyboardInterrupt: | ||||
|         embed() | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
|     f.close() | ||||
|     temp_f.close() | ||||
| 
 | ||||
|     if daq_device: | ||||
|         # Stop the acquisition if it is still running. | ||||
|         if status == ScanStatus.RUNNING: | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user