summaryrefslogtreecommitdiff
path: root/apps/plugins/lua (follow)
Commit message (Collapse)AuthorAge
* lua: wrap thread_set_priority with #ifdef HAVE_PRIORITY_SCHEDULINGFranklin Wei2019-07-28
| | | | | | Should fix a compile-time error on simulator. Change-Id: I5962479579350ebffe6dcce4f65a629b108ff936
* Lua Add Emergency Garbage CollectorWilliam Wilgus2019-07-28
| | | | | | | | | | | | | 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
* lua remove unneeded plugin functionsWilliam Wilgus2019-07-28
| | | | Change-Id: I04bc38d03b7f0ca65a815685eb6ab0f5ff825c45
* lua add sound_current, consolidate sound_ functionsWilliam Wilgus2019-07-25
| | | | | | | | | | | | | | | | | 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
* lua events from rockboxWilliam Wilgus2019-07-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* lua disable bytecode dump & undump functionsWilliam Wilgus2019-07-18
| | | | | | | | Adds a flag to remove the ability to dump and load lua bytecode saves 6+kb Change-Id: I080323df7f03f752e0a10928e22a7ce3190a9633
* Fix Red lua move constants out of binary imageWilliam Wilgus2019-07-18
| | | | | | didn't consider sims might have reserved enums Change-Id: Ic404972f0836bc81ba149f4ecdd3ec61bd8bd4b3
* lua move constants out of binary imageWilliam Wilgus2019-07-18
| | | | | | | | | | | | 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
* lua alphabetically sort perl generated rocklib_aux functionsWilliam Wilgus2019-07-17
| | | | Change-Id: I6566c19a0fee630a5e250c1244159d5b488b57ff
* lua close state on os.exitWilliam Wilgus2019-07-13
| | | | Change-Id: I376fad0f92f1155698740e1b8599a3385998575c
* lua reduce heap allocated buffer sizes, organize luaconf.hWilliam Wilgus2019-07-11
| | | | Change-Id: Ib9e568ea73a01474facd57cc155e62fa3dc093f7
* lua late bound cfunction tablesWilliam Wilgus2019-07-11
| | | | | | | | | | | | | | | | | | | | | | | | 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
* lua inbinary stringsWilliam Wilgus2019-07-11
| | | | | | | | | | | | | | 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
* lua add track length & elapsed to rb.audio()William Wilgus2019-07-10
| | | | | | | track elapsed is needed to use fast-forward and rewind effectively track length might as well be added too.. Change-Id: I906c92eb5260164c6177d8c0a8ff879b1fad7898
* lua remove error messages for pre-compiled chunksWilliam Wilgus2019-07-09
| | | | | | | | 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
* Fix lua helpers -- supress line markers in preproc source generation scriptsWilliam Wilgus2018-12-24
| | | | | | | | | | | | | 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
* Lua Fix settings_helper for the gigaBeastSWilliam Wilgus2018-12-17
| | | | | | the gigabeatS has an embedded struct that needs to be parsed Change-Id: I88c9101afaaa95182f37ade1410cccb4fb768e33
* Lua add read/write access to global_status, global_settings, audio_current_trackWilliam Wilgus2018-12-16
| | | | | | | moved items to rb.system added read access to audio_current_track and audio_next_track Change-Id: Ia055b8cb3848e540067818f596ffd1058da057fb
* lua add LCD_DEFAULT_FG, fix 2-bit screen fg/bg inversionWilliam Wilgus2018-11-24
| | | | Change-Id: Ibe2bc6602ff27524a3b96d9523780acbfbf03c76
* Lua fix crash on arm devicesWilliam Wilgus2018-11-17
| | | | | | | | 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
* Lua fix reader bug in lzioWilliam Wilgus2018-11-15
| | | | | | | | | 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
* lua update to 5.1.5William Wilgus2018-11-11
| | | | | | | | Modify Rocklua towards upstream 5.1.5 Clean up some of the Rocklua implementation Change-Id: Iac722e827899cf84f5ca004ef7ae7ddce5f7fbbe
* Lua fix failure to read lines longer than LUAL_BUFFERSIZEWilliam Wilgus2018-11-02
| | | | | | | Readline didn't handle lines longer than LUAL_BUFFERSIZE it now reads these in chunks. Change-Id: Iffe12447e5441ff6b479ce3de1d36df64c276183
* Lua optimize combine and rework similar functionsWilliam Wilgus2018-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* lua fix rlimage FB_SCALARPACK()William Wilgus2018-11-02
| | | | | | FB_SCALARPACK(lua_tointeger()) was calling lua_tointeger 3x on color targets Change-Id: I7b3d73bba5dbc0aa4388b123de11410572fe67c5
* Lua fix dir string constants and pcm_play_pause & pcm_set_frequencyWilliam Wilgus2018-11-01
| | | | | | | 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
* Lua Fix utf8encode, remove utf16 functionsWilliam Wilgus2018-11-01
| | | | | | | | | | 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
* Lua Add underscores in audio, pcm, playlist functionsWilliam Wilgus2018-10-31
| | | | | | | Lessen confusion for end users looking for the underlying function names in plugin.h Change-Id: I6662dc7bd9f22d83af372b3d3c5af53d9a1eac9a
* lua consolidate pcm_ functionsWilliam Wilgus2018-10-30
| | | | | | | | | | | | | | 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
* Lua restore audio_set_recording_gain, audio_set_output,inputWilliam Wilgus2018-10-30
| | | | | | | | Did not mean to wipe out these function when I consolidated audio Made the regex for audio_ and playlist_ exact matches instead of fuzzy Change-Id: I7537d1b494afb114c8b6333ea177b1e482f6b672
* Lua update strftime.c from dietlibc sourceWilliam Wilgus2018-10-30
| | | | | | | | Adds %F -- %Y-%m-%d Fixes possible buffer overflow when writing final \0 Frees a bit of code on NON-RTC targets Change-Id: I1c2600a68ee88c6c99f411ae6646861578683f90
* Lua replace fscanfWilliam Wilgus2018-10-29
| | | | | | | | | | | | | | | | | | | | | | Rocklua was using the full fscanf implementation to simply read %ld for the file:read("*n") function wasting 1k on unneeded/unused functionality Instead, I've implemented a filetol function to duplicate it without the extra overhead using strtol which as an added bonus ERANGE errors now resolve to LONG_MIN and LONGMAX instead of integer overflow filetol() reads long int from an open file, skips preceding whitespaces returns -1 if error, 1 on success. *num set to LONG_MAX or LONG_MIN on overflow. If number of digits is > than LUAI_MAXNUMBER2STR filepointer will continue till the next non digit but buffer will stop being filled with characters. Preceding zero is ignored. Change-Id: Ia42d0f73c63a894625bca4581e9b7e1cc7387fd2
* Lua remove strncat.c & strcspn.cWilliam Wilgus2018-10-30
| | | | Change-Id: I08256f31e733d2674054e8e589d539d1396a0ee6
* Lua expand multiple screen supportWilliam Wilgus2018-10-30
| | | | | | | | | | Some of the lcd functions had support for multiple screens but this wasn't very safe since the screen number wasn't bounded within the screens[] array This adds support for all the lcd functions along with checking that screen# is bounded properly, adds around 600 bytes to devices with a remote screen devices without a remote screen lock to SCREEN_MAIN Change-Id: I618bbc7b3919c7b0ff375fb2d71949d7cab43c87
* Lua rliimage optimize rli_marshal, rli_copy, lcd_xxx_bitmapWilliam Wilgus2018-10-30
| | | | | | | | | | | | | | | | | | rli_marshal and rli_copy allow the use of a custom lua function instead of the built-ins, this custom function can signal to stop before the whole image is iterated. Originally it was checking for a return of 0 which was additional overhead for the built-in functions (which never stop early) as well. Now custom_transform sets the x & y deltas to 0 to indicate early exit removing an extra 'if' per cycle and return from all of the rli_transform functions The lcd_xxx_bitmap functions all require x, y, w, h, screen these calls have been consolidated into a single function get_bmp_bounds() Change-Id: I88de3149c58d1bfb40e9d1a91341fb86cbd63b51
* Lua remove gmtime.c use rb_plugin version insteadWilliam Wilgus2018-10-28
| | | | Change-Id: Ia6d47a13ec8ae407661a78c56513ac0c164216da
* Lua Rlimage metatableWilliam Wilgus2018-10-25
| | | | | | Put rliimage functions into the rb.image metatable instead of the rb. table Change-Id: Iecdc564c2ea9739656e2025b51bb5d5c62e3dbc1
* Lua Fix kbd_inputWilliam Wilgus2018-10-25
| | | | | | | | | While luaL_addstring() works perfectly fine for the final buffer once Lual_pushresult() is called kbd_input doesn't display a previous input properly since the buffer hasn't been finalized yet Change-Id: Ic50acaa8b7b17077dec8750dd2b6382624e8a549
* Lua cleanup kbd_input, gui_syncyesno_run, do_menuWilliam Wilgus2018-10-25
| | | | | | | Removes unneeded functions from kbd_input Consolidates message filling function for gui_syncyesno_run & do_menu Change-Id: If3c3cea3cbf37a8dc52983c0db174de6d54b35f8
* lua consolidate playlist_ functionsWilliam Wilgus2018-10-25
| | | | | | | | | | | | | | | | The way to call the playlist functions has changed rb.playlist("option", var) rb.playlist_add(filename) = becomes rb.playlist("add", filename) added playlist.lua to the includes for conversion to old functions if your script is broken by this change you simply add `require("playlist")` to the top for the old functionality added rb.playlist_tracks(dir, filename) to playlist.lua this will allow you to add all tracks in a playlist.m3u8 to a lua table Change-Id: I87fcc56be365d8495d214f069331b6ddbfbef1db
* lua add audio_play consolidate audio_ functionsWilliam Wilgus2018-10-24
| | | | | | | | | | | | | | | | | | | | | audio_play was removed from the rocklib I assume due to inconsistent behavior I've readded it with a check for audio paused which instead uses rewind/ff and then resumes audio the way to call the audio functions has changed as well rb.audio("option", var) so rb.audio_play(0, 0) becomes rb.audio("play", 0, 0) audio_audio_flush_and_reload_tracks becomes rb.audio("flushandreloadtracks") all functions except audio("getfilepos") return the previous (or still current) status added audio.lua to the includes for conversion to old functions if your script is broken by this change you simply add `require("audio")` to the top for the old functionality Change-Id: I364adf0c85d9c12b98cde29c26fbe5ee05b9d331
* Lua fix create_numbered_filenameWilliam Wilgus2018-10-24
| | | | | | | I didn't realize that some devices used the *num variable this fixes that oversight Change-Id: I2ecd6f475bebdd6ce745b360be3762a069bfc2b1
* Lua fix strip_extension and create_numbered_filenameWilliam Wilgus2018-10-24
| | | | | | | | | | | | | | | | | | | | Both of these functions modified the string in the lua stack per lua manual: 'When a C function receives a string argument from Lua, there are only two rules that it must observe: Not to pop the string from the stack while accessing it and never to modify the string' strip_extension will still work with old parameters and is thus backwards compatible strip_extension("filename") create_numbered_filename has changed slightly and IS NOT backwards compatible create_numbered_filename(path, prefix, suffix, [number]) (number defaults to -1) Change-Id: I34cf7e2f6f691f33d5ac2b2e995855a171fb99b3
* lua move rocklib_img to its own separate loadable moduleWilliam Wilgus2018-10-22
| | | | | | | | | allows rocklib_img to be excluded if needed stops rocklib_aux from generating redundant prototypes for lcd_mono_bitmap[_part] Change-Id: Ie208ad71ab5f9a7deb026dc01a5b0a0631a0d29c
* lua optimize current_path functionWilliam Wilgus2018-10-15
| | | | | | frees up around 500 bytes by using the builtin string functionality Change-Id: Icd4ec921d3fec339b8a4b7f80c9c63d51d4c101c
* Lua remove unusable/unneeded functions from rocklib_auxWilliam Wilgus2018-10-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rocklib_aux is auto generated from plugin.h there are a few functions that get added automatically that are unusable without their companion functions or duplicate functionality already supplied by lua Duplicated functionality: rb->rand, rb->srand -- see math.rand math.srand rb->remove, rb->rename -- see os.remove, os.rename Unusable: rb->open_utf8 -- this should be added to the lua file open routines (if at all) rb->codec_run_proc, rb->codec_close -- without rb->codec_load_file these are pointless rb->timer_set_period, timer_unregister -- even with timer_register implemented lua is not -- reentrant and crashes the state when timer fires Shouldn't be used!: rb->strlcpy, rb->strlcat, rb->strcpy, rb->strcat -- lua reuses strings by hashed values you break this contract if -- you change strings behind its back plus lua provides a way to -- do these functions safely within the strings api Change-Id: I2f65704a90930378cbbceb254e52f61e8074471e
* Fix red rocklib_img 32-24 bit targetsWilliam Wilgus2018-10-08
| | | | | | | int is an incompatible type for targets that have 32bit fb_data need to use FB_SCALARPACK for them Change-Id: Ib3b5ff19c54d8d1bb76af33d0538a17a71301514
* Clean up rocklib_imgWilliam Wilgus2018-10-09
| | | | | | | optimize both size and speed fix invert for color screens Change-Id: I7edecae32dcb3daf5b3ed984a0e5b3d463269e60
* lua rocklib cleanupWilliam Wilgus2018-10-08
| | | | | | | | | | | removes tslf allocations from do_menu and gui_syncyesno_run in favor of lua_newuserdata removes some luaL_opt functions in favor of equivalent lua_to functions moves some definitions to the rocklib.h file Change-Id: Iaacc3249b8f1af2c220ce59dead0050c66cb3b04
* lua optimize integer and string consts in rocklibWilliam Wilgus2018-09-14
| | | | | | use a table approach for registering integer / string constants Change-Id: Idbccae9c2203de1c694f6dd5a7014a7fccedae9b