summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lua
AgeCommit message (Collapse)AuthorFilesLines
2020-10-05lua add better memory statsWilliam Wilgus2-3/+68
lua gives you a memory used number that only reflects the current allocations if fact it doesn't even give you a way to get the amount of ram free rb.mem_stats() seeks to fill this gap by marking the memory allocated for lua with a sentinel value which can later be checked to get a high water mark of the ram used by lua and a pretty good idea of how much ram is available Also includes an example script usage: used, allocd, free = rb.mem_stats() Change-Id: Ia282869f989848324d7d88c7df4827fdbce4fb4e
2020-10-04lua misc tweaks and cleanupWilliam Wilgus5-23/+24
checks button_status in rockev strpbrk_n custom implementation allows setting max search len in source string add some branch prediction where appropriate fix formatting in splash_scroller script Change-Id: Id5d8e9d83f4b3e361ccb67b403af8f9a8a31b8f0
2020-10-03lua Add scrollable stack traceback WIPWilliam Wilgus4-3/+140
lua currently splashes a stack traceback on error for deep tracebacks and especially on devices with smaller screens this leaves out a lot of vital information in the past I have resorted to splitting the traceback string or even saving the return to a file This patch provides a scrollable buffer with rudimentary text reflow to allow you to read the whole traceback string Upon traceback if you press nothing the screen will display for 5 seconds If you press OK or CANCEL it will quit immediately PREV/NEXT scrolls the list on button press timeout is disabled lua now provides rb.splash_scroller(timeout, str) example script provided too Change-Id: Idbc8ce0c514196f0fae48c43aeaea8b60d6da1a5
2020-10-01lua: fix ipod builds broken by 127862cSolomon Peachy1-1/+1
Change-Id: Ibef7de6b4e87568206ede66c399093b66b827b69
2020-09-30lua: Include $TARGET when preprocessing the headers for the button helperSolomon Peachy1-2/+1
Change-Id: I3ab98b52991949adb1db2f13ea99ed24d827e575
2020-09-30lua rockevents reduce context switching for action and buttonsWilliam Wilgus1-13/+24
check if any buttons are waiting in the queue before triggering the event thread for action & button events makes button events quicker and also spend less time interrupting lua both wins Change-Id: I38346c084afdd99e4608f40b52053ee39730fb40
2020-09-27lua playback exampleWilliam Wilgus1-0/+1
cool little lua based audio player creates dynamic playlist of 10 mp3s found on device if no music loaded I had to limit the depth of search to 3 levels due to the recursive nature of the current dirbrowser functions this could be rectified with a bit more code fixed a bug in print.lua that kept scrolling text even after screen clear Change-Id: Ifd285332df41a409ecaeb1ea447ad15537b5d04c
2020-07-24plugins: Fix the builds for targets lacking HAVE_BACKLIGHTSolomon Peachy1-9/+13
Change-Id: Ifdb1501834b7ea63ca6f731bbd6414305d7e0001
2020-07-24[4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.Solomon Peachy2-9/+0
Note: I left behind lcd_bitmap in features.txt, because removing it would require considerable work in the manual and the translations. Change-Id: Ia8ca7761f610d9332a0d22a7d189775fb15ec88a
2020-07-24[3/4] Completely remove HWCODEC supportSolomon Peachy1-5/+1
'swcodec' is now always set (and recording_swcodec for recording-capable units) in feature.txt so the manual and language strings don't need to all be fixed up. Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24[1/4] Remove SH support and all archos targetsSolomon Peachy3-17/+3
This removes all code specific to SH targets Change-Id: I7980523785d2596e65c06430f4638eec74a06061
2020-07-22keyboard add ability to specify temporary custom layoutsWilliam Wilgus1-1/+1
rb core allows you to load custom keyboard layouts this patch adds the ability to load a keyboard layout in a buffer the custom layout is temporary and does not overwrite the current layout use like so: unsigned short kbd[64]; unsigned short *kbd_p = kbd; if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd))) kbd_p = NULL; rb->kbd_input(buf,sizeof(buf), kbd_p); Change-Id: I7be2bd4a1b4797a147fa70228a9749dc56ac052a
2020-07-19do_menu pass internal synclist reference to callbackWilliam Wilgus1-3/+6
keep running into the rigid nature of do_menu it isn't too bad when you don't need voice but once you do the fun awaits do_menu likes to talk on menu enter which is in a loop when you use do_menu I would like to move the processing to the callback TOO BAD you only get an action and the menu_item_ex struct you sent it when calling the function Change-Id: Iaefd0cc133435d675b7dd27a558c504d6ccb327a
2020-06-23lua RockEv timing fixesWilliam Wilgus1-6/+3
just a few tweaks to the RockEv backend to allow tighter event timing originally there was a timeout where events would be consolidated prior to running the event thread, this slowed the faster events but it turns out this isn't really a big waster of time The callback from C => lua is a far bigger bottleneck Change-Id: Iffacbe49c4b83155099b1304590450f746576fa4
2020-06-01lua add _fullpath and argument parsingWilliam Wilgus1-7/+47
WIP for passing arguments to lua scripts args are recognized by adding ?arg to the end of the script path The easiest way to do this currently is to use the function rb.restart_lua local sfile = rawget(_G, "_fullpath") or "" local sArgs = rawget(_G, "_arguments") if not sArgs then rb.restart_lua(sfile .. "?my arguments") else rb.splash(1000, sfile .. "?" .. sArgs) end I'd eventually like to figure out a sensible way to do this from a shortcut / quick list Change-Id: I2b60fe3b8f1d04b57361fe532510bd6afee59fbf
2019-11-15lua rockev rewriteWilliam Wilgus1-281/+305
After a few issues with the timer code in the hosted players I realized a few shortcomings in the original rockev code... This rewrite gives thread_exit an explicit flag instead of 0 custom events now have a set-able timeout previous lua hooks are restored flags are stored in uint8_t Change-Id: I9ca45246ac9233a2faa581e26a8cc5e5fb512e88
2019-10-07lua rockev cleanupWilliam Wilgus1-14/+13
with the addition of suspending all events on thread start and exit we don't really need to block on THREAD_QUIT in so many places Removed suspend clearing on event unregister and updated comments Change-Id: Id9c6a460def558c5331ee292035691a9f82b2c43
2019-10-08lua rockev fix possible race on thread exitWilliam Wilgus1-25/+45
report of call after free on event thread on Agptek Rocker I'm guessing its a race condition between the thread and the timer but can't say for sure without some more testing Change-Id: If11bd718b3cfa81ea13fff378df56d12afa17a7f
2019-09-28lua move strip_extension and create_numbered_filename out of main binaryWilliam Wilgus4-1/+64
rb.strip_extension and rb.create_numbered_filename have been moved to include_lua/files.lua to use simply add require('files') to your script Change-Id: I95af7b312c8614cb10da4b71b22714b3e282e08a
2019-09-27lua rocklib_aux.pl support for enumsWilliam Wilgus1-1/+21
everything that would have been added has already been added or needs more supporting functions so they've been excluded for the time being Change-Id: I4ae4753c543287934702a3bd2eeccce5b032235d
2019-09-27Fix red lua remove and consolidate some rb plugin functionsWilliam Wilgus1-8/+1
I'll revisit adding enums once I research it a bit more Change-Id: If10c445cf770e5b90defc543f08d8de0817b2f3d
2019-09-26lua remove and consolidate some rb plugin functionsWilliam Wilgus2-6/+73
removes some usless / duplicated functions removes atoi - lua tonumber() does this for you removes strlen - lua string.len does this for you removes system_memory_guard - if a device that actually implements system_memory_guard needs it we can add it back conditionally consolidates talk_number and talk_spell (on backend) consolidates talk_shutup and talk_force_shutup talk_shutup(bForce) Change-Id: Id132642f087975a7c132e99a668a41c977942b81
2019-09-18lua give luadir the ability to return table of attributesWilliam Wilgus1-14/+27
for fname, isdir, attrib in luadir.dir(scrpath, true) do passing true for the second argument returns table of file/dir attributes in attrib Change-Id: I7c999e2fc5dac95b8ccbe169f2119c31b63f6a41
2019-09-14lua add menu callbackWilliam Wilgus1-0/+49
forum user fprockboxer asked for a way to detect long presses within the do_menu routine this adds that functionality result = rb.do_menu("Title",t_items, start, menu_callback) function menu_callback(action) ... return action end Change-Id: I110c590095a743a57d0a7d45b24309899a4629cf
2019-09-06Fix red Lua extend error splash timeout and stop cutting off infoWilliam Wilgus1-1/+1
Change-Id: Icd6fe0fa1088ab59b8214f7c860f262ce67fe205
2019-09-06Lua extend error splash timeout and stop cutting off infoWilliam Wilgus2-4/+5
Change-Id: Ia1a9e39b9f203002cbbea85ef965e66c334b83fc
2019-09-07Lua add metadata and settings reading helper moduleWilliam Wilgus4-10/+203
Adds example scripts for reading track metadata + dumping albumart and rockbox settings settings are now stored as a table of strings rather than a table of tables as it saves ~15 kb of ram without adding much complexity Change-Id: I611c312b2a60ab96e595e4710b17aedbd6c0689b
2019-08-28lua fix mem_read_write, strtolWilliam Wilgus2-3/+4
back when I wrote this I was running the sim on a 32 bit machine I didn't catch the hardcoded LONG_MAX reference or the fact that lua_tointeger maxes ot at 32 bits on 64 bit machines strtol caused all kinds of issues especially since it returned the real LONG_MIN/MAX values Change-Id: I3571ebbd9df333f7cbf4077562412c27429bfadc
2019-08-26lua optimize poly_draw add draw_number, poly_points modulesWilliam Wilgus4-46/+300
Change-Id: Id36e765f18234f5a4f3092d090c0adffa3da1612
2019-08-20lua fix polydraw missing functionsWilliam Wilgus1-0/+2
Change-Id: I9e2537e4839e2b4f9beddbc887610213ed954a87
2019-08-12lua rock events crash on error in main stateWilliam Wilgus1-3/+4
on errors thread stack overflows yielding before thread_exit() is a bad idea apparently Change-Id: Iac45d4321fac496738384fdbbeb480356ef2a1bb
2019-08-08Fix lua compile error on most targets, introduced in 8d77ec8Solomon Peachy1-1/+1
Change-Id: I217f78a9e348a18552563c6c3b235c9aed956f54
2019-08-08lua LCD fixWilliam Wilgus2-0/+2
forgot to set new size after realloc forgot to set sizelineinfo to 0 after free Change-Id: Iaf7533aafaba1e2abf9599c9e1d0b75d913a8c36
2019-08-08lua LCD (Lua Compact Debug) patchWilliam Wilgus13-6/+373
LCD developed 9/2015 by Terry Ellison We've already discarded the ldebug module from lua it only makes sense to discard the debug info as well adds 1.5 K to the binary saves 8 Kb on the base state once scripts start getting called i've seen 10-50Kb savings but it all depends on what exactly you are running Change-Id: Ibb74f344df1c4c96380ec6c98b010a810e9ae9cc
2019-08-05lua fix lua_close on os.exit(0)William Wilgus1-0/+2
Change-Id: Ib225ecf9ea64c95e438c4114b23239c118ab19a2
2019-08-05lua fix crashes EGC failure to lock stack in concatWilliam Wilgus1-4/+7
Change-Id: I980637b1d8aa91d7ac0ed71fd0e7d21bda7876c4
2019-08-04lua optimize print include, fix draw_polyWilliam Wilgus2-4/+6
Change-Id: Ibb530cfa63681727be518173404952e897c9d297
2019-08-04lua add rlimg.lua example script split large includes to separate filesWilliam Wilgus7-393/+545
Change-Id: I67cac5bc4ce5525ab30abf9443f6cc1a33190512
2019-07-29lua rocklib_img optimize functions with multiple checkint callsWilliam Wilgus2-68/+106
Uses int arrays and calls luaL_checkint in a loop Change-Id: Ib73dab886f018c787bd995f64d990981d194069f
2019-07-29lua add demo scripts, atexit handler, gui_scrollbar_drawWilliam Wilgus7-22/+481
Change-Id: Ie8794e8a487f73952dae43e036787b6972fdbbee
2019-07-29lua: wrap thread_set_priority with #ifdef HAVE_PRIORITY_SCHEDULINGFranklin Wei1-0/+5
Should fix a compile-time error on simulator. Change-Id: I5962479579350ebffe6dcce4f65a629b108ff936
2019-07-28Lua Add Emergency Garbage CollectorWilliam Wilgus21-68/+266
Derivative of work by RobertGabrielJakabosky http://lua-users.org/wiki/EmergencyGarbageCollector I've only implemented the not enough memory part and expanded this idea to adding a mechanism to signal the OOM condition of the plugin buffer which allows us to only grab the playback buffer after garbage collection fails (SO THE MUSIC KEEPS PLAYING AS LONG AS POSSIBLE) Change-Id: I684fb98b540ffc01f7ba324ab5b761ceb59b9f9b
2019-07-28lua remove unneeded plugin functionsWilliam Wilgus2-1/+18
Change-Id: I04bc38d03b7f0ca65a815685eb6ab0f5ff825c45
2019-07-25lua add sound_current, consolidate sound_ functionsWilliam Wilgus5-36/+184
add defines for sound functions SOUND_VOLUME, SOUND_BALANCE, SOUND_CHANNELS, SOUND_STEREO_WIDTH ... defines depend on target require "sound_defines" to add them to rb.sound_settings[] consolidates: sound_set, sound_current, sound_default, sound_min, sound_max, sound_unit, sound_pitch, sound_val2phys to a single function rb.sound("name", setting, [value]) require "sound.lua" for old functionality Change-Id: Ice695218aa433f4fcbb48fbd6b8a9bf29c994110
2019-07-19lua events from rockboxWilliam Wilgus8-13/+674
This library allows events to be subscribed / recieved within a lua script most events in rb are synchronous so flags are set and later checked by a secondary thread to make them (semi?) asynchronous. There are a few caveats to be aware of: FIRST, The main lua state is halted till the lua callback(s) are finished Yielding will not return control to your script from within a callback Also, subsequent callbacks may be delayed by the code in your lua callback SECOND, You must store the value returned from the event_register function you might get away with it for a bit but gc will destroy your callback eventually if you do not store the event THIRD, You only get one cb per event type ["action", "button", "custom", "playback", "timer"] (Re-registration of an event overwrites the previous one) Usage: possible events =["action", "button", "custom", "playback", "timer"] local evX = rockev.register("event", cb_function, [timeout / flags]) cb_function([id] [, data]) ... end rockev.suspend(["event"/nil][true/false]) passing nil affects all events stops event from executing, any but the last event before re-enabling will be lost, passing false, unregistering or re-registering an event will clear the suspend rockev.trigger("event", [true/false], [id]) sets an event to triggered, NOTE!, CUSTOM_EVENT must be unset manually id is only passed to callback by custom and playback events rockev.unregister(evX) Use unregister(evX) to remove an event Unregistering is not necessary before script end, it will be cleaned up on script exit Change-Id: Iea12a5cc0c0295b955dcc1cdf2eec835ca7e354d
2019-07-18lua disable bytecode dump & undump functionsWilliam Wilgus4-5/+33
Adds a flag to remove the ability to dump and load lua bytecode saves 6+kb Change-Id: I080323df7f03f752e0a10928e22a7ce3190a9633
2019-07-18Fix Red lua move constants out of binary imageWilliam Wilgus1-4/+13
didn't consider sims might have reserved enums Change-Id: Ic404972f0836bc81ba149f4ecdd3ec61bd8bd4b3
2019-07-18lua move constants out of binary imageWilliam Wilgus4-7/+215
Rockbox constants are auto generated by a perl script like the majority of the plugin functions. Constants are contained in rb_defines.lua, if the file exists it is auto loaded by the lua state for backwards compatibility Frees ~1k Change-Id: I237700576c748f468249e501c839d89effca3f39
2019-07-17lua alphabetically sort perl generated rocklib_aux functionsWilliam Wilgus1-1/+4
Change-Id: I6566c19a0fee630a5e250c1244159d5b488b57ff
2019-07-13lua close state on os.exitWilliam Wilgus1-1/+3
Change-Id: I376fad0f92f1155698740e1b8599a3385998575c