bug fix static in motor und speed
This commit is contained in:
+7
-6
@@ -20,18 +20,19 @@ void Menu::addEntry(MenuAction* entry) {
|
||||
// TODO: Same shit here. Why I get the first element after an increment.
|
||||
static uint8_t inc = 0;
|
||||
inc++;
|
||||
if (inc == 2) {
|
||||
if (inc == 1) {
|
||||
this->it = this->entrys.begin();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::printMenu() {
|
||||
Serial.println("\n\n");
|
||||
std::cout << std::endl;
|
||||
for (std::list<MenuAction*>::iterator iter = this->entrys.begin(); iter != this->entrys.end(); iter++) {
|
||||
MenuAction* selectedEntry = *(iter);
|
||||
if (this->it == iter)
|
||||
Serial.print(" ");
|
||||
Serial.println(selectedEntry->getName());
|
||||
std::cout << " " << selectedEntry->getName() << std::endl;
|
||||
else
|
||||
std::cout << selectedEntry->getName() << std::endl;
|
||||
}
|
||||
this->inSubmenu = false;
|
||||
}
|
||||
@@ -62,11 +63,9 @@ void Menu::up() {
|
||||
std::list<MenuAction*>::iterator iter = this->entrys.end();
|
||||
iter--;
|
||||
if (this->it != this->entrys.begin()) {
|
||||
Serial.println("--");
|
||||
this->it--;
|
||||
}
|
||||
else {
|
||||
Serial.println("begin");
|
||||
this->it = iter;
|
||||
}
|
||||
this->printMenu();
|
||||
@@ -86,6 +85,8 @@ void Menu::right() {
|
||||
selectedEntry->getMenu()->setParentMenu(this);
|
||||
}
|
||||
selectedEntry->runAction();
|
||||
if (selectedEntry->getIsMenu())
|
||||
selectedEntry->getMenu()->down();
|
||||
}
|
||||
|
||||
void Menu::left() {
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
// Only for print in consol
|
||||
// have to be deleted after display installation
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "menuAction.h"
|
||||
#include "menuControl.h"
|
||||
|
||||
|
||||
@@ -22,6 +22,14 @@ MenuAction::MenuAction(const char* name, void (*function) ()) {
|
||||
this->callback = nullptr;
|
||||
}
|
||||
|
||||
// MenuAction::MenuAction(const char* name, void (DriveManager:: *classFunction) ()) {
|
||||
// this->name = name;
|
||||
// this->classFunction = classFunction;
|
||||
// this->classFunc = true;
|
||||
// this->function = nullptr;
|
||||
// this->callback = nullptr;
|
||||
// }
|
||||
|
||||
MenuAction::MenuAction(const char* name, MenuControl* menu) {
|
||||
this->name = name;
|
||||
this->menu = menu;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#ifndef MENU_CONTROLL_H
|
||||
#define MENU_CONTROLL_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class MenuControl {
|
||||
public:
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* @file pidSettings.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-01-19
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuPidSettings.h"
|
||||
|
||||
MenuPidSettings::MenuPidSettings(PID* pid) {
|
||||
this->pid = pid;
|
||||
this->values[0] = (uint8_t) pid->GetKp();
|
||||
this->values[1] = (uint8_t) pid->GetKi();
|
||||
this->values[2] = (uint8_t) pid->GetKd();
|
||||
}
|
||||
|
||||
void MenuPidSettings::down() {
|
||||
if (values[curPos] > 0)
|
||||
values[curPos]--;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::up() {
|
||||
if (values[curPos] < UINT8_MAX)
|
||||
values[curPos]++;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::right() {
|
||||
if (curPos < NUM_VAL - 1)
|
||||
curPos++;
|
||||
else
|
||||
curPos = 0;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::left() {
|
||||
if (curPos > 0)
|
||||
curPos--;
|
||||
else
|
||||
curPos = NUM_VAL - 1;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::no() {
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::yes() {
|
||||
this->pid->SetTunings(this->values[0], this->values[1], this->values[2]);
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuPidSettings::printMenu() {
|
||||
Serial.println(" P I D ");
|
||||
char pos[16];
|
||||
switch (this->curPos) {
|
||||
case 0:
|
||||
sprintf(pos, "_%d.3_ %d.3 %d.3 ", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sprintf(pos, " %d.3 _%d.3_ %d.3 ", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sprintf(pos, " %d.3 %d.3 _%d.3_", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Serial.println(pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @file pidSettings.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-01-19
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PID_SETTINGS_H
|
||||
#define PID_SETTINGS_H
|
||||
|
||||
#include "menuControl.h"
|
||||
#include <PID_v1.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// TODO: delete after installtion of display
|
||||
#include <Arduino.h>
|
||||
|
||||
#define NUM_VAL 3
|
||||
|
||||
class MenuPidSettings : public MenuControl {
|
||||
public:
|
||||
MenuPidSettings(PID* pid);
|
||||
|
||||
void down();
|
||||
void up();
|
||||
void right();
|
||||
void left();
|
||||
void no();
|
||||
void yes();
|
||||
|
||||
void printMenu();
|
||||
|
||||
private:
|
||||
PID* pid;
|
||||
uint8_t values[NUM_VAL];
|
||||
uint8_t curPos = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PID_SETTINGS_H
|
||||
Reference in New Issue
Block a user