|
調(diào)整循環(huán)的起始和結(jié)束條件,以及數(shù)組索引的計算方式。修改后的代碼:
```c
void WaterLampToCol3(unsigned long _uColor, unsigned char _uTime)
{
unsigned char i;
for (i = 0; i < nWs; i++)
{
WsDat[i] = _uColor;
WsDat[nWs - 1 - i] = _uColor;
WS_L_SetAll();
delay_ms(_uTime);
}
reset();
}
```
1. 循環(huán)從 `i = 0` 開始,而不是 `i = nWs/2`。
2. 將 `WsDat[nWs/2 - (i - nWs/2)]` 改為 `WsDat[i]` 和 `WsDat[nWs - 1 - i]`,這樣就會先設(shè)置數(shù)組的兩端,然后逐漸向中間設(shè)置。
|
|