Skip to content
Draft
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(openppg_controller)
62 changes: 31 additions & 31 deletions inc/sp140/altimeter.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#ifndef INC_SP140_ALTIMETER_H_
#define INC_SP140_ALTIMETER_H_
#include <Arduino.h>
#include <CircularBuffer.hpp>
#include "sp140/structs.h"
#include "sp140/shared-config.h"
// Constants
#define VARIO_BUFFER_SIZE 25 // Number of samples to average for vertical speed
#define MAX_VERTICAL_SPEED 250.0f // Maximum vertical speed to display (m/s)
// Set up the barometer
bool setupAltimeter(bool alt_wire = false);
// Get the altitude (in meters)
float getAltitude(const STR_DEVICE_DATA_140_V1& deviceData);
// Get the vertical speed in meters per second
float getVerticalSpeed();
// Set the ground altitude to the current altitude to compute AGL
void setGroundAltitude(const STR_DEVICE_DATA_140_V1& deviceData);
// Get the temperature in degrees Celsius
float getBaroTemperature();
// Get the pressure in hPa
float getBaroPressure();
#endif // INC_SP140_ALTIMETER_H_
#ifndef INC_SP140_ALTIMETER_H_
#define INC_SP140_ALTIMETER_H_

#include <Arduino.h>
#include <CircularBuffer.hpp>
#include "sp140/structs.h"
#include "sp140/shared-config.h"

// Constants
#define VARIO_BUFFER_SIZE 25 // Number of samples to average for vertical speed
#define MAX_VERTICAL_SPEED 250.0f // Maximum vertical speed to display (m/s)

// Set up the barometer
bool setupAltimeter();

// Get the altitude (in meters)
float getAltitude(const STR_DEVICE_DATA_140_V1& deviceData);

// Get the vertical speed in meters per second
float getVerticalSpeed();

// Set the ground altitude to the current altitude to compute AGL
void setGroundAltitude(const STR_DEVICE_DATA_140_V1& deviceData);

// Get the temperature in degrees Celsius
float getBaroTemperature();

// Get the pressure in hPa
float getBaroPressure();

#endif // INC_SP140_ALTIMETER_H_
7 changes: 7 additions & 0 deletions inc/sp140/ble/ble_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@
#define CONTROLLER_SERVICE_UUID "01C63B60-0891-4655-BBCA-8E745C48A175"
#define CONTROLLER_TELEMETRY_UUID "01C63B61-0891-4655-BBCA-8E745C48A176"

// Espressif Standard OTA Service UUIDs (Android esp-ble-ota-android app)
static const NimBLEUUID OTA_SERVICE_UUID("00008018-0000-1000-8000-00805f9b34fb");
static const NimBLEUUID OTA_RECV_FW_UUID("00008020-0000-1000-8000-00805f9b34fb"); // Firmware data (Write/Indicate)
static const NimBLEUUID OTA_PROGRESS_UUID("00008021-0000-1000-8000-00805f9b34fb"); // Progress (Indicate)
static const NimBLEUUID OTA_COMMAND_UUID("00008022-0000-1000-8000-00805f9b34fb"); // Command (Write/Indicate)
static const NimBLEUUID OTA_CUSTOMER_UUID("00008023-0000-1000-8000-00805f9b34fb"); // Customer (Indicate)

#endif // INC_SP140_BLE_BLE_IDS_H_
18 changes: 18 additions & 0 deletions inc/sp140/ble/ota_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef INC_SP140_BLE_OTA_SERVICE_H_
#define INC_SP140_BLE_OTA_SERVICE_H_

#include <NimBLEDevice.h>

/**
* Initialize the OTA BLE service.
* @param pServer Pointer to the NimBLEServer instance.
*/
void initOtaBleService(NimBLEServer* pServer);

/**
* Check if an OTA update is currently in progress.
* @return true if OTA is active (should pause other tasks)
*/
bool isOtaInProgress();

#endif // INC_SP140_BLE_OTA_SERVICE_H_
1 change: 1 addition & 0 deletions inc/sp140/bms.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ extern STR_BMS_TELEMETRY_140 bmsTelemetryData;
extern BMS_CAN* bms_can;

// BMS functions
bool initBMSCAN(SPIClass* spi);
void updateBMSData();
void printBMSData();
17 changes: 17 additions & 0 deletions inc/sp140/device_settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef INC_SP140_DEVICE_SETTINGS_H_
#define INC_SP140_DEVICE_SETTINGS_H_

#include "structs.h"
#include "esp32s3-config.h"

// Constants
extern const unsigned int DEFAULT_SCREEN_ROTATION;
void refreshDeviceData();
void writeDeviceData();
void resetDeviceData();
void parse_serial_commands();
void send_device_data();
bool sanitizeDeviceData();
void debugHardwareConfig(const HardwareConfig& config);

#endif // INC_SP140_DEVICE_SETTINGS_H_
6 changes: 6 additions & 0 deletions partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, , 0x4000,
otadata, data, ota, , 0x2000,
app0, app, ota_0, , 3M,
app1, app, ota_1, , 3M,
spiffs, data, spiffs, , 1500K,
7 changes: 5 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ lib_ignore =
[env:OpenPPG-CESP32S3-CAN-SP140]
platform = espressif32@6.12.0
board = m5stack-stamps3
framework = arduino
src_folder = sp140
framework = arduino, espidf
board_build.partitions = partitions.csv
src_folder = sp140 ; Commented out as we are using standard src structure
; 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 @@ -38,6 +39,8 @@ build_flags =
-D LV_LVGL_H_INCLUDE_SIMPLE
; Disable legacy individual BLE characteristics (use packed binary only)
-D DISABLE_LEGACY_BLE_TELEMETRY
-D CONFIG_ARDUINO_LOOP_STACK_SIZE=8192
-Wno-error=format

build_type = debug
debug_speed = 12000
Expand Down
Loading