Skip to content

Commit

Permalink
Optimise loop time and track command time
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Dec 30, 2023
1 parent 4cb7c6c commit e22ef54
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sensor/src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ HABinarySensor heater("heater");
HASwitch light("light");
HASensorNumber tubpower("tubpower", HANumber::PrecisionP1);
HASensorNumber commandQueueSize("commandQueueSize", HANumber::PrecisionP0);
HASensorNumber timeSinceMsgStartSensor("timeSinceMsgStart", HANumber::PrecisionP0);

HAButton btnUp("up");
HAButton btnDown("down");
Expand Down Expand Up @@ -501,6 +502,7 @@ void setup() {
rawData3.setName("post temp: ");
fbData.setName("FB");
commandQueueSize.setName("Command Queue");
timeSinceMsgStartSensor.setName("Command Time");

tubMode.setName("Mode");
tubMode.setOptions("Standard;Economy;Sleep");
Expand Down Expand Up @@ -588,7 +590,7 @@ int waitforGLBytes() {
}
void readSerial(bool panelSelect) {
// is data available and we are selected
if ((tub.available() > 0) && (panelSelect == LOW)) {
if ((panelSelect == LOW) && (tub.available() > 0)) {
int msgLength = waitforGLBytes();
// only do something if we've got a message
if (msgLength > 0) {
Expand Down Expand Up @@ -814,6 +816,7 @@ void handleMessage(size_t len, uint8_t buf[]) {
commandPending = false;
sendBuffer.dequeue();
Serial.printf("YAY: command response : %u\n", timeSinceMsgStart);
timeSinceMsgStartSensor.setValue((int) timeSinceMsgStart);
}
}

Expand Down

0 comments on commit e22ef54

Please sign in to comment.