From 230f0cb2914b02c4d70b19ac4358f2a0a078a676 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 30 Mar 2019 17:17:58 -0400 Subject: better scrolling, vibration --- source/sharp.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'source/sharp.cpp') diff --git a/source/sharp.cpp b/source/sharp.cpp index 4b7aa94..ab0788b 100644 --- a/source/sharp.cpp +++ b/source/sharp.cpp @@ -31,7 +31,6 @@ TaskHandle_t Sharp::taskHandle; std::vector Sharp::widgets; int Sharp::topY = 0; -int Sharp::scrollVelocity = 0; void Sharp::begin(void) { @@ -70,31 +69,26 @@ void Sharp::sendInput(int ypos) void Sharp::updateTask([[maybe_unused]] void *arg) { - static unsigned int counter = 0; - while (1) { - if (counter++ == 3) { - counter = 0; + static int oldTopY = 0; - auto y = topY; - for (auto& w : widgets) { - w->render(display, y); - y += w->getHeight(); - display.drawFastHLine(0, y + 1, SHARP_WIDTH, BLACK); - y += 3; - if (y >= SHARP_HEIGHT) - break; - } + while (1) { + if (oldTopY != topY) { + oldTopY = topY; + display.clearDisplay(); + } - display.refresh(); - } else { - topY += scrollVelocity * 20; - if (scrollVelocity != 0) - display.clearDisplay(); - if (topY > 0) - topY = 0; + auto y = topY; + for (auto& w : widgets) { + w->render(display, y); + y += w->getHeight(); + display.drawFastHLine(0, y + 1, SHARP_WIDTH, BLACK); + y += 3; + if (y >= SHARP_HEIGHT) + break; } - delay(50); + display.refresh(); + delay(150); } } -- cgit v1.2.3