mirror of https://github.com/radex/radmatrix.git
move rendering to core1
parent
f46da1e22c
commit
4e877d784a
|
@ -6,7 +6,7 @@
|
||||||
#define AUDIO_PIN 2
|
#define AUDIO_PIN 2
|
||||||
|
|
||||||
#define AUDIO_RATE 44000.0f
|
#define AUDIO_RATE 44000.0f
|
||||||
#define BUFFER_LEN 16384
|
#define BUFFER_LEN 512*32
|
||||||
#define BUFFER_LEN_MS (BUFFER_LEN / AUDIO_RATE) * 1000.0f
|
#define BUFFER_LEN_MS (BUFFER_LEN / AUDIO_RATE) * 1000.0f
|
||||||
|
|
||||||
extern uint8_t wav_buffer_0[BUFFER_LEN];
|
extern uint8_t wav_buffer_0[BUFFER_LEN];
|
||||||
|
|
|
@ -56,34 +56,26 @@ void leds_init() {
|
||||||
// clear output - rows
|
// clear output - rows
|
||||||
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
|
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
|
||||||
pulsePin(ROW_RCLK);
|
pulsePin(ROW_RCLK);
|
||||||
|
|
||||||
/*
|
|
||||||
// launch core1
|
|
||||||
// NOTE: For some reason, without delay, core1 doesn't start?
|
|
||||||
delay(500);
|
|
||||||
multicore_reset_core1();
|
|
||||||
multicore_launch_core1(main2);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void leds_disable() {
|
void leds_disable() {
|
||||||
outputEnable(ROW_OE, false);
|
outputEnable(ROW_OE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void leds_loop() {
|
void main2() {
|
||||||
// game of life step
|
// where we're going, we don't need no interrupts
|
||||||
// auto now = millis();
|
noInterrupts();
|
||||||
// if (now - frameLastChangedAt > 100) {
|
while (true) {
|
||||||
// frameLastChangedAt = now;
|
leds_render();
|
||||||
// life_step();
|
}
|
||||||
// for (int y = 0; y < ROW_COUNT; y++) {
|
}
|
||||||
// for (int x = 0; x < COL_COUNT; x++) {
|
|
||||||
// framebuffer[y * ROW_COUNT + x] = cells[y * ROW_COUNT + x] ? 255 : 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
leds_render();
|
void leds_initRenderer() {
|
||||||
|
// launch core1
|
||||||
|
// NOTE: For some reason, without delay, core1 doesn't start?
|
||||||
|
// delay(500);
|
||||||
|
multicore_reset_core1();
|
||||||
|
multicore_launch_core1(main2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void leds_render() {
|
void leds_render() {
|
||||||
|
@ -153,7 +145,7 @@ void leds_render() {
|
||||||
|
|
||||||
// show for a certain period
|
// show for a certain period
|
||||||
outputEnable(ROW_OE, true);
|
outputEnable(ROW_OE, true);
|
||||||
delayMicroseconds(brightnessPhaseDelays[brightnessPhase]);
|
busy_wait_us_32(brightnessPhaseDelays[brightnessPhase]);
|
||||||
outputEnable(ROW_OE, false);
|
outputEnable(ROW_OE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define MS_PER_FRAME 1000 / FPS
|
#define MS_PER_FRAME 1000 / FPS
|
||||||
|
|
||||||
void leds_init();
|
void leds_init();
|
||||||
|
void leds_initRenderer();
|
||||||
void leds_disable();
|
void leds_disable();
|
||||||
void leds_loop();
|
void leds_loop();
|
||||||
void leds_render();
|
void leds_render();
|
||||||
|
|
|
@ -34,10 +34,12 @@ void setup() {
|
||||||
Serial.println("Failed to load gfx blob");
|
Serial.println("Failed to load gfx blob");
|
||||||
while (true) {}
|
while (true) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leds_initRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
sd_loadNextAudio();
|
// sd_loadNextAudio();
|
||||||
|
|
||||||
// if (Serial.available() > 0) {
|
// if (Serial.available() > 0) {
|
||||||
// char c = Serial.read();
|
// char c = Serial.read();
|
||||||
|
@ -55,6 +57,4 @@ void loop() {
|
||||||
if (!gfx_decoder_handleLoop()) {
|
if (!gfx_decoder_handleLoop()) {
|
||||||
Serial.println("Failed to load frame...");
|
Serial.println("Failed to load frame...");
|
||||||
}
|
}
|
||||||
|
|
||||||
leds_render();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,6 +193,7 @@ void sd_loadNextAudio() {
|
||||||
}
|
}
|
||||||
next_buffer_requested = false;
|
next_buffer_requested = false;
|
||||||
|
|
||||||
|
auto b4 = millis();
|
||||||
auto next_buffer = wav_buffer1_active ? &wav_buffer_0 : &wav_buffer_1;
|
auto next_buffer = wav_buffer1_active ? &wav_buffer_0 : &wav_buffer_1;
|
||||||
auto bytesRead = audioFile.read(next_buffer, BUFFER_LEN);
|
auto bytesRead = audioFile.read(next_buffer, BUFFER_LEN);
|
||||||
|
|
||||||
|
@ -202,7 +203,9 @@ void sd_loadNextAudio() {
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Read ");
|
Serial.print("Read ");
|
||||||
Serial.print(bytesRead);
|
Serial.print(bytesRead);
|
||||||
Serial.println(" bytes from audio file");
|
Serial.print(" bytes from audio file in ");
|
||||||
|
Serial.print(millis() - b4);
|
||||||
|
Serial.println("ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue