Advertisement
aalh

pressure loop

Dec 28th, 2023
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | Source Code | 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, pressfile, PLOG_FILE, LOG_MODE, current_time
  17.         low_light = False
  18.         stamped = False
  19.         plog_path = "/sd/"
  20.         pyportal.set_backlight(1.00)
  21.         pyportal.set_background(mugsy_background)
  22.         try:
  23.             board.DISPLAY.refresh(target_frames_per_second=60)
  24.         except AttributeError:
  25.             board.DISPLAY.refresh_soon()
  26.             board.DISPLAY.wait_for_frame()
  27.         gps.update()
  28.         t_stamp = time.mktime(gps.timestamp_utc)
  29.         PLOG_FILE = f"{t_stamp}pressure.txt"
  30.         loop = 1200
  31.         timep = time.monotonic_ns()
  32.         while loop > 0:
  33.             with open((plog_path+PLOG_FILE), LOG_MODE) as pressfile:
  34.                 if stamped is False:
  35.                     debugp(t_stamp, gps.latitude, gps.longitude, gps.altitude_m)
  36.                     stamped = True
  37.                 debugp(((time.monotonic_ns() - timep) / 1000000000), lps.pressure)
  38.             loop -= 1
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement