FIX: Buffer overflow: Mode::timers
This commit is contained in:
parent
c562c7d932
commit
d53d60fb2c
@ -8,7 +8,6 @@
|
||||
#include "mode/NewYear/NewYear.h"
|
||||
#include "mode/Starfield/Starfield.h"
|
||||
#include "display.h"
|
||||
#include "mode/Matrix/Matrix.h"
|
||||
|
||||
ModeId currentModeId = NONE;
|
||||
|
||||
@ -23,8 +22,6 @@ void loadNewMode();
|
||||
void mode_step();
|
||||
|
||||
void mode_loop() {
|
||||
Serial.print("\n");
|
||||
|
||||
if (currentModeId != config.mode) {
|
||||
unloadOldMode();
|
||||
loadNewMode();
|
||||
@ -52,7 +49,6 @@ void setSpeed(double speed) {
|
||||
|
||||
void unloadOldMode() {
|
||||
if (mode != nullptr) {
|
||||
Serial.print("[MODE] unload\n");
|
||||
delete mode;
|
||||
mode = nullptr;
|
||||
}
|
||||
@ -62,7 +58,6 @@ void unloadOldMode() {
|
||||
void loadNewMode() {
|
||||
currentModeId = config.mode;
|
||||
lastMicros = 0;
|
||||
Serial.printf("[MODE] loading %d\n", currentModeId);
|
||||
switch (currentModeId) {
|
||||
case BORDER:
|
||||
mode = new Border(display);
|
||||
@ -94,9 +89,6 @@ void loadNewMode() {
|
||||
case STARFIELD:
|
||||
mode = new Starfield(display);
|
||||
break;
|
||||
case MATRIX:
|
||||
mode = new Matrix(display);
|
||||
break;
|
||||
default:
|
||||
Serial.print("No mode loaded.\n");
|
||||
display.clear();
|
||||
|
||||
@ -19,10 +19,8 @@ public:
|
||||
protected:
|
||||
|
||||
void draw(Display &display) override {
|
||||
Serial.print("[BORDER] draw\n");
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
Serial.printf("[BORDER] draw %d / %d\n", x, y);
|
||||
if (x == 0 || x == width - 1 || y == 0 || y == height - 1) {
|
||||
display.set(x, y, WHITE);
|
||||
} else {
|
||||
|
||||
@ -16,7 +16,6 @@ enum ModeId {
|
||||
SPACE_INVADERS,
|
||||
NEW_YEAR,
|
||||
STARFIELD,
|
||||
MATRIX,
|
||||
};
|
||||
|
||||
class Mode {
|
||||
@ -83,18 +82,14 @@ public:
|
||||
virtual const char *getName() = 0;
|
||||
|
||||
void loop(microseconds_t dt) {
|
||||
Serial.print("[MODE] realtime\n");
|
||||
realtime();
|
||||
|
||||
Serial.print("[MODE] handleTimers\n");
|
||||
handleTimers();
|
||||
|
||||
Serial.print("[MODE] step\n");
|
||||
step(dt);
|
||||
|
||||
if (dirty) {
|
||||
dirty = false;
|
||||
Serial.print("[MODE] draw\n");
|
||||
draw(_display);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user