From c2a0fdd2107a5077a4e8cc0df3b1848696db25d2 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Thu, 27 Mar 2025 11:52:14 -0400 Subject: [PATCH] draw gridlines --- main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.c b/main.c index 4ef62d5..f8e7cd9 100644 --- a/main.c +++ b/main.c @@ -16,6 +16,7 @@ #include "Crystalfontz128x128_ST7735.h" #include #include "buttons.h" +#include "grlib/grlib.h" #include "sampling.h" #include #include "inc/hw_memmap.h" @@ -79,6 +80,25 @@ int main(void) { while (true) { GrContextForegroundSet(&sContext, ClrBlack); GrRectFill(&sContext, &rectFullScreen); // fill screen with black + + // assumming square lcd + #define HEIGHT LCD_VERTICAL_MAX + #define PIXELS_PER_DIV 20 + + GrContextForegroundSet(&sContext, ClrBlue); + + uint8_t xy_pos; + // draw gridlines from the center out + for (xy_pos = HEIGHT/2; xy_pos < HEIGHT; xy_pos += PIXELS_PER_DIV) { + GrLineDrawV(&sContext, xy_pos, 0, 128); // right + GrLineDrawV(&sContext, HEIGHT - xy_pos, 0, 128); // left + + GrLineDrawH(&sContext, 0, 128, xy_pos); // down + GrLineDrawH(&sContext, 0, 128, HEIGHT - xy_pos); // up + } + + + time = gTime; // read shared global only once uint32_t hundredths = time % 100;