942bbfaefe
* add input debounce code from old fw * exampl of input api * change input API to get/release * revert input API to read * pointer instead of instance * add input API description * add display API * rewrite display names * migrate to valuemanager * add LED API * add closing brakets * add sound api * fix led api * basic api * rename API pages * change pubsub implementation * move FURI AC -> flapp, add valuemutex example, add valuemanager implementation * pubsub usage example * user led example * update example * simplify input * add composed display * add SPI/GPIO and CC1101 bus * change cc1101 api * spi api and devices * spi api and devices * move SPI to page, add GPIO * not block pin open * backlight API and more * add minunit tests * fix logging * ignore unexisting time service on embedded targets * fix warning, issue with printf * Deprecate furi_open and furi_close (#167) Rename existing furi_open and furi_close to deprecated version * add exitcode * migrate to printf * indicate test by leds * add testing description * rename furi.h * wip basic api * add valuemutex, pubsub, split files * add value expanders * value mutex realization and tests * valuemutex test added to makefile * do not build unimplemented files * fix build furmware target f2 * redesigned minunit tests to allow testing in separate files * test file for valuemutex minunit testing * minunit partial test valuemutex * local cmsis_os2 mutex bindings * implement furi open/create, tests * migrate concurrent_access to ValueMutex * add spi header * Lib: add mlib submodule. Co-authored-by: rusdacent <rusdacentx0x08@gmail.com> Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2.0 KiB
2.0 KiB
All display operations based on u8g2 library.
API available as ValueComposer
.
Driver call render callback and pass API contains u8g2 functions, instance and fonts:
typedef struct {
u8g2_t* display;
void (*u8g2_SetFont)(u8g2_t *u8g2, const uint8_t *font);
void (*u8g2_SetDrawColor)(u8g2_t *u8g2, uint8_t color);
void (*u8g2_SetFontMode)(u8g2_t *u8g2, uint8_t is_transparent);
u8g2_uint_t (*u8g2_DrawStr)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
Fonts fonts;
} DisplayApi;
typedef struct {
const uint8_t* u8g2_font_6x10_mf;
} Fonts;
First of all you can open display API instance by calling open_display
/// Get display instance and API
inline Display* open_display(const char* name) {
return (Display*)furi_open(name);
}
Default display name is /dev/display
.
For draw something to display you need to register new layer in display composer:
typedef void (RenderCallback*)(void* ctx, DisplayApi* api);
inline ValueComposerHandle* init_display_composer(
Display* api, RenderCallback render, void* ctx, uint32_t layer) {
return add_compose_layer(api->composer, (ValueComposerCallback)render, ctx, layer);
}
And then call request_compose
every time you need to redraw your image.
Usage example
void example_render(void* ctx, DisplayApi* api) {
api->u8g2_SetFont(api->display, display_api->fonts.u8g2_font_6x10_mf);
api->u8g2_SetDrawColor(api->display, 1);
api->u8g2_SetFontMode(api->display, 1);
api->u8g2_DrawStr(api->display, 2, 12, (char*)ctx); // ctx contains some static text
}
void u8g2_example(void* p) {
Display* display_api = open_display("/dev/display");
if(display_api == NULL) return; // display not available, critical error
ValueComposerHandle display_handler = init_display_composer(
display_api, example_render, (void*)"Hello world", UiLayerBelowNotify);
request_compose(display_handler);
}