From fddb04eab52f397fe4fd358605b6d3864ae9d591 Mon Sep 17 00:00:00 2001 From: bray Date: Wed, 27 May 2020 00:06:40 +0200 Subject: [PATCH] threshold sans exceptions --- sketch_ino.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/sketch_ino.cpp b/sketch_ino.cpp index 2e69b3d..f4d9f2f 100644 --- a/sketch_ino.cpp +++ b/sketch_ino.cpp @@ -200,6 +200,78 @@ void Board::loop() { } } } + }else if (menu->getId() == 7){ + Keyboard::saisie = true ; + sleep(4); + if ( (&bus!=NULL)&&!(bus.isEmptyRegister(2))) { + bus.requestFrom(2, inputBuf, 150); + if (inputBuf[0] != '\0') { + input = ""; + for (int j = 0; inputBuf[j] != '\0'; ++j) { + input += inputBuf[j]; + } //TODO vérifier que chiffres + if (stoi(input) >= temperature->getThresholdLow()){ + temperature->setThresholdHigh(stoi(input)); + menu->menuBack(); + } else { + cout << "booooo" << endl; + } + } + } + }else if (menu->getId() == 8){ + Keyboard::saisie = true ; + sleep(4); + if ( (&bus!=NULL)&&!(bus.isEmptyRegister(2))) { + bus.requestFrom(2, inputBuf, 150); + if (inputBuf[0] != '\0') { + input = ""; + for (int j = 0; inputBuf[j] != '\0'; ++j) { + input += inputBuf[j]; + } + if (stoi(input) <= temperature->getThresholdHigh()){ + temperature->setThresholdLow(stoi(input)); + menu->menuBack(); + } else { + cout << "booooo" << endl; + } + } + } + }else if (menu->getId() == 9){ + Keyboard::saisie = true ; + sleep(4); + if ( (&bus!=NULL)&&!(bus.isEmptyRegister(2))) { + bus.requestFrom(2, inputBuf, 150); + if (inputBuf[0] != '\0') { + input = ""; + for (int j = 0; inputBuf[j] != '\0'; ++j) { + input += inputBuf[j]; + } + if (stoi(input) >= pressure->getThresholdLow()){ + pressure->setThresholdHigh(stoi(input)); + menu->menuBack(); + } else { + cout << "booooo" << endl; + } + } + } + }else if (menu->getId() == 10){ + Keyboard::saisie = true ; + sleep(4); + if ( (&bus!=NULL)&&!(bus.isEmptyRegister(2))) { + bus.requestFrom(2, inputBuf, 150); + if (inputBuf[0] != '\0') { + input = ""; + for (int j = 0; inputBuf[j] != '\0'; ++j) { + input += inputBuf[j]; + } + if (stoi(input) <= pressure->getThresholdHigh()){ + pressure->setThresholdLow(stoi(input)); + menu->menuBack(); + } else { + cout << "booooo" << endl; + } + } + } } cpt++;