diff --git a/flix/flix.ino b/flix/flix.ino index 2b2332c..6933183 100644 --- a/flix/flix.ino +++ b/flix/flix.ino @@ -10,7 +10,6 @@ #define SERIAL_BAUDRATE 115200 #define WIFI_ENABLED 1 -#define RC_CHANNELS 16 #define RC_CHANNEL_ROLL 0 #define RC_CHANNEL_PITCH 1 #define RC_CHANNEL_THROTTLE 2 @@ -20,8 +19,8 @@ float t = NAN; // current step time, s float dt; // time delta from previous step, s -int16_t channels[RC_CHANNELS]; // raw rc channels -float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle) +int16_t channels[16]; // raw rc channels +float controls[16]; // normalized controls in range [-1..1] ([0..1] for throttle) Vector gyro; // gyroscope data Vector acc; // accelerometer data, m/s/s Vector rates; // filtered angular rates, rad/s diff --git a/flix/rc.ino b/flix/rc.ino index 8cf8e5c..2e47bd3 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -28,7 +28,7 @@ void readRC() { } void normalizeRC() { - for (uint8_t i = 0; i < RC_CHANNELS; i++) { + for (uint8_t i = 0; i < 16; i++) { controls[i] = mapf(channels[i], channelNeutral[i], channelMax[i], 0, 1); } } @@ -38,20 +38,20 @@ void calibrateRC() { Serial.println("··o ··o\n··· ···\n··· ···"); delay(4000); for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated - for (int i = 0; i < RC_CHANNELS; i++) { + for (int i = 0; i < 16; i++) { channelMax[i] = channels[i]; } Serial.println("Calibrate RC: move all sticks to neutral positions in 4 seconds"); Serial.println("··· ···\n··· ·o·\n·o· ···"); delay(4000); for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated - for (int i = 0; i < RC_CHANNELS; i++) { + for (int i = 0; i < 16; i++) { channelNeutral[i] = channels[i]; } printRCCal(); } void printRCCal() { - printArray(channelNeutral, RC_CHANNELS); - printArray(channelMax, RC_CHANNELS); + printArray(channelNeutral, 16); + printArray(channelMax, 16); } diff --git a/gazebo/flix.h b/gazebo/flix.h index 3f2f994..b96c6e4 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -10,14 +10,13 @@ #include "Arduino.h" #include "wifi.h" -#define RC_CHANNELS 16 #define WIFI_ENABLED 1 float t = NAN; float dt; float motors[4]; int16_t channels[16]; // raw rc channels -float controls[RC_CHANNELS]; +float controls[16]; Vector acc; Vector gyro; Vector rates; diff --git a/gazebo/joystick.h b/gazebo/joystick.h index 3297e2b..88b6dcb 100644 --- a/gazebo/joystick.h +++ b/gazebo/joystick.h @@ -38,8 +38,8 @@ bool joystickInit() { } // apply calibration overrides - extern int channelNeutral[RC_CHANNELS]; - extern int channelMax[RC_CHANNELS]; + extern int channelNeutral[16]; + extern int channelMax[16]; memcpy(channelNeutral, channelNeutralOverride, sizeof(channelNeutralOverride)); memcpy(channelMax, channelMaxOverride, sizeof(channelMaxOverride));