Consistently use defines to set parameters

This commit is contained in:
Oleg Kalachev 2023-05-31 20:16:43 +03:00
parent 39875cafb9
commit 9eaa45c1d9
3 changed files with 12 additions and 13 deletions

View File

@ -5,8 +5,7 @@
#include <MPU9250.h> #include <MPU9250.h>
#define IMU_CS_PIN 4 // chip-select pin for IMU SPI connection #define IMU_CS_PIN 4 // chip-select pin for IMU SPI connection
#define CALIBRATE_GYRO_ON_START false
const bool CALIBRATE_GYRO_ON_START = false;
MPU9250 IMU(SPI, IMU_CS_PIN); MPU9250 IMU(SPI, IMU_CS_PIN);

View File

@ -3,11 +3,11 @@
// In-RAM logging // In-RAM logging
const int LOG_RATE = 100; #define LOG_RATE 100
const int LOG_DURATION = 10; #define LOG_DURATION 10
const float LOG_PERIOD = 1 / LOG_RATE; #define LOG_PERIOD 1 / LOG_RATE
const int LOG_SIZE = LOG_DURATION * LOG_RATE; #define LOG_SIZE LOG_DURATION * LOG_RATE
const int LOG_COLUMNS = 14; #define LOG_COLUMNS 14
float logBuffer[LOG_SIZE][LOG_COLUMNS]; // * 4 (float) float logBuffer[LOG_SIZE][LOG_COLUMNS]; // * 4 (float)
int logPointer = 0; int logPointer = 0;

View File

@ -15,10 +15,10 @@
#define PWM_NEUTRAL 1500 #define PWM_NEUTRAL 1500
static const uint16_t pwmMin[] = {1600, 1600, 1600, 1600}; const uint16_t pwmMin[] = {1600, 1600, 1600, 1600};
static const uint16_t pwmMax[] = {2300, 2300, 2300, 2300}; const uint16_t pwmMax[] = {2300, 2300, 2300, 2300};
static const uint16_t pwmReverseMin[] = {1390, 1440, 1440, 1440}; const uint16_t pwmReverseMin[] = {1390, 1440, 1440, 1440};
static const uint16_t pwmReverseMax[] = {1100, 1100, 1100, 1100}; const uint16_t pwmReverseMax[] = {1100, 1100, 1100, 1100};
void setupMotors() { void setupMotors() {
Serial.println("Setup Motors"); Serial.println("Setup Motors");
@ -39,7 +39,7 @@ void setupMotors() {
Serial.println("Motors initialized"); Serial.println("Motors initialized");
} }
static uint16_t getPWM(float val, int n) uint16_t getPWM(float val, int n)
{ {
if (val == 0) { if (val == 0) {
return PWM_NEUTRAL; return PWM_NEUTRAL;
@ -50,7 +50,7 @@ static uint16_t getPWM(float val, int n)
} }
} }
static uint8_t pwmToDutyCycle(uint16_t pwm) { uint8_t pwmToDutyCycle(uint16_t pwm) {
return map(pwm, 0, 1000000 / PWM_FREQUENCY, 0, (1 << PWM_RESOLUTION) - 1); return map(pwm, 0, 1000000 / PWM_FREQUENCY, 0, (1 << PWM_RESOLUTION) - 1);
} }