From 45d4f7e0900072a51e243cd332a5195be9abece6 Mon Sep 17 00:00:00 2001 From: jens Date: Wed, 9 Jul 2025 22:41:40 +0200 Subject: [PATCH] tubid now ok --- gui/main.py | 5 +++-- ph_controller/ph_controller.ino | 33 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/gui/main.py b/gui/main.py index 745c1d2..f7bfbf3 100644 --- a/gui/main.py +++ b/gui/main.py @@ -199,6 +199,7 @@ class PHControllerGUI(QMainWindow): self.volume_spin.setEnabled(enabled) def send_command(self, command): + print(command) if self.serial_connection and self.serial_connection.is_open: try: self.serial_connection.write(command.encode('utf-8')) @@ -235,8 +236,8 @@ class PHControllerGUI(QMainWindow): if not self.updating_tube_combo: # Simple approach: send <1XX> where XX is 20+index # This should trigger the default case in Arduino - command_number = 120 + index # 120-145 for tubes 0-25 - self.send_command(f"<{command_number}>") + # command_number = 120 + index # 120-145 for tubes 0-25 + self.send_command(f"<17{index}>") self.status_bar.showMessage(f"Schlauchgröße {self.tube_combo.itemText(index)} ausgewählt") def send_calibration_command(self, ph): diff --git a/ph_controller/ph_controller.ino b/ph_controller/ph_controller.ino index 254f646..da6e0c7 100644 --- a/ph_controller/ph_controller.ino +++ b/ph_controller/ph_controller.ino @@ -300,33 +300,28 @@ if ( RxCmd[1] == '1' ){ Serial.println(""); // Bestätigung break; } - default: { - // Handle tube selection commands (120-145 for tubes 0-25) - // Parse the complete command number - if (RxCmd[2] >= '0' && RxCmd[2] <= '9' && RxCmd[3] >= '0' && RxCmd[3] <= '9') { - // Two digit case: parse the full number - int tens = RxCmd[1] - '0'; // First digit after '<' - int hundreds = RxCmd[2] - '0'; // Second digit - int ones = RxCmd[3] - '0'; // Third digit - - int command_number = tens * 100 + hundreds * 10 + ones; - - // Check if it's a tube command (120-145) - if (command_number >= 120 && command_number <= 145) { - tubid = command_number - 120; // Convert to 0-25 range - - // Validate and save tube ID - if (tubid >= 0 && tubid <= MAXTUB) { + case '7':{ + int a = RxCmd[3]-'0'; + Serial.println(a); + int b = RxCmd[4] -'3'; + Serial.println(b); + // int c = RxCmd[5]-'0'; + //Serial.println(c); + if (b>9){ // only one diget + tubid = a; + } else { + tubid = a* 10 + b; + } + if (tubid >= 0 && tubid <= MAXTUB) { EEPROM.put(ee_tubid, tubid); Serial.print(""); // Bestätigung } - } - } break; } + } }