Skip to content

Commit

Permalink
keira: fix lines demo
Browse files Browse the repository at this point in the history
  • Loading branch information
and3rson committed Mar 14, 2024
1 parent 2d43ab0 commit a6492a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions firmware/keira/src/apps/demos/lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ DemoLines::DemoLines() : App("Лінії") {
}

void DemoLines::run() {
// Створюємо додатковий буфер для малювання ліній.
lilka::Canvas buffer(canvas->width(), canvas->height());
buffer.begin();
buffer.fillScreen(0);
canvas->drawCanvas(&buffer);
queueDraw();

while (1) {
// Малюємо 64 випадкові лінії на буфері.
for (int i = 0; i < 64; i++) {
int x1 = random(0, canvas->width());
int y1 = random(0, canvas->height());
Expand All @@ -21,12 +20,16 @@ void DemoLines::run() {
uint16_t color = random(0, 0xFFFF);
buffer.drawLine(x1, y1, x2, y2, color);
}
// Малюємо наш буфер в передній буфер.
canvas->drawCanvas(&buffer);
queueDraw();

// Перевіряємо, чи натиснута кнопка "A".
if (lilka::controller.getState().a.justPressed) {
stop();
return;
}

// Чекаємо 30 мс.
vTaskDelay(30 / portTICK_PERIOD_MS);
}
}

0 comments on commit a6492a5

Please sign in to comment.