From ab1584d73fa095f0d2bc0aeb07c2a1754c6a77af Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 17 Mar 2022 22:52:22 +0100 Subject: [PATCH] panel blinkenlights (poc with 1 neopixel) --- ESP32/main.ino | 43 +++++++++++++++++++++++++++++++++++-------- ESP32/platformio.ini | 1 + 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/ESP32/main.ino b/ESP32/main.ino index d6c8924..4af7cab 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -1,5 +1,6 @@ // (C) 2018-2022 by Folkert van Heusden // Released under Apache License v2.0 +#include #include #include @@ -10,17 +11,17 @@ #include "error.h" -bus *b = nullptr; -cpu *c = nullptr; +#define NEOPIXELS_PIN 27 +bus *b = nullptr; +cpu *c = nullptr; tty *tty_ = nullptr; uint16_t exec_addr = 0; -uint32_t start_ts = 0; +uint32_t start_ts = 0; -void setBootLoader(bus *const b) -{ - cpu *const c = b->getCpu(); +void setBootLoader(bus *const b) { + cpu *const c = b->getCpu(); const uint16_t offset = 01000; @@ -41,6 +42,25 @@ void setBootLoader(bus *const b) c->setRegister(7, offset); } + +void panel(void *p) { + bus *const b = reinterpret_cast(p); + cpu *const c = b->getCpu(); + + CRGB leds[1]; // FIXME 1: aantal leds, zie ook v + FastLED.addLeds(leds, 1); + + for(;;) { + vTaskDelay(100 / portTICK_RATE_MS); + + uint16_t current_pc = c->getPC(); + + leds[0] = current_pc & (1 << 5) ? CRGB::Red : CRGB::Black; + + FastLED.show(); + } +} + void setup() { Serial.begin(115200); @@ -49,10 +69,10 @@ void setup() { Serial.print(F("Size of int: ")); Serial.println(sizeof(int)); - Serial.print(F("CPU clock frequency: ")); + Serial.print(F("CPU clock frequency (MHz): ")); Serial.println(getCpuFrequencyMhz()); - Serial.print(F("Free RAM before init: ")); + Serial.print(F("Free RAM before init (decimal bytes): ")); Serial.println(ESP.getFreeHeap()); Serial.println(F("Init bus")); @@ -80,6 +100,13 @@ void setup() { pinMode(LED_BUILTIN, OUTPUT); + Serial.flush(); + + Serial.print(F("Starting panel (on CPU 0, main emulator runs on CPU ")); + Serial.print(xPortGetCoreID()); + Serial.println(F(")")); + xTaskCreatePinnedToCore(&panel, "panel", 2048, b, 5, nullptr, 0); + Serial.println(F("Press to start")); for(;;) { diff --git a/ESP32/platformio.ini b/ESP32/platformio.ini index 973b77f..f4f2b04 100644 --- a/ESP32/platformio.ini +++ b/ESP32/platformio.ini @@ -15,5 +15,6 @@ framework = arduino monitor_speed = 115200 upload_speed = 1000000 lib_deps = greiman/SdFat@^2.1.2 + fastled/FastLED@^3.5.0 build_flags = -std=c++14 -Ofast -DESP32=1 build_unflags = -std=gnu++11 -Os