Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pioarduino support #801

Merged
merged 39 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
611f06b
Reimplement LED blinker to support RGB LEDs
mairas Dec 8, 2024
43ab081
Make the RGB LED blue when connected to SK
mairas Dec 17, 2024
80c2db1
Field removed in esp-idf 5
mairas Dec 15, 2024
fa5070d
Use Arduino analogRead for AnalogReader
mairas Dec 15, 2024
603d7f2
Fix template class constructor syntax
mairas Dec 15, 2024
718c20c
Support MDNS Arduino 3 changes
mairas Dec 15, 2024
78837eb
Support Mbedtls Arduino 3 changes
mairas Dec 15, 2024
598174b
Deprecate PWMOutput
mairas Dec 15, 2024
156b36e
Change neopixelWrite -> rgbLedWrite
mairas Dec 15, 2024
caac6e4
Use the correct call for RGB LED updates
mairas Dec 17, 2024
d1b9f10
Add ESP-IDF managed_components to .gitignore
mairas Dec 15, 2024
b50ebc8
Use pioarduino by default
mairas Dec 13, 2024
31de49f
Add a dependency to the ESP-IDF websocket component
mairas Dec 17, 2024
55d6145
Don't import FastLED in headers
mairas Dec 17, 2024
67f81d4
Rename event_loop_param to avoid a name conflict
mairas Dec 17, 2024
1ecbc69
Explicitly include ArduinoJson
mairas Dec 17, 2024
8581f33
Don't use PWMOutput for system_status_led
mairas Dec 17, 2024
eff8bff
Don't use PWMOutput in rgb_led.*
mairas Dec 17, 2024
2ebaa1a
Adjust default log level
mairas Dec 17, 2024
e3325c0
Adjust default GPIO LED and button macro names
mairas Dec 17, 2024
87ab286
Restructure and comment platformio.ini
mairas Dec 17, 2024
2e56086
Implement CI test matrix
mairas Dec 18, 2024
ac77679
Add ini files for different platforms
mairas Dec 18, 2024
640524f
Use env variables to customize the ini file
mairas Dec 18, 2024
714c8cc
Add command handlers to freertos_tasks example
mairas Dec 18, 2024
ff87ba4
Rename relay_control example to listener
mairas Dec 18, 2024
de1ad56
Add command handlers to minimal_app.cpp
mairas Dec 18, 2024
f9ccd3d
Update the repeat_sensor example
mairas Dec 18, 2024
823c3e6
Provide a default min_spiffs.csv for espard build
mairas Dec 18, 2024
0b2901e
Provide sdkconfig.defaults
mairas Dec 18, 2024
31c0d75
Fix rgb_led and system_status_led Arduino 2 builds
mairas Dec 18, 2024
aafbc78
Remove the esp_websocket_client dependency from library.json
mairas Dec 18, 2024
74363eb
Provide a multi-environment platformio.ini
mairas Dec 18, 2024
e04e555
Make CI build use the default platformio.ini
mairas Dec 18, 2024
e4c9433
Add an 8MB partition map
mairas Dec 18, 2024
e84aecd
Defer the ESP-IDF builds for now
mairas Dec 18, 2024
faa3d5c
Fix the minimal_app example after a failed rebase
mairas Dec 18, 2024
9d444b3
Make ESP32 the default build platform
mairas Dec 18, 2024
1ff708e
Update the example platformio.ini file
mairas Dec 20, 2024
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
37 changes: 20 additions & 17 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@ jobs:
strategy:
matrix:
example:
- examples/minimal_app.cpp
- examples/analog_input.cpp
- examples/hysteresis.cpp
- examples/lambda_transform.cpp
- examples/manual_networking.cpp
- examples/minimal_app.cpp
- examples/relay_control.cpp
- examples/rpm_counter.cpp
- examples/async_repeat_sensor.cpp
- examples/listener.cpp
- examples/repeat_sensor_analog_input.cpp
- examples/freertos_tasks.cpp
- examples/raw_json.cpp
- examples/constant_sensor.cpp
- examples/time_counter.cpp
target_device:
- esp32dev
- examples/rpm_counter.cpp
device:
- esp32
- esp32c3
platform:
- arduino
- pioarduino
# Can't build with espidf until there's a way to copy the
# sdkconfig.defaults file to the correct location in the
# CI build environment.
#- espidf
exclude:
- platform: arduino
device: esp32c3
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
Expand All @@ -42,4 +44,5 @@ jobs:
run: ci/run-ci.sh
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
CI_TARGET_DEVICE: ${{ matrix.target_device }}
CI_DEVICE: ${{ matrix.device }}
CI_PLATFORM: ${{ matrix.platform }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
docs/Gemfile.lock
docs/.bundle
docs/_site
managed_components
23 changes: 0 additions & 23 deletions ci/platformio-esp32dev.ini

This file was deleted.

7 changes: 2 additions & 5 deletions ci/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ set -euo pipefail

# assume this command is always run from the project root directory

PROJDIR=$(pwd)

# replace the
sed -e "s|\${PROJDIR}|$PROJDIR|" ci/platformio-${CI_TARGET_DEVICE}.ini > ci/platformio.ini
export PROJDIR=$(pwd)

# the example to build comes from $PLATFORMIO_CI_SRC

pio ci -c ci/platformio.ini
pio ci -e ${CI_PLATFORM}_${CI_DEVICE} --project-conf platformio.ini --lib . --exclude examples --exclude docs --exclude .pio
7 changes: 7 additions & 0 deletions default_8MB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x330000,
app1, app, ota_1, 0x340000,0x330000,
spiffs, data, spiffs, 0x670000,0x180000,
coredump, data, coredump,0x7F0000,0x10000,
10 changes: 10 additions & 0 deletions examples/freertos_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "sensesp/net/discovery.h"
#include "sensesp/net/http_server.h"
#include "sensesp/net/networking.h"
#include "sensesp/net/web/app_command_handler.h"
#include "sensesp/net/web/base_command_handler.h"
#include "sensesp/net/web/config_handler.h"
#include "sensesp/net/web/static_file_handler.h"
#include "sensesp/sensors/digital_input.h"
#include "sensesp/signalk/signalk_delta_queue.h"
#include "sensesp/signalk/signalk_output.h"
Expand Down Expand Up @@ -41,6 +45,12 @@ void setup() {
auto networking = std::make_shared<Networking>("/system/networking", "", "");
auto http_server = std::make_shared<HTTPServer>();

// Add the default HTTP server response handlers
add_static_file_handlers(http_server);
add_base_app_http_command_handlers(http_server);
add_app_http_command_handlers(http_server, networking);
add_config_handlers(http_server);

// create the SK delta object
auto sk_delta_queue_ = std::make_shared<SKDeltaQueue>();

Expand Down
File renamed without changes.
99 changes: 56 additions & 43 deletions examples/minimal_app.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#include <math.h>

#include "sensesp/net/http_server.h"
#include "sensesp/net/networking.h"
#include "sensesp/net/web/app_command_handler.h"
#include "sensesp/net/web/base_command_handler.h"
#include "sensesp/net/web/config_handler.h"
#include "sensesp/net/web/static_file_handler.h"
#include "sensesp/signalk/signalk_delta_queue.h"
#include "sensesp/signalk/signalk_ws_client.h"
#include "sensesp/system/button.h"
#include "sensesp/sensors/digital_input.h"
#include "sensesp/transforms/lambda_transform.h"
#include "sensesp/transforms/linear.h"
#include "sensesp/transforms/typecast.h"
#include "sensesp_minimal_app_builder.h"

using namespace sensesp;

const unsigned int read_delay = 500;

constexpr int input_pin1 = 15;
constexpr int input_pin2 = 13;
constexpr int output_pin1 = 18;
constexpr int output_pin2 = 21;

// This is a sample program to demonstrate how to instantiate a
// SensESPMinimalApp application and only enable some required components
// explicitly.
Expand All @@ -26,46 +36,49 @@ void setup() {
SensESPMinimalAppBuilder builder;
auto sensesp_app = builder.set_hostname("counter-test")->get_app();

auto button_handler = std::make_shared<ButtonHandler>(0);

// As an example, we'll connect to WiFi manually using the Arduino ESP32 WiFi
// library instead of using the SensESP Networking class.

WiFi.mode(WIFI_STA); // Optional
WiFi.begin("ssid", "password");
Serial.println("\nConnecting");

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}

Serial.println("\nConnected to the WiFi network");
Serial.print("Local ESP32 IP: ");
Serial.println(WiFi.localIP());

// Initiate the objects you need for your application here. Have a look
// at sensesp_app.h and pick the necessary items from there.

// create the SK delta queue
auto sk_delta_queue = std::make_shared<SKDeltaQueue>();

// Use this if you want to hardcode the Signal K server address
String sk_server_address = "openplotter.local";
// Use this if you want to hardcode the Signal K server port
uint16_t sk_server_port = 3000;
// Set this to true if you want to use mDNS to discover the Signal K server
bool use_mdns = false;

auto ws_client =
std::make_shared<SKWSClient>("/System/Signal K Settings", sk_delta_queue,
sk_server_address, sk_server_port, use_mdns);

// To avoid garbage collecting all shared pointers
// created in setup(), loop from here.
while (true) {
loop();
}
// manually create Networking and HTTPServer objects to enable
// the HTTP configuration interface

auto networking = std::make_shared<Networking>("/system/networking", "", "");
auto http_server = std::make_shared<HTTPServer>();

// Add the default HTTP server response handlers
add_static_file_handlers(http_server);
add_base_app_http_command_handlers(http_server);
add_app_http_command_handlers(http_server, networking);
add_config_handlers(http_server);

auto digin1 = std::make_shared<DigitalInputCounter>(input_pin1, INPUT, RISING,
read_delay);
auto digin2 = std::make_shared<DigitalInputCounter>(input_pin2, INPUT, CHANGE,
read_delay);

auto scaled1 = std::make_shared<Linear>(2, 1, "/digin1/scale");
auto scaled2 = std::make_shared<Linear>(4, -1, "/digin2/scale");
digin1->connect_to(scaled1);

auto lambda_transform1 =
std::make_shared<LambdaTransform<int, int>>([](int input) {
Serial.printf("millis: %d\n", millis());
Serial.printf("Counter 1: %d\n", input);
return input;
});
scaled1->connect_to(lambda_transform1);
auto lambda_transform2 =
std::make_shared<LambdaTransform<int, int>>([](int input) {
Serial.printf("Counter 2: %d\n", input);
return input;
});

digin2->connect_to(scaled2)->connect_to(lambda_transform2);

pinMode(output_pin1, OUTPUT);
event_loop()->onRepeat(
5, []() { digitalWrite(output_pin1, !digitalRead(output_pin1)); });

pinMode(output_pin2, OUTPUT);
event_loop()->onRepeat(
100, []() { digitalWrite(output_pin2, !digitalRead(output_pin2)); });
}

void loop() { event_loop()->tick(); }
Loading
Loading