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
61#define RGB_TO_RGB565(r, g, b) ( \
62 ((r & 0x1F) << 11) | \
63 ((g & 0x3F) << 5) | \
64 (b & 0x1F) \
65)
66
73#define RGB565_TO_R(rgb565) ((rgb565 >> 11) & 0x1F)
74
81#define RGB565_TO_G(rgb565) ((rgb565 >> 5) & 0x3F)
82
89#define RGB565_TO_B(rgb565) (rgb565 & 0x1F)
90
94extern void (*LCD_ClearScreen)();
95
104extern uint16_t (*LCD_GetPixel)(unsigned int x, unsigned int y);
105
111extern void (*LCD_GetSize)(unsigned int *width, unsigned int *height);
112
113extern uint16_t *(*_FP_LCD_GetVRAMAddress)() __asm__ (UCONCAT("LCD_GetVRAMAddress"));
114
122static inline __attribute__((const, always_inline)) uint16_t *LCD_GetVRAMAddress() {
123 return _FP_LCD_GetVRAMAddress();
124}
125
129extern void (*LCD_Refresh)();
130
138extern void (*LCD_SetPixel)(unsigned int x, unsigned int y, uint16_t color);
139
140extern void (*LCD_SetPixelFromPaletteU)(unsigned int x, unsigned int y, uint8_t index) __asm__ (UCONCAT("LCD_SetPixelFromPalette"));
141
149static inline __attribute__((always_inline)) void LCD_SetPixelFromPalette(unsigned int x, unsigned int y, enum LCD_Palette color) {
150 LCD_SetPixelFromPaletteU(x, y, (uint8_t)color);
151}
152
160extern void (*LCD_VRAMBackup)();
161
168extern void (*LCD_VRAMRestore)();
169
170#undef __UCONCAT
171#undef _UCONCAT
172#undef UCONCAT
173
174#ifdef __cplusplus
175}
176#endif
static unsigned int enum LCD_Palette color void(* LCD_VRAMBackup)()
Definition lcd.h:160
void(* LCD_SetPixel)(unsigned int x, unsigned int y, uint16_t color)
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)