Fixed some small issues with some programs still using the old configuration way

This commit is contained in:
BlueFox 2024-11-15 18:38:33 +01:00
parent f48315f18e
commit 78933f6090
Signed by: BlueFox
GPG Key ID: 327233DA85435270
3 changed files with 21 additions and 28 deletions

View File

@ -14,26 +14,13 @@ You should have received a copy of the GNU General Public License along with thi
@ Feature: Fades "HELLO" over two lines in and out
"""
import machine
import time
import config
lcd = config.LCD
lcd.custom_char(0, bytearray([0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03])) # right
lcd.custom_char(1, bytearray([0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18])) # left
lcd.custom_char(2, bytearray([0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F])) # 2-down
lcd.custom_char(3, bytearray([0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00])) # 2-up
lcd.custom_char(4, bytearray([0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x1F])) # e-up
lcd.custom_char(5, bytearray([0x1F,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F])) # e-down
lcd.custom_char(6, bytearray([0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x1F])) # l-down
lcd.custom_char(7, bytearray([0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18])) # l-right
line1 = str(chr(0) + chr(2) + chr(1) + chr(0) + chr(4) + " " + chr(1) + " " + chr(1) + " " + chr(0) + chr(3) + chr(1))
line2 = str(chr(0) + chr(3) + chr(1) + chr(0) + chr(5) + " " + chr(6) + chr(7) + chr(6) + chr(7) + chr(0) + chr(2) + chr(1))
def right2left(line1, line2, speed=0.3):
def right2left(lcd, line1, line2, speed=0.3):
padding = " " # 16 spaces
line2 = padding + line2 + padding
line1 = padding + line1 + padding
@ -44,7 +31,7 @@ def right2left(line1, line2, speed=0.3):
time.sleep(speed)
def top2bottom(line1, line2, speed=0.2):
def top2bottom(lcd, line1, line2, speed=0.2):
lcd.clear()
time.sleep(speed)
lcd.putstr(line2)
@ -61,7 +48,7 @@ def top2bottom(line1, line2, speed=0.2):
lcd.clear()
time.sleep(speed)
def showAll(waitAfter=0.5):
def showAll(lcd, waitAfter=0.5):
lcd.clear()
lcd.putstr(line1)
lcd.move_to(0,1)
@ -69,11 +56,21 @@ def showAll(waitAfter=0.5):
time.sleep(waitAfter)
def run(): # for the ProgramChooser as callback
right2left(line1, line2, 0.2)
top2bottom(line1, line2, 0.2)
showAll()
def run(lcd): # for the ProgramChooser as callback
lcd.custom_char(0, bytearray([0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03])) # right
lcd.custom_char(1, bytearray([0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18])) # left
lcd.custom_char(2, bytearray([0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F])) # 2-down
lcd.custom_char(3, bytearray([0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00])) # 2-up
lcd.custom_char(4, bytearray([0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x1F])) # e-up
lcd.custom_char(5, bytearray([0x1F,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F])) # e-down
lcd.custom_char(6, bytearray([0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x1F])) # l-down
lcd.custom_char(7, bytearray([0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18])) # l-right
right2left(lcd, line1, line2, 0.2)
top2bottom(lcd, line1, line2, 0.2)
showAll(lcd)
if __name__ == "__main__":
run() # run once
from utils import Config
cfg = Config()
run(cfg.LCD) # run once

View File

@ -30,7 +30,7 @@ def manual():
set_value = config.PIN_OUT_RELAIS.value()
config.LCD.putstr(f"---- MANUAL ---- State: {set_value} ")
if config.PIN_IN_BTN_1.value() == 1 or config.PIN_IN_BTN_2.value() == 1:
return True # exit on press of these buttons
return True # exit on press of these buttons; True to disable the Quitting message from lcdMenu
def timer():
# display WIP
config.LCD.clear()
@ -51,7 +51,7 @@ def uv_off():
return True # disable the "Quitting" message from lcdMenu
def lcd_big_hello():
import lcd_big_hello as lbh
lbh.run()
lbh.run(config.LCD)
del lbh
collect()
return True

View File

@ -117,8 +117,6 @@ class Config:
def __delattr__(self, name):
raise AttributeError(f"You may not delete any attribute of the '{self.__class__.__name__}' object")
cfg = Config()
"""
Very simple logging function
@ -133,5 +131,3 @@ def log(log_level: int, message: str):
elif cfg.LOG_LEVEL >= log_level: # if log level is valid
print(f"[{log_mapping[log_level]}] {message}")