瀏覽代碼

Diving Part 1

master
Flo Smilari 3 年之前
父節點
當前提交
6eb3639540
共有 6 個檔案被更改,包括 70 行新增6 行删除
  1. 9
    3
      Display.cpp
  2. 1
    0
      Display.h
  3. 19
    1
      Fraestisch_SFTools.ino
  4. 33
    1
      RouterElevator.cpp
  5. 7
    0
      RouterElevator.h
  6. 1
    1
      sloeber.ino.cpp

+ 9
- 3
Display.cpp 查看文件

switch (status) { switch (status) {
case MOVING_ELEVATOR: case MOVING_ELEVATOR:
rotateAndDrawRotationBitmap(); rotateAndDrawRotationBitmap();
drawBitmap((37 - imageSide_R) / 2, 47, imageSide_D, imageSide_D, epd_bitmap_Dive);
break; break;
case TOOL_CHANGE: case TOOL_CHANGE:
redrawFrame(); redrawFrame();
drawStatusText(STATUS_TXT_NULLING); drawStatusText(STATUS_TXT_NULLING);
drawBitmap(37 + (SCREEN_WIDTH - 37 - imageSide) / 2, (SCREEN_HEIGHT - imageSide) / 2, imageSide, imageSide, epd_bitmap_Nulling); drawBitmap(37 + (SCREEN_WIDTH - 37 - imageSide) / 2, (SCREEN_HEIGHT - imageSide) / 2, imageSide, imageSide, epd_bitmap_Nulling);
break; 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: default:
break; break;
} }
String txt = mode.toString(); String txt = mode.toString();
char *s = &txt[0]; char *s = &txt[0];
int16_t w = 0; int16_t w = 0;
u8g2_gfx.setFont(u8g2_font_helvB10_tf);
u8g2_gfx.setFont(u8g2_font_helvB08_tf);
w = u8g2_gfx.getUTF8Width(s); 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)); u8g2_gfx.println(F(s));
} }

+ 1
- 0
Display.h 查看文件

#define STATUS_TXT_TOOLCHG "WZW" #define STATUS_TXT_TOOLCHG "WZW"
#define STATUS_TXT_CFG "SETUP" #define STATUS_TXT_CFG "SETUP"
#define STATUS_TXT_NULLING "NULL" #define STATUS_TXT_NULLING "NULL"
#define STATUS_TXT_DIVING "EINT"
class Display { class Display {
private: private:

+ 19
- 1
Fraestisch_SFTools.ino 查看文件

} else if (BlueButton.isLongPressed()) { } else if (BlueButton.isLongPressed()) {
SetActualStatus(TOOL_CHANGE); SetActualStatus(TOOL_CHANGE);
} else if (GreenButton.isLongPressed()) { } else if (GreenButton.isLongPressed()) {
SetActualStatus(DIVING);
} else if (GreenButton.isPressed()) { } else if (GreenButton.isPressed()) {
Router_Elevator.moveToTarget(); Router_Elevator.moveToTarget();
SetActualStatus(MOVING_ELEVATOR); SetActualStatus(MOVING_ELEVATOR);
case DIVING: case DIVING:
printStatus("DIVING"); printStatus("DIVING");
originStatus = 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; break;


case MOVING_ELEVATOR: case MOVING_ELEVATOR:

+ 33
- 1
RouterElevator.cpp 查看文件

LimitSwitch = _LimitSwitch; LimitSwitch = _LimitSwitch;
DOWNWARD_DIR = _DOWNWARD_DIR; DOWNWARD_DIR = _DOWNWARD_DIR;
UPWARD_DIR = -DOWNWARD_DIR; UPWARD_DIR = -DOWNWARD_DIR;
targetDistance = 0;
targetDistance = 0.0;
maxDiveDistance = 0.0;
doDiveInitialization = true;
} }
void RouterElevator::setZeroPosition() { void RouterElevator::setZeroPosition() {
targetDistance = max(0.0f, targetDistance + increment / 100 * sign); targetDistance = max(0.0f, targetDistance + increment / 100 * sign);
display.setDistanceValue(targetDistance); display.setDistanceValue(targetDistance);
display.setDistanceUnit("mm"); 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(); 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;
}

+ 7
- 0
RouterElevator.h 查看文件

int DOWNWARD_DIR; int DOWNWARD_DIR;
int UPWARD_DIR; int UPWARD_DIR;
float targetDistance; float targetDistance;
float maxDiveDistance;
ValueMode mode; ValueMode mode;
bool doDiveInitialization;
public: public:
RouterElevator(ESP_FlexyStepper &_Stepper, Display &_display, RouterSetup &_Router_Setup, RouterElevator(ESP_FlexyStepper &_Stepper, Display &_display, RouterSetup &_Router_Setup,
void setMode(ValueMode mode); void setMode(ValueMode mode);
void toggleMode(); void toggleMode();
void onRotaryControlerTurn(RotaryEncoder::Direction turn); void onRotaryControlerTurn(RotaryEncoder::Direction turn);
bool isDoDiveInitialization() const;
void setDoDiveInitialization(bool doDiveInitialization);
float getMaxDiveDistance() const;
void setMaxDiveDistance();
bool incrementDiveDistance();
}; };

+ 1
- 1
sloeber.ino.cpp 查看文件

//This is a automatic generated file //This is a automatic generated file
//Please do not modify this file //Please do not modify this file
//If you touch this file your change will be overwritten during the next build //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"
#include <Arduino.h> #include <Arduino.h>

Loading…
取消
儲存