设置闪光的频率(频率亮灭频率)
每次按下确认键后调节阈值
static volatile uint16_t strobe = 0;
static bool FlashLightSelect(){
if (strobe < 500)
strobe += 50 * ((strobe / 50) + 1);
else
strobe = 0;
return true;
}
设置闪光功能的Draw函数
每隔阈值一定的事件亮灭反转,实现闪光效果。
static void FlashLightDraw(){
static bool invert;
static uint32_t lastStrobe;
if (strobe)
{
uint32_t now = mills();
if (now - lastStrobe >= strobe)
{
lastStrobe = now;
invert = !invert;
if(invert){
OledSendCmd(0xA7);
}else{
OledSendCmd(0xA6);
}
OledSendCmd(0xAF);
LedFlash(invert ? LEDGREEN : LEDRED, 20);
}
return;
}
OledSendCmd(0xA7);
OledSendCmd(0xAF);
LedFlash(LEDGREEN, 20);
LedFlash(LEDRED, 20);
}