forked from zjwhitehead/eppg-controller
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from openppg/develop/free-rtos
Rewrite threading to use FreeRTOS
- Loading branch information
Showing
17 changed files
with
725 additions
and
738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef INC_SP140_ALTIMETER_H_ | ||
#define INC_SP140_ALTIMETER_H_ | ||
|
||
#include <Arduino.h> | ||
|
||
#include "sp140/structs.h" | ||
|
||
// Set up the barometer | ||
void setupAltimeter(); | ||
|
||
// Get the altitude (in meters) | ||
float getAltitude(const STR_DEVICE_DATA_140_V1& deviceData); | ||
|
||
// Set the ground altitude to the current altitude to compute AGL | ||
void setGroundAltitude(const STR_DEVICE_DATA_140_V1& deviceData); | ||
|
||
#endif // INC_SP140_ALTIMETER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifndef INC_SP140_DISPLAY_H_ | ||
#define INC_SP140_DISPLAY_H_ | ||
|
||
#include <Arduino.h> | ||
|
||
#include "sp140/structs.h" | ||
#include <Adafruit_ST7735.h> | ||
#include "utilities.h" | ||
|
||
// Library config | ||
#define NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY | ||
|
||
#define BLACK ST77XX_BLACK | ||
#define WHITE ST77XX_WHITE | ||
#define GREEN ST77XX_GREEN | ||
#define YELLOW ST77XX_YELLOW | ||
#define RED ST77XX_RED | ||
#define BLUE ST77XX_BLUE | ||
#define ORANGE ST77XX_ORANGE | ||
#define CYAN ST77XX_CYAN | ||
#define PURPLE 0x780F | ||
#define GRAY 0xDEFB | ||
|
||
// Light mode (default) | ||
// #define DEFAULT_TEXT_COLOR BLACK | ||
// #define ERROR_TEXT_COLOR RED | ||
// #define CHILL_TEXT_COLOR CYAN | ||
|
||
// #define DEFAULT_BG_COLOR WHITE | ||
// #define ARMED_BG_COLOR CYAN | ||
// #define CRUISE_BG_COLOR YELLOW | ||
// #define UI_ACCENT_COLOR BLACK | ||
|
||
// Dark mode | ||
// #define DEFAULT_TEXT_COLOR WHITE | ||
// #define ERROR_TEXT_COLOR RED | ||
// #define CHILL_TEXT_COLOR CYAN | ||
|
||
// #define DEFAULT_BG_COLOR BLACK | ||
// #define ARMED_BG_COLOR BLUE | ||
// #define CRUISE_BG_COLOR ORANGE | ||
// #define UI_ACCENT_COLOR GRAY | ||
|
||
struct UIColors { | ||
uint16_t default_text; | ||
uint16_t error_text; | ||
uint16_t chill_text; | ||
uint16_t default_bg; | ||
uint16_t armed_bg; | ||
uint16_t cruise_bg; | ||
uint16_t ui_accent; | ||
}; | ||
|
||
extern float watts; | ||
extern float wattHoursUsed; | ||
|
||
// Set up the display and show splash screen | ||
void setupDisplay(const STR_DEVICE_DATA_140_V1& deviceData); | ||
|
||
void displayMeta(const STR_DEVICE_DATA_140_V1& deviceData, int duration = 2000); | ||
|
||
// Clear screen and reset properties | ||
void resetRotation(unsigned int orientation); | ||
|
||
// Show data on screen | ||
void updateDisplay(const STR_DEVICE_DATA_140_V1& deviceData, | ||
const STR_ESC_TELEMETRY_140& escTelemetry, | ||
float altitude, bool armed, bool cruising, | ||
unsigned int armedStartMillis); | ||
|
||
void setTheme(int theme); // 0,1 | ||
|
||
#endif // INC_SP140_DISPLAY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef INC_SP140_UTILITIES_H_ | ||
#define INC_SP140_UTILITIES_H_ | ||
|
||
double mapd(double x, double in_min, double in_max, double out_min, double out_max); | ||
|
||
#endif // INC_SP140_UTILITIES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
libr_dir = libraries | ||
include_dir = inc | ||
default_envs = | ||
OpenPPG-CM0-SP140 | ||
;OpenPPG-CM0-SP140 ; not currently supported | ||
OpenPPG-CRP2040-SP140 | ||
|
||
[extra] | ||
|
@@ -46,7 +46,7 @@ lib_ignore = | |
${extra.lib_ignore} | ||
|
||
[env:OpenPPG-CRP2040-SP140] | ||
platform = https://github.com/openppg/platform-raspberrypi.git#190d06ec0ece2f38031389c8b5eccf2bd3d349e9 | ||
platform = https://github.com/openppg/platform-raspberrypi.git#d558b307a404efbfc4282ce9e61d16f338f1c172 | ||
board = sparkfun_promicrorp2040 | ||
framework = arduino | ||
board_build.core = earlephilhower | ||
|
@@ -58,17 +58,16 @@ board_build.filesystem_size = 14M ; 14 Mbyte for filesystem and 2 Mbyte for prog | |
src_folder = sp140 | ||
extra_scripts = pre:extra_script.py | ||
lib_deps = | ||
[email protected] | ||
[email protected] | ||
[email protected] ; deprecated | ||
[email protected] | ||
[email protected] | ||
[email protected] ; deprecated | ||
[email protected] | ||
adafruit/Adafruit [email protected] | ||
adafruit/Adafruit BMP3XX [email protected] | ||
adafruit/Adafruit DRV2605 [email protected] | ||
adafruit/Adafruit ST7735 and ST7789 Library@1.9.3 | ||
adafruit/Adafruit ST7735 and ST7789 Library@1.10.2 | ||
https://github.com/rlogiacco/CircularBuffer | ||
Adafruit GFX [email protected].5 | ||
Adafruit GFX [email protected].7 | ||
lib_ignore = | ||
Adafruit SleepyDog Library | ||
${extra.lib_ignore} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "sp140/altimeter.h" | ||
#include "sp140/structs.h" | ||
|
||
#include <Adafruit_BMP3XX.h> | ||
|
||
Adafruit_BMP3XX bmp; | ||
bool bmpPresent = false; | ||
float groundAltitude = 0; | ||
|
||
float getAltitude(const STR_DEVICE_DATA_140_V1& deviceData) { | ||
if (bmpPresent) { | ||
const float altitude = bmp.readAltitude(deviceData.sea_pressure); | ||
return altitude - groundAltitude; | ||
} | ||
return __FLT_MIN__; | ||
} | ||
|
||
// set the ground altitude to the current altitude | ||
void setGroundAltitude(const STR_DEVICE_DATA_140_V1& deviceData) { | ||
groundAltitude = bmp.readAltitude(deviceData.sea_pressure); | ||
} | ||
|
||
// Start the bmp388 sensor | ||
void setupAltimeter() { | ||
if (!bmp.begin_I2C()) return; | ||
bmp.setOutputDataRate(BMP3_ODR_25_HZ); | ||
bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_2X); | ||
bmp.setPressureOversampling(BMP3_OVERSAMPLING_4X); | ||
bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_15); | ||
bmp.readPressure(); // throw away first reading | ||
bmpPresent = true; | ||
} |
Oops, something went wrong.