Landtiger LPC1768 C BigLib 1
A self made, custom C library for the LandTiger board.
 
Loading...
Searching...
No Matches
/home/runner/work/polito-cas-landtiger-lib/polito-cas-landtiger-lib/Keil/Include/Peripherals/glcd_macros.h

Constructs an identifiable object from a list of components, in a declarative fashion.

Constructs an identifiable object from a list of components, in a declarative fashion.

Parameters
id[OUTPUT] A pointer to an LCD_ObjID variable, where the ID of the object will be stored. This ID can be used to remove the object from the list, or to update it. You can specify NULL if you don't need the ID (in that case just use the LCD_RENDER_IMM!)
...The components that make up the object.

LCD_ObjID id; LCD_Error err = LCD_OBJECT(&id, { LCD_RECT(pos_rect, { .width = 10, .height = 10, .fill_color = LCD_COL_RED, }), LCD_TEXT(pos_text, { .text = "Hello, World!", .font = LCD_DEF_FONT_SYSTEM, .text_color = LCD_COL_BLUE, }), });

if (err != LCD_ERR_OK) LCD_RMRender();

Note
Since the objects are identifiable, they need space in the memory arena specified during the initialization of the LCD module. If the memory arena is full, the function will return the error.
Returns
The LCD_Error that LCD_RMAdd returns.
#ifndef __GLCD_MACROS_H
#define __GLCD_MACROS_H
#include "glcd_types.h"
#include <stdlib.h>
#include <string.h>
#define LCD_OBJECT_DEFINE(...) \
(LCD_Obj) \
{ \
.comps = (LCD_Component[]){__VA_ARGS__}, \
.comps_size = sizeof((LCD_Component[]){__VA_ARGS__}) / sizeof(LCD_Component) \
}
#define LCD_OBJECT(id, ...) \
LCD_RMAdd(&((LCD_Obj){.comps = (LCD_Component[])__VA_ARGS__, \
.comps_size = sizeof((LCD_Component[])__VA_ARGS__) / sizeof(LCD_Component)}), \
id, 0);
#define LCD_INVISIBLE_OBJECT(id, ...) \
LCD_RMAdd(&((LCD_Obj){.comps = (LCD_Component[])__VA_ARGS__, \
.comps_size = sizeof((LCD_Component[])__VA_ARGS__) / sizeof(LCD_Component)}), \
id, LCD_ADD_OBJ_OPT_DONT_MARK_VISIBLE);
#define LCD_OBJECT_UPDATE_COMMANDS(id, redraw_underneath, ...) \
({ \
LCD_Error __err = LCD_RMSetVisibility(id, false, redraw_underneath); \
if (__err == LCD_ERR_OK) \
{ \
__VA_ARGS__ \
__err = LCD_RMSetVisibility(id, true, false); \
} \
__err; \
})
#define LCD_RENDER_TMP(...) \
LCD_RMRenderTemporary(&(LCD_Obj){.comps = (LCD_Component[])__VA_ARGS__, \
.comps_size = sizeof((LCD_Component[])__VA_ARGS__) / sizeof(LCD_Component)})
// COMPONENTS
#define LCD_LINE(...) \
(LCD_Component) \
{ \
.type = LCD_COMP_LINE, .object.line = (LCD_Line *)&((LCD_Line)__VA_ARGS__) \
}
#define LCD_RECT(coords, ...) \
(LCD_Component) \
{ \
.type = LCD_COMP_RECT, .pos = coords, .object.rect = (LCD_Rect *)&((LCD_Rect)__VA_ARGS__) \
}
#define LCD_RECT2(x, y, ...) \
(LCD_Component) \
{ \
.type = LCD_COMP_RECT, .pos = (LCD_Coordinate){x, y}, .object.rect = (LCD_Rect *)&((LCD_Rect)__VA_ARGS__) \
}
#define LCD_CIRCLE(...) \
(LCD_Component) \
{ \
.type = LCD_COMP_CIRCLE, .object.circle = (LCD_Circle *)&((LCD_Circle)__VA_ARGS__) \
}
#define LCD_IMAGE(coords, img) \
(LCD_Component) \
{ \
.type = LCD_COMP_IMAGE, .pos = coords, .object.image = (LCD_Image *)&(img) \
}
#define LCD_IMAGE2(x, y, img) \
(LCD_Component) \
{ \
.type = LCD_COMP_IMAGE, .pos = (LCD_Coordinate){x, y}, .object.image = (LCD_Image *)&(img) \
}
#define LCD_TEXT(coords, ...) \
(LCD_Component) \
{ \
.type = LCD_COMP_TEXT, .pos = coords, .object.text = (LCD_Text *)&((LCD_Text)__VA_ARGS__) \
}
#define LCD_TEXT2(x, y, ...) \
(LCD_Component) \
{ \
.type = LCD_COMP_TEXT, .pos = (LCD_Coordinate){x, y}, .object.text = (LCD_Text *)&((LCD_Text)__VA_ARGS__) \
}
// BUTTON
#define LCD_BUTTON_LABEL(...) (LCD_ButtonLabel) __VA_ARGS__
#define LCD_BUTTON2(x, y, out_button_area, ...) \
((out_button_area = TP_AssignButtonArea((LCD_Button)__VA_ARGS__, (LCD_Coordinate){x, y})), \
(LCD_Component){ \
.type = LCD_COMP_BUTTON, \
.pos = (LCD_Coordinate){x, y}, \
.object.button = (LCD_Button *)&((LCD_Button)__VA_ARGS__), \
})
#define LCD_BUTTON(coords, out_button_area, ...) \
((out_button_area = TP_AssignButtonArea((LCD_Button)__VA_ARGS__, coords)), \
(LCD_Component){ \
.type = LCD_COMP_BUTTON, \
.pos = coords, \
.object.button = (LCD_Button *)&((LCD_Button)__VA_ARGS__), \
})
#endif