📄 mix.c
字号:
uint32_t KB_GetNum(uint8_t posX,uint8_t posY,uint32_t numInit,uint32_t numMin,uint32_t numMax,uint32_t numRes,char *MaskStr)
{
uint8_t ch;
uint32_t retV;
retV = numInit;
LCD_SetXY(posX,posY);
LCD_DispStr(MaskStr);
LCD_SetXY(posX,posY);
LCD_DispNum(retV);
while(1)
{
ch = KB_GetChar(1,1);
if(ch == 'B')
retV /= 10;
else if(ch == 'C')
retV = 0;
else if(ch == 'E')
{
if(retV >= numMin && retV <= numMax)
return retV;
}
else if(ch == 'D')
{
if(retV >= numRes)
retV -= numRes;
else
retV = 0;
}
else if(ch == 'F')
{
retV += numRes;
if(retV > numMax)
retV = numMax;
}
else if(ch == 'A')
;
else
{
retV = retV * 10 + ch - '0';
if(retV > numMax)
retV /= 10;
}
LCD_SetXY(posX,posY);
LCD_DispStr(MaskStr);
LCD_SetXY(posX,posY);
LCD_DispNum(retV);
}
}
uint8_t LCD_DispMenu(const char *MenuStr[],uint8_t MenuNum)
{
uint8_t idx,ch;
idx = 0;
while(1)
{
LCD_Clear();
if(idx > 0)
LCD_WriteChar(0,0x7F);
else
LCD_WriteChar(0,' ');
LCD_DispStr(MenuStr[idx]);
if(idx < MenuNum)
LCD_WriteChar(0,0x7E);
else
LCD_WriteChar(0,' ');
LCD_SetXY(0,1);
LCD_DispStr("SELECT 0-");
LCD_DispNum(MenuNum);
LCD_WriteChar(0,':');
LCD_WriteChar(0,' ');
LCD_DispNum(idx);
ch = KB_GetChar(1,1);
switch(ch)
{
case 'A':
break;
case 'B':
{
idx/= 10;
break;
}
case 'C':
{
idx = 0;
break;
}
case 'D':
{
if(idx > 0)
idx--;
break;
}
case 'E':
return idx;
case 'F':
{
if(idx < MenuNum)
idx++;
break;
}
default:
{
idx = idx*10 + ch - '0';
if(idx > MenuNum)
idx /= 10;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -