ESP32: emulation heartbeat

This commit is contained in:
folkert van heusden 2024-05-05 02:45:37 +02:00
parent d44667771e
commit b52fe53e3b
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
3 changed files with 28 additions and 7 deletions

View file

@ -61,11 +61,11 @@ void console_esp32::refresh_virtual_terminal()
void console_esp32::panel_update_thread() void console_esp32::panel_update_thread()
{ {
#if !defined(BUILD_FOR_RP2040) && defined(NEOPIXELS_PIN)
Serial.println(F("panel task started")); Serial.println(F("panel task started"));
cpu *const c = b->getCpu(); cpu *const c = b->getCpu();
#if !defined(BUILD_FOR_RP2040) && defined(NEOPIXELS_PIN)
constexpr const uint8_t n_leds = 60; constexpr const uint8_t n_leds = 60;
Adafruit_NeoPixel pixels(n_leds, NEOPIXELS_PIN, NEO_RGBW); Adafruit_NeoPixel pixels(n_leds, NEOPIXELS_PIN, NEO_RGBW);
pixels.begin(); pixels.begin();
@ -142,7 +142,22 @@ void console_esp32::panel_update_thread()
pixels.clear(); pixels.clear();
pixels.show(); pixels.show();
#elif defined(HEARTBEAT_PIN)
uint64_t prev_count = 0;
bool led_state = true;
while(!stop_panel) {
vTaskDelay(333 / portTICK_PERIOD_MS);
uint64_t current_count = c->get_instructions_executed_count();
if (prev_count != current_count) {
prev_count = current_count;
digitalWrite(HEARTBEAT_PIN, led_state ? HIGH : LOW);
led_state = !led_state;
}
}
#endif
Serial.println(F("panel task terminating")); Serial.println(F("panel task terminating"));
#endif
} }

View file

@ -15,5 +15,8 @@
// #define NEOPIXELS_PIN 24 // #define NEOPIXELS_PIN 24
#define HEARTBEAT_PIN LED_BUILTIN
// #define HEARTBEAT_PIN 18
// #define CONSOLE_SERIAL_RX 16 // #define CONSOLE_SERIAL_RX 16
// #define CONSOLE_SERIAL_TX 17 // #define CONSOLE_SERIAL_TX 17

View file

@ -343,7 +343,14 @@ void setup() {
tty_ = new tty(cnsl, b); tty_ = new tty(cnsl, b);
b->add_tty(tty_); b->add_tty(tty_);
#if !defined(BUILD_FOR_RP2040) && defined(NEOPIXELS_PIN) #if !defined(SHA2017)
pinMode(LED_BUILTIN, OUTPUT);
#endif
#if defined(HEARTBEAT_PIN)
pinMode(HEARTBEAT_PIN, OUTPUT);
#endif
#if !defined(BUILD_FOR_RP2040) && (defined(NEOPIXELS_PIN) || defined(HEARTBEAT_PIN))
Serial.println(F("Starting panel")); Serial.println(F("Starting panel"));
xTaskCreate(&console_thread_wrapper_panel, "panel", 3072, cnsl, 1, nullptr); xTaskCreate(&console_thread_wrapper_panel, "panel", 3072, cnsl, 1, nullptr);
#endif #endif
@ -354,10 +361,6 @@ void setup() {
Serial.println(F("")); Serial.println(F(""));
#endif #endif
#if !defined(SHA2017)
pinMode(LED_BUILTIN, OUTPUT);
#endif
Serial.flush(); Serial.flush();
Serial.println(F("* Starting console")); Serial.println(F("* Starting console"));