additional sleep logic removed

This commit is contained in:
Martin Brodbeck 2022-06-02 09:56:45 +02:00
parent 7f6873284c
commit 80fb3c8cb5

View file

@ -31,10 +31,11 @@ absolute_time_t lastPressed = get_absolute_time();
using std::string; using std::string;
void buttonPressedCallback(uint gpio, uint32_t events) { void buttonPressedCallback(uint gpio, uint32_t events) {
if (absolute_time_diff_us(lastPressed, get_absolute_time()) < 750000) { absolute_time_t now = get_absolute_time();
if (absolute_time_diff_us(lastPressed, now) < 750000) {
return; return;
} else { } else {
lastPressed = get_absolute_time(); lastPressed = now;
} }
switch (gpio) { switch (gpio) {
@ -88,7 +89,6 @@ int main() {
sleep_ms(3000); sleep_ms(3000);
while (true) { while (true) {
absolute_time_t start = get_absolute_time();
oneWire.convert_temperature(address, true, false); oneWire.convert_temperature(address, true, false);
temp_act = oneWire.temperature(address); temp_act = oneWire.temperature(address);
@ -99,6 +99,7 @@ int main() {
} else if (!isSystemOn) { } else if (!isSystemOn) {
isHeating = false; isHeating = false;
} }
isHeating ? heatInfo = ">H<" : heatInfo = " "; isHeating ? heatInfo = ">H<" : heatInfo = " ";
isSystemOn ? systemInfo = "ON " : systemInfo = "OFF"; isSystemOn ? systemInfo = "ON " : systemInfo = "OFF";
@ -113,13 +114,5 @@ int main() {
myLCD.setCursor(0, 0); myLCD.setCursor(0, 0);
myLCD.sendString(lcdText.str()); myLCD.sendString(lcdText.str());
absolute_time_t stop = get_absolute_time();
int64_t duration_ms = absolute_time_diff_us(start, stop) / 1000;
int64_t timeToSleep = 1000 - duration_ms;
if (timeToSleep > 0)
sleep_ms(timeToSleep);
} }
} }