| @@ -112,7 +112,6 @@ void Display::showFrame(Status status) { | |||
| switch (status) { | |||
| case MOVING_ELEVATOR: | |||
| rotateAndDrawRotationBitmap(); | |||
| drawBitmap((37 - imageSide_R) / 2, 47, imageSide_D, imageSide_D, epd_bitmap_Dive); | |||
| break; | |||
| case TOOL_CHANGE: | |||
| redrawFrame(); | |||
| @@ -140,6 +139,13 @@ void Display::showFrame(Status status) { | |||
| drawStatusText(STATUS_TXT_NULLING); | |||
| drawBitmap(37 + (SCREEN_WIDTH - 37 - imageSide) / 2, (SCREEN_HEIGHT - imageSide) / 2, imageSide, imageSide, epd_bitmap_Nulling); | |||
| break; | |||
| case DIVING: | |||
| redrawFrame(); | |||
| drawStatusText(STATUS_TXT_DIVING); | |||
| drawBitmap((37 - imageSide_R) / 2, 47, imageSide_D, imageSide_D, epd_bitmap_Dive); | |||
| drawDistanceValue(distanceValue); | |||
| drawDistanceUnit(distanceUnit); | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| @@ -234,9 +240,9 @@ void Display::drawMode(ValueMode mode) { | |||
| String txt = mode.toString(); | |||
| char *s = &txt[0]; | |||
| int16_t w = 0; | |||
| u8g2_gfx.setFont(u8g2_font_helvB10_tf); | |||
| u8g2_gfx.setFont(u8g2_font_helvB08_tf); | |||
| w = u8g2_gfx.getUTF8Width(s); | |||
| u8g2_gfx.setCursor((SCREEN_WIDTH - w - 6), 63 - 4); | |||
| u8g2_gfx.setCursor((SCREEN_WIDTH - w - 6), 63 - 6); | |||
| u8g2_gfx.println(F(s)); | |||
| } | |||
| @@ -29,6 +29,7 @@ | |||
| #define STATUS_TXT_TOOLCHG "WZW" | |||
| #define STATUS_TXT_CFG "SETUP" | |||
| #define STATUS_TXT_NULLING "NULL" | |||
| #define STATUS_TXT_DIVING "EINT" | |||
| class Display { | |||
| private: | |||
| @@ -274,7 +274,7 @@ void loop() { | |||
| } else if (BlueButton.isLongPressed()) { | |||
| SetActualStatus(TOOL_CHANGE); | |||
| } else if (GreenButton.isLongPressed()) { | |||
| SetActualStatus(DIVING); | |||
| } else if (GreenButton.isPressed()) { | |||
| Router_Elevator.moveToTarget(); | |||
| SetActualStatus(MOVING_ELEVATOR); | |||
| @@ -284,6 +284,24 @@ void loop() { | |||
| case DIVING: | |||
| printStatus("DIVING"); | |||
| originStatus = DIVING; | |||
| Router_Elevator.setMaxDiveDistance(); | |||
| if (GreenButton.isPressed()) { | |||
| Serial.println("GB && BB pressing"); | |||
| bool maxDiveDistReached = Router_Elevator.incrementDiveDistance(); | |||
| //Router_Elevator.moveToTarget(); | |||
| SetActualStatus(MOVING_ELEVATOR); | |||
| if (maxDiveDistReached) { | |||
| originStatus = IDLE; | |||
| Router_Elevator.setDoDiveInitialization(true); | |||
| Router_Elevator.moveToParkPosition(); | |||
| SetActualStatus(MOVING_ELEVATOR); | |||
| } | |||
| } else if (GreenButton.isLongPressed()) { | |||
| originStatus = IDLE; | |||
| Router_Elevator.setDoDiveInitialization(true); | |||
| Router_Elevator.moveToParkPosition(); | |||
| SetActualStatus(MOVING_ELEVATOR); | |||
| } | |||
| break; | |||
| case MOVING_ELEVATOR: | |||
| @@ -13,7 +13,9 @@ RouterElevator::RouterElevator(ESP_FlexyStepper &_Stepper, Display &_display, Ro | |||
| LimitSwitch = _LimitSwitch; | |||
| DOWNWARD_DIR = _DOWNWARD_DIR; | |||
| UPWARD_DIR = -DOWNWARD_DIR; | |||
| targetDistance = 0; | |||
| targetDistance = 0.0; | |||
| maxDiveDistance = 0.0; | |||
| doDiveInitialization = true; | |||
| } | |||
| void RouterElevator::setZeroPosition() { | |||
| @@ -112,6 +114,36 @@ void RouterElevator::onRotaryControlerTurn(RotaryEncoder::Direction turn) { | |||
| targetDistance = max(0.0f, targetDistance + increment / 100 * sign); | |||
| display.setDistanceValue(targetDistance); | |||
| display.setDistanceUnit("mm"); | |||
| } | |||
| } | |||
| bool RouterElevator::isDoDiveInitialization() const { | |||
| return doDiveInitialization; | |||
| } | |||
| void RouterElevator::setDoDiveInitialization(bool doDiveInitialization) { | |||
| this->doDiveInitialization = doDiveInitialization; | |||
| } | |||
| float RouterElevator::getMaxDiveDistance() const { | |||
| return maxDiveDistance; | |||
| } | |||
| void RouterElevator::setMaxDiveDistance() { | |||
| if (isDoDiveInitialization()) { | |||
| Serial.println("setMaxDiveDistance"); | |||
| maxDiveDistance = targetDistance; | |||
| targetDistance = 0.0; | |||
| display.setDistanceValue(maxDiveDistance); | |||
| display.setDistanceUnit("mm"); | |||
| display.setRefreshScreen(); | |||
| setDoDiveInitialization(false); | |||
| } | |||
| } | |||
| bool RouterElevator::incrementDiveDistance() { | |||
| float increment = Router_Setup.getLevelHeightDiving(); | |||
| targetDistance = min(maxDiveDistance, targetDistance + increment); | |||
| Serial.println("targetDistance: " + String(targetDistance, 2)); | |||
| return targetDistance == maxDiveDistance; | |||
| } | |||
| @@ -29,7 +29,9 @@ class RouterElevator { | |||
| int DOWNWARD_DIR; | |||
| int UPWARD_DIR; | |||
| float targetDistance; | |||
| float maxDiveDistance; | |||
| ValueMode mode; | |||
| bool doDiveInitialization; | |||
| public: | |||
| RouterElevator(ESP_FlexyStepper &_Stepper, Display &_display, RouterSetup &_Router_Setup, | |||
| @@ -51,6 +53,11 @@ class RouterElevator { | |||
| void setMode(ValueMode mode); | |||
| void toggleMode(); | |||
| void onRotaryControlerTurn(RotaryEncoder::Direction turn); | |||
| bool isDoDiveInitialization() const; | |||
| void setDoDiveInitialization(bool doDiveInitialization); | |||
| float getMaxDiveDistance() const; | |||
| void setMaxDiveDistance(); | |||
| bool incrementDiveDistance(); | |||
| }; | |||
| @@ -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-25 22:27:34 | |||
| //This file has been generated on 2022-02-26 22:19:46 | |||
| #include "Arduino.h" | |||
| #include <Arduino.h> | |||