bug fix static in motor und speed
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "menuManualDrive.h"
|
||||
|
||||
MenuManualControl::MenuManualControl(DriveManager* driveManager) {
|
||||
this->driveManager = driveManager;
|
||||
}
|
||||
|
||||
void MenuManualControl::left() {
|
||||
this->driveManager->changeModus(Modi::Off);
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuManualControl::no() {
|
||||
this->left();
|
||||
}
|
||||
|
||||
void MenuManualControl::printMenu() {
|
||||
this->driveManager->changeModus(Modi::ManualControl);
|
||||
std::cout << "Jetzt kannst du\n fahren. :-)" << std::endl;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file menuManualDrive.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-01-20
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MENU_MANUAL_DRIVE_H
|
||||
#define MENU_MANUAL_DRIVE_H
|
||||
|
||||
#include "menuControl.h"
|
||||
#include "driveModi/driveManager.h"
|
||||
|
||||
// TODO: delete after installtion of display
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
|
||||
class MenuManualControl : public MenuControl {
|
||||
public:
|
||||
MenuManualControl(DriveManager* driveManager);
|
||||
|
||||
void down(){}
|
||||
void up(){}
|
||||
void right(){}
|
||||
void left();
|
||||
void no();
|
||||
void yes(){}
|
||||
|
||||
void printMenu();
|
||||
|
||||
private:
|
||||
DriveManager* driveManager;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MENU_MANUAL_DRIVE_H
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @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() {
|
||||
std::cout << " P I D " << std::endl;
|
||||
switch (this->curPos) {
|
||||
case 0:
|
||||
printf("_%3.d_ %3.d %3.d \n", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
printf(" %3.d _%3.d_ %3.d \n", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
printf(" %3.d %3.d _%3.d_\n", this->values[0], this->values[1], this->values[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @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