From be01760c32a00276e2d7c9f526b97d7e1b249743 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Tue, 1 Oct 2019 13:35:05 +0200 Subject: [PATCH] pax curve plotter --- src/display.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 8b7564e1..9662dc3f 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -397,18 +397,15 @@ void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y, const uint8_t dot) { - uint8_t page, bit; - if (x > DISPLAY_WIDTH || y > DISPLAY_HEIGHT) return -1; - page = y / 8; - bit = y % 8; + uint8_t bit = y & 7; + uint16_t idx = y / 8 * DISPLAY_WIDTH + x; + buf[idx] &= ~(1 << bit); // clear pixel if (dot) - buf[page * DISPLAY_WIDTH + x] |= (1 << bit); // mark - else - buf[page * DISPLAY_WIDTH + x] &= ~(0 << bit); // clear + buf[idx] |= (1 << bit); // set pixel return 0; }