#include "glcd.h"
#include "cl_list.h"
#include "glcd_config.h"
#include "glcd_lowlevel.h"
#include "glcd_processor.h"
#include <LPC17xx.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "font_msgothic.h"
#include "font_system.h"
Go to the source code of this file.
Classes | |
struct | __RLItem |
Macros | |
#define | VISIBLE_MASK (0x1) |
#define | RENDERED_MASK (0x2) |
#define | RLITEM_SET_VISIBLE(obj) ((obj)->metadata |= VISIBLE_MASK) |
#define | RLITEM_SET_RENDERED(obj) ((obj)->metadata |= RENDERED_MASK) |
#define | RLITEM_UNSET_VISIBLE(obj) ((obj)->metadata &= ~VISIBLE_MASK) |
#define | RLITEM_UNSET_RENDERED(obj) ((obj)->metadata &= ~RENDERED_MASK) |
#define | RLITEM_IS_VISIBLE(obj) ((obj)->metadata & VISIBLE_MASK) |
#define | RLITEM_IS_RENDERED(obj) ((obj)->metadata & RENDERED_MASK) |
Functions | |
_PRIVATE bool | bboxes_intersect (const LCD_BBox *const a, const LCD_BBox *const b) |
_PRIVATE bool | alloc_component_object (const LCD_Component *const src, LCD_Component *dest) |
_PRIVATE void | dealloc_component_object (LCD_Component *const comp) |
_PRIVATE LCD_Error | render (struct __RLItem *const item) |
_PRIVATE LCD_Error | unrender (struct __RLItem *const item, bool redraw_underneath) |
LCD_Error | LCD_Init (LCD_Orientation orientation, MEM_Allocator *const alloc, const LCD_Color *const clear_to) |
Initializes TFT LCD Controller. | |
bool | LCD_IsInitialized (void) |
Checks if the LCD has been initialized. | |
u16 | LCD_GetWidth (void) |
Returns the width of the screen at the current orientation. | |
u16 | LCD_GetHeight (void) |
Returns the height of the screen at the current orientation. | |
LCD_Coordinate | LCD_GetSize (void) |
Returns the size of the screen at the current orientation. | |
LCD_Coordinate | LCD_GetCenter (void) |
Returns the center of the screen at the current orientation. | |
LCD_Color | LCD_GetPointColor (LCD_Coordinate point) |
Returns the RGB565 color of the pixel at the specified coordinates. | |
LCD_Error | LCD_SetPointColor (LCD_Color color, LCD_Coordinate point) |
Sets the color of the pixel at the specified coordinates. | |
LCD_Error | LCD_SetBackgroundColor (LCD_Color color, bool redraw_objects) |
Sets the background color of the screen. | |
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 pointer. | |
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 in the memory arena. | |
LCD_Error | LCD_RMClear (void) |
Removes all visible and non-visible objects from the screen. | |
LCD_Error | LCD_RMRender (void) |
Manually triggers an update of the screen. Useful when you want to add multiple objects at once, and only update the screen at the end. | |
LCD_Error | LCD_RMRenderTemporary (LCD_Obj *const obj) |
Renders the object immediately, without adding neither to the render list nor to the memory arena. This is useful for objects that are not frequently updated, and that you don't want to store in the memory arena. | |
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. | |
bool | LCD_RMIsVisible (LCD_ObjID id) |
Returns whether an object is visible on the screen or not. | |
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 itself, and in the memory arena. | |
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_FMRemoveFont (LCD_FontID id) |
Removes a font from the font manager by its ID. | |
LCD_Error | LCD_GetBBox (LCD_ObjID id, LCD_BBox *out_bbox) |
Returns the bounding box of an object in the render list. | |
LCD_Error | LCD_CalcBBoxForObject (const LCD_Obj *const obj, LCD_BBox *out_bbox) |
Returns the bounding box of a temporary object. | |
LCD_Error | LCD_DEBUG_RenderBBox (LCD_ObjID id) |
Debug function to render the bounding box of a component. | |
Variables | |
_PRIVATE bool | s_initialized = false |
Whether the LCD has been initialized. | |
_PRIVATE MEM_Allocator * | s_allocator |
The memory allocator used to allocate the objects. | |
_USED_EXTERNALLY u16 | LCDMaxX |
Current LCD maximum X and Y coordinates. | |
_USED_EXTERNALLY u16 | LCDMaxY |
_USED_EXTERNALLY LCD_Color | LCDCurrentBGColor = LCD_COL_BLACK |
Current background color of the screen. | |
_USED_EXTERNALLY LCD_Font | LCDFontList [GLCD_MAX_FONTS] = {0} |
The list of fonts that have been loaded into the LCD. | |
_USED_EXTERNALLY u8 | LCDFontListSize = 0 |
_PRIVATE CL_List * | s_render_list |
Render list, containing all the components to be rendered & metadata. | |
_PRIVATE u32 | s_render_list_id_ctr = 0 |
#define RLITEM_IS_RENDERED | ( | obj | ) | ((obj)->metadata & RENDERED_MASK) |
#define RLITEM_IS_VISIBLE | ( | obj | ) | ((obj)->metadata & VISIBLE_MASK) |
#define RLITEM_SET_RENDERED | ( | obj | ) | ((obj)->metadata |= RENDERED_MASK) |
#define RLITEM_SET_VISIBLE | ( | obj | ) | ((obj)->metadata |= VISIBLE_MASK) |
#define RLITEM_UNSET_RENDERED | ( | obj | ) | ((obj)->metadata &= ~RENDERED_MASK) |
#define RLITEM_UNSET_VISIBLE | ( | obj | ) | ((obj)->metadata &= ~VISIBLE_MASK) |
_PRIVATE bool alloc_component_object | ( | const LCD_Component *const | src, |
LCD_Component * | dest | ||
) |
Definition at line 68 of file glcd.c.
Definition at line 58 of file glcd.c.
_PRIVATE void dealloc_component_object | ( | LCD_Component *const | comp | ) |
Definition at line 117 of file glcd.c.
Returns the bounding box of a temporary object.
obj | The object to get the bounding box of. |
out_bbox | The bounding box of the object, if it was found. |
Definition at line 621 of file glcd.c.
Debug function to render the bounding box of a component.
id | The ID of the object to render the bounding box of. |
Definition at line 635 of file glcd.c.
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.
font | The font to add |
out_id | The ID of the font, if it was added successfully to the font manager. |
Definition at line 577 of file glcd.c.
LCD_Error LCD_FMRemoveFont | ( | LCD_FontID | id | ) |
Removes a font from the font manager by its ID.
id | The ID of the font to remove from the font manager. |
Returns the bounding box of an object in the render list.
id | The ID of the object to get the bounding box of. |
out_bbox | The bounding box of the object, if it was found. |
Definition at line 602 of file glcd.c.
LCD_Coordinate LCD_GetCenter | ( | void | ) |
u16 LCD_GetHeight | ( | void | ) |
LCD_Color LCD_GetPointColor | ( | LCD_Coordinate | point | ) |
LCD_Coordinate LCD_GetSize | ( | void | ) |
u16 LCD_GetWidth | ( | void | ) |
LCD_Error LCD_Init | ( | LCD_Orientation | orientation, |
MEM_Allocator *const | alloc, | ||
const LCD_Color *const | clear_to | ||
) |
Initializes TFT LCD Controller.
orientation | The orientation of the screen, from the LCD_Orientation enum |
alloc | The memory allocator to use for the LCD objects |
clear_to | [OPTIONAL] The color to clear the screen with |
Definition at line 200 of file glcd.c.
bool LCD_IsInitialized | ( | void | ) |
Adds a new object to the render list, and returns its ID (if out_id is not NULL) through the out_id pointer.
obj | The object to add |
out_id | The ID of the object, or NULL on error. |
options | Adding preferences, from the LCD_RMAddOption enum. |
Definition at line 292 of file glcd.c.
LCD_Error LCD_RMClear | ( | void | ) |
Removes all visible and non-visible objects from the screen.
Definition at line 395 of file glcd.c.
bool LCD_RMIsVisible | ( | LCD_ObjID | id | ) |
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 itself, and in the memory arena.
id | The ID of the object to move |
new_pos | The new position of the object, which will replace the old one |
redraw_underneath | Whether to redraw the objects that are below the object prior to the move |
Definition at line 507 of file glcd.c.
Removes an object from the render list by its ID. It also deallocates the memory used by that object in the memory arena.
id | The ID of the object to remove |
redraw_underneath | Whether to redraw the objects that are below the removed object |
Definition at line 362 of file glcd.c.
LCD_Error LCD_RMRender | ( | void | ) |
Renders the object immediately, without adding neither to the render list nor to the memory arena. This is useful for objects that are not frequently updated, and that you don't want to store in the memory arena.
obj | The object to render immediately |
Definition at line 438 of file glcd.c.
Shows/hides an object on/from the screen without modifying the render list.
id | The ID of the object to hide |
visible | Whether the object should be visible or not |
redraw_underneath | Whether to redraw the objects that are below the current one. |
Definition at line 449 of file glcd.c.
Sets the background color of the screen.
color | The RGB565 color to set |
redraw_objects | If true, the object that were previously visible are re-rendered on top of the new background color. |
Definition at line 264 of file glcd.c.
LCD_Error LCD_SetPointColor | ( | LCD_Color | color, |
LCD_Coordinate | point | ||
) |
Sets the color of the pixel at the specified coordinates.
color | The RGB565 color to set |
point | The coordinates of the pixel to color |
Definition at line 245 of file glcd.c.
Definition at line 147 of file glcd.c.
Definition at line 165 of file glcd.c.
_USED_EXTERNALLY LCD_Color LCDCurrentBGColor = LCD_COL_BLACK |
_USED_EXTERNALLY LCD_Font LCDFontList[GLCD_MAX_FONTS] = {0} |
_USED_EXTERNALLY u8 LCDFontListSize = 0 |
_USED_EXTERNALLY u16 LCDMaxX |
_USED_EXTERNALLY u16 LCDMaxY |
_PRIVATE MEM_Allocator* s_allocator |
_PRIVATE bool s_initialized = false |