|
如图,我将滑块的值设置为0-2,0代表风扇不转,1代表一档,2代表2档。
我尝试了两个办法:
1. 在滑块的回调函数中加入slider.print();2. 在数据管理dataRead中添加slider.print();
3. 添加全局变量,在滑块的回调函数中改变全局变量的值。
新手,对blinker理解不深,还请高手指教!
分别如下:1:
void SLIDER_FAN_callback(int value)
{
BLINKER_LOG("get slider value: ", value);
if (value == 0) {
ledcWrite(pwmChannel, 0);
FAN_NUM.unit("leve");
SLIDER_FAN.print(value) ;
}else if (value == 1) {
ledcWrite(pwmChannel, 200);
FAN_NUM.unit("leve");
SLIDER_FAN.print(value)
}else {
ledcWrite(pwmChannel, 255);
FAN_NUM.unit("leve");
SLIDER_FAN.print(value)
}
}
2.
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
FAN_NUM.print(fanLevel);
}
3.
int fanLevel = 0;
void SLIDER_FAN_callback(int value)
{
BLINKER_LOG("get slider value: ", value);
if (value == 0) {
ledcWrite(pwmChannel, 0);
FAN_NUM.unit("leve");
fanLevel = value;
}else if (value == 1) {
ledcWrite(pwmChannel, 200);
FAN_NUM.unit("leve");
fanLevel = value;
}else {
ledcWrite(pwmChannel, 255);
FAN_NUM.unit("leve");
fanLevel = value;
}
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
FAN_NUM.print(fanLevel);
}
|
-
|