draw gridlines

This commit is contained in:
Andy Killorin 2025-03-27 11:52:14 -04:00
parent fa95b4a93a
commit c2a0fdd210
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

20
main.c
View file

@ -16,6 +16,7 @@
#include "Crystalfontz128x128_ST7735.h" #include "Crystalfontz128x128_ST7735.h"
#include <stdio.h> #include <stdio.h>
#include "buttons.h" #include "buttons.h"
#include "grlib/grlib.h"
#include "sampling.h" #include "sampling.h"
#include <math.h> #include <math.h>
#include "inc/hw_memmap.h" #include "inc/hw_memmap.h"
@ -79,6 +80,25 @@ int main(void) {
while (true) { while (true) {
GrContextForegroundSet(&sContext, ClrBlack); GrContextForegroundSet(&sContext, ClrBlack);
GrRectFill(&sContext, &rectFullScreen); // fill screen with black 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 time = gTime; // read shared global only once
uint32_t hundredths = time % 100; uint32_t hundredths = time % 100;