Add definition of spi_buffer size

Add check cell and spi_buffer size
This commit is contained in:
DiSlord 2020-02-23 17:13:52 +03:00
parent c92987c52e
commit 5ee23be06f
3 changed files with 9 additions and 2 deletions

View file

@ -21,7 +21,7 @@
#include "hal.h" #include "hal.h"
#include "nanovna.h" #include "nanovna.h"
uint16_t spi_buffer[2048]; uint16_t spi_buffer[SPI_BUFFER_SIZE];
// Default foreground & background colors // Default foreground & background colors
uint16_t foreground_color=DEFAULT_FG_COLOR; uint16_t foreground_color=DEFAULT_FG_COLOR;
uint16_t background_color=DEFAULT_BG_COLOR; uint16_t background_color=DEFAULT_BG_COLOR;

View file

@ -300,6 +300,9 @@ extern int16_t vbat;
#define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) ) #define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) )
#define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) #define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) )
// Define size of screen buffer in pixels (one pixel 16bit size)
#define SPI_BUFFER_SIZE 2048
#define DEFAULT_FG_COLOR RGB565(255,255,255) #define DEFAULT_FG_COLOR RGB565(255,255,255)
#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) #define DEFAULT_BG_COLOR RGB565( 0, 0, 0)
#define DEFAULT_GRID_COLOR RGB565(128,128,128) #define DEFAULT_GRID_COLOR RGB565(128,128,128)
@ -317,7 +320,7 @@ extern int16_t vbat;
extern uint16_t foreground_color; extern uint16_t foreground_color;
extern uint16_t background_color; extern uint16_t background_color;
extern uint16_t spi_buffer[2048]; extern uint16_t spi_buffer[SPI_BUFFER_SIZE];
void ili9341_init(void); void ili9341_init(void);
//void ili9341_setRotation(uint8_t r); //void ili9341_setRotation(uint8_t r);

4
plot.c
View file

@ -16,6 +16,10 @@ int16_t area_height = AREA_HEIGHT_NORMAL;
// Depends from spi_buffer size, CELLWIDTH*CELLHEIGHT <= sizeof(spi_buffer) // Depends from spi_buffer size, CELLWIDTH*CELLHEIGHT <= sizeof(spi_buffer)
#define CELLWIDTH (64) #define CELLWIDTH (64)
#define CELLHEIGHT (32) #define CELLHEIGHT (32)
// Check buffer size
#if CELLWIDTH*CELLHEIGHT > SPI_BUFFER_SIZE
#error "Too small spi_buffer size SPI_BUFFER_SIZE < CELLWIDTH*CELLHEIGH"
#endif
// indicate dirty cells (not redraw if cell data not changed) // indicate dirty cells (not redraw if cell data not changed)
#define MAX_MARKMAP_X ((320+CELLWIDTH-1)/CELLWIDTH) #define MAX_MARKMAP_X ((320+CELLWIDTH-1)/CELLWIDTH)