Skip to content

Commit

Permalink
Make util module header instead of .ino-file
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Jan 10, 2025
1 parent ddc46c0 commit f9e1802
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"${workspaceFolder}/flix/motors.ino",
"${workspaceFolder}/flix/rc.ino",
"${workspaceFolder}/flix/time.ino",
"${workspaceFolder}/flix/util.ino",
"${workspaceFolder}/flix/wifi.ino"
],
"compilerPath": "~/.arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++",
Expand Down Expand Up @@ -75,7 +74,6 @@
"${workspaceFolder}/flix/motors.ino",
"${workspaceFolder}/flix/rc.ino",
"${workspaceFolder}/flix/time.ino",
"${workspaceFolder}/flix/util.ino",
"${workspaceFolder}/flix/wifi.ino"
],
"compilerPath": "~/Library/Arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++",
Expand Down Expand Up @@ -122,7 +120,6 @@
"${workspaceFolder}/flix/motors.ino",
"${workspaceFolder}/flix/rc.ino",
"${workspaceFolder}/flix/time.ino",
"${workspaceFolder}/flix/util.ino",
"${workspaceFolder}/flix/wifi.ino"
],
"compilerPath": "~/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2405/bin/xtensa-esp32-elf-g++.exe",
Expand Down
1 change: 1 addition & 0 deletions flix/control.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "quaternion.h"
#include "pid.h"
#include "lpf.h"
#include "util.h"

#define PITCHRATE_P 0.05
#define PITCHRATE_I 0.2
Expand Down
2 changes: 1 addition & 1 deletion flix/estimate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "quaternion.h"
#include "vector.h"
#include "lpf.h"
#include "util.h"

#define WEIGHT_ACC 0.5f
#define RATES_LFP_ALPHA 0.2 // cutoff frequency ~ 40 Hz

LowPassFilter<Vector> ratesFilter(RATES_LFP_ALPHA);
extern const float ONE_G;

void estimate() {
applyGyro();
Expand Down
1 change: 1 addition & 0 deletions flix/flix.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "vector.h"
#include "quaternion.h"
#include "util.h"

#define SERIAL_BAUDRATE 115200

Expand Down
3 changes: 1 addition & 2 deletions flix/imu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <SPI.h>
#include <MPU9250.h>
#include "util.h"

// NOTE: use 'ca' command to calibrate the accelerometer and put the values here
Vector accBias(0, 0, 0);
Expand All @@ -13,8 +14,6 @@ Vector accScale(1, 1, 1);
MPU9250 IMU(SPI);
Vector gyroBias;

extern const float ONE_G;

void setupIMU() {
Serial.println("Setup IMU");
bool status = IMU.begin();
Expand Down
2 changes: 2 additions & 0 deletions flix/motors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// In case of using ESC, use this version of the code: https://gist.github.com/okalachev/8871d3a94b6b6c0a298f41a4edd34c61.
// Motor: 8520 3.7V

#include "util.h"

#define MOTOR_0_PIN 12 // rear left
#define MOTOR_1_PIN 13 // rear right
#define MOTOR_2_PIN 14 // front right
Expand Down
1 change: 1 addition & 0 deletions flix/rc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Work with the RC receiver

#include <SBUS.h>
#include "util.h"

// NOTE: use 'cr' command to calibrate the RC and put the values here
int channelNeutral[] = {995, 883, 200, 972, 512, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Expand Down
2 changes: 2 additions & 0 deletions flix/util.ino → flix/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

// Utility functions

#pragma once

#include <math.h>
#include <soc/soc.h>
#include <soc/rtc_cntl_reg.h>
Expand Down
1 change: 0 additions & 1 deletion gazebo/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "Arduino.h"
#include "flix.h"
#include "util.ino"
#include "rc.ino"
#include "time.ino"
#include "motors.ino"
Expand Down
2 changes: 1 addition & 1 deletion gazebo/soc/rtc_cntl_reg.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// Dummy file to make it possible to compile simulator with util.ino
// Dummy file to make it possible to compile simulator with Flix' util.h
2 changes: 1 addition & 1 deletion gazebo/soc/soc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Dummy file to make it possible to compile simulator with util.ino
// Dummy file to make it possible to compile simulator with Flix' util.h

#define WRITE_PERI_REG(addr, val) {}

0 comments on commit f9e1802

Please sign in to comment.