40#define VISIBLE_MASK (0x1)
41#define RENDERED_MASK (0x2)
43#define RLITEM_SET_VISIBLE(obj) ((obj)->metadata |= VISIBLE_MASK)
44#define RLITEM_SET_RENDERED(obj) ((obj)->metadata |= RENDERED_MASK)
46#define RLITEM_UNSET_VISIBLE(obj) ((obj)->metadata &= ~VISIBLE_MASK)
47#define RLITEM_UNSET_RENDERED(obj) ((obj)->metadata &= ~RENDERED_MASK)
49#define RLITEM_IS_VISIBLE(obj) ((obj)->metadata & VISIBLE_MASK)
50#define RLITEM_IS_RENDERED(obj) ((obj)->metadata & RENDERED_MASK)
177 if (!redraw_underneath)
254 if ((color & ~(0xFFFF)) != 0)
272 if ((color & ~(0xFFFF)) != 0)
405 for (
u8 i = 0; i < item->obj->comps_size; i++)
563 dx = new_pos.
x - comp->
pos.
x;
564 dy = new_pos.
y - comp->
pos.
y;
623 if (!
obj || !out_bbox)
659 .width = dim.width, .height = dim.height,
660 .edge_color = LCD_COL_RED, .fill_color = LCD_COL_NONE,
void MEM_Free(MEM_Allocator *ma, void *ptr)
Free a previously allocated block.
void * MEM_Alloc(MEM_Allocator *ma, u32 size)
Allocate a block of memory from the pool with at least 'size' bytes.
CL_Error CL_ListRemoveAt(CL_List *const list, u32 index, void *out_elem)
Removes an element at the specified index.
void CL_ListClear(CL_List *const list)
Removes all elements from the list.
u32 CL_ListSize(const CL_List *const list)
Gets the number of elements in the list.
#define CL_LIST_FOREACH_PTR(__type, __name, __list,...)
Macro to iterate over the elements of the list with a pointer to the current element.
CL_Error CL_ListPushBack(CL_List *const list, const void *const elem)
Adds an element at the end of the list.
bool CL_ListIsEmpty(const CL_List *const list)
Checks if the list is empty.
CL_Error CL_ListGetPtr(const CL_List *const list, u32 index, void **out_elem)
Gets an element at the specified index as a pointer, so the user can modify it.
CL_List * CL_ListAlloc(MEM_Allocator *const alloc, u32 elem_sz)
Initializes a new doubly-linked list with tail, with the allocated memory provided by the user.
const LCD_Font Font_MSGothic
const LCD_Font Font_System
_PRIVATE LCD_Error render(struct __RLItem *const item)
bool LCD_RMIsVisible(LCD_ObjID id)
Returns whether an object is visible on the screen or not.
#define RLITEM_UNSET_RENDERED(obj)
#define RLITEM_IS_VISIBLE(obj)
LCD_Coordinate LCD_GetCenter(void)
Returns the center of the screen at the current orientation.
_USED_EXTERNALLY u16 LCDMaxY
_PRIVATE bool bboxes_intersect(const LCD_BBox *const a, const LCD_BBox *const b)
#define RLITEM_IS_RENDERED(obj)
bool LCD_IsInitialized(void)
Checks if the LCD has been initialized.
LCD_Coordinate LCD_GetSize(void)
Returns the size of the screen at the current orientation.
LCD_Error LCD_FMAddFont(LCD_Font font, LCD_FontID *out_id)
Adds a new font to the font manager, and returns its ID through the out_id pointer.
LCD_Error LCD_CalcBBoxForObject(const LCD_Obj *const obj, LCD_BBox *out_bbox)
Returns the bounding box of a temporary object.
u16 LCD_GetHeight(void)
Returns the height of the screen at the current orientation.
LCD_Error LCD_SetPointColor(LCD_Color color, LCD_Coordinate point)
Sets the color of the pixel at the specified coordinates.
_USED_EXTERNALLY u8 LCDFontListSize
_PRIVATE bool s_initialized
Whether the LCD has been initialized.
_PRIVATE LCD_Error unrender(struct __RLItem *const item, bool redraw_underneath)
LCD_Error LCD_RMAdd(LCD_Obj *const obj, LCD_ObjID *out_id, u8 options)
Adds a new object to the render list, and returns its ID (if out_id is not NULL) through the out_id p...
u16 LCD_GetWidth(void)
Returns the width of the screen at the current orientation.
_USED_EXTERNALLY u16 LCDMaxX
Current LCD maximum X and Y coordinates.
LCD_Error LCD_SetBackgroundColor(LCD_Color color, bool redraw_objects)
Sets the background color of the screen.
LCD_Error LCD_Init(LCD_Orientation orientation, MEM_Allocator *const alloc, const LCD_Color *const clear_to)
Initializes TFT LCD Controller.
_PRIVATE MEM_Allocator * s_allocator
The memory allocator used to allocate the objects.
LCD_Error LCD_RMRemove(LCD_ObjID id, bool redraw_underneath)
Removes an object from the render list by its ID. It also deallocates the memory used by that object ...
LCD_Error LCD_DEBUG_RenderBBox(LCD_ObjID id)
Debug function to render the bounding box of a component.
LCD_Error LCD_RMClear(void)
Removes all visible and non-visible objects from the screen.
LCD_Error LCD_RMRenderTemporary(LCD_Obj *const obj)
Renders the object immediately, without adding neither to the render list nor to the memory arena....
LCD_Color LCD_GetPointColor(LCD_Coordinate point)
Returns the RGB565 color of the pixel at the specified coordinates.
_USED_EXTERNALLY LCD_Font LCDFontList[GLCD_MAX_FONTS]
The list of fonts that have been loaded into the LCD.
LCD_Error LCD_RMSetVisibility(LCD_ObjID id, bool visible, bool redraw_underneath)
Shows/hides an object on/from the screen without modifying the render list.
_PRIVATE CL_List * s_render_list
Render list, containing all the components to be rendered & metadata.
LCD_Error LCD_RMRender(void)
Manually triggers an update of the screen. Useful when you want to add multiple objects at once,...
_PRIVATE u32 s_render_list_id_ctr
_USED_EXTERNALLY LCD_Color LCDCurrentBGColor
Current background color of the screen.
LCD_Error LCD_GetBBox(LCD_ObjID id, LCD_BBox *out_bbox)
Returns the bounding box of an object in the render list.
_PRIVATE bool alloc_component_object(const LCD_Component *const src, LCD_Component *dest)
LCD_Error LCD_FMRemoveFont(LCD_FontID id)
Removes a font from the font manager by its ID.
#define RLITEM_SET_RENDERED(obj)
_PRIVATE void dealloc_component_object(LCD_Component *const comp)
LCD_Error LCD_RMMove(LCD_ObjID id, LCD_Coordinate new_pos, bool redraw_underneath)
Moves an object in the render list to a new position. It also updates the object's position in the RL...
#define RGB8_TO_RGB565(rgb)
Converts RGB (24 bit) into RGB565 (16 bit):
#define GLCD_MAX_FONTS
Maximum number of fonts that can be loaded into the LCD.
#define GLCD_MAX_COMPS_PER_OBJECT
This macro controls the timing between the low level operations with the GLCD controller....
LCD_Error
Error codes returned by the GLCD library.
@ LCD_ERR_UNINITIALIZED
The library is not initialized.
@ LCD_ERR_DURING_RENDER
An error occurred during shape drawing.
@ LCD_ERR_DURING_UNRENDER
An error occurred during shape deletion.
@ LCD_ERR_INVALID_OBJ
The object is invalid (invalid ID, empty components array, etc.)
@ LCD_ERR_COORDS_OUT_OF_BOUNDS
The specified (x,y) coordinates are out of the screen boundaries.
@ LCD_ERR_INVALID_FONT_ID
The font ID is invalid.
@ LCD_ERR_NO_MEMORY
The memory pool does not have enough space to allocate the object.
@ LCD_ERR_NULL_PARAMS
One or more params is NULL.
@ LCD_ERR_DURING_BBOX_CALC
An error occurred during bounding box calculation.
@ LCD_ERR_FONT_LIST_FULL
The font list is full. No more fonts can be added.
@ LCD_ERR_TOO_MANY_COMPS_IN_OBJ
The object has too many components.
@ LCD_ERR_OK
No error occurred.
void __LCD_LL_FillScreen(u16 color)
void __LCD_LL_Init(u16 orientation)
u16 __LCD_LL_GetPointColor(u16 x, u16 y)
void __LCD_LL_SetPointColor(u16 rgb565, u16 x, u16 y)
#define LCD_OBJECT_DEFINE(...)
Defines an object without adding it to the LCD render list.
#define LCD_RECT(coords,...)
bool __LCD_PROC_DoProcessObject(const LCD_Obj *const obj, LCD_BBox *out_bbox, u8 mode)
u32 LCD_Color
Represents a color in the RGB565 format.
@ LCD_ADD_OBJ_OPT_DONT_MARK_VISIBLE
Request GLCD to not mark the newly added object as visible. In that way, it it won't be rendered by a...
LCD_Coordinate bottom_right
Used to store a drawable component of any type.
union LCD_Component::@0 object
Represents a generic object, made up of 1 or more basic components, that are rendered on the screen.