???
This commit is contained in:
parent
71d8400bca
commit
9980658ade
@ -18,7 +18,7 @@ except:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class Configuration():
|
class Configuration():
|
||||||
def __init__(self):
|
def __init__(self, recording_duration = None):
|
||||||
# recording setup
|
# recording setup
|
||||||
self.channels = None
|
self.channels = None
|
||||||
self.samplerate = None
|
self.samplerate = None
|
||||||
@ -34,7 +34,17 @@ class Configuration():
|
|||||||
# timestamps
|
# timestamps
|
||||||
self.now = datetime.datetime.now()
|
self.now = datetime.datetime.now()
|
||||||
self.start_clock = [datetime.datetime.now().hour, datetime.datetime.now().minute]
|
self.start_clock = [datetime.datetime.now().hour, datetime.datetime.now().minute]
|
||||||
self.end_clock = None
|
if not recording_duration == None:
|
||||||
|
self.end_clock = [datetime.datetime.now().hour + recording_duration[0], datetime.datetime.now().minute + recording_duration[1]]
|
||||||
|
if self.end_clock[1] >= 60:
|
||||||
|
self.end_clock[0] += 1
|
||||||
|
self.end_clock[1] -= 60
|
||||||
|
if self.end_clock[0] >= 24:
|
||||||
|
self.end_clock[0] -= 24
|
||||||
|
else:
|
||||||
|
self.end_clock = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
self.path = './'
|
self.path = './'
|
||||||
@ -302,6 +312,17 @@ class Recorder():
|
|||||||
last_idx = 0
|
last_idx = 0
|
||||||
buffer_no = 0
|
buffer_no = 0
|
||||||
|
|
||||||
|
self.terminate = False
|
||||||
|
|
||||||
|
if True: # close access
|
||||||
|
subprocess.run(['tvservice', '-o'])
|
||||||
|
subprocess.run(['vcgencmd', 'display_power', '0']) #
|
||||||
|
|
||||||
|
subprocess.run(['sudo', 'ip', 'link', 'set', 'eth0', 'down'])
|
||||||
|
GPIO.output(self.LED2_pin, GPIO.LOW)
|
||||||
|
disp_eth_power = False
|
||||||
|
self.last_button_2_t = time()
|
||||||
|
|
||||||
while GPIO.input(self.Button1_pin) == GPIO.LOW:
|
while GPIO.input(self.Button1_pin) == GPIO.LOW:
|
||||||
|
|
||||||
if GPIO.input(self.Button2_pin) == GPIO.HIGH:
|
if GPIO.input(self.Button2_pin) == GPIO.HIGH:
|
||||||
@ -382,7 +403,7 @@ class Recorder():
|
|||||||
else:
|
else:
|
||||||
(np.array(data[last_idx:], dtype=np.float32) / self.config.gain).tofile(self.f)
|
(np.array(data[last_idx:], dtype=np.float32) / self.config.gain).tofile(self.f)
|
||||||
if hasattr(self.config.end_clock, '__len__'):
|
if hasattr(self.config.end_clock, '__len__'):
|
||||||
if datetime.datetime.now().hour * 60 + datetime.datetime.now().minute >= self.config.end_clock[0] * 60 + self.config.end_clock[1]:
|
if datetime.datetime.now().hour * 60 + datetime.datetime.now().minute == self.config.end_clock[0] * 60 + self.config.end_clock[1]:
|
||||||
self.f.flush()
|
self.f.flush()
|
||||||
GPIO.output(self.LED1_pin, GPIO.LOW)
|
GPIO.output(self.LED1_pin, GPIO.LOW)
|
||||||
GPIO.output(self.LED_out_pin, GPIO.LOW)
|
GPIO.output(self.LED_out_pin, GPIO.LOW)
|
||||||
@ -393,7 +414,9 @@ class Recorder():
|
|||||||
|
|
||||||
buffer_no += 1
|
buffer_no += 1
|
||||||
last_idx = index
|
last_idx = index
|
||||||
print('\nDone!')
|
else:
|
||||||
|
self.terminate = True
|
||||||
|
print('\nDone!')
|
||||||
|
|
||||||
self.f.close()
|
self.f.close()
|
||||||
if self.config.record_temp == True:
|
if self.config.record_temp == True:
|
||||||
@ -425,18 +448,22 @@ class Recorder():
|
|||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = Configuration()
|
while True:
|
||||||
if len(sys.argv) > 1:
|
config = Configuration(recording_duration=[12, 0])
|
||||||
rec_duration = int(sys.argv[1])
|
if len(sys.argv) > 1:
|
||||||
config.start_clock = [config.now.hour, config.now.minute]
|
rec_duration = int(sys.argv[1])
|
||||||
config.end_clock = [config.now.hour, config.now.minute + rec_duration]
|
config.start_clock = [config.now.hour, config.now.minute]
|
||||||
if config.end_clock[1] >= 60:
|
config.end_clock = [config.now.hour, config.now.minute + rec_duration]
|
||||||
config.end_clock[0] += 1
|
if config.end_clock[1] >= 60:
|
||||||
config.end_clock[1] -= 60
|
config.end_clock[0] += 1
|
||||||
|
config.end_clock[1] -= 60
|
||||||
rc = Recorder(config)
|
|
||||||
|
rc = Recorder(config)
|
||||||
rc.run()
|
|
||||||
|
rc.run()
|
||||||
|
|
||||||
|
if rc.terminate == True:
|
||||||
|
break
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user