杰理-文字组合显示
// -----------------------------------------睡眠-文字组合显示(星期)-------------------------------------------
static u16 T_Main_ItemString[1][7];
static const u16 Week_text[] = {
M1080,
M1074,
M1075,
M1076,
M1077,
M1078,
M1079,
M1072,
M1073,
M1097,
};
#define UI_RGB565(c) \
_RGB565((c>>16)&0xff,(c>>8)&0xff,c&0xff)
void week_text_combine_show(u16 *buf, u8 *show_buf)
{
u8 count = 0;
for(u8 i=0;i<7;i++)
{
if(show_buf[i] == 1)
{
buf[count++] = Week_text[i];
}
}
if(count == 0)
{
count = 1;
memset(buf,0,sizeof(buf));
buf[0] = Week_text[9];
buf[1] = 0;
}
else if(count == 5)
{
if(show_buf[6] == 0 && show_buf[0] == 0)
{
count = 1;
memset(buf,0,sizeof(buf));
buf[0] = Week_text[7];
buf[1] = 0;
}
}
else if(count == 7)
{
count = 1;
memset(buf,0,sizeof(buf));
buf[0] = Week_text[8];
buf[1] = 0;
}
for(u8 i=0;i<=count;i++)
{
G_log("-buf[%d] = %d ---",i,buf[i]);
}
}
static int SLEEP_WEEK_CHOOSE_onchange(void *ctr, enum element_change_event e, void *arg)
{
struct ui_grid *grid = (struct ui_grid *)ctr;
struct ui_text *text = (struct ui_text *)ctr;
switch (e) {
case ON_CHANGE_INIT:
memset(T_Main_ItemString,0,sizeof(T_Main_ItemString));
week_text_combine_show(T_Main_ItemString[0],sleep_curr_week);
text->attrs.str = (char *)(T_Main_ItemString[0]);
text->attrs.format = "mulstr";
break;
}
return false;
}
REGISTER_UI_EVENT_HANDLER(SLEEP_WEEK_CHOOSE)
.onchange = SLEEP_WEEK_CHOOSE_onchange,
.onkey = NULL,
.ontouch = NULL,
};
REGISTER_UI_EVENT_HANDLER(SLEEP_EDIT_TIMER_TEXT)
.onchange = SLEEP_WEEK_CHOOSE_onchange,
.onkey = NULL,
.ontouch = NULL,
};