Skip to content

Commit 7c6466b

Browse files
committed
Module IO readpins ethernet bugfix ethernetservice class
1 parent 4daa951 commit 7c6466b

File tree

4 files changed

+46
-45
lines changed

4 files changed

+46
-45
lines changed

firmware/esp32-p4.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ upload_speed = 921600
2727
; monitor_speed = 115200
2828
build_flags = ${esp32-p4-base.build_flags}
2929
-Wl,-wrap,esp_dma_capable_malloc ;; makes SDIO for ESP-Hosted use PSRAM if available.
30-
; -D FT_ETHERNET=1 ; 🚧 not implemented yet
3130

3231
lib_deps = ${esp32-p4-base.lib_deps}
3332
; RAM: [= ] 11.2% (used 36580 bytes from 327680 bytes)

firmware/esp32-s3.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ board_build.extra_flags =
7777
-DBOARD_HAS_PSRAM
7878
build_flags = ${esp32-s3-base.build_flags}
7979
-D LOLIN_WIFI_FIX ; some boards have wifi issues if this is not defined, this sets WIFI_POWER_8_5dBm
80-
; -D FT_ETHERNET=1 ; 🚧 not implemented yet
8180
; -D USE_M5UNIFIED=1 ;for MoonManEffect (but low on heap) crashes on this board
8281
lib_deps = ${esp32-s3-base.lib_deps}
8382
; m5stack/M5Unified ;for MoonManEffect (but low on heap)

src/MoonBase/Modules/ModuleIO.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ enum IO_Boards {
104104

105105
class ModuleIO : public Module {
106106
public:
107+
ESP32SvelteKit* _sveltekit;
108+
107109
ModuleIO(PsychicHttpServer* server, ESP32SvelteKit* sveltekit) : Module("inputoutput", server, sveltekit) {
108110
EXT_LOGV(MB_TAG, "constructor");
109111

110112
// #if CONFIG_IDF_TARGET_ESP32
111113
// pinMode(19, OUTPUT); digitalWrite(19, HIGH); // for serg shield boards: to be done: move to new pin manager module, switch off for S3!!!! tbd: add pin manager
112114
// #endif
113115

114-
addUpdateHandler([&](const String& originId) { readPins(sveltekit); }, false);
116+
_sveltekit = sveltekit;
117+
118+
addUpdateHandler([&](const String& originId) { readPins(); }, false);
115119
}
116120

117121
void setupDefinition(const JsonArray& controls) override {
@@ -476,15 +480,11 @@ class ModuleIO : public Module {
476480
}
477481
}
478482

479-
void readPins(ESP32SvelteKit* sveltekit) {
483+
void readPins() {
484+
#if FT_ENABLED(FT_ETHERNET)
480485
EXT_LOGD(MB_TAG, "Try to configure ethernet");
481-
EthernetSettingsService* ess = sveltekit->getEthernetSettingsService();
482-
if ((uintptr_t)ess < 0x3FC00000) {
483-
EXT_LOGW(MB_TAG, "EthernetSettingsService not available");
484-
EXT_LOGW(MB_TAG, "ESS PTR = %p\n", (void*)ess);
485-
return;
486-
}
487-
#ifdef CONFIG_IDF_TARGET_ESP32S3
486+
EthernetSettingsService* ess = _sveltekit->getEthernetSettingsService();
487+
#ifdef CONFIG_IDF_TARGET_ESP32S3
488488
ess->v_ETH_SPI_SCK = UINT8_MAX;
489489
ess->v_ETH_SPI_MISO = UINT8_MAX;
490490
ess->v_ETH_SPI_MOSI = UINT8_MAX;
@@ -494,7 +494,7 @@ class ModuleIO : public Module {
494494
// find the pins needed
495495
for (JsonObject pinObject : _state.data["pins"].as<JsonArray>()) {
496496
uint8_t usage = pinObject["usage"];
497-
uint8_t gpio = pinObject["GPIO"];
497+
uint8_t gpio = pinObject["GPIO"];
498498
if (usage == pin_SPI_SCK) ess->v_ETH_SPI_SCK = gpio;
499499
if (usage == pin_SPI_MISO) ess->v_ETH_SPI_MISO = gpio;
500500
if (usage == pin_SPI_MOSI) ess->v_ETH_SPI_MOSI = gpio;
@@ -509,6 +509,7 @@ class ModuleIO : public Module {
509509
ess->v_ETH_PHY_RST = -1; // not wired
510510
ess->initEthernet(); // restart ethernet
511511
}
512+
#endif
512513
#endif
513514
}
514515
};

src/MoonLight/Nodes/Drivers/D_Infrared.h

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,46 @@ class IRDriver : public Node {
3939

4040
void readPins() {
4141
moduleIO->read([&](ModuleState& state) {
42+
pinInfrared = UINT8_MAX;
4243
for (JsonObject pinObject : state.data["pins"].as<JsonArray>()) {
4344
uint8_t usage = pinObject["usage"];
4445
if (usage == pin_Infrared) {
45-
pinInfrared = pinObject["GPIO"].as<uint8_t>();
46+
pinInfrared = pinObject["GPIO"];
4647
EXT_LOGD(ML_TAG, "pin_Infrared found %d", pinInfrared);
48+
}
49+
}
50+
if (pinInfrared != UINT8_MAX) {
51+
EXT_LOGI(IR_DRIVER_TAG, "Changing to pin #%d", pinInfrared);
52+
53+
if (rx_channel) {
54+
EXT_LOGI(IR_DRIVER_TAG, "Removing callback");
55+
ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_channel, &cbs_empty, receive_queue));
56+
EXT_LOGI(IR_DRIVER_TAG, "Stopping RMT reception");
57+
ESP_ERROR_CHECK(rmt_disable(rx_channel));
58+
EXT_LOGI(IR_DRIVER_TAG, "Deleting old RX channel");
59+
ESP_ERROR_CHECK(rmt_del_channel(rx_channel));
60+
rx_channel = NULL;
61+
}
4762

48-
EXT_LOGI(IR_DRIVER_TAG, "Changing to pin #%d", pinInfrared);
49-
50-
if (rx_channel) {
51-
EXT_LOGI(IR_DRIVER_TAG, "Removing callback");
52-
ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_channel, &cbs_empty, receive_queue));
53-
EXT_LOGI(IR_DRIVER_TAG, "Stopping RMT reception");
54-
ESP_ERROR_CHECK(rmt_disable(rx_channel));
55-
EXT_LOGI(IR_DRIVER_TAG, "Deleting old RX channel");
56-
ESP_ERROR_CHECK(rmt_del_channel(rx_channel));
57-
rx_channel = NULL;
58-
}
59-
60-
if (receive_queue) {
61-
vQueueDelete(receive_queue);
62-
receive_queue = NULL;
63-
}
64-
65-
rx_channel_cfg.gpio_num = (gpio_num_t)pinInfrared;
66-
EXT_LOGI(IR_DRIVER_TAG, "create RMT RX channel");
67-
ESP_ERROR_CHECK(rmt_new_rx_channel(&rx_channel_cfg, &rx_channel));
68-
69-
EXT_LOGI(IR_DRIVER_TAG, "Enable RMT RX channel");
70-
ESP_ERROR_CHECK(rmt_enable(rx_channel));
71-
72-
EXT_LOGI(IR_DRIVER_TAG, "Register RX done callback");
73-
receive_queue = xQueueCreate(1, sizeof(rmt_rx_done_event_data_t));
74-
assert(receive_queue);
75-
ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_channel, &cbs, receive_queue));
76-
77-
EXT_LOGI(IR_DRIVER_TAG, "Arm receive");
78-
ESP_ERROR_CHECK(rmt_receive(rx_channel, raw_symbols, sizeof(raw_symbols), &receive_config));
63+
if (receive_queue) {
64+
vQueueDelete(receive_queue);
65+
receive_queue = NULL;
7966
}
67+
68+
rx_channel_cfg.gpio_num = (gpio_num_t)pinInfrared;
69+
EXT_LOGI(IR_DRIVER_TAG, "create RMT RX channel");
70+
ESP_ERROR_CHECK(rmt_new_rx_channel(&rx_channel_cfg, &rx_channel));
71+
72+
EXT_LOGI(IR_DRIVER_TAG, "Enable RMT RX channel");
73+
ESP_ERROR_CHECK(rmt_enable(rx_channel));
74+
75+
EXT_LOGI(IR_DRIVER_TAG, "Register RX done callback");
76+
receive_queue = xQueueCreate(1, sizeof(rmt_rx_done_event_data_t));
77+
assert(receive_queue);
78+
ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_channel, &cbs, receive_queue));
79+
80+
EXT_LOGI(IR_DRIVER_TAG, "Arm receive");
81+
ESP_ERROR_CHECK(rmt_receive(rx_channel, raw_symbols, sizeof(raw_symbols), &receive_config));
8082
}
8183
// for (int i = 0; i < sizeof(pins); i++) EXT_LOGD(ML_TAG, "pin %d = %d", i, pins[i]);
8284
});
@@ -405,7 +407,7 @@ class IRDriver : public Node {
405407
void loop() override {
406408
if (receive_queue) {
407409
if (xQueueReceive(receive_queue, &rx_data, 0) == pdPASS) {
408-
if (rx_data.num_symbols != 1) EXT_LOGD(IR_DRIVER_TAG, "Received symbols: #%d", rx_data.num_symbols); // will not be processed (only 34 and 2)
410+
if (rx_data.num_symbols != 1) EXT_LOGD(IR_DRIVER_TAG, "Received symbols: #%d", rx_data.num_symbols); // will not be processed (only 34 and 2)
409411
// parse the receive symbols and print the result
410412
parse_nec_frame(rx_data.received_symbols, rx_data.num_symbols);
411413
// start receive again

0 commit comments

Comments
 (0)