Skip to content

Commit

Permalink
Manage keyboard interrupt on demo
Browse files Browse the repository at this point in the history
  • Loading branch information
valletw committed Dec 11, 2022
1 parent 58f9646 commit f559d45
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ def parse_args():
export = ExportCSV(params.export)
# Run data dump process.
with UMmeter(params.tty) as meter:
while True:
data = meter.get_data()
now = datetime.now()
if export is not None:
export.update(now, data)
print(
f"[{data['model']}] {now.time()}"
f" {data['voltage']:1.04f}V {data['intensity']:1.04f}A"
f" {data['power']:1.04f}W {data['resistance']}Ohm"
)
sleep(params.refresh)
try:
while True:
data = meter.get_data()
now = datetime.now()
if export is not None:
export.update(now, data)
print(
f"[{data['model']}] {now.time()}"
f" {data['voltage']:1.04f}V {data['intensity']:1.04f}A"
f" {data['power']:1.04f}W {data['resistance']}Ohm"
)
sleep(params.refresh)
except KeyboardInterrupt:
pass

0 comments on commit f559d45

Please sign in to comment.