From 6cd84f9685aa3569da0bcd1d30eae728d1335413 Mon Sep 17 00:00:00 2001 From: Wastl Kraus Date: Mon, 15 Sep 2025 11:58:56 +0200 Subject: [PATCH] Cosmetics --- examples/web_client/web_client.ino | 353 +------------------------- examples/web_control/web_control.ino | 353 +------------------------- src/DShotRMT.cpp | 10 +- src/DShotRMT.h | 6 +- src/web_content.h | 360 +++++++++++++++++++++++++++ 5 files changed, 370 insertions(+), 712 deletions(-) create mode 100644 src/web_content.h diff --git a/examples/web_client/web_client.ino b/examples/web_client/web_client.ino index e4a3e2f..3bf66f7 100644 --- a/examples/web_client/web_client.ino +++ b/examples/web_client/web_client.ino @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -62,358 +63,6 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp bool connectToWiFi(); void printWiFiStatus(); -// Web Site Content -const char index_html[] PROGMEM = R"rawliteral( - - - - - - - DShotRMT Web Client - - - - -

DShotRMT Web Client

-
- -
-
- ARMING SWITCH - -
-
- DISARMED -
-
- ⚠️ Disabled when disarmed! -
-
- - -
-
0
- -
- -
- RPM: -- -
-
- - - - - - -)rawliteral"; - // void setup() { diff --git a/examples/web_control/web_control.ino b/examples/web_control/web_control.ino index 2b66c8b..5db9332 100644 --- a/examples/web_control/web_control.ino +++ b/examples/web_control/web_control.ino @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -58,358 +59,6 @@ void handleWebSocketMessage(void *arg, uint8_t *data, size_t len); void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len); void setArmingStatus(bool armed); -// Web Site Content -const char index_html[] PROGMEM = R"rawliteral( - - - - - - - DShotRMT Web Client - - - - -

DShotRMT Web Client

-
- -
-
- ARMING SWITCH - -
-
- DISARMED -
-
- ⚠️ Disabled when disarmed! -
-
- - -
-
0
- -
- -
- RPM: -- -
-
- - - - - - -)rawliteral"; - // void setup() { diff --git a/src/DShotRMT.cpp b/src/DShotRMT.cpp index aef9490..de34797 100644 --- a/src/DShotRMT.cpp +++ b/src/DShotRMT.cpp @@ -286,7 +286,7 @@ dshot_result_t DShotRMT::_initTXChannel() dshot_result_t DShotRMT::_initRXChannel() { // Direct RMT symbol processing - Performance optimized - _rx_event_callbacks.on_recv_done = _rmt_rx_done_callback; + _rx_event_callbacks.on_recv_done = _on_rx_done; // Config RMT RX _rx_channel_config.gpio_num = _gpio; @@ -325,7 +325,7 @@ dshot_result_t DShotRMT::_initDShotEncoder() return {false, ENCODER_INIT_FAILED}; } - return {true, TX_INIT_SUCCESS}; + return {true, ENCODER_INIT_SUCCESS}; } // Private Packet Management Functions @@ -474,7 +474,7 @@ dshot_result_t DShotRMT::_sendDShotFrame(const dshot_packet_t &packet) } // Encode DShot packet into RMT symbol format (placed in IRAM for performance) -bool DShotRMT::_encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols) +bool IRAM_ATTR DShotRMT::_encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols) { _parsed_packet = _parseDShotPacket(packet); @@ -541,7 +541,7 @@ uint16_t DShotRMT::_decodeDShotFrame(const rmt_symbol_word_t *symbols) // Private Timing Control Functions // Check if enough time has passed for next transmission -bool DShotRMT::_timer_signal() +bool IRAM_ATTR DShotRMT::_timer_signal() { uint64_t current_time = esp_timer_get_time(); @@ -561,7 +561,7 @@ bool DShotRMT::_timer_reset() // Static Callback Functions // Callback for RMT RX -bool DShotRMT::_rmt_rx_done_callback(rmt_channel_handle_t rmt_rx_channel, const rmt_rx_done_event_data_t *edata, void *user_data) +bool IRAM_ATTR DShotRMT::_on_rx_done(rmt_channel_handle_t rmt_rx_channel, const rmt_rx_done_event_data_t *edata, void *user_data) { DShotRMT *instance = static_cast(user_data); diff --git a/src/DShotRMT.h b/src/DShotRMT.h index 954d354..ad356b0 100644 --- a/src/DShotRMT.h +++ b/src/DShotRMT.h @@ -221,13 +221,13 @@ private: // Private Frame Processing Functions dshot_result_t _sendDShotFrame(const dshot_packet_t &packet); - bool IRAM_ATTR _encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols); + bool _encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols); uint16_t _decodeDShotFrame(const rmt_symbol_word_t *symbols); // Private Timing Control Functions - bool IRAM_ATTR _timer_signal(); + bool _timer_signal(); bool _timer_reset(); // Static Callback Functions - static bool IRAM_ATTR _rmt_rx_done_callback(rmt_channel_handle_t rmt_rx_channel, const rmt_rx_done_event_data_t *edata, void *user_data); + static bool _on_rx_done(rmt_channel_handle_t rmt_rx_channel, const rmt_rx_done_event_data_t *edata, void *user_data); }; diff --git a/src/web_content.h b/src/web_content.h new file mode 100644 index 0000000..5a1bf28 --- /dev/null +++ b/src/web_content.h @@ -0,0 +1,360 @@ +/** + * @file web_content.h + * @brief DShot signal generation using ESP32 RMT with bidirectional support + * @author Wastl Kraus + * @date 2025-09-13 + * @license MIT + */ + +#pragma onve + +// Web Site Content +static constexpr char index_html[] = R"rawliteral( + + + + + + + DShotRMT Web Client + + + + +

DShotRMT Web Client

+
+ +
+
+ ARMING SWITCH + +
+
+ DISARMED +
+
+ ⚠️ Disabled when disarmed! +
+
+ + +
+
0
+ +
+ +
+ RPM: -- +
+
+ + + + + +)rawliteral";