mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
6ac505a181
It now illustrates how to create and use a module in Lua for eLua. An LM3S platform-dependend module is created, exposing it's buttons, leds and offering some utility functions.
21 lines
405 B
Lua
21 lines
405 B
Lua
local pio = pio
|
|
|
|
module(...)
|
|
|
|
BTN_UP = pio.PE_0
|
|
BTN_DOWN = pio.PE_1
|
|
BTN_LEFT = pio.PE_2
|
|
BTN_RIGHT = pio.PE_3
|
|
BTN_SELECT = pio.PF_1
|
|
btnpressed = function( button )
|
|
return ( pio.get ( button ) == 0 )
|
|
end
|
|
|
|
LED_1 = pio.PF_0
|
|
|
|
pio.input( BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_SELECT )
|
|
pio.pullup( BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_SELECT )
|
|
pio.output ( LED_1 )
|
|
|
|
|