Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"Bash(cpplint:*)",
"Bash(grep:*)",
"Bash(pio test:*)",
"Bash(pio run:*)"
"Bash(pio run:*)",
"Bash(pio --version)",
"Bash(python -c \"import platformio; print\\(platformio.__file__\\)\")"
],
"deny": []
}
Expand Down
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.cpptools-extension-pack",
"pioarduino.pioarduino-ide",
"platformio.platformio-ide"
"pioarduino.pioarduino-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
Expand Down
6 changes: 0 additions & 6 deletions extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
import subprocess

Import("env")
folder = env.GetProjectOption("custom_src_folder")

# Generic
env.Replace(
PROJECT_SRC_DIR="$PROJECT_DIR/src/" + folder
)

def get_git_revision_short_hash():
try:
Expand Down
3 changes: 3 additions & 0 deletions inc/sp140/alert_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ void updateAlertCounterDisplay(const AlertCounts& counts);
// Helper for monitors/UI logger to push alert events
void sendAlertEvent(SensorID id, AlertLevel level);

// Current active alert counts limited to ESC and BMS categories.
AlertCounts getEscBmsAlertCounts();

// ILogger sink that pushes events to the alert queue (for UI)
struct AlertUILogger : ILogger {
void log(SensorID id, AlertLevel lvl, float v) override {
Expand Down
6 changes: 6 additions & 0 deletions inc/sp140/altimeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ float getBaroTemperature();
// Get the pressure in hPa
float getBaroPressure();

// Cached getters — safe to call from any task (atomic float reads on Xtensa).
// Populated by the designated I2C reader (uiTask via getAltitude()).
float getCachedAltitude();
float getCachedBaroTemperature();
float getCachedVerticalSpeed();

#endif // INC_SP140_ALTIMETER_H_
1 change: 1 addition & 0 deletions inc/sp140/ble/ble_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ void requestNormalConnParams();
// Temporarily disable whitelist filtering so a new device can bond.
// Advertising reopens for ~60 seconds then whitelisting is restored.
void enterBLEPairingMode();
bool isBLEPairingModeActive();

#endif // INC_SP140_BLE_BLE_CORE_H_
17 changes: 17 additions & 0 deletions inc/sp140/esc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ inline bool isMotorTempValidC(float tempC) {
#include <SineEsc.h>
#include <CanardAdapter.h>

enum class EscStatusLightMode : uint8_t {
OFF = 0,
DISARMED_NOMINAL,
DISARMED_WARNING,
DISARMED_CRITICAL,
FLIGHT_NOMINAL,
FLIGHT_WARNING,
FLIGHT_CRITICAL,
};

void initESC();
void setESCThrottle(int throttlePWM);
void readESCTelemetry();
Expand Down Expand Up @@ -58,6 +68,13 @@ bool hasMotorIDet2Error(uint16_t errorCode);
bool hasSwHwIncompatError(uint16_t errorCode);
bool hasBootloaderBadError(uint16_t errorCode);

// ESC LED control
void requestEscStatusLightMode(EscStatusLightMode mode);

// ESC motor beep
void queueEscMotorBeepArm();
void queueEscMotorBeepDisarm();

// for debugging
void dumpThrottleResponse(const sine_esc_SetThrottleSettings2Response *res);
void dumpESCMessages(); // dumps all messages to USBSerial
Expand Down
2 changes: 2 additions & 0 deletions inc/sp140/lvgl/lvgl_updates.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,7 @@ void stopCriticalBorderFlashDirect();
// BLE pairing icon flash functions
void startBLEPairingIconFlash();
void stopBLEPairingIconFlash();
void showBLEStatusIcon();
void hideBLEStatusIcon();

#endif // INC_SP140_LVGL_LVGL_UPDATES_H_
28 changes: 10 additions & 18 deletions inc/sp140/utilities.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#ifndef INC_SP140_UTILITIES_H_
#define INC_SP140_UTILITIES_H_

#include <Arduino.h>

// Function to get unique chip ID
String chipId();
#ifndef INC_SP140_UTILITIES_H_
#define INC_SP140_UTILITIES_H_

// Definitions for main rainbow colors in WRGB format for NeoPixel.
// The 32-bit color value is WRGB. W (White) is ignored for RGB pixels.
// The next bytes are R (Red), G (Green), and B (Blue).
// For example, YELLOW is 0x00FFFF00, with FF for Red and Green, and 00 for Blue.
#include <Arduino.h>

#define LED_RED 0x00FF0000
#define LED_ORANGE 0x00FF7F00
#define LED_YELLOW 0x00FFFF00
#define LED_GREEN 0x0000FF00
#define LED_BLUE 0x000000FF
#define LED_INDIGO 0x004B0082
#define LED_VIOLET 0x008000FF
// Function to get unique chip ID
String chipId();

// Controller status LED colors in WRGB format for NeoPixel.
#define STATUS_LED_RED 0x00FF0000
#define STATUS_LED_YELLOW 0x00FFFF00
#define STATUS_LED_GREEN 0x0000FF00

#endif // INC_SP140_UTILITIES_H_
13 changes: 7 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[platformio]
lib_dir = libraries
include_dir = inc
src_dir = src/sp140
default_envs =
OpenPPG-CESP32S3-CAN-SP140

Expand All @@ -27,7 +28,6 @@ framework = arduino, espidf
board_build.f_cpu = 240000000L
board_build.flash_mode = qio
board_build.partitions = default_8MB.csv
custom_src_folder = sp140 ; Used by extra_script.py to rewrite PROJECT_SRC_DIR
; If esptool.py complains about missing intelhex, install into the tool package:
; ~/.platformio/penv/bin/python -m pip install intelhex -t ~/.platformio/packages/tool-esptoolpy
extra_scripts =
Expand All @@ -42,7 +42,8 @@ build_flags =
-D CORE_DEBUG_LEVEL=2
-D CONFIG_ARDUINO_LOOP_STACK_SIZE=8192
-Wno-error=format
-D BLE_PAIR_ON_BOOT
-Wno-error=int-in-bool-context
;-D BLE_PAIR_ON_BOOT
build_type = debug
debug_speed = 12000
debug_tool = esp-builtin
Expand All @@ -58,7 +59,7 @@ lib_deps =
adafruit/Adafruit CAN@0.2.3
adafruit/Adafruit MCP2515@0.2.1
https://github.com/rlogiacco/CircularBuffer@1.4.0
https://github.com/openppg/SINE-ESC-CAN#8caa93996b5d000fe10ca5265bd1c472dfdf885b
https://github.com/openppg/SINE-ESC-CAN#2ab56a4e5b52e4456317c8ee3e3d802b232c6148
https://github.com/openppg/ANT-BMS-CAN#fd54852bc6f1c9608e37af9ca7c13ea4135c095b
lvgl/lvgl@^9.5.0
h2zero/NimBLE-Arduino@^2.3.9
Expand Down Expand Up @@ -105,9 +106,9 @@ build_flags =
-std=c++17
build_src_filter =
-<*>
+<sp140/lvgl/lvgl_main_screen.cpp>
+<sp140/lvgl/lvgl_updates.cpp>
+<sp140/lvgl/lvgl_alerts.cpp>
+<lvgl/lvgl_main_screen.cpp>
+<lvgl/lvgl_updates.cpp>
+<lvgl/lvgl_alerts.cpp>
test_filter = test_screenshots
lib_deps =
lvgl/lvgl@^9.5.0
Loading
Loading