瀏覽代碼

Configuration functionality complete

master
Flo Smilari 4 年之前
父節點
當前提交
417cce3e07
共有 2 個檔案被更改,包括 23 行新增4 行删除
  1. 19
    2
      RouterSetup.cpp
  2. 4
    2
      RouterSetup.h

+ 19
- 2
RouterSetup.cpp 查看文件

@@ -7,6 +7,9 @@
#include "RouterSetup.h"
#include <HardwareSerial.h>
#include <WString.h>
/******************
** Constructors
@@ -185,6 +188,7 @@ void RouterSetup::onRotaryControlerTurn(RotaryEncoder::Direction turn) {
if (turn != RotaryEncoder::Direction::NOROTATION) {
String value = "";
int index = 0;
int sign = (turn == RotaryEncoder::Direction::CLOCKWISE) ? 1 : -1;
String unit = getCfgOptUnitForStepIndex(configStepIndex);
@@ -198,8 +202,12 @@ void RouterSetup::onRotaryControlerTurn(RotaryEncoder::Direction turn) {
value = String(getAcceleration(), 1);
break;
case 2:
setStepsPerRev(getStepsPerRev() + 1 * sign);
value = String(getStepsPerRev());
index = getIndexOfStepsPerRevValue(getStepsPerRev());
if (index > -1) {
index = min(max((index + 1 * sign), 0), StepsPerRevOptsSize - 1) % 5;
setStepsPerRev(StepsPerRevolutionOptions[index]);
value = String(getStepsPerRev());
}
break;
case 3:
setPitch(getPitch() + 0.1 * sign);
@@ -299,3 +307,12 @@ String RouterSetup::getCfgOptUnitForStepIndex(byte configStepIndex) {
}
return value;
}
int RouterSetup::getIndexOfStepsPerRevValue(uint16_t value) {
for (int i = 0; i < sizeof(StepsPerRevolutionOptions); i++) {
if (StepsPerRevolutionOptions[i] == value) {
return i;
}
}
return -1;
}

+ 4
- 2
RouterSetup.h 查看文件

@@ -12,6 +12,7 @@
#include <Preferences.h>
#include <RotaryEncoder.h>
#include "Display.h"
#include <stdio.h>
const static char ROUTER_NAMESPACE[] = "routerelv_stp";
const static char SPEED[] = "speed";
@@ -24,9 +25,9 @@ const static char ENCSPEEDFAST[] = "encSpeedFast";
const static char LVLHEIGHTDIVE[] = "lvlHeightDive";
const static char TOOLCHGONPWRON[] = "toolChgOnPwrOn";
const static String ConfigStep[9] = { "Geschw.", "Beschl.", "Schritte/U", "Steigung", "Höhe WLS", "SLOW", "FAST", "Ink. Eint.", "WzW P-ON" };
const static int StepsPerRevOptsSize = 5;
const static uint16_t StepsPerRevolutionOptions[StepsPerRevOptsSize] = { 200, 400, 800, 1600, 3200 };
class RouterSetup {
private:
@@ -46,6 +47,7 @@ class RouterSetup {
byte configStepIndex;
String getCfgOptForStepIndex(byte configStepIndex);
String getCfgOptUnitForStepIndex(byte configStepIndex);
int getIndexOfStepsPerRevValue(uint16_t value);
public:
const static int eeprom_start_adress = 0;

Loading…
取消
儲存