Rockbox

Tasklist

FS#9174 - Lua Scripting Language for Rockbox

Attached to Project: Rockbox
Opened by Dan Everton (safetydan) - Wednesday, 09 July 2008, 10:14 GMT
Last edited by Maurus Cuelenaere (mcuelenaere) - Thursday, 21 May 2009, 19:02 GMT
Task Type Patches
Category Plugins
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Here is an (very, very) early proof of concept Lua viewer plugin (v.5.1.3).

Currently only a few functions are exported from the plugin API and it also lacks a setjmp/longjmp implementation for actual targets so error handling will go wrong very quickly.

However it does work so far for simple scripts like the following:

function sayhello(seconds)
message = string.format("Hello from LUA for %d seconds", 5)
rb.splash(seconds, message)
end

-- Drawn an X on the screen
rb.clear()
rb.drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT)
rb.drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT)
rb.update()

seconds = 5

rb.sleep(5 * rb.HZ)

sayhello(seconds)
This task depends upon

Closed by  Maurus Cuelenaere (mcuelenaere)
Thursday, 21 May 2009, 19:02 GMT
Reason for closing:  Accepted
Additional comments about closing:  in r21020
Comment by Dan Everton (safetydan) - Wednesday, 09 July 2008, 10:18 GMT
I forgot to mention that it's designed to be used as a viewer of .lua files. So you would save the above example Lua file to test.lua on your target and then play it as you would any other file.
Comment by Maurus Cuelenaere (mcuelenaere) - Wednesday, 09 July 2008, 20:09 GMT
Nice patch, works fine on the sim! (can't test on a device atm)

I've added some extra functions to the rb lib (see attached diff)
Comment by Jens Erdmann (pyro_maniac) - Friday, 10 April 2009, 13:17 GMT
I reworked the patch a bit and make it work in the current tree.

I will test it later on a device but it looked good in sim.
Comment by Tony Huynh (insanepotato) - Wednesday, 15 April 2009, 10:05 GMT
I'm going to try it out on my c250. Looking forward to future developments =]
Comment by Maurus Cuelenaere (mcuelenaere) - Thursday, 16 April 2009, 14:37 GMT
This is v2 with some more functions added, setjmp implementation and tested on target (Onda VX747 - works!).
Comment by Jens Erdmann (pyro_maniac) - Thursday, 16 April 2009, 18:32 GMT
The current patch also worked good on my e250. :-)
Comment by Maurus Cuelenaere (mcuelenaere) - Thursday, 16 April 2009, 22:15 GMT
* updated to Lua 5.1.4
* added more functions to rocklib
* added ability to use audiobuffer when out of pluginbuffer RAM
Comment by Jens Erdmann (pyro_maniac) - Monday, 20 April 2009, 16:37 GMT
Are there some open tasks?
Comment by Maurus Cuelenaere (mcuelenaere) - Monday, 20 April 2009, 16:39 GMT
You mean TODO's before this gets committed?
AFAIK, this is pretty stable; but I would like to get another dev to confirm that..
Comment by Maurus Cuelenaere (mcuelenaere) - Wednesday, 22 April 2009, 15:07 GMT Comment by Maurus Cuelenaere (mcuelenaere) - Wednesday, 22 April 2009, 22:14 GMT
* Fixes issue with line numbers not showing up when error occured
* Adds UNLIKELY & LIKELY
Comment by Robert Kukla (roolku) - Thursday, 23 April 2009, 12:44 GMT
Nice stuff.

I tried v6 on the gigabeat and it looks as if numbers are not parsed correctly. I.e. the 5 seconds become 1075052544 - maybe to do with the fact that the only numerical datatype in LUA is float. Also the rectangle doesn't get drawn - I suspect for the same reason.

In the simulator (cygwin) it is worse. To get it to compile I had to make the "int error_no = 0;" unconditional. I didn't get it to draw anything, but the splash was displayed (with a rather big number).
Comment by Jens Erdmann (pyro_maniac) - Friday, 24 April 2009, 23:23 GMT
You just missed the viewer.config.
But i got problems running the test script in the simulator.
The screen gets cleaned and nothing else happends.
Comment by Maurus Cuelenaere (mcuelenaere) - Tuesday, 19 May 2009, 22:52 GMT
* fixes sim build
* removes strtod
* adds strtol
* should completely remove floating-point support

If this version doesn't break somewhere/something I'll probably commit it soon.
Comment by Thomas Martitz (kugel.) - Thursday, 21 May 2009, 15:28 GMT
Why remove floating point support?
Comment by Maurus Cuelenaere (mcuelenaere) - Thursday, 21 May 2009, 18:11 GMT
* adds support for auto-generating ACTION_*
* adds some more wrappers
* adds the current path & /.rockbox/rocks/viewers/ to the search path when including files

Loading...