📄 mcugui.c
字号:
else if (Gui.focus_buf[Gui.focus_cursor] == '9')
Gui.focus_buf[Gui.focus_cursor] = ' ';
else if (Gui.focus_buf[Gui.focus_cursor] == 'Z')
Gui.focus_buf[Gui.focus_cursor] = '-';
else
Gui.focus_buf[Gui.focus_cursor]++;
break;
}
}
/* */
void DrawCtrlBMP(int index)
{
const CONTROL *ctrl;
ctrl = &Win[Gui.active_win].controls[Gui.active_ctrl];
index = index;
}
void DrawDrid(uchar type, uchar top)
{
type = type;
top = top;
}
/*****************************************************************************/
/* text and graphics function*/
/* bright font blink hide*/
uchar EditSafe(char *buf, char *fmt, int value)
{
uchar ch; /* character in format string */
uchar i, len;
uchar format = 0, flag = 0; /* b7 - zero fill float */
char *ofmt;
int min, max, limit_low, limit_up, mult;
format = min = max = 0;
limit_low = 0;
limit_up = 0x7FFF;
ofmt = fmt;
for( ;; )
{
ch = *fmt++;
if( !ch )
return 0;
else if( ch == '%' )
{
while( 1 )
{
ch = *fmt++;
if( ch == '-' )
flag |= 0x40; /* left alignment */
else if( ch == '+' )
flag = (flag & 0xF3) | 0x04;
else if( ch == ' ' )
{
/* do not overrule '+' */
if( !(flag & 0x0C) )
flag |= 0x08; /* sign or space */
}
else if( ch == '#' )
flag |= 0x10; /* alternate print */
else
break;
}
while( ch >= '0' && ch <= '9' )
{ /* get minimum field width */
min = min * 10 + ch - '0';
ch = *fmt++;
}
if( ch == '.' || ch == '~' )
{ /* next argument is maximum field width specifier */
ch = *fmt++;
while( ch >= '0' && ch <= '9' )
{ /* get maximum field width */
max = max * 10 + ch - '0';
ch = *fmt++;
}
}
switch (ch)
{
case 'd':
case 'x':
case 'X':
if (limit_up == 0)
{
limit_low = 0;
limit_up = 0x7FFF;
}
fmt = ofmt;
len = TextFormat(buf, fmt, limit_low);
if (Gui.focus_format == EF_NUM)
{
len = left_nrm(buf, len);
}
buf[len] = '~';
fmt = ofmt;
min = TextFormat(&buf[1+len], fmt, limit_up);
if (Gui.focus_format == EF_NUM)
{
min = left_nrm(&buf[1+len], min);
len += min+1;
}
if (value > limit_up )
return 1;
else if (value < limit_low)
return 2;
else
return 0;
break;
case 's':
//ss
break;
case 'b':
limit_low = min;
if (max == 0)
limit_up = 0x7FFF;
else
limit_up = max;
if ((flag & 0x10) && 0)
{
limit_up >>= 1;
limit_low >>= 1;
}
break;
case 'm':
mult = min;
break;
default:
return 0;
}
}
}
return 0;
}
uchar GetFormat(char *fmt)
{
uchar ch; /* character in format string */
for( ;; )
{
ch = *fmt++;
if( !ch )
return 0;
else if( ch == '%' )
{
ch = *fmt++;
while(ch)
{
if (ch == 'D' || ch == 'd') return EF_NUM;
if (ch == 'X' || ch == 'x') return EF_HEX;
if (ch == 'S' || ch == 's') return EF_TEXT;
ch = *fmt++;
}
return 0;
}
}
}
/****************************************************************************/
void TimerProc(uchar event)
{
const CONTROL *ctrl;
/*
0系统延时 fen
1屏幕保护 fen
2均充周期时间 fen
3均充保护时间 fen
4稳流均充时间 fen
5转均充延时 fen
6电池测试时间 fen
*/
uchar i;
for (i = 0; i < TIMER_COUNT; i++)
{
ctrl = &Win[71].controls[i];
if (event & TIME_CHANGE_MIN)
{
if ((TimerCount[i] > 0) && (TS_MINUTE == (ctrl->style&0x0F)))
{
TimerCount[i]--;
if (TimerCount[i] == 0)
PostMsg(MSG_TOUT, i);
}
}
if (event & TIME_CHANGE_HOUR)
{
if ((TimerCount[i] > 0) && (TS_HOUR == (ctrl->style&0x0F)))
{
TimerCount[i]--;
if (TimerCount[i] == 0)
PostMsg(MSG_TOUT, i);
}
}
SetModuleData(MODULE_JKMK|DATA_TM, i, 0, TimerCount[i]);
}
}
void TimerAct(uchar index, uchar action)
{
const CONTROL *ctrl;
ctrl = &Win[71].controls[index];
switch (action)
{
case MSG_TPLAY:
if (TimerCount[index] < 0)
{
TimerCount[index] = -TimerCount[index];
}
if (TimerCount[index] == 0)
{
TimerCount[index] = TimerFull[index];
}
break;
case MSG_TSTART:
TimerCount[index] = TimerFull[index];
break;
case MSG_TPAUSE:
TimerCount[index] = -TimerCount[index];
break;
case MSG_TOUT:
TimeOut(index);
if (TS_LOOP == ctrl->style&0xF0)
{
PostMsg(MSG_TSTART, index);
}
if (TS_ONCE == ctrl->style&0xF0)
{
PostMsg(MSG_TSTOP, index);
}
if (TS_STOP == ctrl->style&0xF0)
{
PostMsg(MSG_TSTOP, index);
}
break;
case MSG_TSTOP:
TimerCount[index] = 0;
break;
case MSG_TRELOAD:
TimerInit();
if (TimerCount[index] < 0)
{
TimerCount[index] = -TimerFull[index];
}
else
{
TimerCount[index] = TimerFull[index];
}
break;
}
}
/****************************************************************************/
void TimerInit(void)
{
int i;
for (i = 0; i < TIMER_COUNT; i++)
{
TimerFull[i] = GetModuleData(MODULE_JKMK|DATA_TMCFG, i, 0);
}
}
/****************************************************************************/
void GetTime(uchar *buf)
{
//RTC_Get_TimeBuf(buf);
}
void SetDate(uchar yy, uchar mm, uchar dd)
{
yy = yy;
mm = mm;
dd = dd;
}
void SetTime(uchar hh, uchar mm, uchar ss)
{
hh = hh;
mm = mm;
ss = ss;
}
uchar SafeDate(uchar yy, uchar mm)
{
/* yy is 20XX */
uchar dd;
if (mm == 2)
dd = (yy%4 == 0) ? 29 : 28;
else
{
if (mm < 7 )
dd = (mm%2 == 0) ? 30 : 31;
else
dd = (mm%2 == 0) ? 31 : 30;
}
return dd;
}
/****************************************************************************/
void BeepPlay(void)
{
if (Gui.beep);
//SOUND = 0;
else;
//SOUND = 1;
}
/****************************************************************************/
void BeepOff(void)
{
//SOUND = 1;
}
/****************************************************************************/
void BeepSet(uint value)
{
Gui.beep = value;
BeepPlay();
}
/****************************************************************************/
uint BeepGet(void)
{
return Gui.beep;
}
/****************************************************************************/
/* window page manage function*/
int PageNum(void)
{
return Gui.page;
}
void PageNumHome(void)
{
Gui.page = 0;
}
void PageNumEnd(void)
{
Gui.page = Gui.max_page;
}
void PageNumPrev(void)
{
if (Gui.page) Gui.page--;
}
void PageNumNext(void)
{
Gui.page++;
if (Gui.page > Gui.max_page)
Gui.page = Gui.max_page;
}
void PageNumMax(int value)
{
Gui.max_page = value;
if (Gui.page > Gui.max_page)
{
Gui.page = Gui.max_page;
}
}
/* window page manage function*/
void PageNumPut(void)
{
uchar style;
style = 0;
if (Gui.win_status & WS_PAGENUM_HIDE)
{
return;
}
if (Gui.max_page == 0)
{
// TextOut(27, 0, " ", FONT_SMALL);
return;
}
switch (style)
{
case 0:
if (Gui.max_page < 9)
{
TextFormat(Gui.data_buf, "%1d", (int)Gui.page+1);
TextOut(27, 0, Gui.data_buf, FONT_SMALL);
TextOut(28, 0, "/", FONT_SMALL);
TextFormat(Gui.data_buf, "%1d", (int)Gui.max_page+1);
TextOut(29, 0, Gui.data_buf, FONT_SMALL);
}
else if (Gui.max_page < 99)
{
TextFormat(Gui.data_buf, "%2d", (int)Gui.page+1);
TextOut(25, 0, Gui.data_buf, FONT_SMALL);
TextOut(27, 0, "/", FONT_SMALL);
TextFormat(Gui.data_buf, "%2d", (int)Gui.max_page+1);
TextOut(28, 0, Gui.data_buf, FONT_SMALL);
}
else
{
TextFormat(Gui.data_buf, "%3d", (int)Gui.page+1);
TextOut(23, 0, Gui.data_buf, FONT_SMALL);
TextOut(26, 0, "/", FONT_SMALL);
TextFormat(Gui.data_buf, "%3d", (int)Gui.max_page+1);
TextOut(27, 0, Gui.data_buf, FONT_SMALL);
}
break;
case 1:
if (Gui.page == 0)
{// ->
TextOut(28, 0, " >", FONT_SMALL);
}
else if (Gui.page == Gui.max_page)
{// <-
TextOut(28, 0, "< ", FONT_SMALL);
}
else
{// <->
TextOut(28, 0, "<>", FONT_SMALL);
}
break;
case 2:
if (Gui.page == 0)
{// ->
TextOut(29, 0, " ", FONT_SMALL);
TextOut(29, 1, "}", FONT_SMALL);
}
else if (Gui.page == Gui.max_page)
{// <-
TextOut(29, 0, "{", FONT_SMALL);
TextOut(29, 1, " ", FONT_SMALL);
}
else
{// <->
TextOut(29, 0, "{", FONT_SMALL);
TextOut(29, 1, "}", FONT_SMALL);
}
break;
case 3: break;
}
}
/****************************************************************************/
void SetGuiModule(int value)
{
Gui.module = value;
}
/****************************************************************************/
int GetGuiModule(void)
{
return Gui.module;
}
uchar GetWinStyle(int index)
{
return Win[index].style;
}
/****************************************************************************/
/****************************************************************************/
/* module data process function */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -