panel blinkenlights (poc with 1 neopixel)

This commit is contained in:
folkert van heusden 2022-03-17 22:52:22 +01:00
parent 378d4a620f
commit ab1584d73f
2 changed files with 36 additions and 8 deletions

View file

@ -1,5 +1,6 @@
// (C) 2018-2022 by Folkert van Heusden // (C) 2018-2022 by Folkert van Heusden
// Released under Apache License v2.0 // Released under Apache License v2.0
#include <FastLED.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -10,6 +11,7 @@
#include "error.h" #include "error.h"
#define NEOPIXELS_PIN 27
bus *b = nullptr; bus *b = nullptr;
cpu *c = nullptr; cpu *c = nullptr;
tty *tty_ = nullptr; tty *tty_ = nullptr;
@ -18,8 +20,7 @@ uint16_t exec_addr = 0;
uint32_t start_ts = 0; uint32_t start_ts = 0;
void setBootLoader(bus *const b) void setBootLoader(bus *const b) {
{
cpu *const c = b->getCpu(); cpu *const c = b->getCpu();
const uint16_t offset = 01000; const uint16_t offset = 01000;
@ -41,6 +42,25 @@ void setBootLoader(bus *const b)
c->setRegister(7, offset); c->setRegister(7, offset);
} }
void panel(void *p) {
bus *const b = reinterpret_cast<bus *>(p);
cpu *const c = b->getCpu();
CRGB leds[1]; // FIXME 1: aantal leds, zie ook v
FastLED.addLeds<NEOPIXEL, NEOPIXELS_PIN>(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() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@ -49,10 +69,10 @@ void setup() {
Serial.print(F("Size of int: ")); Serial.print(F("Size of int: "));
Serial.println(sizeof(int)); Serial.println(sizeof(int));
Serial.print(F("CPU clock frequency: ")); Serial.print(F("CPU clock frequency (MHz): "));
Serial.println(getCpuFrequencyMhz()); 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(ESP.getFreeHeap());
Serial.println(F("Init bus")); Serial.println(F("Init bus"));
@ -80,6 +100,13 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT); 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 <enter> to start")); Serial.println(F("Press <enter> to start"));
for(;;) { for(;;) {

View file

@ -15,5 +15,6 @@ framework = arduino
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 1000000 upload_speed = 1000000
lib_deps = greiman/SdFat@^2.1.2 lib_deps = greiman/SdFat@^2.1.2
fastled/FastLED@^3.5.0
build_flags = -std=c++14 -Ofast -DESP32=1 build_flags = -std=c++14 -Ofast -DESP32=1
build_unflags = -std=gnu++11 -Os build_unflags = -std=gnu++11 -Os