Advertisement
aalh

fixed loop

Dec 29th, 2023
1,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. class Pressure_State(Time_State):
  2.     """This state records a pressure log """
  3.  
  4.     def __init__(self):
  5.         super().__init__()
  6.  
  7.     @property
  8.     def name(self):
  9.         return 'pressurel'
  10.  
  11.     def tick(self, now):
  12.         # Once the job is done, go back to the main screen
  13.         change_to_state('time')
  14.  
  15.     def enter(self):
  16.         global low_light, LOG_MODE
  17.         low_light = False
  18.         plog_path = "/sd/"
  19.         pyportal.set_backlight(1.00)
  20.         pyportal.set_background(mugsy_background)
  21.         try:
  22.             board.DISPLAY.refresh(target_frames_per_second=60)
  23.         except AttributeError:
  24.             board.DISPLAY.refresh_soon()
  25.             board.DISPLAY.wait_for_frame()
  26.         gps.update()
  27.         t_stamp = time.mktime(gps.timestamp_utc)
  28.         PLOG_FILE = f"{t_stamp}pressure.txt"
  29.         start = (time.monotonic_ns() / 1e9)
  30.         with open((plog_path+PLOG_FILE), LOG_MODE) as pressfile:
  31.             print(t_stamp, gps.latitude, gps.longitude, gps.altitude_m, file=pressfile)
  32.             curr_time = 0
  33.         # with open((plog_path+PLOG_FILE), LOG_MODE) as pressfile:
  34.             while curr_time < 60:
  35.                 curr_time = ((time.monotonic_ns() / 1e9) - start)
  36.                 print(curr_time, lps.pressure, file=pressfile)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement