mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
f729155fce
- all eLua modules updated to work with LTR - "cpu" module added to avr32, at91sam7x, str7 - "disp" module no longer generic (now stays in src/modules/lm3s). For this reason, the "disp" platform interface was also removed. - the "modcommon" mechanism in STM32 (ROM loader) was depreciated in favour of the Lua Tiny RAM patch (and the "stm3210lcd" module from the STM32 backend now uses LTR). - small bugfixes
30 lines
664 B
Lua
30 lines
664 B
Lua
-- Control LED intensity with PWM on two channels
|
|
|
|
local pwmid1, pwmid2, tmrid = 0, 1, 3
|
|
|
|
if pd.board() ~= "MOD711" then
|
|
print "Unsopported board"
|
|
return
|
|
end
|
|
|
|
print "Control LED with PWM (fade up/down)"
|
|
print "Press any key to exit"
|
|
local crtduty, incr = 10, 5
|
|
pwm.setup( pwmid1, 50000, crtduty )
|
|
pwm.setup( pwmid2, 50000, 100 - crtduty )
|
|
pwm.start( pwmid1 )
|
|
pwm.start( pwmid2 )
|
|
while uart.recv( 1, 0, 0 ) < 0 do
|
|
if crtduty == 95 or crtduty == 5 then
|
|
incr = -incr
|
|
end
|
|
crtduty = crtduty + incr
|
|
pwm.setup( pwmid1, 50000, crtduty )
|
|
pwm.setup( pwmid2, 50000, 100 - crtduty )
|
|
tmr.delay( tmrid, 50000 )
|
|
end
|
|
|
|
pwm.stop( pwmid1 )
|
|
pwm.stop( pwmid2 )
|
|
|