From 1ac6c895df4d1d7dd7345f380ad052058efcb356 Mon Sep 17 00:00:00 2001 From: Arghya Biswas Date: Fri, 11 Jul 2025 13:57:29 +0530 Subject: [PATCH] trying to fix lcd restart issue Signed-off-by: Arghya Biswas --- Script/common.py | 12 +++++------ Script/main.py | 2 +- Script/rpigpio.py | 2 +- Script/utility.py | 53 +++++++++++++++++++++++++++++------------------ config.yaml | 2 +- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Script/common.py b/Script/common.py index 4d81b8f..14b02da 100644 --- a/Script/common.py +++ b/Script/common.py @@ -6,14 +6,14 @@ CONFIG_YAML_FILE = os.path.join(BASE_PATH, "config.yaml") RT_DB_FILE = os.path.join(BASE_PATH, "rtDb.json") -INPUT = 0 -OUTPUT = 1 +INPUT = False +OUTPUT = True -PULL_UP = 0 -PULL_DOWN = 1 +PULL_UP = False +PULL_DOWN = True -HIGH = 1 -LOW = 0 +HIGH = True +LOW = False LCD_MODULE_NO_OF_ROW = 4 LCD_MODULE_NO_OF_COLUMN = 20 diff --git a/Script/main.py b/Script/main.py index 530df13..1dd24d3 100644 --- a/Script/main.py +++ b/Script/main.py @@ -88,7 +88,7 @@ def printCountValue(row: int, currentCount: int, totalCount: int): # Turn on only the position LED -def showPositionLED(position: int): +def showPositionLED(position: int|None): if position == POSITION_LEFT: gpio.digitalWrite(POSITION_RIGHT_LED_PIN, LOW) gpio.digitalWrite(POSITION_MIDDLE_LED_PIN, LOW) diff --git a/Script/rpigpio.py b/Script/rpigpio.py index ef07da1..9753d0b 100644 --- a/Script/rpigpio.py +++ b/Script/rpigpio.py @@ -15,7 +15,7 @@ def deinit(self): GPIO.cleanup() - def pinMode(self, pin: int, state: bool, pullUpDown: bool = None): + def pinMode(self, pin: int, state: bool, pullUpDown: bool|None = None): _state = None _pullUpDown = None diff --git a/Script/utility.py b/Script/utility.py index 1530187..7ae7e2a 100644 --- a/Script/utility.py +++ b/Script/utility.py @@ -27,7 +27,10 @@ def setYamlData(yamlFile, data): def getAppVersion(): configData = getYamlData(CONFIG_YAML_FILE) - return configData.get("appVersion") + if configData: + return configData.get("appVersion") + else: + return "0.0.0.0000" def createRtDbFile(): @@ -41,42 +44,52 @@ def createRtDbFile(): def getCycleCount(): rtData = getYamlData(RT_DB_FILE) - cycleCount = rtData.get("cycleCount") - if cycleCount == None: - cycleCount = 0 + if rtData: + cycleCount = rtData.get("cycleCount") + if cycleCount == None: + cycleCount = 0 - return int(cycleCount) + return int(cycleCount) + else: + return 0 def getTotalCount(): rtData = getYamlData(RT_DB_FILE) - totalCount = rtData.get("maxCount") - if totalCount == None: - configData = getYamlData(CONFIG_YAML_FILE) - totalCount = configData.get("maxCount") + if rtData: + totalCount = rtData.get("maxCount") + if totalCount == None: + configData = getYamlData(CONFIG_YAML_FILE) + if configData: + totalCount = configData.get("maxCount") - if totalCount == None: - totalCount = 0 + if totalCount == None: + totalCount = 0 - return int(totalCount) + return int(totalCount) + return 0 def setCycleCount(count: int): rtData = getYamlData(RT_DB_FILE) - rtData["cycleCount"] = count - setYamlData(RT_DB_FILE, rtData) + if rtData: + rtData["cycleCount"] = count + setYamlData(RT_DB_FILE, rtData) def getConfigUpdateStatus(): rtData = getYamlData(RT_DB_FILE) - updateNeeded = rtData.get("updateNeeded") - if updateNeeded == None: - updateNeeded = NO_CONFIG_UPDATE + if rtData: + updateNeeded = rtData.get("updateNeeded") + if updateNeeded == None: + updateNeeded = NO_CONFIG_UPDATE - return int(updateNeeded) + return int(updateNeeded) + return 0 def setConfigUpdateStatus(status): rtData = getYamlData(RT_DB_FILE) - rtData["updateNeeded"] = status - setYamlData(RT_DB_FILE, rtData) + if rtData: + rtData["updateNeeded"] = status + setYamlData(RT_DB_FILE, rtData) diff --git a/config.yaml b/config.yaml index 995da8f..7884fbf 100644 --- a/config.yaml +++ b/config.yaml @@ -1,2 +1,2 @@ -appVersion: 1.7.1.1011 +appVersion: 1.7.2.1012 maxCount : 7500000