mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
getting ready for 0.4
This commit is contained in:
parent
e0ae30c61e
commit
95e5875b82
@ -4,7 +4,7 @@
|
|||||||
-- we need a random function
|
-- we need a random function
|
||||||
-- using math.random for now, which implies target=lua, not lualong
|
-- using math.random for now, which implies target=lua, not lualong
|
||||||
if not math then
|
if not math then
|
||||||
print "\nError: Hangman needs the math module (disabled when target=lualong) !\n"
|
print "\nError: Hangman needs the math module (disabled when target=lualong) !"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,10 +4,12 @@ if pd.board() == "SAM7-EX256" then
|
|||||||
ledpin = pio.PB_20
|
ledpin = pio.PB_20
|
||||||
elseif pd.board() == "EK-LM3S8962" or pd.board() == "EK-LM3S6965" then
|
elseif pd.board() == "EK-LM3S8962" or pd.board() == "EK-LM3S6965" then
|
||||||
ledpin = pio.PF_0
|
ledpin = pio.PF_0
|
||||||
elseif pd.board() == "STR9-comStick" then
|
elseif pd.board() == "STR9-COMSTICK" then
|
||||||
ledpin = pio.P9_0
|
ledpin = pio.P9_0
|
||||||
|
elseif pd.board() == "LPC-H2888" then
|
||||||
|
ledpin = pio.P2_1
|
||||||
else
|
else
|
||||||
print( "\nError: Unknown board " .. pd.board() .. " !\n" )
|
print( "\nError: Unknown board " .. pd.board() .. " !" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ elseif pd.board() == "SAM7-EX256" then
|
|||||||
pwmid, tmrid = 0, 1
|
pwmid, tmrid = 0, 1
|
||||||
tmr.setclock( 1, 1000000 )
|
tmr.setclock( 1, 1000000 )
|
||||||
else
|
else
|
||||||
print( pd.board() .. " not supported with this example\n" )
|
print( pd.board() .. " not supported with this example" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
28
romfs/pwmled.lua
Normal file
28
romfs/pwmled.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
-- Control LED intensity with PWM
|
||||||
|
|
||||||
|
local pwmid, tmrid, ledpin
|
||||||
|
if pd.board() == 'EK-LM3S8962' or pd.board() == 'EK-LM3S6965' then
|
||||||
|
pwmid, tmrid = 0, 1
|
||||||
|
pwm.setclock( pwmid, 25000000 )
|
||||||
|
else
|
||||||
|
print( pd.board() .. " not supported by this example" )
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
print( tmr.mindelay( tmrid ), tmr.maxdelay( tmrid ), tmr.getclock( tmrid ) )
|
||||||
|
|
||||||
|
print "Control LED with PWM (fade up/down)"
|
||||||
|
print "Press any key to exit"
|
||||||
|
local crtduty, incr = 10, 5
|
||||||
|
pwm.setup( pwmid, 50000, crtduty )
|
||||||
|
pwm.start( pwmid )
|
||||||
|
while uart.recv( 0, 0, 0 ) < 0 do
|
||||||
|
if crtduty == 95 or crtduty == 5 then
|
||||||
|
incr = -incr
|
||||||
|
end
|
||||||
|
crtduty = crtduty + incr
|
||||||
|
pwm.setup( pwmid, 50000, crtduty )
|
||||||
|
tmr.delay( tmrid, 50000 )
|
||||||
|
end
|
||||||
|
|
||||||
|
pwm.stop( pwmid )
|
@ -1,12 +1,5 @@
|
|||||||
-- TVBGone in eLua
|
-- TVBGone in eLua
|
||||||
-- Adapted from LadyAda's TVBGone project
|
-- Adapted from LadyAda's TVBGone project
|
||||||
-- Currently working only on the LM3S platform
|
|
||||||
|
|
||||||
-- Safety checks
|
|
||||||
if pwm == nil or tmr == nil or pio == nil then
|
|
||||||
print "The PWM and/or TMR/PIO modules not found, exiting"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check codes file
|
-- Check codes file
|
||||||
local codes = io.open( "/rom/codes.bin", "rb" )
|
local codes = io.open( "/rom/codes.bin", "rb" )
|
||||||
@ -15,17 +8,35 @@ if codes == nil then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup PWM
|
local pwmid, tmrid
|
||||||
local pwmid = pwm.PWM2
|
if pd.board() == 'EK-LM3S8962' or pd.board() == 'EK-LM3S6965' then
|
||||||
local tmrid = tmr.TMR0
|
pwmid, tmrid = 2, 1
|
||||||
local led = pio.PF_0
|
pwm.setclock( pwmid, 25000000 )
|
||||||
pwm.setclock( pwmid, 25000000 )
|
led, startpin, exitpin = pio.PF_0, pio.PF_1, pio.PE_1
|
||||||
|
else
|
||||||
|
print( pd.board() .. " not supported with this example" )
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Setup PIO
|
||||||
pio.output( led )
|
pio.output( led )
|
||||||
local _, fstr, freq, timesstr, ontime, offtime
|
pio.input( startpin, exitpin )
|
||||||
|
pio.pullup( startpin, exitpin )
|
||||||
|
|
||||||
|
-- Local variables
|
||||||
|
local _, fstr, freq, timesstr, ontime, offtime, runme
|
||||||
|
|
||||||
-- Send all the codes in an infinite loop
|
-- Send all the codes in an infinite loop
|
||||||
collectgarbage( "stop" )
|
collectgarbage( "stop" )
|
||||||
while true do
|
runme = true
|
||||||
|
while runme do
|
||||||
|
while pio.get( startpin ) == 1 do
|
||||||
|
if pio.get( exitpin ) == 0 then
|
||||||
|
runme = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not runme then break end
|
||||||
pio.set( led )
|
pio.set( led )
|
||||||
codes:seek( "set", 0 )
|
codes:seek( "set", 0 )
|
||||||
while true do
|
while true do
|
||||||
@ -42,11 +53,17 @@ while true do
|
|||||||
pwm.stop( pwmid )
|
pwm.stop( pwmid )
|
||||||
if offtime == 0 then break end
|
if offtime == 0 then break end
|
||||||
tmr.delay( tmrid, offtime * 10 )
|
tmr.delay( tmrid, offtime * 10 )
|
||||||
|
if pio.get( exitpin ) == 0 then
|
||||||
|
runme = false
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
if not runme then break end
|
||||||
tmr.delay( tmrid, 250000 )
|
tmr.delay( tmrid, 250000 )
|
||||||
end
|
end
|
||||||
pio.clear( led )
|
pio.clear( led )
|
||||||
tmr.delay( tmrid, 1000000 )
|
if not runme then break end
|
||||||
|
tmr.delay( tmrid, 500000 )
|
||||||
end
|
end
|
||||||
|
|
||||||
codes:close()
|
codes:close()
|
||||||
|
@ -19,7 +19,7 @@ extern char etext[];
|
|||||||
|
|
||||||
// Maximum file size that can be received via XMODEM
|
// Maximum file size that can be received via XMODEM
|
||||||
// Should be a multiple of 128
|
// Should be a multiple of 128
|
||||||
#define XMODEM_MAX_FILE_SIZE 3072
|
#define XMODEM_MAX_FILE_SIZE 4096
|
||||||
|
|
||||||
#ifdef BUILD_XMODEM
|
#ifdef BUILD_XMODEM
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ cpumode = ARGUMENTS.get( 'cpumode', 'arm' ).lower()
|
|||||||
specific_files = "startup912.s startup_generic.s platform.c 91x_scu.c 91x_fmi.c 91x_gpio.c 91x_uart.c 91x_tim.c"
|
specific_files = "startup912.s startup_generic.s platform.c 91x_scu.c 91x_fmi.c 91x_gpio.c 91x_uart.c 91x_tim.c"
|
||||||
|
|
||||||
# Check CPU
|
# Check CPU
|
||||||
if cputype == 'str912fw44':
|
if cputype == 'STR912FW44':
|
||||||
ldscript = "str912fw44.lds"
|
ldscript = "str912fw44.lds"
|
||||||
else:
|
else:
|
||||||
print "Invalid STR9 CPU %s", cputype
|
print "Invalid STR9 CPU %s", cputype
|
||||||
|
Loading…
x
Reference in New Issue
Block a user