Last active
April 16, 2024 21:51
-
-
Save PaulskPt/ad9e39cdcb9aefc392f02be2fc83fd62 to your computer and use it in GitHub Desktop.
Revisions
-
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -153,12 +153,15 @@ def get_dt(): now = datetime.now() dt = now.timetuple() dt1 = "{:s}, {:s} {:02d}, {:02d},".format(state.RTCtpl_DOW[dt.tm_wday], state.RTCtpl_MONTH[dt.tm_mon], dt.tm_mday, dt.tm_year) if dt.tm_hour < 12: hh = dt.tm_hour ampm = "am" elif dt.tm_hour == 12: hh = dt.tm_hr ampm = "pm" elif dt.tm_hour >= 13: hh = dt.tm_hour - 12 ampm = "pm" dt2 = "at: {:02d}:{:02d}:{:02d} {:s} ".format(hh, dt.tm_min, dt.tm_sec, ampm ) return dt1+" "+dt2 -
PaulskPt revised this gist
Apr 16, 2024 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - New run: 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - from python script: "gamepadqt_and_aht20.py" 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - Runtime: Tuesday, April 16, 2024, at: 10:21:39 pm 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - board id: RASPBERRY_PI_5 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - New run: 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - from python script: "gamepadqt_and_aht20.py" 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - Runtime: Tuesday, April 16, 2024, at: 10:21:39 pm 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - board id: RASPBERRY_PI_5 -
PaulskPt revised this gist
Apr 16, 2024 . 3 changed files with 139 additions and 60 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,6 +68,23 @@ def __init__(self, saved_state_json=None): 5: "Saturday", 6: "Sunday" } self.RTCtpl_MONTH = \ { 0: "Dummy", 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" } self.BUTTON_X = const(6) self.BUTTON_Y = const(2) self.BUTTON_A = const(5) @@ -132,6 +149,20 @@ def __init__(self, saved_state_json=None): del file_handler_qt del file_handler_aht def get_dt(): now = datetime.now() dt = now.timetuple() dt1 = "{:s}, {:s} {:02d}, {:02d},".format(state.RTCtpl_DOW[dt.tm_wday], state.RTCtpl_MONTH[dt.tm_mon], dt.tm_mday, dt.tm_year) if dt.tm_hour >= 12: hh = dt.tm_hour - 12 ampm = "pm" else: hh = dt.tm_hour ampm = "am" dt2 = "at: {:02d}:{:02d}:{:02d} {:s} ".format(hh, dt.tm_min, dt.tm_sec, ampm ) return dt1+" "+dt2 line = "-" * 55 print(line) logger_qt.info(line) @@ -144,6 +175,10 @@ def __init__(self, saved_state_json=None): print(s) logger_qt.info(s) logger_aht.info(s) s = "Runtime: "+get_dt() print(s) logger_qt.info(s) logger_aht.info(s) print(line) logger_qt.info(line) logger_aht.info(line) @@ -428,6 +463,14 @@ def ck_temphum(state): logger_aht.exception(f"Error: {e}") def get_dt(): now = datetime.now() dt = now.timetuple() dt1 = "{:d}/{:02d}/{:02d}".format(dt.tm_mon, dt.tm_mday, dt.tm_year) dt2 = "{:02d}:{:02d}:{:02d} weekday: {:s}".format(dt.tm_hour, dt.tm_min, dt.tm_sec, state.RTCtpl_DOW[dt.tm_wday]) return dt1+" "+dt2 def get_INT_RTC(state): if not state.get_INT_RTC: return This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,51 +1,74 @@ 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - New run: 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - from python script: "gamepadqt_e_aht20.py" 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - Runtime: Tuesday, April 16, 2024, at: 10:21:39 pm 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - AHT20 sensor is present 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - get_INT_RTC(): 22:21:39 weekday: Tuesday 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - Adafruit AHT20 test: 2024-04-16 22:21:39 - RPi5_aht20_test - INFO - logged values of temperature and humidity from Adafruit AHT20 sensor: 2024-04-16 22:21:40 - RPi5_aht20_test - INFO - temperature: 25.64 °C 2024-04-16 22:21:40 - RPi5_aht20_test - INFO - humidity: 47.81 % 2024-04-16 22:21:41 - RPi5_aht20_test - INFO - temperature: 25.64 °C 2024-04-16 22:21:41 - RPi5_aht20_test - INFO - humidity: 47.95 % 2024-04-16 22:21:42 - RPi5_aht20_test - INFO - temperature: 25.65 °C 2024-04-16 22:21:42 - RPi5_aht20_test - INFO - humidity: 48.01 % 2024-04-16 22:21:42 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:42 - RPi5_aht20_test - INFO - humidity: 48.03 % 2024-04-16 22:21:43 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:21:43 - RPi5_aht20_test - INFO - humidity: 47.98 % 2024-04-16 22:21:44 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:21:44 - RPi5_aht20_test - INFO - humidity: 47.92 % 2024-04-16 22:21:45 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:45 - RPi5_aht20_test - INFO - humidity: 47.91 % 2024-04-16 22:21:46 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:46 - RPi5_aht20_test - INFO - humidity: 47.82 % 2024-04-16 22:21:46 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:46 - RPi5_aht20_test - INFO - humidity: 47.73 % 2024-04-16 22:21:47 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:21:47 - RPi5_aht20_test - INFO - humidity: 47.60 % 2024-04-16 22:21:48 - RPi5_aht20_test - INFO - temperature: 25.68 °C 2024-04-16 22:21:48 - RPi5_aht20_test - INFO - humidity: 47.50 % 2024-04-16 22:21:49 - RPi5_aht20_test - INFO - temperature: 25.64 °C 2024-04-16 22:21:49 - RPi5_aht20_test - INFO - humidity: 47.45 % 2024-04-16 22:21:50 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:50 - RPi5_aht20_test - INFO - humidity: 47.57 % 2024-04-16 22:21:51 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:51 - RPi5_aht20_test - INFO - humidity: 47.67 % 2024-04-16 22:21:51 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:51 - RPi5_aht20_test - INFO - humidity: 47.66 % 2024-04-16 22:21:52 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:21:52 - RPi5_aht20_test - INFO - humidity: 47.45 % 2024-04-16 22:21:53 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:53 - RPi5_aht20_test - INFO - humidity: 47.35 % 2024-04-16 22:21:54 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:54 - RPi5_aht20_test - INFO - humidity: 47.12 % 2024-04-16 22:21:55 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:55 - RPi5_aht20_test - INFO - humidity: 46.93 % 2024-04-16 22:21:55 - RPi5_aht20_test - INFO - temperature: 25.68 °C 2024-04-16 22:21:55 - RPi5_aht20_test - INFO - humidity: 46.85 % 2024-04-16 22:21:56 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:21:56 - RPi5_aht20_test - INFO - humidity: 46.95 % 2024-04-16 22:21:57 - RPi5_aht20_test - INFO - temperature: 25.68 °C 2024-04-16 22:21:57 - RPi5_aht20_test - INFO - humidity: 46.93 % 2024-04-16 22:21:58 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:21:58 - RPi5_aht20_test - INFO - humidity: 46.86 % 2024-04-16 22:21:58 - RPi5_aht20_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 22:21:58 - RPi5_aht20_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 22:22:01 - RPi5_aht20_test - INFO - You answered: 'n' 2024-04-16 22:22:01 - RPi5_aht20_test - INFO - not rebooting 2024-04-16 22:22:01 - RPi5_aht20_test - INFO - temperature: 25.64 °C 2024-04-16 22:22:01 - RPi5_aht20_test - INFO - humidity: 46.63 % 2024-04-16 22:22:02 - RPi5_aht20_test - INFO - temperature: 25.66 °C 2024-04-16 22:22:02 - RPi5_aht20_test - INFO - humidity: 46.55 % 2024-04-16 22:22:03 - RPi5_aht20_test - INFO - temperature: 25.67 °C 2024-04-16 22:22:03 - RPi5_aht20_test - INFO - humidity: 46.59 % 2024-04-16 22:22:04 - RPi5_aht20_test - INFO - temperature: 25.68 °C 2024-04-16 22:22:04 - RPi5_aht20_test - INFO - humidity: 46.54 % 2024-04-16 22:22:04 - RPi5_aht20_test - INFO - main(): KeyboardInterrrupt. Exiting... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,28 @@ 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - New run: 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - from python script: "gamepadqt_e_aht20.py" 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - Runtime: Tuesday, April 16, 2024, at: 10:21:39 pm 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - Gamepad QT is present 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 22:21:39 weekday: Tuesday 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - Adafruit Gamepad QT test: 2024-04-16 22:21:39 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 511) 2024-04-16 22:21:46 - RPi5_gamepadqt_test - INFO - Button A pressed 2024-04-16 22:21:51 - RPi5_gamepadqt_test - INFO - Button B pressed 2024-04-16 22:21:52 - RPi5_gamepadqt_test - INFO - Button X pressed 2024-04-16 22:21:53 - RPi5_gamepadqt_test - INFO - Button Y pressed 2024-04-16 22:21:56 - RPi5_gamepadqt_test - INFO - Button Select pressed 2024-04-16 22:21:58 - RPi5_gamepadqt_test - INFO - Button Start pressed 2024-04-16 22:21:58 - RPi5_gamepadqt_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 22:21:58 - RPi5_gamepadqt_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 22:22:01 - RPi5_gamepadqt_test - INFO - You answered: 'n' 2024-04-16 22:22:01 - RPi5_gamepadqt_test - INFO - not rebooting 2024-04-16 22:22:02 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 832) 2024-04-16 22:22:03 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 511) 2024-04-16 22:22:04 - RPi5_gamepadqt_test - INFO - main(): KeyboardInterrrupt. Exiting... -
PaulskPt revised this gist
Apr 16, 2024 . 3 changed files with 70 additions and 49 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -133,15 +133,23 @@ def __init__(self, saved_state_json=None): del file_handler_aht line = "-" * 55 print(line) logger_qt.info(line) logger_aht.info(line) s = "New run:" print(s) logger_qt.info(s) logger_aht.info(s) s = f"from python script: \"{sys.argv[0]}\"" # __file__ includes the full path to the file print(s) logger_qt.info(s) logger_aht.info(s) print(line) logger_qt.info(line) logger_aht.info(line) del line state.board_id = board.board_id logger_qt.info(f"board id: {state.board_id}") logger_aht.info(f"board id: {state.board_id}") @@ -164,7 +172,8 @@ def __init__(self, saved_state_json=None): try: seesaw = Seesaw(i2c_bus, addr=0x50) seesaw.pin_mode_bulk(state.button_mask, seesaw.INPUT_PULLUP) if state.my_debug: print(f"global(): type(seesaw) = {type(seesaw)}") if seesaw: state.seesaw = seesaw state.qt_btns_present = True This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,34 +1,51 @@ 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - New run: 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - from python script: "gamepadqt_e_aht20.py" 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 19:53:47 - RPi5_aht20_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - AHT20 sensor is present 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - get_INT_RTC(): 19:53:48 weekday: Tuesday 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - Adafruit AHT20 test: 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - logged values of temperature and humidity from Adafruit AHT20 sensor: 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - temperature: 26.79 °C 2024-04-16 19:53:48 - RPi5_aht20_test - INFO - humidity: 50.60 % 2024-04-16 19:53:49 - RPi5_aht20_test - INFO - temperature: 26.82 °C 2024-04-16 19:53:49 - RPi5_aht20_test - INFO - humidity: 50.59 % 2024-04-16 19:53:50 - RPi5_aht20_test - INFO - temperature: 26.82 °C 2024-04-16 19:53:50 - RPi5_aht20_test - INFO - humidity: 50.56 % 2024-04-16 19:53:51 - RPi5_aht20_test - INFO - temperature: 26.83 °C 2024-04-16 19:53:51 - RPi5_aht20_test - INFO - humidity: 50.51 % 2024-04-16 19:53:52 - RPi5_aht20_test - INFO - temperature: 26.84 °C 2024-04-16 19:53:52 - RPi5_aht20_test - INFO - humidity: 50.48 % 2024-04-16 19:53:53 - RPi5_aht20_test - INFO - temperature: 26.83 °C 2024-04-16 19:53:53 - RPi5_aht20_test - INFO - humidity: 50.51 % 2024-04-16 19:53:53 - RPi5_aht20_test - INFO - temperature: 26.83 °C 2024-04-16 19:53:53 - RPi5_aht20_test - INFO - humidity: 50.49 % 2024-04-16 19:53:54 - RPi5_aht20_test - INFO - temperature: 26.83 °C 2024-04-16 19:53:54 - RPi5_aht20_test - INFO - humidity: 50.56 % 2024-04-16 19:53:55 - RPi5_aht20_test - INFO - temperature: 26.84 °C 2024-04-16 19:53:55 - RPi5_aht20_test - INFO - humidity: 50.86 % 2024-04-16 19:53:56 - RPi5_aht20_test - INFO - temperature: 26.85 °C 2024-04-16 19:53:56 - RPi5_aht20_test - INFO - humidity: 51.16 % 2024-04-16 19:53:57 - RPi5_aht20_test - INFO - temperature: 26.83 °C 2024-04-16 19:53:57 - RPi5_aht20_test - INFO - humidity: 51.39 % 2024-04-16 19:53:57 - RPi5_aht20_test - INFO - temperature: 26.84 °C 2024-04-16 19:53:57 - RPi5_aht20_test - INFO - humidity: 51.40 % 2024-04-16 19:53:58 - RPi5_aht20_test - INFO - temperature: 26.84 °C 2024-04-16 19:53:58 - RPi5_aht20_test - INFO - humidity: 51.41 % 2024-04-16 19:53:59 - RPi5_aht20_test - INFO - temperature: 26.84 °C 2024-04-16 19:53:59 - RPi5_aht20_test - INFO - humidity: 51.45 % 2024-04-16 19:54:00 - RPi5_aht20_test - INFO - temperature: 26.85 °C 2024-04-16 19:54:00 - RPi5_aht20_test - INFO - humidity: 51.49 % 2024-04-16 19:54:01 - RPi5_aht20_test - INFO - temperature: 26.85 °C 2024-04-16 19:54:01 - RPi5_aht20_test - INFO - humidity: 51.54 % 2024-04-16 19:54:02 - RPi5_aht20_test - INFO - temperature: 26.85 °C 2024-04-16 19:54:02 - RPi5_aht20_test - INFO - humidity: 51.57 % 2024-04-16 19:54:02 - RPi5_aht20_test - INFO - temperature: 26.85 °C 2024-04-16 19:54:02 - RPi5_aht20_test - INFO - humidity: 51.49 % 2024-04-16 19:54:03 - RPi5_aht20_test - INFO - main(): KeyboardInterrrupt. Exiting... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,15 @@ 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - New run: 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - from python script: "gamepadqt_e_aht20.py" 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 19:53:47 - RPi5_gamepadqt_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 19:53:48 - RPi5_gamepadqt_test - INFO - Gamepad QT is present 2024-04-16 19:53:48 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 19:53:48 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 19:53:48 weekday: Tuesday 2024-04-16 19:53:48 - RPi5_gamepadqt_test - INFO - Adafruit Gamepad QT test: 2024-04-16 19:53:48 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 511) 2024-04-16 19:54:03 - RPi5_gamepadqt_test - INFO - main(): KeyboardInterrrupt. Exiting... -
PaulskPt revised this gist
Apr 16, 2024 . 3 changed files with 61 additions and 68 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -132,6 +132,16 @@ def __init__(self, saved_state_json=None): del file_handler_qt del file_handler_aht line = "-" * 55 logger_qt.info(line) logger_aht.info(line) s = "New run:" logger_qt.info(s) logger_aht.info(s) logger_qt.info(line) logger_aht.info(line) del line state.board_id = board.board_id logger_qt.info(f"board id: {state.board_id}") logger_aht.info(f"board id: {state.board_id}") @@ -149,6 +159,8 @@ def __init__(self, saved_state_json=None): logger_aht.error(s) sys.exit() e = None try: seesaw = Seesaw(i2c_bus, addr=0x50) seesaw.pin_mode_bulk(state.button_mask, seesaw.INPUT_PULLUP) @@ -175,6 +187,7 @@ def __init__(self, saved_state_json=None): state.aht20_present = False pass del e del i2c_bus s = "Gamepad QT is {} present".format("" if state.qt_btns_present else " not") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,53 +1,34 @@ 2024-04-16 19:10:16 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 19:10:16 - RPi5_aht20_test - INFO - New run: 2024-04-16 19:10:16 - RPi5_aht20_test - INFO - ------------------------------------------------------- 2024-04-16 19:10:16 - RPi5_aht20_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 19:10:16 - RPi5_aht20_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 19:10:17 - RPi5_aht20_test - INFO - AHT20 sensor is present 2024-04-16 19:10:17 - RPi5_aht20_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 19:10:17 - RPi5_aht20_test - INFO - get_INT_RTC(): 19:10:17 weekday: Tuesday 2024-04-16 19:10:17 - RPi5_aht20_test - INFO - Adafruit AHT20 test: 2024-04-16 19:10:17 - RPi5_aht20_test - INFO - logged values of temperature and humidity from Adafruit AHT20 sensor: 2024-04-16 19:10:18 - RPi5_aht20_test - INFO - temperature: 26.97 °C 2024-04-16 19:10:18 - RPi5_aht20_test - INFO - humidity: 53.21 % 2024-04-16 19:10:19 - RPi5_aht20_test - INFO - temperature: 27.00 °C 2024-04-16 19:10:19 - RPi5_aht20_test - INFO - humidity: 53.48 % 2024-04-16 19:10:19 - RPi5_aht20_test - INFO - temperature: 27.00 °C 2024-04-16 19:10:19 - RPi5_aht20_test - INFO - humidity: 53.35 % 2024-04-16 19:10:20 - RPi5_aht20_test - INFO - temperature: 27.01 °C 2024-04-16 19:10:20 - RPi5_aht20_test - INFO - humidity: 53.15 % 2024-04-16 19:10:21 - RPi5_aht20_test - INFO - temperature: 27.00 °C 2024-04-16 19:10:21 - RPi5_aht20_test - INFO - humidity: 52.99 % 2024-04-16 19:10:22 - RPi5_aht20_test - INFO - temperature: 27.02 °C 2024-04-16 19:10:22 - RPi5_aht20_test - INFO - humidity: 52.84 % 2024-04-16 19:10:23 - RPi5_aht20_test - INFO - temperature: 27.01 °C 2024-04-16 19:10:23 - RPi5_aht20_test - INFO - humidity: 52.78 % 2024-04-16 19:10:23 - RPi5_aht20_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 19:10:23 - RPi5_aht20_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 19:10:25 - RPi5_aht20_test - INFO - You answered: 'n' 2024-04-16 19:10:25 - RPi5_aht20_test - INFO - not rebooting 2024-04-16 19:10:26 - RPi5_aht20_test - INFO - temperature: 26.99 °C 2024-04-16 19:10:26 - RPi5_aht20_test - INFO - humidity: 52.45 % 2024-04-16 19:10:26 - RPi5_aht20_test - INFO - main(): KeyboardInterrrupt. Exiting... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,20 @@ 2024-04-16 19:10:16 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 19:10:16 - RPi5_gamepadqt_test - INFO - New run: 2024-04-16 19:10:16 - RPi5_gamepadqt_test - INFO - ------------------------------------------------------- 2024-04-16 19:10:16 - RPi5_gamepadqt_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 19:10:16 - RPi5_gamepadqt_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 19:10:17 - RPi5_gamepadqt_test - INFO - Gamepad QT is present 2024-04-16 19:10:17 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 19:10:17 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 19:10:17 weekday: Tuesday 2024-04-16 19:10:17 - RPi5_gamepadqt_test - INFO - Adafruit Gamepad QT test: 2024-04-16 19:10:17 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 511) 2024-04-16 19:10:20 - RPi5_gamepadqt_test - INFO - Button B pressed 2024-04-16 19:10:23 - RPi5_gamepadqt_test - INFO - Button Start pressed 2024-04-16 19:10:23 - RPi5_gamepadqt_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 19:10:23 - RPi5_gamepadqt_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 19:10:25 - RPi5_gamepadqt_test - INFO - You answered: 'n' 2024-04-16 19:10:25 - RPi5_gamepadqt_test - INFO - not rebooting 2024-04-16 19:10:26 - RPi5_gamepadqt_test - INFO - main(): KeyboardInterrrupt. Exiting... -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -81,7 +81,7 @@ def __init__(self, saved_state_json=None): | (1 << self.BUTTON_B) | (1 << self.BUTTON_SELECT) | (1 << self.BUTTON_START) ) state = State() -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -434,13 +434,13 @@ def get_INT_RTC(state): dt = state.RTCtpl # print(TAG+f"dt= {dt}") dt1 =TAG+"{:d}/{:02d}/{:02d}".format(dt.tm_mon, dt.tm_mday, dt.tm_year) dt2 = TAG+"{:02d}:{:02d}:{:02d} weekday: {:s}".format(dt.tm_hour, dt.tm_min, dt.tm_sec, state.RTCtpl_DOW[dt.tm_wday]) logger_qt.info(dt1) logger_aht.info(dt1) logger_qt.info(dt2) logger_aht.info(dt2) def setup(state): -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -379,7 +379,7 @@ def ck_qt_btns(state): _time.sleep(0.01) def ck_temphum(state): if not state.aht20_present: return @@ -477,7 +477,7 @@ def main(): loopnr = 0 ck_qt_btns(state) _time.sleep(0.5) ck_temphum(state) except KeyboardInterrupt: s = TAG+"KeyboardInterrrupt. Exiting..." print(s) -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 0 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -250,15 +250,6 @@ def pr_btn_name(res): print(s) logger_qt.info(s) # Check for button presses on the Gamepad QT def ck_qt_btns(state): -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -212,6 +212,7 @@ def test_msg(state): def ck_usr_answr(): ret = False ays = "Are you sure? (Y/n)+<Enter>: " answer = "" while True: logger_qt.warning(ays) logger_aht.warning(ays) @@ -220,10 +221,10 @@ def ck_usr_answr(): print(s) logger_qt.info(s) logger_aht.info(s) if answer.upper() == "Y": ret = True break elif answer.upper() == "N": s = "not rebooting" logger_qt.info(s) logger_aht.info(s) -
PaulskPt revised this gist
Apr 16, 2024 . 2 changed files with 68 additions and 70 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,58 +1,53 @@ 2024-04-16 18:26:03 - RPi5_aht20_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 18:26:03 - RPi5_aht20_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 18:26:04 - RPi5_aht20_test - INFO - AHT20 sensor is present 2024-04-16 18:26:04 - RPi5_aht20_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 18:26:04 - RPi5_aht20_test - INFO - get_INT_RTC(): 18:26:04 weekday: Tuesday 2024-04-16 18:26:04 - RPi5_aht20_test - INFO - Adafruit AHT20 test: 2024-04-16 18:26:04 - RPi5_aht20_test - INFO - logged values of temperature and humidity from Adafruit AHT20 sensor: 2024-04-16 18:26:05 - RPi5_aht20_test - INFO - temperature: 27.13 °C 2024-04-16 18:26:05 - RPi5_aht20_test - INFO - humidity: 54.71 % 2024-04-16 18:26:06 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:06 - RPi5_aht20_test - INFO - humidity: 55.02 % 2024-04-16 18:26:06 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:06 - RPi5_aht20_test - INFO - humidity: 55.38 % 2024-04-16 18:26:07 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:07 - RPi5_aht20_test - INFO - humidity: 55.52 % 2024-04-16 18:26:08 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:08 - RPi5_aht20_test - INFO - humidity: 55.66 % 2024-04-16 18:26:09 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:09 - RPi5_aht20_test - INFO - humidity: 55.73 % 2024-04-16 18:26:10 - RPi5_aht20_test - INFO - temperature: 27.18 °C 2024-04-16 18:26:10 - RPi5_aht20_test - INFO - humidity: 55.81 % 2024-04-16 18:26:11 - RPi5_aht20_test - INFO - temperature: 27.19 °C 2024-04-16 18:26:11 - RPi5_aht20_test - INFO - humidity: 55.74 % 2024-04-16 18:26:11 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:11 - RPi5_aht20_test - INFO - humidity: 55.57 % 2024-04-16 18:26:12 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:12 - RPi5_aht20_test - INFO - humidity: 55.43 % 2024-04-16 18:26:13 - RPi5_aht20_test - INFO - temperature: 27.16 °C 2024-04-16 18:26:13 - RPi5_aht20_test - INFO - humidity: 55.31 % 2024-04-16 18:26:14 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:14 - RPi5_aht20_test - INFO - humidity: 55.17 % 2024-04-16 18:26:15 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:15 - RPi5_aht20_test - INFO - humidity: 55.10 % 2024-04-16 18:26:15 - RPi5_aht20_test - INFO - temperature: 27.17 °C 2024-04-16 18:26:15 - RPi5_aht20_test - INFO - humidity: 55.04 % 2024-04-16 18:26:16 - RPi5_aht20_test - INFO - temperature: 27.16 °C 2024-04-16 18:26:16 - RPi5_aht20_test - INFO - humidity: 54.95 % 2024-04-16 18:26:17 - RPi5_aht20_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 18:26:17 - RPi5_aht20_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 18:26:19 - RPi5_aht20_test - INFO - You answered: 'n' 2024-04-16 18:26:19 - RPi5_aht20_test - INFO - not rebooting 2024-04-16 18:26:19 - RPi5_aht20_test - INFO - temperature: 27.13 °C 2024-04-16 18:26:19 - RPi5_aht20_test - INFO - humidity: 54.79 % 2024-04-16 18:26:20 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:20 - RPi5_aht20_test - INFO - humidity: 54.74 % 2024-04-16 18:26:21 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:21 - RPi5_aht20_test - INFO - humidity: 54.99 % 2024-04-16 18:26:22 - RPi5_aht20_test - INFO - temperature: 27.15 °C 2024-04-16 18:26:22 - RPi5_aht20_test - INFO - humidity: 55.36 % 2024-04-16 18:26:22 - RPi5_aht20_test - INFO - main(): KeyboardInterrrupt. Exiting... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,21 @@ 2024-04-16 18:26:03 - RPi5_gamepadqt_test - INFO - board id: RASPBERRY_PI_5 2024-04-16 18:26:03 - RPi5_gamepadqt_test - INFO - using Adafruit_Python_extended_Bus. Using I2C bus #3 2024-04-16 18:26:04 - RPi5_gamepadqt_test - INFO - Gamepad QT is present 2024-04-16 18:26:04 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 4/16/2024 2024-04-16 18:26:04 - RPi5_gamepadqt_test - INFO - get_INT_RTC(): 18:26:04 weekday: Tuesday 2024-04-16 18:26:04 - RPi5_gamepadqt_test - INFO - Adafruit Gamepad QT test: 2024-04-16 18:26:04 - RPi5_gamepadqt_test - INFO - joystick: (x, y)= (504, 511) 2024-04-16 18:26:07 - RPi5_gamepadqt_test - INFO - Button A pressed 2024-04-16 18:26:08 - RPi5_gamepadqt_test - INFO - Button B pressed 2024-04-16 18:26:10 - RPi5_gamepadqt_test - INFO - Button X pressed 2024-04-16 18:26:11 - RPi5_gamepadqt_test - INFO - Button Y pressed 2024-04-16 18:26:14 - RPi5_gamepadqt_test - INFO - Button Select pressed 2024-04-16 18:26:17 - RPi5_gamepadqt_test - INFO - Button Start pressed 2024-04-16 18:26:17 - RPi5_gamepadqt_test - INFO - About to reboot the RASPBERRY_PI_5 2024-04-16 18:26:17 - RPi5_gamepadqt_test - WARNING - Are you sure? (Y/n)+<Enter>: 2024-04-16 18:26:19 - RPi5_gamepadqt_test - INFO - You answered: 'n' 2024-04-16 18:26:19 - RPi5_gamepadqt_test - INFO - not rebooting 2024-04-16 18:26:22 - RPi5_gamepadqt_test - INFO - main(): KeyboardInterrrupt. Exiting... -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -211,8 +211,11 @@ def test_msg(state): def ck_usr_answr(): ret = False ays = "Are you sure? (Y/n)+<Enter>: " while True: logger_qt.warning(ays) logger_aht.warning(ays) answer = input(ays) s = f"You answered: \'{answer}\'" print(s) logger_qt.info(s) -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -141,8 +141,6 @@ def __init__(self, saved_state_json=None): logger_aht.info(s) del s i2c_bus = I2C(3) # I2C bus to be used: /dev/i2c-3 if i2c_bus is None: -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 52 additions and 30 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,8 @@ def __init__(self, saved_state_json=None): self.board_id = None self.USE_TAG = None self.my_debug = False self.seesaw = None self.tempSensor = None self.msg1_shown = False self.last_x = 0 self.last_y = 0 @@ -66,6 +68,20 @@ def __init__(self, saved_state_json=None): 5: "Saturday", 6: "Sunday" } self.BUTTON_X = const(6) self.BUTTON_Y = const(2) self.BUTTON_A = const(5) self.BUTTON_B = const(1) self.BUTTON_SELECT = const(0) self.BUTTON_START = const(16) self.button_mask = const( (1 << self.BUTTON_X) | (1 << self.BUTTON_Y) | (1 << self.BUTTON_A) | (1 << self.BUTTON_B) | (1 << self.BUTTON_SELECT) | (1 << self.BUTTON_START) ) state = State() @@ -125,20 +141,7 @@ def __init__(self, saved_state_json=None): logger_aht.info(s) del s i2c_bus = I2C(3) # I2C bus to be used: /dev/i2c-3 @@ -150,8 +153,12 @@ def __init__(self, saved_state_json=None): try: seesaw = Seesaw(i2c_bus, addr=0x50) seesaw.pin_mode_bulk(state.button_mask, seesaw.INPUT_PULLUP) print(f"global(): type(seesaw) = {type(seesaw)}") if seesaw: state.seesaw = seesaw state.qt_btns_present = True del seesaw except Exception as e: logger_qt.error(f"global(): Error while creating an instance seesaw class: {e}") state.qt_btns_present = False @@ -161,7 +168,10 @@ def __init__(self, saved_state_json=None): # tempSensor = PiicoDev_TMP117() # initialise the sensor tempSensor = AHTx0(i2c_bus) # initialise the sensor #logger_aht.info(f"type(tempSensor)= {type(tempSensor)}") if tempSensor: state.tempSensor = tempSensor state.aht20_present = True del tempSensor except Exception as e: logger_aht.error(f"global(): Error while creating an instance ath20 sensor class: {e}") state.aht20_present = False @@ -238,14 +248,24 @@ def pr_btn_name(res): print(s) logger_qt.info(s) def btn_mask(state): return const( (1 << state.BUTTON_X) | (1 << state.BUTTON_Y) | (1 << state.BUTTON_A) | (1 << state.BUTTON_B) | (1 << state.BUTTON_SELECT) | (1 << state.BUTTON_START) ) # Check for button presses on the Gamepad QT def ck_qt_btns(state): TAG = "ck_qt_btns(): " if not state.qt_btns_present: print(TAG+f"state.qt_btns_present= {state.qt_btns_present}") return nr_btns = 6 res_x = res_y = res_a = res_b = res_sel = res_sta = -1 elapsed_t = None @@ -256,8 +276,8 @@ def ck_qt_btns(state): try: # get the joystick x and y axis value x = 1023 - state.seesaw.analog_read(14) y = 1023 - state.seesaw.analog_read(15) except Exception as e: if e.errno == 121: # Remote I/O Error logger_qt.error(f"Error: {e}") @@ -281,9 +301,11 @@ def ck_qt_btns(state): state.last_y = y # Get the button presses, if any... buttons = state.seesaw.digital_read_bulk(state.button_mask) if state.my_debug: s = "\n"+TAG+f"buttons = {buttons}" print(s) logger_qt.info(s) if buttons == 65639: if state.my_debug: logger_qt.info(TAG+f"Gamepad QT: no button pressed") @@ -295,47 +317,47 @@ def ck_qt_btns(state): res = -1 for _ in range(nr_btns): if _ == 0: bz = 1 << state.BUTTON_X if not buttons & (bz): res = _ if res_x != res: pr_btn_name(res) res_x = res break if _ == 1: bz = 1 << state.BUTTON_Y if not buttons & (bz): res = _ if res_y != res: pr_btn_name(res) res_y = res break if _ == 2: bz = 1 << state.BUTTON_A if not buttons & (bz): res = _ if res_a != res: pr_btn_name(res) res_a = res break if _ == 3: bz = 1 << state.BUTTON_B if not buttons & (bz): res = _ if res_b != res: pr_btn_name(res) res_b = res break if _ == 4: bz = 1 << state.BUTTON_SELECT if not buttons & (bz): res = _ if res_sel != res: pr_btn_name(res) res_sel = res break if _ == 5: bz = 1 << state.BUTTON_START if not buttons & (bz): res = _ if res_sta != res: @@ -369,8 +391,8 @@ def temphum(state): if not state.aht20_present: return tmp = state.tempSensor.temperature # Celsius hum = state.tempSensor.relative_humidity # # Convert temperature and humidity values into a string and print the data t = "temperature: {:5.2f} °C".format(tmp) h = "humidity: {:5.2f} %".format(hum) -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,6 @@ def __init__(self, saved_state_json=None): except Exception as e: logger_qt.error(f"global(): Error while creating an instance seesaw class: {e}") state.qt_btns_present = False pass try: -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -139,9 +139,9 @@ def __init__(self, saved_state_json=None): | (1 << BUTTON_SELECT) | (1 << BUTTON_START) ) i2c_bus = I2C(3) # I2C bus to be used: /dev/i2c-3 if i2c_bus is None: s = f"Error: type(i2c_bus)= {type(i2c_bus)}. Exiting..." logger_qt.error(s) -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -176,6 +176,7 @@ def __init__(self, saved_state_json=None): logger_aht.info(s) del s gc.collect() def test_msg(state): TAG = "gamepad_test(): " @@ -191,7 +192,7 @@ def test_msg(state): print(s) logger_qt.error(s) logger_aht.error(s) # _time.sleep(3) sys.exit() elif state.qt_btns_present or state.aht20_present: state.msg1_shown = True @@ -222,6 +223,7 @@ def ck_usr_answr(): def reboot(): s = "\nRebooting..." print(s) logger_qt.info(s) logger_aht.info(s) _time.sleep(3) @@ -464,6 +466,7 @@ def main(): temphum(state) except KeyboardInterrupt: s = TAG+"KeyboardInterrrupt. Exiting..." print(s) logger_qt.info(s) logger_aht.info(s) break -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ A Raspberry Pi 5B-8GB single board computer with, via I2C, connected: a) an Adafruit Mini I2C Gamepad with seesaw - STEMMA QT / Qwiic (https://www.adafruit.com/product/5743); b) an Adafruit AHT20 Temperatur & Humidity Sensor Breakout Board - STEMMA QT / Qwiic (https://www.adafruit.com/product/4566). Added functionality to save data to two separate log files: 1) gamepadqt.log for some system info and data from the Gamepad QT; 2) aht20.log for some system info and data from the AHT20 sensor. This script has been successfully tested on a Raspberry Pi 5B-8GB -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -340,7 +340,7 @@ def ck_qt_btns(state): if res_sta != res: pr_btn_name(res) res_sta = res s = f"About to reboot the {state.board_id}" logger_qt.info(s) logger_aht.info(s) if ck_usr_answr(): -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 17 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,8 @@ def __init__(self, saved_state_json=None): except Exception as e: logger_qt.error(f"global(): Error while creating an instance seesaw class: {e}") state.qt_btns_present = False #raise pass try: # tempSensor = PiicoDev_TMP117() # initialise the sensor @@ -165,7 +166,7 @@ def __init__(self, saved_state_json=None): except Exception as e: logger_aht.error(f"global(): Error while creating an instance ath20 sensor class: {e}") state.aht20_present = False pass del i2c_bus @@ -182,19 +183,22 @@ def test_msg(state): if state.qt_btns_present: s1 = "the Gamepad QT" if state.aht20_present: s2 = "and the AHT20 sensor" if not state.msg1_shown: if not state.qt_btns_present and not state.aht20_present: s = TAG+f"neither of the Gamepad QT or the AHT20 sensor is present. Check wiring. Exiting..." print(s) logger_qt.error(s) logger_aht.error(s) _time.sleep(3) sys.exit() elif state.qt_btns_present or state.aht20_present: state.msg1_shown = True print(TAG+f"We\'re going to test {s1} {s2} with this {state.board_id}.") if state.qt_btns_present: print("\t\tPress any of the buttons (X, Y, A, B, Select or Start) on the Gamepad QT.\n\t\t" + \ f"To reboot {state.board_id} press Gamepad QT button Start.\n") def ck_usr_answr(): @@ -249,8 +253,6 @@ def ck_qt_btns(state): gc.collect() _time.sleep(0.2) try: # get the joystick x and y axis value x = 1023 - seesaw.analog_read(14) @@ -440,13 +442,17 @@ def main(): TAG= "main(): " loopnr = 0 setup(state) test_msg(state) s = "\n\nAdafruit Gamepad QT test:\n" logger_qt.info(s) s = "\n\nAdafruit AHT20 test:\n" logger_aht.info(s) if state.aht20_present: logger_aht.info('logged values of temperature and humidity from Adafruit AHT20 sensor:') while True: try: loopnr += 1 -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,8 +217,9 @@ def ck_usr_answr(): def reboot(): s = "\nRebooting..." logger_qt.info(s) logger_aht.info(s) _time.sleep(3) os.system("sudo reboot") # for Raspberry Pi boards #microcontroller.reset() # for CircuitPython boards -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -177,7 +177,6 @@ def __init__(self, saved_state_json=None): def test_msg(state): TAG = "gamepad_test(): " s1 = s2 = "" if state.qt_btns_present: -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 5 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -221,8 +221,8 @@ def reboot(): logger_qt.info("\nRebooting...") logger_aht.info("\nRebooting...") _time.sleep(3) os.system("sudo reboot") # for Raspberry Pi boards #microcontroller.reset() # for CircuitPython boards def pr_btn_name(res): @@ -252,6 +252,7 @@ def ck_qt_btns(state): test_msg(state) try: # get the joystick x and y axis value x = 1023 - seesaw.analog_read(14) y = 1023 - seesaw.analog_read(15) except Exception as e: @@ -269,7 +270,6 @@ def ck_qt_btns(state): diff_y = abs(state.last_y - y) if (diff_x > 3) or (diff_y > 3): s = f"joystick: (x, y)= ({x}, {y})" print(s) logger_qt.info(s) @@ -342,8 +342,7 @@ def ck_qt_btns(state): logger_qt.info(s) logger_aht.info(s) if ck_usr_answr(): reboot() # Reboot the board else: state.msg1_shown = False res_sta = -2 @@ -363,14 +362,13 @@ def ck_qt_btns(state): def temphum(state): if not state.aht20_present: return tmp = tempSensor.temperature # Celsius hum = tempSensor.relative_humidity # # Convert temperature and humidity values into a string and print the data t = "temperature: {:5.2f} °C".format(tmp) h = "humidity: {:5.2f} %".format(hum) if state.temperature_old is None: @@ -383,10 +381,8 @@ def temphum(state): state.humidity_old = t try: print(t) logger_aht.info(t) print(h) logger_aht.info(h) except Exception as e: logger_aht.exception(f"Error: {e}") -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -175,6 +175,7 @@ def __init__(self, saved_state_json=None): logger_aht.info(s) del s def test_msg(state): global msg1_shown TAG = "gamepad_test(): " @@ -196,6 +197,7 @@ def test_msg(state): _time.sleep(3) sys.exit() def ck_usr_answr(): ret = False while True: @@ -214,13 +216,15 @@ def ck_usr_answr(): break return ret def reboot(): logger_qt.info("\nRebooting...") logger_aht.info("\nRebooting...") _time.sleep(3) # os.system('sudo shutdown -r now') # for Raspberry Pi boards microcontroller.reset() # for CircuitPython boards def pr_btn_name(res): btns = ["X", "Y", "A", "B", "Select", "Start"] if res >= 0 and res < len(btns): @@ -357,6 +361,7 @@ def ck_qt_btns(state): _time.sleep(0.01) def temphum(state): # Read and print the temperature in various units @@ -423,6 +428,7 @@ def get_INT_RTC(state): logger_qt.info(dt2) logger_aht.info(dt2) def setup(state): TAG = "setup(): " @@ -433,6 +439,7 @@ def setup(state): gc.collect() def main(): TAG= "main(): " loopnr = 0 -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -232,14 +232,11 @@ def pr_btn_name(res): # Check for button presses on the Gamepad QT def ck_qt_btns(state): if not state.qt_btns_present: return TAG = "ck_qt_btns(): " nr_btns = 6 res_x = res_y = res_a = res_b = res_sel = res_sta = -1 elapsed_t = None -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -167,9 +167,11 @@ def __init__(self, saved_state_json=None): state.aht20_present = False raise del i2c_bus s = "Gamepad QT is {} present".format("" if state.qt_btns_present else " not") logger_qt.info(s) s = "AHT20 sensor is {} present".format("" if state.aht20_present else " not") logger_aht.info(s) del s -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 17 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -174,12 +174,25 @@ def __init__(self, saved_state_json=None): del s def test_msg(state): global msg1_shown TAG = "gamepad_test(): " s1 = s2 = "" if state.qt_btns_present: s1 = "the Gamepad QT" if state.aht20_present: s2 = ", the AHT20 sensor" if not state.msg1_shown: if state.qt_btns_present or state.aht20_present: state.msg1_shown = True print(TAG+f"We\'re going to test {s1}{s2} with this {state.board_id}.") if state.qt_btns_present: print("\t\tPress any of the buttons (X, Y, A, B, Select or Start) on the Gamepad QT.\n\t\t" + \ f"To reboot {state.board_id} press Gamepad QT button Start.\n") else: print(TAG+"none of {}{} present. Check wiring. Exiting...") _time.sleep(3) sys.exit() def ck_usr_answr(): ret = False -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 26 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,9 @@ def __init__(self, saved_state_json=None): self.board_id = None self.USE_TAG = None self.my_debug = False self.msg1_shown = False self.last_x = 0 self.last_y = 0 self.qt_btns_present = False self.aht20_present = False self.LOG_QT = None @@ -120,13 +123,7 @@ def __init__(self, saved_state_json=None): s= "using Adafruit_Python_extended_Bus. Using I2C bus #3" # github.com/adafruit/Adafruit_Python_extended_Bus logger_qt.info(s) logger_aht.info(s) del s BUTTON_X = const(6) BUTTON_Y = const(2) @@ -170,16 +167,16 @@ def __init__(self, saved_state_json=None): state.aht20_present = False raise s = "Gamepad QT is {} present".format(" not" if not state.qt_btns_present else "") logger_qt.info(s) s = "AHT20 sensor is {} present".format(" not" if not state.aht20_present else "") logger_aht.info(s) del s def test_msg(state): TAG = "gamepad_test(): " if not state.msg1_shown: state.msg1_shown = True print(TAG+f"We\'re going to test the Gamepad QT and the {state.board_id}.") print("\t\tor press any of the buttons (X, Y, A, B, Select or Start) on the Gamepad QT.\n\t\t" + \ f"To reboot {state.board_id} press Gamepad QT button Start.\n") @@ -220,7 +217,7 @@ def pr_btn_name(res): # Check for button presses on the Gamepad QT def ck_qt_btns(state): global led_state if not state.qt_btns_present: return @@ -245,24 +242,24 @@ def ck_qt_btns(state): if e.errno == 121: # Remote I/O Error logger_qt.error(f"Error: {e}") pass if x >= state.last_x: diff_x = abs(x - state.last_x) else: diff_x = abs(state.last_x - x) if y >= state.last_y: diff_y = abs(y - state.last_y) else: diff_y = abs(state.last_y - y) if (diff_x > 3) or (diff_y > 3): # blink_led(state) s = f"joystick: (x, y)= ({x}, {y})" print(s) logger_qt.info(s) # print(TAG+f"diff_x= {diff_x}, diff_y= {diff_y}") state.last_x = x state.last_y = y # Get the button presses, if any... buttons = seesaw.digital_read_bulk(button_mask) @@ -332,7 +329,7 @@ def ck_qt_btns(state): #reboot() # Reboot the board os.system("sudo reboot") else: state.msg1_shown = False res_sta = -2 test_msg(state) break @@ -379,7 +376,6 @@ def temphum(state): def get_INT_RTC(state): if not state.get_INT_RTC: return @@ -389,22 +385,20 @@ def get_INT_RTC(state): try: now = datetime.now() state.RTCtpl = now.timetuple() except OSError as e: logger_qt.error(TAG+f"Error: {e}") raise except Exception as e: raise if state.RTCtpl is not None: if state.my_debug: logger_aht.info(f"type(state.RTCtpl) = {type(state.RTCtpl)}") if state.my_debug: logger_qt.info(TAG+f"state.RTCtpl: {state.RTCtpl}") logger_aht.info(TAG+f"state.RTCtpl: {state.RTCtpl}") state.SYS_RTC_is_set = True dt = state.RTCtpl -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -105,6 +105,14 @@ def __init__(self, saved_state_json=None): logger_aht.addHandler(logging.NullHandler()) # Don't log #logger_aht.addHandler(console) del logfile_qt del logfile_aht del logging_level del format del formatter del file_handler_qt del file_handler_aht state.board_id = board.board_id logger_qt.info(f"board id: {state.board_id}") logger_aht.info(f"board id: {state.board_id}") -
PaulskPt revised this gist
Apr 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def __init__(self, saved_state_json=None): self.humidity_old = None self.get_INT_RTC = True self.SYS_RTC_is_set = False self.RTCtpl = None self.RTCtpl_DOW = DOW = \ { 0: "Monday",
NewerOlder