remove most of the defines

This commit is contained in:
2023-08-18 15:34:56 +02:00
parent 4cd2b9368d
commit a82b32087c
21 changed files with 155 additions and 285 deletions
+9 -30
View File
@@ -16,14 +16,7 @@
#include <iostream>
#include <Arduino.h>
#include <component.h>
#define DELAY 10
#define PWMFREQ 16000
#define PWMRES 8
#define POWERSTEPS 2 // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms
#define PWMMIN 55
#define PWMMAX 94 // Max 98% of 2^PWM_RES
#include "component.h"
/**
* @brief A class which use PWM to control the power of DC Motor
@@ -58,24 +51,6 @@ class MotorControl : public Component {
*/
void setMaxPwm(uint8_t max);
/**
* @brief Set the Power Steps
*
* Set the increment of the steps with which the dutycycle is
* increased or decreased. Note the dependency between the increment
* and delayLoop().
*
* The formula for the time between 0% and 100% power is:
* time[ms] = delayLoop * ( 100 / increment )
* 500 ms are recommended
*
* @see setDelay()
*
* @param increment
* @return time from 0% power to 100% power in Milliseconds
*/
uint16_t setPowerSteps(uint8_t increment);
/**
* @brief Set the Target Power
*
@@ -122,20 +97,24 @@ class MotorControl : public Component {
void setRealPower(int8_t power);
void increasePower(int8_t power);
static constexpr uint8_t loopDelay = 10;
static constexpr uint16_t pwmFreq = 16000;
static constexpr uint8_t pwmRes = 8;
static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms
static constexpr uint8_t pwmMin = 55;
static constexpr uint8_t pwmMax = 98; // Max 98% of 2^PWM_RES
int8_t targetPower = 0;
int8_t power = 0;
uint8_t direction = 0; // 0 = stop, 1 = forward, 2 = backward
uint8_t pwmPin;
uint8_t pwmChannel;
uint8_t pwmRes = PWMRES;
uint16_t dutycycle = 0;
uint8_t dutycycleMin;
uint8_t dutycycleMax;
uint8_t dir_1;
uint8_t dir_2;
uint8_t powersteps = POWERSTEPS;
uint8_t dir_2;
};
#endif // MOTOR_CONTROL_H