google-coral / coralmicro

Source code for Coral Dev Board Micro
Apache License 2.0
106 stars 44 forks source link

LedSet(Led::kTpu, false) is not working #113

Open LanceBao0313 opened 5 months ago

LanceBao0313 commented 5 months ago

Description

Tried to turn off the white TPU led when running the detect_faces example, but it doesn't work:

bool result = LedSet(Led::kTpu, false);
printf("tpu led off: %d\r\n", result);

Output: tpu led off: 1

But the led is still on

Click to expand! ### Issue Type Support ### Operating System Mac OS ### Coral Device Dev Board Micro ### Other Devices _No response_ ### Programming Language _No response_ ### Relevant Log Output _No response_
dylan-leslie commented 3 months ago

@LanceBao0313 not sure if you managed to fix this or not. However, a fix that worked for me was changing the LedSetBrightness function which LedSet calls.

Replace the following code in LedSetBrightness found in led.cc:

if (enable) {
    PwmEnable({pin_a_config});
} else {
    PwmDisable({pin_a_config});
}

With:

PwmEnable({pin_a_config});

This keeps the LED on but now you can set a duty cycle of 0 (brightness of 0).

Prior, the enable can only be true for brightness values greater than kLedFullyOff (which is 0). Removing the conditional will call PwmEnable({pin_a_config}) no matter what brightness value is given.

For some reason PwmDisable fails to set stop the PWM timer for the Tpu LED. At the moment I'm not sure why, but the above code should fix your issue. Does feel a bit 'hacky' though.

Hope this helps.