tubid now ok
This commit is contained in:
parent
eda8510721
commit
45d4f7e090
@ -199,6 +199,7 @@ class PHControllerGUI(QMainWindow):
|
|||||||
self.volume_spin.setEnabled(enabled)
|
self.volume_spin.setEnabled(enabled)
|
||||||
|
|
||||||
def send_command(self, command):
|
def send_command(self, command):
|
||||||
|
print(command)
|
||||||
if self.serial_connection and self.serial_connection.is_open:
|
if self.serial_connection and self.serial_connection.is_open:
|
||||||
try:
|
try:
|
||||||
self.serial_connection.write(command.encode('utf-8'))
|
self.serial_connection.write(command.encode('utf-8'))
|
||||||
@ -235,8 +236,8 @@ class PHControllerGUI(QMainWindow):
|
|||||||
if not self.updating_tube_combo:
|
if not self.updating_tube_combo:
|
||||||
# Simple approach: send <1XX> where XX is 20+index
|
# Simple approach: send <1XX> where XX is 20+index
|
||||||
# This should trigger the default case in Arduino
|
# This should trigger the default case in Arduino
|
||||||
command_number = 120 + index # 120-145 for tubes 0-25
|
# command_number = 120 + index # 120-145 for tubes 0-25
|
||||||
self.send_command(f"<{command_number}>")
|
self.send_command(f"<17{index}>")
|
||||||
self.status_bar.showMessage(f"Schlauchgröße {self.tube_combo.itemText(index)} ausgewählt")
|
self.status_bar.showMessage(f"Schlauchgröße {self.tube_combo.itemText(index)} ausgewählt")
|
||||||
|
|
||||||
def send_calibration_command(self, ph):
|
def send_calibration_command(self, ph):
|
||||||
|
|||||||
@ -300,33 +300,28 @@ if ( RxCmd[1] == '1' ){
|
|||||||
Serial.println("<CAL7>"); // Bestätigung
|
Serial.println("<CAL7>"); // Bestätigung
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
case '7':{
|
||||||
// Handle tube selection commands (120-145 for tubes 0-25)
|
int a = RxCmd[3]-'0';
|
||||||
// Parse the complete command number
|
Serial.println(a);
|
||||||
if (RxCmd[2] >= '0' && RxCmd[2] <= '9' && RxCmd[3] >= '0' && RxCmd[3] <= '9') {
|
int b = RxCmd[4] -'3';
|
||||||
// Two digit case: parse the full number
|
Serial.println(b);
|
||||||
int tens = RxCmd[1] - '0'; // First digit after '<'
|
// int c = RxCmd[5]-'0';
|
||||||
int hundreds = RxCmd[2] - '0'; // Second digit
|
//Serial.println(c);
|
||||||
int ones = RxCmd[3] - '0'; // Third digit
|
if (b>9){ // only one diget
|
||||||
|
tubid = a;
|
||||||
int command_number = tens * 100 + hundreds * 10 + ones;
|
} else {
|
||||||
|
tubid = a* 10 + b;
|
||||||
// Check if it's a tube command (120-145)
|
}
|
||||||
if (command_number >= 120 && command_number <= 145) {
|
if (tubid >= 0 && tubid <= MAXTUB) {
|
||||||
tubid = command_number - 120; // Convert to 0-25 range
|
|
||||||
|
|
||||||
// Validate and save tube ID
|
|
||||||
if (tubid >= 0 && tubid <= MAXTUB) {
|
|
||||||
EEPROM.put(ee_tubid, tubid);
|
EEPROM.put(ee_tubid, tubid);
|
||||||
Serial.print("<T");
|
Serial.print("<T");
|
||||||
Serial.print(tubid);
|
Serial.print(tubid);
|
||||||
Serial.println(">"); // Bestätigung
|
Serial.println(">"); // Bestätigung
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user