Skip to content

Commit 914ae97

Browse files
committed
PlatformIO
1 parent 2388434 commit 914ae97

File tree

10 files changed

+386
-1
lines changed

10 files changed

+386
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the convention is to give header files names that end with `.h'.
29+
30+
Read more about using header files in official GCC documentation:
31+
32+
* Include Syntax
33+
* Include Operation
34+
* Once-Only Headers
35+
* Computed Includes
36+
37+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into the executable file.
4+
5+
The source code of each library should be placed in a separate directory
6+
("lib/your_library_name/[Code]").
7+
8+
For example, see the structure of the following example libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
Example contents of `src/main.c` using Foo and Bar:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
The PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries by scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
;
11+
;
12+
; MADFLIGHT NOTES
13+
; ===============
14+
;
15+
; For the latest madflight release version use
16+
; lib_deps = qqqlab/madflight
17+
;
18+
; For the latest madflight development version use
19+
; lib_deps = https://github.com/qqqlab/madflight.git
20+
;
21+
; For a particular madflight branch/tag use
22+
; lib_deps = https://github.com/qqqlab/madflight.git#v2.0.1
23+
;
24+
; RP2040/RP2350 is not merged into mainline PlatformIO, see
25+
; https://arduino-pico.readthedocs.io/en/latest/platformio.html
26+
; on Windows you need to enable long path names, see above link for instructions
27+
28+
[platformio]
29+
default_envs = esp32s3
30+
31+
[env]
32+
lib_deps = qqqlab/madflight ; Include madflight library
33+
monitor_speed = 115200 ; Default monitor speed for madflight
34+
35+
[env:esp32]
36+
board = esp32dev
37+
platform = espressif32
38+
framework = arduino
39+
40+
[env:esp32s3]
41+
board = lolin_s3_mini
42+
platform = espressif32
43+
framework = arduino
44+
build_flags =
45+
-DCONFIG_IDF_TARGET_ESP32S3
46+
-DARDUINO_USB_MODE=1
47+
-DARDUINO_USB_CDC_ON_BOOT=1
48+
49+
[env:rp2040]
50+
board = pico
51+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
52+
framework = arduino
53+
board_build.core = earlephilhower
54+
55+
[env:rp2350A]
56+
board = rpipico2
57+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
58+
framework = arduino
59+
board_build.core = earlephilhower
60+
61+
[env:rp2350B]
62+
board = solderparty_rp2350_stamp_xl
63+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
64+
framework = arduino
65+
board_build.core = earlephilhower
66+
67+
[env:stm32f411]
68+
board = blackpill_f411ce
69+
platform = ststm32
70+
framework = arduino
71+
72+
[env:stm32h743]
73+
board = weact_mini_h743vitx
74+
platform = ststm32
75+
framework = arduino
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*========================================================================================================================
2+
MADFLIGHT CONFIG
3+
==========================================================================================================================
4+
5+
The configuration is loaded from two strings: first from madflight_board in from the board header in /brd/, and then from
6+
madflight_config in this file. If the same setting occurs more than once, the last one is applied.
7+
8+
The strings are multi-line raw strings in with a key-value list. Anything after '#' or '/' is ignored as comment.
9+
10+
You have 3 options to setup the flight controller:
11+
12+
1) Default - Keep #define MF_BOARD "brd/default.h", this defines the default pinout as shown on https://madflight.com
13+
for the supported processor families. Now edit madflight_config below, and uncomment and configure imu_gizmo,
14+
imu_bus_type, rcl_gizmo, and other lines as needed. (Do not change the pin_xxx_yyy and xxx_yyy_bus settings.)
15+
16+
2) BetaFlight - Change "brd/default.h" to the BetaFlight flight controller you want to use, for example:
17+
#define MF_BOARD "brd/betaflight/MTKS-MATEKH743.h". See library/madflight/src for all available boards. Edit
18+
madflight_config to fine-tune the configuration.
19+
20+
3) Bare Metal - Comment out "#define MF_BOARD", and set the full configuration in madflight_config below.
21+
22+
Pins and spi/i2c/serial busses use zero-based numbering, i.e. "gps_ser_bus 0" connects the GPS to the first serial bus
23+
with pins pin_ser0_tx and pin_ser0_rx. Pins use GPIO numbers, not physical pin numbers. Use -1 to disable a pin or bus.
24+
25+
You can also modify the configuration from the CLI, for example "set imu_gizmo MPU6500" or "set imu_spi_bus 1", then
26+
use "save" to save the config to eeprom and reboot to use the new config.
27+
28+
If things do not work as expected, have a good look at the startup messages!
29+
30+
========================================================================================================================*/
31+
32+
//define the board header to use, or comment out for none
33+
#define MF_BOARD "brd/default.h"
34+
35+
const char madflight_config[] = R""(
36+
37+
//--- IMU --- Inertial Measurement Unit (use spi -OR- i2c bus)
38+
//imu_gizmo NONE // options: NONE, BMI270, MPU6000, MPU6050, MPU6500, MPU9150, MPU9250, ICM45686, ICM42688
39+
//imu_bus_type SPI // options: SPI, I2C (not all combinations of gizmo and bus_type are supported)
40+
//imu_align CW0 // options: CW0, CW90, CW180, CW270, CW0FLIP, CW90FLIP, CW180FLIP, CW270FLIP
41+
//imu_spi_bus -1 //spi
42+
//pin_imu_cs -1 //spi
43+
//pin_imu_int -1 //spi and i2c
44+
//imu_i2c_bus -1 //i2c
45+
//imu_i2c_adr 0 //i2c: enter decimal i2c address, not hex (use 0 for default i2c address)
46+
47+
// IMPORTANT: the IMU sensor should be the ONLY sensor on the selected bus
48+
49+
50+
//--- RCL --- Remote Controller Link (use serial bus -OR- ppm pin)
51+
//rcl_gizmo NONE // options: NONE, MAVLINK, CRSF, SBUS, DSM, PPM
52+
//rcl_num_ch 8 // number of channels
53+
//rcl_deadband 0 // center stick deadband
54+
//rcl_ser_bus -1
55+
//pin_rcl_ppm -1
56+
57+
//--- BAR --- Barometer
58+
//bar_gizmo NONE // options: NONE, BMP390, BMP388, BMP280, MS5611, HP203B
59+
//bar_i2c_adr 0
60+
//bar_i2c_bus -1
61+
62+
//--- MAG --- Magnetometer
63+
//mag_gizmo NONE // options: NONE, QMC5883, QMC6309, RM3100
64+
//mag_i2c_adr 0
65+
//mag_i2c_bus -1
66+
67+
//--- BAT --- Battery Monitor (use i2c bus -OR- adc pins)
68+
//bat_gizmo NONE // options: NONE, ADC, INA226, INA228
69+
//bat_i2c_adr 0
70+
//bat_i2c_bus -1
71+
//pin_bat_i -1
72+
//pin_bat_v -1
73+
//bat_cal_v 1 //adc voltage scale, value is: actual_voltage_in_v / adc_reading
74+
//bat_cal_i, 1 //adc current scale, value is: actual_current_in_a / adc_reading; for ina226/228: rshunt value in ohm
75+
76+
//--- GPS ---
77+
//gps_gizmo NONE // options: NONE, UBLOX
78+
//gps_baud 0 // use 0 for auto baud
79+
//gps_ser_bus -1
80+
81+
//--- BBX --- Black Box Data Logger (use spi -OR- mmc)
82+
//bbx_gizmo NONE // options: NONE, SDSPI, SDMMC
83+
//pin_bbx_cs -1 // spi
84+
//bbx_spi_bus -1 // spi
85+
//pin_mmc_dat -1 // mmc
86+
//pin_mmc_clk -1 // mmc
87+
//pin_mmc_cmd -1 // mmc
88+
89+
//--- RDR --- Radar (use serial bus -OR- trig+echo pins)
90+
//rdr_gizmo NONE // options: NONE, LD2411S, LD2413, USD1, SR04
91+
//rdr_baud 0
92+
//rdr_ser_bus -1
93+
//pin_rdr_trig -1
94+
//pin_rdr_echo -1
95+
96+
//--- LED ---
97+
//led_on LOW_IS_ON // options: LOW_IS_ON, HIGH_IS_ON
98+
//pin_led -1
99+
100+
//--- AHR --- AHRS (keep MAHONY, unless you want to experiment)
101+
//ahr_gizmo MAHONY // options: MAHONY, MAHONY_BF, MADGWICK, VQF
102+
103+
//--- Serial bus 0 ---
104+
//pin_ser0_rx -1
105+
//pin_ser0_tx -1
106+
107+
//--- Serial bus 1 ---
108+
//pin_ser1_rx -1
109+
//pin_ser1_tx -1
110+
111+
//--- SPI bus 0 ---
112+
//pin_spi0_miso -1
113+
//pin_spi0_mosi -1
114+
//pin_spi0_sclk -1
115+
116+
//--- SPI bus 1 ---
117+
//pin_spi1_miso -1
118+
//pin_spi1_mosi -1
119+
//pin_spi1_sclk -1
120+
121+
//--- I2C Bus 0 ---
122+
//pin_i2c0_sda -1
123+
//pin_i2c0_scl -1
124+
125+
//--- I2C Bus 1 ---
126+
//pin_i2c1_sda -1
127+
//pin_i2c1_scl -1
128+
129+
//--- OUT Pins ---
130+
//pin_out0 -1
131+
//pin_out1 -1
132+
//pin_out2 -1
133+
//pin_out3 -1
134+
//pin_out4 -1
135+
//pin_out5 -1
136+
//pin_out6 -1
137+
//pin_out7 -1
138+
//pin_out8 -1
139+
//pin_out9 -1
140+
//pin_out10 -1
141+
//pin_out11 -1
142+
//pin_out12 -1
143+
//pin_out13 -1
144+
//pin_out14 -1
145+
//pin_out15 -1
146+
147+
)""; // End of madflight_config
148+
149+
150+
//========================================================================================================================//
151+
// COMPILER OPTIONS //
152+
//========================================================================================================================//
153+
154+
// Reset config eeprom to defaults (uncomment this, upload, execute, then comment out, and upload again)
155+
//#define MF_CONFIG_CLEAR
156+
157+
// Uncomment to print additional debug information and reduce startup delay
158+
//#define MF_DEBUG
159+
160+
// Uncomment to enable Lua Scripting
161+
//#define MF_LUA_ENABLE 1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*#########################################################################################################################
2+
3+
"Hello World" for madflight library
4+
5+
Upload, connect Serial Monitor at 115200 baud and send 'help' to see available commands
6+
7+
See http://madflight.com for detailed description
8+
9+
MIT license
10+
Copyright (c) 2023-2025 https://madflight.com
11+
##########################################################################################################################*/
12+
#include <Arduino.h>
13+
14+
#include "madflight_config.h" //Edit this header file to setup the pins, hardware, radio, etc. for madflight
15+
#include <madflight.h>
16+
17+
void setup() {
18+
//setup madflight components: Serial.begin(115200), imu, rcin, led, etc. See src/madflight/interface.h for full interface description of each component.
19+
madflight_setup();
20+
}
21+
22+
void loop() {
23+
rcl.update(); // get rc radio commands
24+
bar.update(); // barometer
25+
mag.update(); // magnetometer
26+
gps.update(); // gps
27+
bat.update(); // battery consumption
28+
rdr.update(); // radar
29+
cli.update(); // process CLI commands
30+
}
31+
32+
//This is __MAIN__ function of this program. It is called when new IMU data is available.
33+
void imu_loop() {
34+
//toggle led on every 1000 samples (normally 1 second)
35+
if(imu.update_cnt % 1000 == 0) led.toggle();
36+
37+
ahr.update(); //Sensor fusion: update ahr.roll, ahr.pitch, and ahr.yaw angle estimates (degrees) from IMU data
38+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
This directory is intended for PlatformIO Test Runner and project tests.
3+
4+
Unit Testing is a software testing method by which individual units of
5+
source code, sets of one or more MCU program modules together with associated
6+
control data, usage procedures, and operating procedures, are tested to
7+
determine whether they are fit for use. Unit testing finds problems early
8+
in the development cycle.
9+
10+
More information about PlatformIO Unit Testing:
11+
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html

src/bbx/BbxGizmoSdspi+Sdmmc_ESP32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class BbxGizmoSdspi : public BbxGizmo {
189189
Serial.print("UNKNOWN");
190190
}
191191
Serial.println();
192-
Serial.printf("SectorSize: %d\n", _BB_SDFS.sectorSize());
192+
//Serial.printf("SectorSize: %d\n", _BB_SDFS.sectorSize()); //'class fs::SDMMCFS' has no member named 'sectorSize'
193193
Serial.printf("CardSize: %lluMB\n", _BB_SDFS.cardSize() / (1024 * 1024));
194194
Serial.printf("used: %lluMB\n", _BB_SDFS.usedBytes()/ (1024 * 1024));
195195
Serial.printf("free: %lluMB\n", (_BB_SDFS.totalBytes() - _BB_SDFS.usedBytes()) / (1024 * 1024));

0 commit comments

Comments
 (0)