summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lua
AgeCommit message (Collapse)AuthorFilesLines
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
2019-07-11lua reduce heap allocated buffer sizes, organize luaconf.hWilliam Wilgus1-141/+194
Change-Id: Ib9e568ea73a01474facd57cc155e62fa3dc093f7
2019-07-11lua late bound cfunction tablesWilliam Wilgus1-0/+132
We have quite a bit of ram tied up in lua with our c libraries I was searching for a way to free up some of this when I came across read only tables in e-lua but that involved a lot of patching through the source Instead I came up with this.. it frees about 15k ram without much slowdown in code execution since after a function gets called it is automatically added to the table If you have a performance issue you can call the bind method to bind a specific function or the whole table in one shot for instance rb table rb("lcd_clear") -- binds/returns function rb.lcd_clear() rb(nil) -- binds every function in rb table + removes latebind metatable .. -- added pairs and ipairs code from lua 5.2 -- cleaned up code + made more seamless existing fields are now saved rather than overwritten when table is bound Change-Id: I1c20e76b736c032dedc727d2e58928641e40191d
2019-07-11lua inbinary stringsWilliam Wilgus10-25/+88
Allows saving of ram by reusing strings already stored in the binary and storing a pointer instead of malloc and copy to get them inside the lua state Saves about 1.5K overall Derivative of work by bogdanm RAM optimizations: pseudo RO strings, functions in Flash https://github.com/elua/elua/commit/d54659b5723bcd2b1e3900362398c72c18a9aa0b Change-Id: I21d6dcfa32523877efd9f70fb0f88f2a02872649
2019-07-10lua add track length & elapsed to rb.audio()William Wilgus1-4/+20
track elapsed is needed to use fast-forward and rewind effectively track length might as well be added too.. Change-Id: I906c92eb5260164c6177d8c0a8ff879b1fad7898
2019-07-09lua remove error messages for pre-compiled chunksWilliam Wilgus2-3/+3
We don't have the functionality in the viewer to run pre-compiled chunks plus if anyone ever wants to add it its easy enough to remove the define frees 3K Change-Id: I8d2086e04b51e3ce147ab8741a7d354cb9bf1ade
2018-12-24Fix lua helpers -- supress line markers in preproc source generation scriptsWilliam Wilgus1-3/+3
In newer builds line markers prevent lua helper scripts from grabbing some inputs especially _bool This patch adds the -P switch Inhibit generation of linemarkers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the linemarkers. Change-Id: I66c3b099729f6651300f9fcf4670533a20cc90c1
2018-12-17Lua Fix settings_helper for the gigaBeastSWilliam Wilgus2-17/+51
the gigabeatS has an embedded struct that needs to be parsed Change-Id: I88c9101afaaa95182f37ade1410cccb4fb768e33
2018-12-16Lua add read/write access to global_status, global_settings, audio_current_trackWilliam Wilgus3-1/+540
moved items to rb.system added read access to audio_current_track and audio_next_track Change-Id: Ia055b8cb3848e540067818f596ffd1058da057fb
2018-11-24lua add LCD_DEFAULT_FG, fix 2-bit screen fg/bg inversionWilliam Wilgus2-2/+6
Change-Id: Ibe2bc6602ff27524a3b96d9523780acbfbf03c76
2018-11-17Lua fix crash on arm devicesWilliam Wilgus1-1/+1
This is a seemingly random bug that only affects (as far as I can tell) arm devices it isn't actually random as code changes cause it to appear/disappear based on alignment Change-Id: I4cbc4370677959319f8589fe454e854c45623468
2018-11-15Lua fix reader bug in lzioWilliam Wilgus1-1/+6
When loading a file, Lua may call the reader function again after it returned end of input https://www.lua.org/bugs.html#5.1.5-2 Change-Id: Ic2f4d727705a0b8f48ce792f6a9f7af25a503037
2018-11-11lua update to 5.1.5William Wilgus15-105/+124
Modify Rocklua towards upstream 5.1.5 Clean up some of the Rocklua implementation Change-Id: Iac722e827899cf84f5ca004ef7ae7ddce5f7fbbe
2018-11-02Lua fix failure to read lines longer than LUAL_BUFFERSIZEWilliam Wilgus1-13/+10
Readline didn't handle lines longer than LUAL_BUFFERSIZE it now reads these in chunks. Change-Id: Iffe12447e5441ff6b479ce3de1d36df64c276183
2018-11-02Lua optimize combine and rework similar functionsWilliam Wilgus4-67/+221
rb.strncasecmp strcasecmp just exclude count -> rb.strncasecmp(s1, s2) rb.backlight_brightness_set backlight_set_brightness -- redundant rb.backlight_brightness_use_setting -> rb.backlight_brightness_set() rb.buttonlight_brightness_set buttonlight_set_brightness -- redundant rb.buttonlight_brightness_use_setting -> rb.buttonlight_brightness_set() rb.mixer_frequency rb.mixer_set_frequency -> mixer_frequency(freq) rb.mixer_get_frequency -> mixer_frequency rb.backlight_onoff rb.backlight_on -> rb.backlight_onoff(true) rb.backlight_off -> rb.backlight_onoff(false) rb.touchscreen_mode rb.touchscreen_set_mode -> rb.touchscreen_mode(mode) rb.touchscreen_get_mode -> rb.touchscreen_mode() rb.schedule_cpu_boost rb.trigger_cpu_boost -> rb.schedule_cpu_boost(true) rb.cancel_cpu_boost -> rb.schedule_cpu_boost(false) Includes rbcompat.lua for backwards compatibility if your script is broken by this change you simply add `require("rbcompat")` to the top for the old functionality Change-Id: Ibffd79a0d9be6d7d6a65cc4af5c0a1c6a0f3f94d
2018-11-02lua fix rlimage FB_SCALARPACK()William Wilgus1-8/+14
FB_SCALARPACK(lua_tointeger()) was calling lua_tointeger 3x on color targets Change-Id: I7b3d73bba5dbc0aa4388b123de11410572fe67c5
2018-11-01Lua fix dir string constants and pcm_play_pause & pcm_set_frequencyWilliam Wilgus2-3/+3
String constants were already expanded in the first macro pcm functions were looking for stack position #1 when they needed stack pos #2 Change-Id: I7b4fb90953ab2395b77cbd550fdd257fafca6aae
2018-11-01Lua Fix utf8encode, remove utf16 functionsWilliam Wilgus2-0/+16
The auto generated utf8/16 encode/decode functions did not work. Upon implementing them correctly I found that lua handles the utf-8 form properly but I could not get utf-16 to work without crashing maybe someone can come along later and implement utf-16 safe string functions but for now utf-16 is removed. Change-Id: I97a044e200dc27f683a45487cd93fce667c670c4
2018-10-31Lua Add underscores in audio, pcm, playlist functionsWilliam Wilgus4-28/+25
Lessen confusion for end users looking for the underlying function names in plugin.h Change-Id: I6662dc7bd9f22d83af372b3d3c5af53d9a1eac9a
2018-10-30lua consolidate pcm_ functionsWilliam Wilgus4-2/+108
The way to call the pcm functions has changed rb.pcm("option", var) rb.pcm_set_frequency(freq) = becomes rb.pcm("pcmsetfrequency", freq) added pcm.lua to the includes for conversion to old functions if your script is broken by this change you simply add `require("pcm")` to the top for the old functionality added rb.pcm("calculatepeaks") Change-Id: I092057b0c0b5575e567862661f122da1ca2680e8