| @@ -6,25 +6,25 @@ | |||
| */ | |||
| #include <ezButton.h> | |||
| #include "Loopable.h" | |||
| class ExEzButton: public ezButton { | |||
| class ExEzButton: public ezButton, public Loopable { | |||
| private: | |||
| bool inverted; | |||
| unsigned long longpressTime; | |||
| unsigned long pressedTime; | |||
| unsigned long releasedTime; | |||
| bool inverted; | |||
| unsigned long longpressTime; | |||
| unsigned long pressedTime; | |||
| unsigned long releasedTime; | |||
| public: | |||
| ExEzButton(int pin); | |||
| ExEzButton(int pin, bool _inverted); | |||
| ExEzButton(int pin, bool _inverted, int _longpressTime); | |||
| bool isPressing(void); | |||
| bool isPressed(); | |||
| bool isLongPressed(void); | |||
| void loop(void); | |||
| ExEzButton(int pin); | |||
| ExEzButton(int pin, bool _inverted); | |||
| ExEzButton(int pin, bool _inverted, int _longpressTime); | |||
| bool isPressing(void); | |||
| bool isPressed(); | |||
| bool isLongPressed(void); | |||
| void loop(void) override; | |||
| }; | |||
| //Added by Sloeber | |||
| #pragma once | |||
| //Added by Sloeber | |||
| #pragma once | |||
| @@ -83,7 +83,6 @@ int PreviousDATA; | |||
| int displaycounter = 0; // Store current counter value | |||
| volatile boolean TurnDetected; | |||
| void printStatus(String actualStatus) { | |||
| if (!oldStatus.equals(actualStatus)) { | |||
| Serial.println(actualStatus); | |||
| @@ -168,12 +167,9 @@ void setup() { | |||
| //*** MAIN LOOP ******** | |||
| //********************** | |||
| void loop() { | |||
| RedButton.loop(); // MUST call the loop() function first | |||
| GreenButton.loop(); | |||
| BlueButton.loop(); | |||
| WlsDetect.loop(); | |||
| Wls.loop(); | |||
| RotaryControler.loop(); | |||
| Display.setWlsConnected(WlsDetect.isConnected()); | |||
| Display.showFrame(actualStatus); | |||
| @@ -186,6 +182,8 @@ void loop() { | |||
| case TOOL_CHANGE: | |||
| printStatus("TOOL_CHANGE"); | |||
| BlueButton.loop(); | |||
| RotaryControler.loop(); | |||
| originStatus = TOOL_CHANGE; | |||
| if (intermediateState == 0) { | |||
| Router_Elevator.moveToUpperLimitSwitch(); | |||
| @@ -206,6 +204,8 @@ void loop() { | |||
| case CONFIGURATION: | |||
| printStatus("CONFIGURATION"); | |||
| BlueButton.loop(); | |||
| RotaryControler.loop(); | |||
| Router_Setup.initialize(); | |||
| Router_Setup.onRotaryControlerTurn(RotaryControler.getEncoderMove()); | |||
| if (RotaryControler.isSwitchPressed()) { | |||
| @@ -221,6 +221,7 @@ void loop() { | |||
| case NULLING: | |||
| printStatus("NULLING"); | |||
| RedButton.loop(); | |||
| if (RedButton.isPressed()) { | |||
| Router_Elevator.setZeroPosition(); | |||
| SetActualStatus(IDLE); | |||
| @@ -228,6 +229,7 @@ void loop() { | |||
| break; | |||
| case NULLING_TLS: | |||
| RedButton.loop(); | |||
| originStatus = NULLING_TLS; | |||
| if (intermediateState == 0) { | |||
| printStatus("NULLING_TLS,0"); | |||
| @@ -262,6 +264,10 @@ void loop() { | |||
| case IDLE: | |||
| printStatus("IDLE"); | |||
| RedButton.loop(); | |||
| GreenButton.loop(); | |||
| BlueButton.loop(); | |||
| RotaryControler.loop(); | |||
| originStatus = IDLE; | |||
| if (RotaryControler.isSwitchPressed()) { | |||
| Router_Elevator.toggleMode(); | |||
| @@ -285,10 +291,11 @@ void loop() { | |||
| case DIVING: | |||
| printStatus("DIVING"); | |||
| GreenButton.loop(); | |||
| originStatus = DIVING; | |||
| Router_Elevator.setMaxDiveDistance(); | |||
| if (GreenButton.isPressed()) { | |||
| Serial.println("GB && BB pressing"); | |||
| Serial.println("GB pressed"); | |||
| if (!Router_Elevator.maxDiveDistanceReached()) { | |||
| Router_Elevator.incrementDiveDistance(); | |||
| Router_Elevator.moveToTarget(); | |||
| @@ -0,0 +1,19 @@ | |||
| /* | |||
| * Looper.h | |||
| * | |||
| * Created on: 01.03.2022 | |||
| * Author: FSmilari | |||
| */ | |||
| #ifndef LOOPABLE_H_ | |||
| #define LOOPABLE_H_ | |||
| class Loopable { | |||
| public: | |||
| virtual void loop(void); | |||
| virtual ~Loopable() { | |||
| } | |||
| }; | |||
| #endif /* LOOPABLE_H_ */ | |||
| @@ -11,7 +11,7 @@ | |||
| #include "RotaryEncoder.h" | |||
| #include "ExEzButton.h" | |||
| class RotaryControler { | |||
| class RotaryControler: public Loopable { | |||
| private: | |||
| RotaryEncoder Encoder; | |||
| ExEzButton RotarySwitch; | |||
| @@ -27,7 +27,7 @@ class RotaryControler { | |||
| int getDirection(void); | |||
| RotaryEncoder::Direction getEncoderMove(); | |||
| void setDebounceTime(unsigned long time); | |||
| void loop(void); | |||
| void loop(void) override; | |||
| }; | |||
| @@ -44,3 +44,6 @@ bool WLS::isConnected(void) { | |||
| } | |||
| } | |||
| void WLS::loop(void) { | |||
| ezButton::loop(); | |||
| } | |||
| @@ -9,8 +9,9 @@ | |||
| #define WLS_H_ | |||
| #include <ezButton.h> | |||
| #include "Loopable.h" | |||
| class WLS: public ezButton { | |||
| class WLS: public ezButton, public Loopable { | |||
| private: | |||
| bool inverted; | |||
| @@ -21,6 +22,7 @@ class WLS: public ezButton { | |||
| bool isPlugged(void); | |||
| bool isUnplugged(void); | |||
| bool isConnected(void); | |||
| void loop(void) override; | |||
| }; | |||
| //Added by Sloeber | |||
| @@ -2,7 +2,7 @@ | |||
| //This is a automatic generated file | |||
| //Please do not modify this file | |||
| //If you touch this file your change will be overwritten during the next build | |||
| //This file has been generated on 2022-02-27 18:38:05 | |||
| //This file has been generated on 2022-03-01 10:11:02 | |||
| #include "Arduino.h" | |||
| #include <Arduino.h> | |||