mirror of
https://github.com/infinition/Bjorn.git
synced 2026-03-17 01:21:04 +00:00
Add RLUtils class for managing RL/AI dashboard endpoints
- Implemented methods for fetching AI stats, training history, and recent experiences. - Added functionality to set operation mode (MANUAL, AUTO, AI) with appropriate handling. - Included helper methods for querying the database and sending JSON responses. - Integrated model metadata extraction for visualization purposes.
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
import logging
|
||||
import time
|
||||
from . import epdconfig
|
||||
from logger import Logger
|
||||
|
||||
# Display resolution
|
||||
EPD_WIDTH = 122
|
||||
EPD_HEIGHT = 250
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = Logger(name="epd2in13_V3.py", level=logging.DEBUG)
|
||||
|
||||
class EPD:
|
||||
def __init__(self):
|
||||
self.is_initialized = False # New flag to track if the display has been initialized #INFINITION
|
||||
# Defensive timeout/logging for BUSY pin stalls.
|
||||
self.busy_timeout_s = 30.0
|
||||
self.busy_poll_ms = 10
|
||||
self.busy_log_interval_s = 5.0
|
||||
# Keep this False in production to avoid log spam on normal refresh cycles.
|
||||
self.log_busy_transitions = False
|
||||
self.reset_pin = epdconfig.RST_PIN
|
||||
self.dc_pin = epdconfig.DC_PIN
|
||||
self.busy_pin = epdconfig.BUSY_PIN
|
||||
@@ -107,10 +115,26 @@ class EPD:
|
||||
parameter:
|
||||
'''
|
||||
def ReadBusy(self):
|
||||
logger.debug("e-Paper busy")
|
||||
if self.log_busy_transitions:
|
||||
logger.debug("e-Paper busy")
|
||||
started = time.monotonic()
|
||||
last_log = started
|
||||
while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy
|
||||
epdconfig.delay_ms(10)
|
||||
logger.debug("e-Paper busy release")
|
||||
now = time.monotonic()
|
||||
waited = now - started
|
||||
if waited >= self.busy_timeout_s:
|
||||
raise TimeoutError(
|
||||
f"EPD busy timeout after {self.busy_timeout_s:.1f}s "
|
||||
f"(pin={self.busy_pin}, state=1, expected idle=0)"
|
||||
)
|
||||
if (now - last_log) >= self.busy_log_interval_s:
|
||||
logger.warning(
|
||||
f"ReadBusy waiting {waited:.1f}s (pin={self.busy_pin}, state=1/busy)"
|
||||
)
|
||||
last_log = now
|
||||
epdconfig.delay_ms(self.busy_poll_ms)
|
||||
if self.log_busy_transitions:
|
||||
logger.debug("e-Paper busy release")
|
||||
|
||||
'''
|
||||
function : Turn On Display
|
||||
@@ -370,4 +394,3 @@ class EPD:
|
||||
epdconfig.module_exit()
|
||||
|
||||
### END OF FILE ###
|
||||
|
||||
|
||||
Reference in New Issue
Block a user