Skip to content
Snippets Groups Projects

Ability to view all activities

Merged willm3 requested to merge wmalisch/view-all-activities into main
4 files
+ 59
5
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 52
2
import time
import numpy as np
from sense_hat import SenseHat
@@ -35,11 +36,60 @@ class Controller:
self.view_activities(activity_log)
# Use a short sleep statement to help save battery. Calls to the SenseHat are battery intensive, this slightly reduces the number of calls
time.sleep(0.1)
time.sleep(0.2)
except KeyboardInterrupt:
print("Exiting...")
self.sense.clear()
def view_activities(self, activity_log):
print(activity_log)
\ No newline at end of file
view = True
print = True
alog = np.array(activity_log)
row = 0
column = 0
while view:
if print:
self.print_current_stat(row, column, alog)
print = False
for event in self.sense.stick.get_events():
if event.action == "pressed":
print = True
if event.direction == "up" and row > 0:
row -= 1
elif event.direction == "down" and row < alog.shape[0] - 1:
row += 1
elif event.direction == "left" and column > 0:
column -= 1
elif event.direction == "right" and column < alog.shape[1] - 1:
column += 1
# Press joy stick in the middle to exit view mode
elif event.direction == "middle":
view = False
# Use a short sleep statement to help save battery. Calls to the SenseHat are battery intensive, this slightly reduces the number of calls
time.sleep(0.2)
def print_current_stat(self, row, column, activity_log):
if column == 0:
message = f"Id: {activity_log[row, column]}"
self.logger.print_individual_stat_in_activity_log(message)
elif column == 1:
message = f"S Date: {activity_log[row, column]}"
self.logger.print_individual_stat_in_activity_log(message)
elif column == 2:
message = f"S Time: {activity_log[row, column]}"
self.logger.print_individual_stat_in_activity_log(message)
elif column == 3:
message = f"Steps: {activity_log[row, column]}"
self.logger.print_individual_stat_in_activity_log(message)
elif column == 4:
message = f"Duration: {activity_log[row, column]}"
self.logger.print_individual_stat_in_activity_log(message)
else:
print("Error")
\ No newline at end of file
Loading