hollyhock
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
lcd.h File Reference

Functions for interacting with the LCD and VRAM. More...

#include <stdint.h>
Include dependency graph for lcd.h:

Go to the source code of this file.

Macros

#define __UCONCAT(a, b)   #a b
 
#define _UCONCAT(a, b)   __UCONCAT(a, b)
 
#define UCONCAT(b)   _UCONCAT(__USER_LABEL_PREFIX__, b)
 
#define RGB_TO_RGB565(r, g, b)
 
#define RGB565_TO_R(rgb565)   ((rgb565 >> 11) & 0x1F)
 
#define RGB565_TO_G(rgb565)   ((rgb565 >> 5) & 0x3F)
 
#define RGB565_TO_B(rgb565)   (rgb565 & 0x1F)
 

Enumerations

enum  LCD_Palette {
  PALETTE_BLACK = 0 , PALETTE_BLUE = 1 , PALETTE_GREEN = 2 , PALETTE_CYAN = 3 ,
  PALETTE_RED = 4 , PALETTE_MAGENTA = 5 , PALETTE_YELLOW = 6 , PALETTE_WHITE = 7
}
 
enum  LCD_Command { COMMAND_SET_X_WINDOW = 0x2A , COMMAND_SET_Y_WINDOW = 0x2B , COMMAND_PREPARE_FOR_DRAW_DATA = 0x2C , COMMAND_READ_DRAW_DATA = 0x2E }
 

Functions

 LCD_SetPixelFromPaletteU (x, y,(uint8_t) color)
 

Variables

volatile uint16_t *const lcd_data_port = (volatile uint16_t *)0xB4000000
 
void(* LCD_ClearScreen )()
 
uint16_t(* LCD_GetPixel )(unsigned int x, unsigned int y)
 
void(* LCD_GetSize )(unsigned int *width, unsigned int *height)
 
uint16_t *(* _FP_LCD_GetVRAMAddress )() __asm__(UCONCAT("LCD_GetVRAMAddress"))
 
void(* LCD_Refresh )()
 
void(* LCD_SetPixel )(unsigned int x, unsigned int y, uint16_t color)
 
void(* LCD_SetPixelFromPaletteU )(unsigned int x, unsigned int y, uint8_t index) __asm__(UCONCAT("LCD_SetPixelFromPalette"))
 
static unsigned int y
 
static unsigned int enum LCD_Palette color
 
static unsigned int enum LCD_Palette color void(* LCD_VRAMBackup )()
 
void(* LCD_VRAMRestore )()
 
void(* LCD_SendCommandU )(uint16_t command) __asm__(UCONCAT("LCD_SendCommand"))
 
void(* LCD_SetDrawingBounds )(unsigned int xstart, unsigned int xend, unsigned int ystart, unsigned int yend)
 

Detailed Description

Functions for interacting with the LCD and VRAM.

Different levels of indirection are availiable to write to VRAM (direct memory access, getter/setters and palette-based drawing). The contents of VRAM are not automatically drawn to the LCD, and must be rendered with LCD_Refresh.

Example: drawing a 30x50 rectangle at 10, 20 in purple

uint16_t *vram = LCD_GetVRAMAddress();
int width, height;
LCD_GetSize(&width, &height);
for (int y = 0; y < 50; ++y) {
for (int x = 0; x < 30; ++x) {
vram[(x + 10) + (y + 20) * width] = RGB_TO_RGB565(0x1F, 0x3B, 0x08);
}
}
// Put our changes on the display
void(* LCD_Refresh)()
#define RGB_TO_RGB565(r, g, b)
Definition lcd.h:73
void(* LCD_GetSize)(unsigned int *width, unsigned int *height)

Macro Definition Documentation

◆ RGB565_TO_B

#define RGB565_TO_B (   rgb565)    (rgb565 & 0x1F)

Extracts the blue component from an RGB565 value.

Parameters
rgb565The RGB565 value.
Returns
The blue component.

◆ RGB565_TO_G

#define RGB565_TO_G (   rgb565)    ((rgb565 >> 5) & 0x3F)

Extracts the green component from an RGB565 value.

Parameters
rgb565The RGB565 value.
Returns
The green component.

◆ RGB565_TO_R

#define RGB565_TO_R (   rgb565)    ((rgb565 >> 11) & 0x1F)

Extracts the red component from an RGB565 value.

Parameters
rgb565The RGB565 value.
Returns
The red component.

◆ RGB_TO_RGB565

#define RGB_TO_RGB565 (   r,
  g,
 
)
Value:
( \
((r & 0x1F) << 11) | \
((g & 0x3F) << 5) | \
(b & 0x1F) \
)

Converts three RGB values into one RGB565 value.

Parameters
rThe red component, between 0 and 31 (0x1F) inclusive.
gThe green component, between 0 and 63 (0x3F) inclusive.
bThe blue component, between 0 and 31 (0x1F) inclusive.
Returns
The specified color, in RGB565 format.

Enumeration Type Documentation

◆ LCD_Command

Passed to LCD_SendCommand.

◆ LCD_Palette

Passed to LCD_SetPixelFromPalette.

Variable Documentation

◆ LCD_ClearScreen

void(* LCD_ClearScreen) () ( )
extern

Clears the LCD. Fills VRAM with white, but does not refresh the LCD.

◆ LCD_GetPixel

uint16_t(* LCD_GetPixel) (unsigned int x, unsigned int y) ( unsigned int  x,
unsigned int  y 
)
extern

Returns the color of a pixel. This is not necessarily the color which is being displayed on the LCD, but instead is the color specified for the pixel in the VRAM buffer. Color is in RGB565 format.

Parameters
x,yThe coordinates of the pixel.
Returns
The color of the pixel, in RGB565 format.

◆ LCD_GetSize

void(* LCD_GetSize) (unsigned int *width, unsigned int *height) ( unsigned int *  width,
unsigned int *  height 
)
extern

Retrieves the size, in pixels, of the LCD.

Parameters
[out]width,heightThe LCD's size.

◆ LCD_Refresh

void(* LCD_Refresh) () ( )
extern

Pushes the content of the VRAM to the LCD.

◆ LCD_SetDrawingBounds

void(* LCD_SetDrawingBounds) (unsigned int xstart, unsigned int xend, unsigned int ystart, unsigned int yend) ( unsigned int  xstart,
unsigned int  xend,
unsigned int  ystart,
unsigned int  yend 
)
extern

Sets the region of the next display update. Needs to be called every time. Usefull for partial updates and/or DMA.

You probably want to use this in conjunction with LCD_SendCommand

◆ LCD_SetPixel

void(* LCD_SetPixel) (unsigned int x, unsigned int y, uint16_t color) ( unsigned int  x,
unsigned int  y,
uint16_t  color 
)
extern

Sets the color of a pixel. The result of this operation will not be visible until LCD_Refresh is called. Color is in RGB565 format.

Parameters
x,yThe coordinate of the pixel.
colorThe color to set the pixel, in RGB565 format.

◆ LCD_VRAMBackup

unsigned int enum LCD_Palette color void(* LCD_VRAMBackup) () ( )

Backs up the current contents of VRAM.

Should be used to prevent display corruption when writing directly to VRAM.

Used in conjunction with LCD_VRAMRestore.

◆ LCD_VRAMRestore

void(* LCD_VRAMRestore) () ( )
extern

Restores the backed up contents of VRAM. The restored content is not displayed until LCD_Refresh is called.

Used in conjunction with LCD_VRAMBackup.