Fixed small bugs, and added fundamental settings
This commit is contained in:
parent
78933f6090
commit
9d395bd2b8
@ -14,5 +14,5 @@
|
||||
"LCD_I2C_CH": 0,
|
||||
"LCD_I2C_ADDR": 39,
|
||||
"LCD_I2C_NUM_ROWS": 2,
|
||||
"LCD_I2C_NUM_COLS": 16,
|
||||
"LCD_I2C_NUM_COLS": 16
|
||||
}
|
60
main.py
60
main.py
@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with thi
|
||||
import utils
|
||||
from lcdMenu import lcdMenu
|
||||
from WelcomeScreen import WelcomeScreen
|
||||
from time import sleep
|
||||
from time import sleep, time_ns
|
||||
from gc import collect # garbage collector for better memory performance
|
||||
|
||||
config = utils.Config()
|
||||
@ -38,13 +38,13 @@ def timer():
|
||||
sleep(3)
|
||||
return True # disable the "Quitting" message from lcdMenu
|
||||
def uv_on():
|
||||
config.RELAIS.value(1)
|
||||
config.PIN_OUT_RELAIS.value(1)
|
||||
config.LCD.clear()
|
||||
config.LCD.putstr("------ UV ------ turned on ")
|
||||
sleep(1)
|
||||
return True # disable the "Quitting" message from lcdMenu
|
||||
def uv_off():
|
||||
config.RELAIS.value(0)
|
||||
config.PIN_OUT_RELAIS.value(0)
|
||||
config.LCD.clear()
|
||||
config.LCD.putstr("------ UV ------ turned off ")
|
||||
sleep(1)
|
||||
@ -61,10 +61,56 @@ def input_tests():
|
||||
collect()
|
||||
return True
|
||||
def settings():
|
||||
# display WIP
|
||||
config.LCD.clear()
|
||||
config.LCD.putstr(" Still work-in-progress")
|
||||
sleep(3)
|
||||
settings_menu = lcdMenu(config.LCD, btn_mapping, scroll_direction=True, cycle=True, hide_menu_name=False, name="SETTINGS")
|
||||
def swap_welcome():
|
||||
config.STARTUP_WELCOME_SHOW = not config.STARTUP_WELCOME_SHOW
|
||||
config.LCD.clear()
|
||||
config.LCD.putstr(f" Welcome Screen ")
|
||||
if config.STARTUP_WELCOME_SHOW:
|
||||
config.LCD.putstr("--- Enabled! ---")
|
||||
else:
|
||||
config.LCD.putstr("--- Disabled ---")
|
||||
sleep(1)
|
||||
def welcome_cycles():
|
||||
config.LCD.clear()
|
||||
current_cycles = config.STARTUP_WELCOME_CYCLES
|
||||
|
||||
option_down = [" ", "v"][current_cycles>1]
|
||||
config.LCD.putstr(f" Cycles \n{option_down} {str(current_cycles).center(12)} ^")
|
||||
while True:
|
||||
if config.PIN_IN_BTN_1.value() == 1:
|
||||
time_ns_when_pressed = time_ns()
|
||||
while config.PIN_IN_BTN_1.value() == 1:
|
||||
if (time_ns() - time_ns_when_pressed) > 1000000000: # if the time passed is longer than a second
|
||||
while config.PIN_IN_BTN_1.value() == 1:
|
||||
pass # wait till release
|
||||
config.STARTUP_WELCOME_CYCLES = current_cycles
|
||||
return True
|
||||
sleep(0.05)
|
||||
current_cycles -= 1
|
||||
if current_cycles < 1: current_cycles = 1
|
||||
option_down = [" ", "v"][current_cycles>1]
|
||||
config.LCD.putstr(f" Cycles \n{option_down} {str(current_cycles).center(12)} ^")
|
||||
if config.PIN_IN_BTN_2.value() == 1:
|
||||
time_ns_when_pressed = time_ns()
|
||||
while config.PIN_IN_BTN_2.value() == 1:
|
||||
if (time_ns() - time_ns_when_pressed) > 1000000000: # if the time passed is longer than a second
|
||||
while config.PIN_IN_BTN_2.value() == 1:
|
||||
pass # wait till release
|
||||
config.STARTUP_WELCOME_CYCLES = current_cycles
|
||||
return True
|
||||
sleep(0.05)
|
||||
current_cycles += 1
|
||||
option_down = [" ", "v"][current_cycles>1]
|
||||
config.LCD.putstr(f" Cycles \n{option_down} {str(current_cycles).center(12)} ^")
|
||||
|
||||
settings_programs = [("Show welcome", swap_welcome),
|
||||
("Welcome cycles", welcome_cycles),
|
||||
("Exit", settings_menu.stop)]
|
||||
settings_menu.setup(settings_programs) # give it the callback list
|
||||
settings_menu.run() # run the menu until it's closed
|
||||
del settings_menu, settings_programs
|
||||
collect()
|
||||
return True
|
||||
def run_demo_menu():
|
||||
demo_menu = lcdMenu(config.LCD, btn_mapping, scroll_direction=True, cycle=True, hide_menu_name=False, name="DEMOS")
|
||||
|
Loading…
Reference in New Issue
Block a user