hollyhock
Loading...
Searching...
No Matches
lcd.h
Go to the documentation of this file.
1
27#pragma once
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdint.h>
34
35#define __UCONCAT(a, b) #a b
36#define _UCONCAT(a, b) __UCONCAT(a, b)
37#define UCONCAT(b) _UCONCAT(__USER_LABEL_PREFIX__, b)
38
43 PALETTE_BLACK = 0,
44 PALETTE_BLUE = 1,
45 PALETTE_GREEN = 2,
46 PALETTE_CYAN = 3,
47 PALETTE_RED = 4,
48 PALETTE_MAGENTA = 5,
49 PALETTE_YELLOW = 6,
50 PALETTE_WHITE = 7
51};
52
57 COMMAND_SET_X_WINDOW = 0x2A,
58 COMMAND_SET_Y_WINDOW = 0x2B,
59 COMMAND_PREPARE_FOR_DRAW_DATA = 0x2C,
60 COMMAND_READ_DRAW_DATA = 0x2E
61};
62
63volatile uint16_t *const lcd_data_port = (volatile uint16_t *)0xB4000000;
64
73#define RGB_TO_RGB565(r, g, b) ( \
74 ((r & 0x1F) << 11) | \
75 ((g & 0x3F) << 5) | \
76 (b & 0x1F) \
77)
78
85#define RGB565_TO_R(rgb565) ((rgb565 >> 11) & 0x1F)
86
93#define RGB565_TO_G(rgb565) ((rgb565 >> 5) & 0x3F)
94
101#define RGB565_TO_B(rgb565) (rgb565 & 0x1F)
102
106extern void (*LCD_ClearScreen)();
107
116extern uint16_t (*LCD_GetPixel)(unsigned int x, unsigned int y);
117
123extern void (*LCD_GetSize)(unsigned int *width, unsigned int *height);
124
125extern uint16_t *(*_FP_LCD_GetVRAMAddress)() __asm__ (UCONCAT("LCD_GetVRAMAddress"));
126
134static inline __attribute__((const, always_inline)) uint16_t *LCD_GetVRAMAddress() {
135 return _FP_LCD_GetVRAMAddress();
136}
137
141extern void (*LCD_Refresh)();
142
150extern void (*LCD_SetPixel)(unsigned int x, unsigned int y, uint16_t color);
151
152extern void (*LCD_SetPixelFromPaletteU)(unsigned int x, unsigned int y, uint8_t index) __asm__ (UCONCAT("LCD_SetPixelFromPalette"));
153
161static inline __attribute__((always_inline)) void LCD_SetPixelFromPalette(unsigned int x, unsigned int y, enum LCD_Palette color) {
162 LCD_SetPixelFromPaletteU(x, y, (uint8_t)color);
163}
164
172extern void (*LCD_VRAMBackup)();
173
180extern void (*LCD_VRAMRestore)();
181
182extern void (*LCD_SendCommandU)(uint16_t command) __asm__ (UCONCAT("LCD_SendCommand"));
183
187static inline __attribute__((always_inline)) void LCD_SendCommand(enum LCD_Command command) {
188 LCD_SendCommandU(command);
189}
190
197extern void (*LCD_SetDrawingBounds)(unsigned int xstart, unsigned int xend, unsigned int ystart, unsigned int yend);
198
199#undef __UCONCAT
200#undef _UCONCAT
201#undef UCONCAT
202
203#ifdef __cplusplus
204}
205#endif
void(* LCD_SetDrawingBounds)(unsigned int xstart, unsigned int xend, unsigned int ystart, unsigned int yend)
static unsigned int enum LCD_Palette color void(* LCD_VRAMBackup)()
Definition lcd.h:172
void(* LCD_SetPixel)(unsigned int x, unsigned int y, uint16_t color)
LCD_Command
Definition lcd.h:56
LCD_Palette
Definition lcd.h:42
void(* LCD_VRAMRestore)()
uint16_t(* LCD_GetPixel)(unsigned int x, unsigned int y)
void(* LCD_Refresh)()
void(* LCD_ClearScreen)()
void(* LCD_GetSize)(unsigned int *width, unsigned int *height)