File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -372,17 +372,23 @@ void SmartConfig(void)
372
372
#endif
373
373
374
374
String SMOD = " " ; // 0亮度
375
- // 串口调试设置函数
375
+ String incomingByte = " " ;
376
+ // 串口调试设置函数
376
377
void Serial_set ()
377
378
{
378
- String incomingByte = " " ;
379
379
if (Serial.available () > 0 )
380
380
{
381
- while (Serial.available () > 0 ) // 监测串口缓存,当有数据输入时,循环赋值给incomingByte
381
+ byte b;
382
+ delay (1 ); // 不能省略,因为读取缓冲区数据需要时间
383
+ b = Serial.read ();
384
+ if (b != ' \r ' )
382
385
{
383
- incomingByte += char (Serial.read ()); // 读取单个字符值,转换为字符,并按顺序一个个赋值给incomingByte
384
- delay (2 ); // 不能省略,因为读取缓冲区数据需要时间
386
+ char c = char (b);
387
+ incomingByte += c; // 读取单个字符值,转换为字符,并按顺序一个个赋值给incomingByte
388
+ Serial.print (c);
389
+ return ;
385
390
}
391
+ Serial.println ();
386
392
if (SMOD == " 0x01" ) // 设置1亮度设置
387
393
{
388
394
int LCDBL = atoi (incomingByte.c_str ()); // int n = atoi(xxx.c_str());//String转int
@@ -475,14 +481,15 @@ void Serial_set()
475
481
Serial.printf (" 天气更新时间更改为:" );
476
482
Serial.print (updateweater_time);
477
483
Serial.println (" 分钟" );
484
+ reflash_openWifi.setInterval (updateweater_time * 60 * TMS); // 设置所需间隔
478
485
}
479
486
else
480
487
Serial.println (" 更新时间太长,请重新设置(1-60)" );
481
488
}
482
489
else
483
490
{
484
491
SMOD = incomingByte;
485
- delay ( 2 ) ;
492
+ incomingByte = " " ;
486
493
if (SMOD == " 0x01" )
487
494
Serial.println (" 请输入亮度值,范围0-100" );
488
495
else if (SMOD == " 0x02" )
You can’t perform that action at this time.
0 commit comments