whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.18k stars 221 forks source link

Internal LED control #149

Open oskarirauta opened 6 years ago

oskarirauta commented 6 years ago

I think we should be able to control internal LED (if set) - or at least, stop blinking. Currently this can be achieved by setting it's GPIO state to input, but I think there could be a better way as well.

How about a minimal module for this? led state module for selecting mode from manual or automatic (blinking).

led.mode(LED.manual) -- stop blinking (and turn it off)
led.state(LED.on) -- turn it on if manual mode is enabled
led.state(LED.off) -- turn it off
led.mode(LED.automatic) -- resume normal operation mode (start blinking)
jolivepetrus commented 6 years ago

Hi @oskarirauta,

Something about your request is done in the mesh feature that we will add to Lua RTOS soon. There will be a new Lua function in the os module to control the activity led.

oskarirauta commented 6 years ago

Sounds good :)

On 22 Apr 2018, at 23.51, Jaume Olivé Petrus notifications@github.com wrote:

Hi @oskarirauta https://github.com/oskarirauta,

Something about your request is done in the mesh feature that we will add to Lua RTOS soon. There will be a new Lua function in the os module to control the activity led.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/whitecatboard/Lua-RTOS-ESP32/issues/149#issuecomment-383411390, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRSHi9NoV7Z3ZUkoLM_BqjMpUUhY2lrks5trO1JgaJpZM4TeqjS.

the0ne commented 4 years ago

@oskarirauta as you can see the LED you mention is not built into the esp32 chip itself but into the board that the esp32 is mounted on:

ESP32-LED So - depending on which PIO the board designer connected the LED to - controlling the LED is as easy as:

-- this depends on the board
led_pin = pio.GPIO2
-- enable controlling the LED
pio.pin.setdir(pio.OUTPUT, led_pin)
-- enable the on-board LED
pio.pin.sethigh(led_pin)
-- disable the on-board LED
pio.pin.setlow(led_pin)

@jolivepetrus do you want to keep this open?