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