This commit is contained in:
kraus 2021-08-28 10:43:44 +02:00
parent e84c6925db
commit cc15f29bf4
8 changed files with 396 additions and 88 deletions

View File

@ -458,26 +458,26 @@ fds_t mui_find_form(mui_t *ui, uint8_t n)
uint8_t mui_task_draw(mui_t *ui)
{
//printf("mui_task_draw fds=%p uif=%p text=%s\n", ui->fds, ui->uif, ui->text);
muif_tget_cb(ui->uif)(ui, MUIF_MSG_DRAW);
muif_get_cb(ui->uif)(ui, MUIF_MSG_DRAW);
return 0; /* continue with the loop */
}
uint8_t mui_task_form_start(mui_t *ui)
{
muif_tget_cb(ui->uif)(ui, MUIF_MSG_FORM_START);
muif_get_cb(ui->uif)(ui, MUIF_MSG_FORM_START);
return 0; /* continue with the loop */
}
uint8_t mui_task_form_end(mui_t *ui)
{
muif_tget_cb(ui->uif)(ui, MUIF_MSG_FORM_END);
muif_get_cb(ui->uif)(ui, MUIF_MSG_FORM_END);
return 0; /* continue with the loop */
}
uint8_t mui_task_find_prev_cursor_uif(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
if ( ui->fds == ui->cursor_focus_fds )
{
@ -491,7 +491,7 @@ uint8_t mui_task_find_prev_cursor_uif(mui_t *ui)
uint8_t mui_task_find_first_cursor_uif(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
// if ( ui->target_fds == NULL )
// {
@ -504,7 +504,7 @@ uint8_t mui_task_find_first_cursor_uif(mui_t *ui)
uint8_t mui_task_find_last_cursor_uif(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
//ui->cursor_focus_position++;
ui->target_fds = ui->fds;
@ -514,7 +514,7 @@ uint8_t mui_task_find_last_cursor_uif(mui_t *ui)
uint8_t mui_task_find_next_cursor_uif(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
if ( ui->tmp_fds != NULL )
{
@ -532,7 +532,7 @@ uint8_t mui_task_find_next_cursor_uif(mui_t *ui)
uint8_t mui_task_get_current_cursor_focus_position(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
if ( ui->fds == ui->cursor_focus_fds )
return 1; /* stop looping */
@ -543,7 +543,7 @@ uint8_t mui_task_get_current_cursor_focus_position(mui_t *ui)
uint8_t mui_task_read_nth_seleectable_field(mui_t *ui)
{
if ( muif_tget_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
if ( muif_get_cflags(ui->uif) & MUIF_CFLAG_IS_CURSOR_SELECTABLE )
{
if ( ui->tmp8 == 0 )
return 1; /* stop looping */
@ -561,7 +561,7 @@ void mui_send_cursor_msg(mui_t *ui, uint8_t msg)
{
ui->fds = ui->cursor_focus_fds;
if ( mui_prepare_current_field(ui) )
muif_tget_cb(ui->uif)(ui, msg);
muif_get_cb(ui->uif)(ui, msg);
}
}

View File

@ -75,12 +75,12 @@ struct muif_struct
#define UIF(id,cflags,data,cb) { id[0], id[1], cflags, 0, data, cb}
#define muif_tget_id0(muif) ((muif)->id0)
#define muif_tget_id1(muif) ((muif)->id1)
#define muif_tget_cflags(muif) ((muif)->cflags)
#define muif_tget_extra(muif) ((muif)->extra)
#define muif_tget_data(muif) ((muif)->data)
#define muif_tget_cb(muif) ((muif)->cb)
#define muif_get_id0(muif) ((muif)->id0)
#define muif_get_id1(muif) ((muif)->id1)
#define muif_get_cflags(muif) ((muif)->cflags)
#define muif_get_extra(muif) ((muif)->extra)
#define muif_get_data(muif) ((muif)->data)
#define muif_get_cb(muif) ((muif)->cb)
#define MUIF_MSG_NONE 0
#define MUIF_MSG_DRAW 1

View File

@ -42,11 +42,11 @@
/*
uint8_t muif_template(mui_t *ui, uint8_t msg)
uint8_t mui_emplate(mui_t *ui, uint8_t msg)
{
//ui->dflags MUIF_DFLAG_IS_CURSOR_FOCUS MUIF_DFLAG_IS_TOUCH_FOCUS
//muif_tget_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
//muif_tget_data(ui->uif)
//muif_get_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
//muif_get_data(ui->uif)
switch(msg)
{
case MUIF_MSG_DRAW:
@ -97,9 +97,6 @@ uint8_t muif_template(mui_t *ui, uint8_t msg)
Side effect: Font transparent mode is enabled setFontMode(1)
if padding_h is larger than or equal to half of the display width, then the button size is maximized to the display size
*/
@ -255,6 +252,7 @@ void u8g2_DrawRadio(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u
#endif
#ifdef _THIS_CODE_SHOULD_BE_REWRITTEN_WITHOUT_PADWIDTH_
/*
Shadow is not supported
@ -265,6 +263,7 @@ void u8g2_DrawRadio(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u
2 | 3, 5, 7, 8, ...
*/
void u8g2_DrawRButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t padding_h_or_width, u8g2_uint_t padding_v, u8g2_uint_t r, const char *text)
{
u8g2_uint_t w = u8g2_GetUTF8Width(u8g2, text);
@ -344,6 +343,8 @@ void u8g2_DrawRButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_
u8g2_SetDrawColor(u8g2, color_backup);
}
#endif
/*=========================================================================*/
/* helper function */
@ -369,10 +370,10 @@ u8g2_t *mui_get_U8g2(mui_t *ui)
/*
xy: yes, arg: no, text: yes
*/
uint8_t muif_tframe_button_bold_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_frame_button_bold_select_u8g2(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = U8G2_BTN_HCENTER | U8G2_BTN_PADWIDTH;
u8g2_uint_t flags = U8G2_BTN_HCENTER;
switch(msg)
{
case MUIF_MSG_DRAW:
@ -411,7 +412,7 @@ uint8_t muif_tframe_button_bold_select_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_thalf_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
A button with size equal to display width / 2 - 10 pixel
@ -434,7 +435,7 @@ uint8_t muif_tframe_button_bold_select_u8g2(mui_t *ui, uint8_t msg)
*/
uint8_t muif_thalf_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = U8G2_BTN_HCENTER | 1;
@ -467,7 +468,7 @@ uint8_t muif_thalf_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_tline_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
A full line button (covers complete width of the display).
@ -488,7 +489,7 @@ uint8_t muif_thalf_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
text: Button label
*/
uint8_t muif_tline_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
//u8g2_uint_t flags = U8G2_BTN_HCENTER ;
@ -523,7 +524,7 @@ uint8_t muif_tline_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_tradio_mark_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_radio_mark_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
A selectable button with a rectangle in front of it, if arg is equal to the current value (*(uint8_t *)data)
@ -544,11 +545,11 @@ uint8_t muif_tline_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
text: Button label
*/
uint8_t muif_tradio_mark_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_radio_mark_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = 0;
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
if ( value == NULL )
value = &(ui->selected_value);
switch(msg)
@ -615,7 +616,7 @@ uint8_t muif_tradio_mark_invers_select_u8g2(mui_t *ui, uint8_t msg)
xy: yes, arg: no, text: yes
*/
uint8_t muif_tlabel_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_label_u8g2(mui_t *ui, uint8_t msg)
{
switch(msg)
{
@ -642,7 +643,7 @@ uint8_t muif_tlabel_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_tgoto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_goto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
A button with size equal to display width / 2 - 10 pixel
@ -665,20 +666,20 @@ uint8_t muif_tlabel_u8g2(mui_t *ui, uint8_t msg)
text: Button label
*/
uint8_t muif_tgoto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_goto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
switch(msg)
{
case MUIF_MSG_CURSOR_SELECT:
return mui_GotoForm(ui, ui->arg, 0);
}
return muif_thalf_width_frame_button_invers_select_u8g2(ui, msg);
return mui_half_width_frame_button_invers_select_u8g2(ui, msg);
}
/*
uint8_t muif_tgoto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_goto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
A full line button (covers complete width of the display).
@ -701,20 +702,20 @@ uint8_t muif_tgoto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t
*/
uint8_t muif_tgoto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_goto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
switch(msg)
{
case MUIF_MSG_CURSOR_SELECT:
return mui_GotoForm(ui, ui->arg, 0);
}
return muif_tline_button_invers_select_u8g2(ui, msg);
return mui_line_button_invers_select_u8g2(ui, msg);
}
/*
uint8_t muif_tinput_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_input_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
Select a number between 0 and 9.
@ -738,13 +739,13 @@ uint8_t muif_tgoto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg)
text: not used
*/
uint8_t muif_tinput_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_input_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
//ui->dflags MUIF_DFLAG_IS_CURSOR_FOCUS MUIF_DFLAG_IS_TOUCH_FOCUS
//muif_tget_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
//mui_get_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = 0;
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
char buf[6];
switch(msg)
{
@ -782,7 +783,7 @@ uint8_t muif_tinput_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_single_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
Select one of several options. First option has value 0.
@ -805,14 +806,14 @@ uint8_t muif_tinput_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg)
text: '|' separated list of options
*/
uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_single_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
//ui->dflags MUIF_DFLAG_IS_CURSOR_FOCUS MUIF_DFLAG_IS_TOUCH_FOCUS
//muif_tget_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
//mui_get_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = 0;
//u8g2_uint_t flags = 0;
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -851,14 +852,14 @@ uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t muif_tshow_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_show_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
//ui->dflags MUIF_DFLAG_IS_CURSOR_FOCUS MUIF_DFLAG_IS_TOUCH_FOCUS
//muif_tget_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
//mui_get_cflags(ui->uif) MUIF_CFLAG_IS_CURSOR_SELECTABLE
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = 0;
//u8g2_uint_t flags = 0;
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -897,7 +898,7 @@ uint8_t muif_tshow_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg)
/*
uint8_t muif_tcheckbox_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_checkbox_invers_select_u8g2(mui_t *ui, uint8_t msg)
Description:
Checkbox with the values 0 (not selected) and 1 (selected).
@ -919,11 +920,11 @@ uint8_t muif_tshow_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg)
*/
uint8_t muif_tcheckbox_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_checkbox_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
u8g2_uint_t flags = 0;
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
switch(msg)
{
case MUIF_MSG_DRAW:
@ -973,15 +974,15 @@ uint8_t muif_tcheckbox_invers_select_u8g2(mui_t *ui, uint8_t msg)
}
uint8_t muif_tassign_arg_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_assign_arg_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
if ( value == NULL )
value = &(ui->selected_value);
switch(msg)
{
case MUIF_MSG_DRAW:
return muif_tradio_mark_invers_select_u8g2(ui, msg);
return mui_radio_mark_invers_select_u8g2(ui, msg);
case MUIF_MSG_FORM_START:
break;
case MUIF_MSG_FORM_END:
@ -1002,15 +1003,15 @@ uint8_t muif_tassign_arg_invers_select_u8g2(mui_t *ui, uint8_t msg)
}
uint8_t muif_tassign_arg_go_back_invers_select_u8g2(mui_t *ui, uint8_t msg)
uint8_t mui_assign_arg_go_back_invers_select_u8g2(mui_t *ui, uint8_t msg)
{
uint8_t *value = (uint8_t *)muif_tget_data(ui->uif);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
if ( value == NULL )
value = &(ui->selected_value);
switch(msg)
{
case MUIF_MSG_DRAW:
return muif_tradio_mark_invers_select_u8g2(ui, msg);
return mui_radio_mark_invers_select_u8g2(ui, msg);
case MUIF_MSG_FORM_START:
break;
case MUIF_MSG_FORM_END:

View File

@ -59,28 +59,28 @@
#define U8G2_BTN_HCENTER 0x40
/* use padding_h value as total string width */
#define U8G2_BTN_PADWIDTH 0x80
//#define U8G2_BTN_PADWIDTH 0x80
void u8g2_DrawButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text);
/* incomplete field functions */
uint8_t muif_tframe_button_bold_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_thalf_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tline_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_frame_button_bold_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
/* ready to use field functions */
uint8_t muif_tlabel_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tgoto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tgoto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tinput_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tshow_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_label_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_goto_half_width_frame_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_goto_line_button_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_input_uint8_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_single_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_show_option_goto_form_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tcheckbox_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t muif_tassign_arg_go_back_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_checkbox_invers_select_u8g2(mui_t *ui, uint8_t msg);
uint8_t mui_assign_arg_go_back_invers_select_u8g2(mui_t *ui, uint8_t msg);
#endif /* mui_u8g2_h */

12
sys/sdl/mui/Makefile Normal file
View File

@ -0,0 +1,12 @@
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags`
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) $(shell ls *.c )
OBJ = $(SRC:.c=.o)
u8g2_sdl: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_sdl
clean:
-rm $(OBJ) u8g2_sdl

302
sys/sdl/mui/main.c Normal file
View File

@ -0,0 +1,302 @@
#include "u8g2.h"
#include <stdio.h>
#include <string.h>
#include "mui.h"
#include "mui_u8g2.h"
u8g2_t u8g2;
mui_t ui;
uint8_t my_value = 2;
uint8_t my_value2 = 2;
uint8_t my_value3 = 0;
uint8_t my_color = 0;
uint8_t touchscreen_selection = 255;
uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg);
muif_t muif_list[] = {
UIF("B0",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_half_width_frame_button_invers_select_u8g2),
UIF("B1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_half_width_frame_button_invers_select_u8g2),
UIF("I1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value,mui_input_uint8_invers_select_u8g2),
UIF("I2",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value2,mui_single_line_option_invers_select_u8g2),
UIF("I3",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value3,mui_checkbox_invers_select_u8g2),
UIF("I4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,mui_show_option_goto_form_invers_select_u8g2),
UIF("O4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,mui_assign_arg_go_back_invers_select_u8g2),
UIF("TS",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&touchscreen_selection,mui_single_line_option_invers_select_u8g2),
UIF(".G",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_goto_half_width_frame_button_invers_select_u8g2), /* MUI_GOTO has the id FG */
UIF(".g",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_goto_line_button_invers_select_u8g2), /* MUI_goto has the id Fg */
UIF(".L",0,0,mui_label_u8g2)
};
fds_t fds =
MUI_FORM(1)
MUI_goto(12,10,2, "Test 1")
MUI_goto(12,22,10, "Button Test")
MUI_goto(12,34,101, "Story")
MUI_FORM(2)
MUI_LABEL(0,10, "Number:")
MUI_XY("I1",50, 10)
MUI_LABEL(0,22, "Fruit:")
MUI_XYAT("I2",50, 22, 60, "Banana|Apple|Peach")
MUI_LABEL(0,34, "Check:")
//MUI_XYT("I3",50, 44, "ABCxyz")
MUI_XY("I3",50, 34)
MUI_LABEL(0,46, "Color:")
MUI_XYAT("I4",50, 46, 4, "red|green|blue")
//MUI_BUTTON("B1",32,50, "Ok")
MUI_GOTO(32,60,3, "Goto 2")
MUI_GOTO(96,60,1, "Home")
MUI_FORM(3)
MUI_goto(32,50,2, "Goto 1")
MUI_FORM(4)
MUI_XYA("O4", 2, 10, 0)
MUI_XYA("O4", 2, 22, 1)
MUI_XYAT("O4", 2, 34, 2, "blue color") /* provide a different text for this option */
MUI_FORM(10)
MUI_goto(10,11,11, "Btn 1")
MUI_goto(10,21,12, "Btn 2")
MUI_goto(10,31,13, "Btn 3")
MUI_goto(10,41,14, "Btn 4")
MUI_goto(10,51,15, "Btn 5")
MUI_goto(10,61,1, "Home")
MUI_FORM(11)
MUI_goto(10,61,10, "Back")
MUI_FORM(12)
MUI_goto(10,61,10, "Back")
MUI_FORM(13)
MUI_goto(10,61,10, "Back")
MUI_FORM(14)
MUI_goto(10,61,10, "Back")
MUI_FORM(15)
MUI_goto(10,61,10, "Back")
MUI_FORM(16)
MUI_goto(10,61,10, "Back")
MUI_FORM(101)
MUI_LABEL(0, 10, "Robot enabled.")
MUI_LABEL(0, 20, "KI activated.")
MUI_GOTO(32,60,102, "Move Out")
MUI_GOTO(96,60,3, "Diagnostics")
MUI_FORM(102)
MUI_LABEL(0, 9, "Floor.")
MUI_LABEL(0, 19, "Robot holder in the wall.")
MUI_LABEL(0, 29, "")
MUI_goto(10,41,107, "Forward")
MUI_goto(10,51,103, "Backward")
MUI_goto(10,61,101, "Into Holder")
MUI_FORM(103)
MUI_LABEL(0, 9, "Floor.")
MUI_LABEL(0, 19, "")
MUI_LABEL(0, 29, "")
MUI_goto(10,41,102, "Forward")
MUI_goto(10,51,104, "Visual Scan")
MUI_goto(10,61,106, "Audio Scan")
MUI_FORM(104)
MUI_LABEL(0, 9, "Visual scan mode.")
MUI_LABEL(0, 19, "Floor to front.")
MUI_LABEL(0, 29, "Backside Window.")
//MUI_goto(10,41,102, "Forward")
MUI_goto(10,51,105, "Scan Window")
MUI_goto(10,61,103, "Exit Scan")
MUI_FORM(105)
MUI_LABEL(0, 9, "Visual scan mode.")
MUI_LABEL(0, 19, "Window:")
MUI_LABEL(0, 29, "Black with white dots.")
//MUI_goto(10,41,102, "Forward")
MUI_goto(10,51,104, "Visual Scan")
MUI_goto(10,61,103, "Exit Scan")
MUI_FORM(106)
MUI_LABEL(0, 9, "Audio scan mode.")
MUI_LABEL(0, 19, "No audio.")
//MUI_LABEL(0, 29, "")
//MUI_goto(10,41,102, "Forward")
//MUI_goto(10,51,104, "Visual Scan")
MUI_goto(10,61,103, "Exit Scan")
MUI_FORM(107)
MUI_LABEL(0, 9, "Floor.")
MUI_LABEL(0, 19, "")
//MUI_LABEL(0, 29, "")
//MUI_goto(10,41,102, "Forward")
MUI_goto(10,51,108, "Visual Scan")
MUI_goto(10,61,102, "Backward")
MUI_FORM(108)
MUI_LABEL(0, 9, "Visual scan mode.")
MUI_LABEL(0, 19, "Touchscreen.")
MUI_LABEL(0, 29, "Door with button.")
//MUI_LABEL(0, 29, "")
MUI_goto(10,41,109, "Press Door Button")
MUI_goto(10,51,110, "Use Touchscreen")
MUI_goto(10,61,107, "Exit Scan")
MUI_FORM(109)
MUI_LABEL(0, 9, "Visual scan mode.")
MUI_LABEL(0, 19, "Door does not open.")
//MUI_LABEL(0, 29, "")
//MUI_goto(10,41,109, "Press Door Button")
//MUI_goto(10,51,110, "Use Touchscreen")
MUI_goto(10,61,107, "Exit Scan")
MUI_FORM(110)
MUI_LABEL(0, 9, "Touchscreen.")
MUI_XYT("TS",0, 25, "Navigation|Energy|Damage|Robot|Security")
MUI_goto(10,61,108, "Exit Touchscreen")
;
int main(void)
{
int x, y;
int k;
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
mui_Init(&ui, &u8g2, fds, muif_list, sizeof(muif_list)/sizeof(muif_t));
mui_EnterForm(&ui, 0);
puts(fds);
x = 4; // use as height for the box
y = 0;
for(;;)
{
u8g2_FirstPage(&u8g2);
do
{
u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr);
u8g2_SetFont(&u8g2, u8g2_font_inb16_mf );
u8g2_SetFont(&u8g2, u8g2_font_courB12_tr);
u8g2_SetFont(&u8g2, u8g2_font_timR08_tr);
u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
u8g2_SetFontMode(&u8g2, 1);
//u8g2_SetFontPosTop(&u8g2);
//u8g2_SetFontPosBottom(&u8g2);
//u8g2_SetFontPosCenter(&u8g2);
u8g2_SetFontRefHeightExtendedText(&u8g2);
if ( ui.current_form_fds[1] == 11 )
{
u8g2_DrawButtonUTF8(&u8g2, 64, 9, /*flags*/U8G2_BTN_HCENTER, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0");
u8g2_DrawButtonUTF8(&u8g2, 64, 22, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0 Inv");
u8g2_DrawButtonUTF8(&u8g2, 64, 35, /*flags*/U8G2_BTN_HCENTER, /*w*/ 128, /*ph*/ 0, /*pv*/0, "Center W128");
u8g2_DrawButtonUTF8(&u8g2, 64, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV, /*w*/ 128, /*ph*/ 0, /*pv*/0, "Center W128 Inv");
}
if ( ui.current_form_fds[1] == 12 )
{
u8g2_DrawButtonUTF8(&u8g2, 64, 9, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0");
u8g2_DrawButtonUTF8(&u8g2, 64, 22, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0 Inv");
u8g2_DrawButtonUTF8(&u8g2, 64, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 126, /*ph*/ 0, /*pv*/0, "Center W128");
u8g2_DrawButtonUTF8(&u8g2, 64, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 126, /*ph*/ 0, /*pv*/0, "Center W128 Inv");
}
if ( ui.current_form_fds[1] == 13 )
{
u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, "C");
u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
u8g2_uint_t x = 5;
u8g2_uint_t y = 9;
u8g2_DrawStr(&u8g2, x, y, "C");
u8g2_DrawFrame(&u8g2, x-1,y-u8g2_GetAscent(&u8g2)-1, w+2, h+2);
u8g2_DrawButtonUTF8(&u8g2, 64, 9, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0");
u8g2_DrawButtonUTF8(&u8g2, 64, 22, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0 Inv");
u8g2_DrawButtonUTF8(&u8g2, 10, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "v");
u8g2_DrawButtonUTF8(&u8g2, 10, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "v");
u8g2_DrawButtonUTF8(&u8g2, 24, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "vd");
u8g2_DrawButtonUTF8(&u8g2, 24, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "vd");
u8g2_DrawButtonUTF8(&u8g2, 40, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "B");
u8g2_DrawButtonUTF8(&u8g2, 40, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "B");
u8g2_DrawButtonUTF8(&u8g2, 60, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "A");
u8g2_DrawButtonUTF8(&u8g2, 60, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "A");
u8g2_DrawButtonUTF8(&u8g2, 80, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Ab");
u8g2_DrawButtonUTF8(&u8g2, 80, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Ab");
u8g2_DrawButtonUTF8(&u8g2, 100, 35, /*flags*/U8G2_BTN_HCENTER|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Abg");
u8g2_DrawButtonUTF8(&u8g2, 100, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Abg");
}
if ( ui.current_form_fds[1] == 14 )
{
u8g2_DrawButtonUTF8(&u8g2, 64, 9, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_SHADOW0|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0");
u8g2_DrawButtonUTF8(&u8g2, 64, 22, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|1, /*w*/ 0, /*ph*/ 0, /*pv*/0, "Center W0 Inv");
u8g2_DrawButtonUTF8(&u8g2, 64, 35, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_SHADOW0|1, /*w*/ 124, /*ph*/ 0, /*pv*/0, "Center W128");
u8g2_DrawButtonUTF8(&u8g2, 64, 48, /*flags*/U8G2_BTN_HCENTER|U8G2_BTN_INV|U8G2_BTN_SHADOW0|1, /*w*/ 124, /*ph*/ 0, /*pv*/0, "Center W128 Inv");
}
if ( ui.current_form_fds[1] == 15 )
{
u8g2_uint_t x = 24;
u8g2_DrawButtonUTF8(&u8g2, 8-8, 9, /*flags*/U8G2_BTN_INV, /*w*/ 112+8*2, /*ph*/ 0, /*pv*/0, "Line");
u8g2_DrawButtonUTF8(&u8g2, 8-4, 22, /*flags*/U8G2_BTN_INV, /*w*/ 112+4*2, /*ph*/ 4, /*pv*/0, "Line");
u8g2_DrawButtonUTF8(&u8g2, x, 35, /*flags*/U8G2_BTN_INV, /*w*/ 128-2*x, /*ph*/ x, /*pv*/0, "Line");
}
//u8g2_DrawBox(&u8g2, 10, 10+y, 20, x);
//u8g2_DrawFrame(&u8g2, 34, 10+y, 20, x);
//u8g2_DrawStr(&u8g2, 10, 50, "XY");
mui_Draw(&ui);
} while( u8g2_NextPage(&u8g2) );
// printf("mui_GetCurrentCursorFocusPosition=%d\n", mui_GetCurrentCursorFocusPosition(&ui));
do
{
k = u8g_sdl_get_key();
} while( k < 0 );
if ( k == 273 ) y -= 1;
if ( k == 274 ) y += 1;
if ( k == 276 ) x -= 1;
if ( k == 275 ) x += 1;
/*
if ( k == 'e' ) y -= 1;
if ( k == 'x' ) y += 1;
if ( k == 's' ) x -= 1;
if ( k == 'd' ) x += 1;
*/
if ( k == 'q' ) break;
if ( k == 'n' ) mui_NextField(&ui);
if ( k == 'p' ) mui_PrevField(&ui);
if ( k == 's' ) mui_SendSelect(&ui);
if ( x < 0 )
x = 0;
}
return 0;
}

View File

@ -7,13 +7,6 @@ OBJ = $(SRC:.c=.o)
u8g2_sdl: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_sdl
mui.o: mui.h mui_u8g2.h
mui_u8g2.o: mui.h mui_u8g2.h
main.o: mui.h mui_u8g2.h
clean:
-rm $(OBJ) u8g2_sdl

View File

@ -20,19 +20,19 @@ uint8_t muif_tsingle_line_option_invers_select_u8g2(mui_t *ui, uint8_t msg);
muif_t muif_list[] = {
UIF("B0",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,muif_thalf_width_frame_button_invers_select_u8g2),
UIF("B1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,muif_thalf_width_frame_button_invers_select_u8g2),
UIF("I1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value,muif_tinput_uint8_invers_select_u8g2),
UIF("I2",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value2,muif_tsingle_line_option_invers_select_u8g2),
UIF("I3",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value3,muif_tcheckbox_invers_select_u8g2),
UIF("I4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,muif_tshow_option_goto_form_invers_select_u8g2),
UIF("B0",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_half_width_frame_button_invers_select_u8g2),
UIF("B1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_half_width_frame_button_invers_select_u8g2),
UIF("I1",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value,mui_input_uint8_invers_select_u8g2),
UIF("I2",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value2,mui_single_line_option_invers_select_u8g2),
UIF("I3",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_value3,mui_checkbox_invers_select_u8g2),
UIF("I4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,mui_show_option_goto_form_invers_select_u8g2),
UIF("O4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,muif_tassign_arg_go_back_invers_select_u8g2),
UIF("O4",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&my_color,mui_assign_arg_go_back_invers_select_u8g2),
UIF("TS",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&touchscreen_selection,muif_tsingle_line_option_invers_select_u8g2),
UIF(".G",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,muif_tgoto_half_width_frame_button_invers_select_u8g2), /* MUI_GOTO has the id FG */
UIF(".g",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,muif_tgoto_line_button_invers_select_u8g2), /* MUI_goto has the id Fg */
UIF(".L",0,0,muif_tlabel_u8g2)
UIF("TS",MUIF_CFLAG_IS_CURSOR_SELECTABLE,&touchscreen_selection,mui_single_line_option_invers_select_u8g2),
UIF(".G",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_goto_half_width_frame_button_invers_select_u8g2), /* MUI_GOTO has the id FG */
UIF(".g",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,mui_goto_line_button_invers_select_u8g2), /* MUI_goto has the id Fg */
UIF(".L",0,0,mui_label_u8g2)
};
fds_t fds =