From 2c5305d2f6d46501d2ae6cf9bf1abe355cf6ce03 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Tue, 25 Jul 2023 10:43:30 -0400 Subject: [PATCH] working progress bar --- misc/gpu/lcd.c | 99 ++++++++++++++++++++++++++++++++++--------------- misc/gpu/lcd.h | 2 +- misc/gpu/main.c | 29 ++++++++------- misc/gpu/main.h | 2 +- 4 files changed, 86 insertions(+), 46 deletions(-) diff --git a/misc/gpu/lcd.c b/misc/gpu/lcd.c index 8d1ccaf7..5c77304a 100644 --- a/misc/gpu/lcd.c +++ b/misc/gpu/lcd.c @@ -15,13 +15,18 @@ const int LCD_WIDTH = 320; const int LCD_HEIGHT = 240; const int NUM_PIXELS = (LCD_WIDTH*LCD_HEIGHT); -const int PROGRESS_BAR_Y = (LCD_HEIGHT - 3); - // doing RGB565, but swab16 const uint16_t COL_BLACK = 0; const uint16_t COL_WHITE = ~0; const uint16_t COL_FOREGROUND = 0x60fd; //SWAB16(0xfd60); // orange +// progress bar specs +const uint16_t PROG_HEIGHT = 3; +const uint16_t PROG_Y = LCD_HEIGHT - PROG_HEIGHT; + +static const int NUM_PHASES = 16; +static int phase = 0; + // forward refs void lcd_write_rows(int y, int num_rows, uint16_t *pixels); @@ -52,18 +57,15 @@ static inline void wait_vsync(void) { static inline void write_byte(uint8_t b) { - asm(" nop; nop; nop; nop; "); - asm(" nop; nop; nop; nop; "); - asm(" nop; nop; nop; nop; "); - asm(" nop; nop; nop; nop; "); - asm(" nop; nop; nop; nop; "); - asm(" nop; nop; nop; nop; "); - while(LL_SPI_GetTxFIFOLevel(SPI1) == LL_SPI_TX_FIFO_FULL) { // wait for space } LL_SPI_TransmitData8(SPI1, b); + + while(LL_SPI_GetTxFIFOLevel(SPI1) != LL_SPI_TX_FIFO_EMPTY) { + // wait for FIFO to drain completely + } } // write_bytes() @@ -72,11 +74,18 @@ write_byte(uint8_t b) write_bytes(int len, const uint8_t *buf) { for(int n=0; n