diff --git a/scripts/displaymenu.py b/scripts/displaymenu.py index 2bbfe483..3f2209ab 100644 --- a/scripts/displaymenu.py +++ b/scripts/displaymenu.py @@ -29,6 +29,7 @@ import lib_language import lib_network import lib_storage +import lib_system class menu(object): @@ -41,6 +42,8 @@ def __init__(self,DISPLAY_LINES,setup): self.WORKING_DIR = os.path.dirname(__file__) + self.board_model_number = lib_system.get_pi_model(number_only=True) + self.const_MEDIA_DIR = self.__setup.get_val('const_MEDIA_DIR') self.conf_DISP_FRAME_TIME = self.__setup.get_val('conf_DISP_FRAME_TIME') self.conf_RSYNC_SERVER = self.__setup.get_val('conf_RSYNC_SERVER') @@ -225,37 +228,40 @@ def __init__(self,DISPLAY_LINES,setup): self.GPIO_init() def GPIO_init(self): - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - - if self.conf_MENU_BUTTON_COMBINATION: - if self.conf_MENU_BUTTON_COMBINATION.isnumeric(): - ButtonsConfigFile = f"{self.WORKING_DIR}/{self.const_BUTTONS_CONFIG_FILE}" - ButtonCombinationNumber = int(self.conf_MENU_BUTTON_COMBINATION) - elif self.conf_MENU_BUTTON_COMBINATION[0:1] == 'c': - ButtonsConfigFile = f"{self.const_MEDIA_DIR}/{self.const_BUTTONS_PRIVATE_CONFIG_FILE}" - ButtonCombinationNumber = int(self.conf_MENU_BUTTON_COMBINATION[1:]) - - if os.path.isfile(ButtonsConfigFile): - ConfigLines = [] - with open(ButtonsConfigFile,'r') as f: - ConfigLines = f.readlines() - - ConfigLineNumber = 0 - for ConfigLine in ConfigLines: - ConfigLine = ConfigLine.strip() - if ConfigLine: - if ConfigLine[0:1] != '#': - ConfigLineNumber += 1 - if ConfigLineNumber == ButtonCombinationNumber: - ConfigLine = ConfigLine.split(':',1)[0] - ButtonDefs = ConfigLine.split(',') - for ButtonDef in ButtonDefs: - GPIO_PIN, ButtonFunction = ButtonDef.split('=') - GPIO_PIN = int(GPIO_PIN) - - self.GPIO_config_button(GPIO_PIN,ButtonFunction) - self.buttonevent_timestamp[GPIO_PIN] = 0 + if self.board_model_number == 5: + pass + else: + GPIO.setmode(GPIO.BCM) + GPIO.setwarnings(False) + + if self.conf_MENU_BUTTON_COMBINATION: + if self.conf_MENU_BUTTON_COMBINATION.isnumeric(): + ButtonsConfigFile = f"{self.WORKING_DIR}/{self.const_BUTTONS_CONFIG_FILE}" + ButtonCombinationNumber = int(self.conf_MENU_BUTTON_COMBINATION) + elif self.conf_MENU_BUTTON_COMBINATION[0:1] == 'c': + ButtonsConfigFile = f"{self.const_MEDIA_DIR}/{self.const_BUTTONS_PRIVATE_CONFIG_FILE}" + ButtonCombinationNumber = int(self.conf_MENU_BUTTON_COMBINATION[1:]) + + if os.path.isfile(ButtonsConfigFile): + ConfigLines = [] + with open(ButtonsConfigFile,'r') as f: + ConfigLines = f.readlines() + + ConfigLineNumber = 0 + for ConfigLine in ConfigLines: + ConfigLine = ConfigLine.strip() + if ConfigLine: + if ConfigLine[0:1] != '#': + ConfigLineNumber += 1 + if ConfigLineNumber == ButtonCombinationNumber: + ConfigLine = ConfigLine.split(':',1)[0] + ButtonDefs = ConfigLine.split(',') + for ButtonDef in ButtonDefs: + GPIO_PIN, ButtonFunction = ButtonDef.split('=') + GPIO_PIN = int(GPIO_PIN) + + self.GPIO_config_button(GPIO_PIN,ButtonFunction) + self.buttonevent_timestamp[GPIO_PIN] = 0 def GPIO_config_button(self,GPIO_PIN,ButtonFunction): GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = self.GPIO_MENU_BUTTON_RESISTOR_PULL) diff --git a/scripts/lang/de.json b/scripts/lang/de.json index 960239d3..f5478083 100644 --- a/scripts/lang/de.json +++ b/scripts/lang/de.json @@ -67,7 +67,9 @@ "camera_identifier": "Identifikation", "camera_model": "Kamera-Modell", "camera_serial": "Seriennummer", - "cameras": "Kameras/Smartphones" + "cameras": "Kameras/Smartphones", + "system": "System", + "model": "Modell" }, "config": { "config": "Einstellungen", diff --git a/scripts/lang/en.json b/scripts/lang/en.json index 8c2a8c54..c7118595 100644 --- a/scripts/lang/en.json +++ b/scripts/lang/en.json @@ -238,7 +238,9 @@ "camera_identifier": "identification", "camera_model": "Camera model", "camera_serial": "Serial number", - "cameras": "Cameras/smartphones" + "cameras": "Cameras/smartphones", + "system": "System", + "model": "Model" }, "sysconditions": { "under_voltage_cur": "The voltage is currently too low.", diff --git a/scripts/lang/es.json b/scripts/lang/es.json index 96a43f0f..0918e4ff 100644 --- a/scripts/lang/es.json +++ b/scripts/lang/es.json @@ -67,7 +67,9 @@ "camera_identifier": "Identificación", "camera_model": "Modelo de cámara", "camera_serial": "Número de serie", - "cameras": "Cámaras/teléfonos inteligentes" + "cameras": "Cámaras/teléfonos inteligentes", + "system": "Sistema", + "model": "Modelo" }, "config": { "config": "Ajustes", diff --git a/scripts/lang/fr.json b/scripts/lang/fr.json index 9fb7cdf0..5639386d 100644 --- a/scripts/lang/fr.json +++ b/scripts/lang/fr.json @@ -67,7 +67,9 @@ "camera_identifier": "Identifiant", "camera_model": "Modèle de caméra", "camera_serial": "Numéro de série", - "cameras": "Appareils photo/smartphones" + "cameras": "Appareils photo/smartphones", + "system": "Système", + "model": "Modèle" }, "config": { "config": "Réglages", diff --git a/scripts/lib_system.py b/scripts/lib_system.py index 84fa700f..81df4942 100644 --- a/scripts/lib_system.py +++ b/scripts/lib_system.py @@ -102,11 +102,49 @@ def get_abnormal_system_conditions(lan): return(Conditions) +def get_pi_model(number_only=False): + + model = '' + + try: + with open('/proc/device-tree/model') as f: + model = f.read() + except: + model = 'unknown' + + if number_only: + if model.startswith('Raspberry Pi Model B'): + model = 1 + + elif model.startswith('Raspberry Pi Zero'): + model = 0 + + elif model.startswith('Raspberry Pi 2'): + model = 2 + + elif model.startswith('Raspberry Pi 3'): + model = 3 + + elif model.startswith('Raspberry Pi 4'): + model = 4 + + elif model.startswith('Raspberry Pi 5'): + model = 5 + + else: + model = -1 + + return(model) + if __name__ == "__main__": if len(sys.argv)>1: if sys.argv[1] == 'get_uptime_sec': print(get_uptime_sec()) + if sys.argv[1] == 'get_abnormal_system_conditions': lan = lib_language.language() print(get_abnormal_system_conditions(lan)) + if sys.argv[1] == 'get_pi_model': + print(get_pi_model()) + diff --git a/scripts/sysinfo.php b/scripts/sysinfo.php index c8a283e7..e8979a5e 100644 --- a/scripts/sysinfo.php +++ b/scripts/sysinfo.php @@ -35,36 +35,44 @@

+

'; + + echo "" . L::sysinfo_model . ": " . $model . ""; if (isset($temp) && is_numeric($temp)) { - echo "

" . L::sysinfo_temp . ": " . $temp . "°C

"; + echo "" . L::sysinfo_temp . ": " . $temp . "°C"; } if (isset($cpuusage) && is_numeric($cpuusage)) { - echo "

" . L::sysinfo_cpuload . ": " . $cpuusage . "%

"; + echo "" . L::sysinfo_cpuload . ": " . $cpuusage . "%"; } - echo "

" . L::sysinfo_memory_ram . ": " . $mem_ram . "

"; + echo "" . L::sysinfo_memory_ram . ": " . $mem_ram . ""; - echo "

" . L::sysinfo_memory_swap . ": " . $mem_swap . "

"; + echo "" . L::sysinfo_memory_swap . ": " . $mem_swap . ""; - echo "

" . L::sysinfo_conditions . ": " . $abnormal_conditions . "

"; + echo "" . L::sysinfo_conditions . ": " . $abnormal_conditions . ""; + echo ''; ?>