update:
flexinfo now supports LiveView too.
just add your configuration there.
info_elem_t info_config_liveview[] =
{
{ .config = { { INFO_TYPE_CONFIG } } },
{ .text = { { INFO_TYPE_TEXT, { 150, 20, 2, .name = "Note" }}, "<FlexInfo unconfigured>", COLOR_CYAN, INFO_COL_PEEK, INFO_FONT_SMALL } },
{ .type = INFO_TYPE_END },
};
we now have dynamic configuration
just register a element using
info_elem_t *info_add_item();
you get a info_elem_t* back, that you can set up exactly like the static configuration in flexinfo.c
set its type e.g. to INFO_TYPE_STRING and fill the fields and it will print the specified string
we now have dynamic items
register a new item using info_add_item(), set its type to INFO_TYPE_DYNAMIC and register a print() function.
whenever flexinfo redraws, your code gets called and has to:
- always update element->pos.x, y, w, h
- paint ONLY when (run_type == INFO_PRINT)
here some example:
#include <flexinfo.h>
uint32_t dyn_print(info_elem_t *element, uint32_t run_type)
{
element->hdr.pos.w = 200;
element->hdr.pos.h = 40;
switch(run_type)
{
case INFO_PRERUN:
break;
case INFO_PRINT:
bmp_printf(FONT_LARGE, element->hdr.pos.x, element->hdr.pos.y, "TEST");
break;
}
element->hdr.pos.x++;
element->hdr.pos.x %= 600;
return 0;
}
static void run_test()
{
info_elem_t *item = info_add_item();
item->dynamic.print = &dyn_print;
item->dynamic.hdr.pos.x = 0;
item->dynamic.hdr.pos.y = 40;
item->dynamic.hdr.pos.z = 2;
strcpy(item->dynamic.hdr.pos.name, "Test");
/* set the type as last, to make sure it is not being used before in the other tasks */
item->dynamic.hdr.type = INFO_TYPE_DYNAMIC;
return;
}