ソースを参照

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 ファイルの表示

#include "RouterSetup.h" #include "RouterSetup.h"
#include <HardwareSerial.h>
#include <WString.h>
/****************** /******************
** Constructors ** Constructors
if (turn != RotaryEncoder::Direction::NOROTATION) { if (turn != RotaryEncoder::Direction::NOROTATION) {
String value = ""; String value = "";
int index = 0;
int sign = (turn == RotaryEncoder::Direction::CLOCKWISE) ? 1 : -1; int sign = (turn == RotaryEncoder::Direction::CLOCKWISE) ? 1 : -1;
String unit = getCfgOptUnitForStepIndex(configStepIndex); String unit = getCfgOptUnitForStepIndex(configStepIndex);
value = String(getAcceleration(), 1); value = String(getAcceleration(), 1);
break; break;
case 2: 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; break;
case 3: case 3:
setPitch(getPitch() + 0.1 * sign); setPitch(getPitch() + 0.1 * sign);
} }
return value; 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 ファイルの表示

#include <Preferences.h> #include <Preferences.h>
#include <RotaryEncoder.h> #include <RotaryEncoder.h>
#include "Display.h" #include "Display.h"
#include <stdio.h>
const static char ROUTER_NAMESPACE[] = "routerelv_stp"; const static char ROUTER_NAMESPACE[] = "routerelv_stp";
const static char SPEED[] = "speed"; const static char SPEED[] = "speed";
const static char LVLHEIGHTDIVE[] = "lvlHeightDive"; const static char LVLHEIGHTDIVE[] = "lvlHeightDive";
const static char TOOLCHGONPWRON[] = "toolChgOnPwrOn"; 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 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 { class RouterSetup {
private: private:
byte configStepIndex; byte configStepIndex;
String getCfgOptForStepIndex(byte configStepIndex); String getCfgOptForStepIndex(byte configStepIndex);
String getCfgOptUnitForStepIndex(byte configStepIndex); String getCfgOptUnitForStepIndex(byte configStepIndex);
int getIndexOfStepsPerRevValue(uint16_t value);
public: public:
const static int eeprom_start_adress = 0; const static int eeprom_start_adress = 0;

読み込み中…
キャンセル
保存