Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Make ONE_G definition const and move to utils.ino

Oleg Kalachevc8109af04fa0
diff --git a/flix/estimate.ino b/flix/estimate.ino
index ea1834f..a9adaf4 100644
--- a/flix/estimate.ino
+++ b/flix/estimate.ino
@@ -11,6 +11,7 @@
#define RATES_LFP_ALPHA 0.2 // cutoff frequency ~ 40 Hz
LowPassFilter<Vector> ratesFilter(RATES_LFP_ALPHA);
+extern const float ONE_G;
void estimate() {
applyGyro();
diff --git a/flix/flix.ino b/flix/flix.ino
index 3eccb26..f2bba3a 100644
--- a/flix/flix.ino
+++ b/flix/flix.ino
@@ -18,8 +18,6 @@
#define RC_CHANNEL_ARMED 4
#define RC_CHANNEL_MODE 5
-#define ONE_G 9.80665
-
float t = NAN; // current step time, s
float dt; // time delta from previous step, s
float loopRate; // loop rate, Hz
diff --git a/flix/imu.ino b/flix/imu.ino
index 36c009f..7f8f858 100644
--- a/flix/imu.ino
+++ b/flix/imu.ino
@@ -12,6 +12,8 @@ Vector accBias;
Vector gyroBias;
Vector accScale(1, 1, 1);
+extern const float ONE_G;
+
void setupIMU() {
Serial.println("Setup IMU");
bool status = IMU.begin();
diff --git a/flix/util.ino b/flix/util.ino
index b5032f7..04e2595 100644
--- a/flix/util.ino
+++ b/flix/util.ino
@@ -7,6 +7,8 @@
#include <soc/soc.h>
#include <soc/rtc_cntl_reg.h>
+const float ONE_G = 9.80665;
+
float mapf(long x, long in_min, long in_max, float out_min, float out_max) {
return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;
}
diff --git a/gazebo/flix.h b/gazebo/flix.h
index 3bebf19..0a6e624 100644
--- a/gazebo/flix.h
+++ b/gazebo/flix.h
@@ -11,11 +11,8 @@
#include "wifi.h"
#define RC_CHANNELS 16
-
#define WIFI_ENABLED 1
-#define ONE_G 9.80665
-
float t = NAN;
float dt;
float loopRate;