软件实现呼吸灯效果
static void doLedItem(int needB, int needL) {
int ib = 0;
int il = 0;
while (il < needL) {
if (ib * needL < il * needB) {
ib++;
api_led_BT(0);
}
else {
il++;
api_led_BT(1);
}
app_sched_execute();
}
}
#define LED_STEP 400
static void doLED(int count, int type) {
int v = 0;
if (type == 0) {
//警告灯效果
while (--count >= 0) {
for (int i = 0; i < LED_STEP; i++) {
doLedItem(i + 10, LED_STEP - i + 10);
}
}
}
else {
//呼吸灯效果
while (--count >= 0) {
for (int i = 0; i < LED_STEP; i++) {
doLedItem(i + 10, LED_STEP - i + 10);
}
for (int i = 0; i < LED_STEP; i++) {
doLedItem(LED_STEP - i + 10, i + 10);
}
}
}
api_led_BT(0);
}