summaryrefslogtreecommitdiff
path: root/apps/plugins/lua (unfollow)
Commit message (Collapse)Author
2018-12-24Fix lua helpers -- supress line markers in preproc source generation scriptsWilliam Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
Change-Id: Ibe2bc6602ff27524a3b96d9523780acbfbf03c76
2018-11-17Lua fix crash on arm devicesWilliam Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
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 Wilgus
Lessen confusion for end users looking for the underlying function names in plugin.h Change-Id: I6662dc7bd9f22d83af372b3d3c5af53d9a1eac9a
2018-10-30lua consolidate pcm_ functionsWilliam Wilgus
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
2018-10-30Lua restore audio_set_recording_gain, audio_set_output,inputWilliam Wilgus
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
2018-10-30Lua update strftime.c from dietlibc sourceWilliam Wilgus
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
2018-10-29Lua replace fscanfWilliam Wilgus
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
2018-10-30Lua remove strncat.c & strcspn.cWilliam Wilgus
Change-Id: I08256f31e733d2674054e8e589d539d1396a0ee6
2018-10-30Lua expand multiple screen supportWilliam Wilgus
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
2018-10-30Lua rliimage optimize rli_marshal, rli_copy, lcd_xxx_bitmapWilliam Wilgus
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
2018-10-28Lua remove gmtime.c use rb_plugin version insteadWilliam Wilgus
Change-Id: Ia6d47a13ec8ae407661a78c56513ac0c164216da
2018-10-25Lua Rlimage metatableWilliam Wilgus
Put rliimage functions into the rb.image metatable instead of the rb. table Change-Id: Iecdc564c2ea9739656e2025b51bb5d5c62e3dbc1
2018-10-25Lua Fix kbd_inputWilliam Wilgus
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
2018-10-25Lua cleanup kbd_input, gui_syncyesno_run, do_menuWilliam Wilgus
Removes unneeded functions from kbd_input Consolidates message filling function for gui_syncyesno_run & do_menu Change-Id: If3c3cea3cbf37a8dc52983c0db174de6d54b35f8
2018-10-25lua consolidate playlist_ functionsWilliam Wilgus
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
2018-10-24lua add audio_play consolidate audio_ functionsWilliam Wilgus
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
2018-10-24Lua fix create_numbered_filenameWilliam Wilgus
I didn't realize that some devices used the *num variable this fixes that oversight Change-Id: I2ecd6f475bebdd6ce745b360be3762a069bfc2b1
2018-10-24Lua fix strip_extension and create_numbered_filenameWilliam Wilgus
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
2018-10-22lua move rocklib_img to its own separate loadable moduleWilliam Wilgus
allows rocklib_img to be excluded if needed stops rocklib_aux from generating redundant prototypes for lcd_mono_bitmap[_part] Change-Id: Ie208ad71ab5f9a7deb026dc01a5b0a0631a0d29c
2018-10-15lua optimize current_path functionWilliam Wilgus
frees up around 500 bytes by using the builtin string functionality Change-Id: Icd4ec921d3fec339b8a4b7f80c9c63d51d4c101c
2018-10-12Lua remove unusable/unneeded functions from rocklib_auxWilliam Wilgus
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
2018-10-08Fix red rocklib_img 32-24 bit targetsWilliam Wilgus
int is an incompatible type for targets that have 32bit fb_data need to use FB_SCALARPACK for them Change-Id: Ib3b5ff19c54d8d1bb76af33d0538a17a71301514
2018-10-09Clean up rocklib_imgWilliam Wilgus
optimize both size and speed fix invert for color screens Change-Id: I7edecae32dcb3daf5b3ed984a0e5b3d463269e60
2018-10-08lua rocklib cleanupWilliam Wilgus
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
2018-09-14lua optimize integer and string consts in rocklibWilliam Wilgus
use a table approach for registering integer / string constants Change-Id: Idbccae9c2203de1c694f6dd5a7014a7fccedae9b
2018-09-14lua move RLIMAGE to own fileWilliam Wilgus
Change-Id: Icd10e4c348deec7729d4a6e2bf1152e1dfc70243
2018-07-27Lua -- Fix device hang when scroll function active on clear_screenWilliam Wilgus
I previously noticed that manually clearing the framebuffer while scroll function was active caused lua to crash I could reproduce in sim and on device but I thought using the plugin supplied rb->lcd_clear_screen was immune to this issue Unfortunately some devices exhibit this behavior with the plugin function as well This patch adds rb->lcd_scroll_stop() before lcd_clear_screen at lua start-up and to the supplied include file lcd.lua Change-Id: I9800145e5c834ea27df5db5f1bca50b0d40faa49
2018-07-24Try #4 for lua makeWilliam Wilgus
Last commit was just a test to see if it work this one cleans it up a bit and should be a bit faster Change-Id: Ifdff5c5b78bcc6889506de607193246beccdde6b
2018-07-24Try # 3 for lua make fileWilliam Wilgus
Change-Id: I888612f3339ffcde28602a4e739b08f630de9c28
2018-07-24Lua Fix image saving for 32 bit targets -- update make fileWilliam Wilgus
Hopefully this will fix the build faliures for a few targets Change-Id: I68f6c85513ef589e5f6a50a8efc7bfae9fd62acd
2018-07-23Rocklua -- Extend / Fix rliImageWilliam Wilgus
Some devices(1-bit / 2-bit displays) have packed bit formats that need to be unpacked in order to work on them at a pixel level. This caused a few issues on 1 & 2-bit devices: Greatly Oversized data arrays for bitmaps Improper handling of native image data Framebuffer data was near unusable without jumping through hoops Conversion between native addressing and per pixel addressing incurs extra overhead but it is much faster to do it on the 'C' side rather than in lua. Not to mention the advantage of a unified interface for the end programer ------------------------------------------------------------------- Adds a sane way to access each pixel of image data Adds: -------------------------------------------------------------------- img:clear([color],[x1],[y1],[x2],[y2]) (set whole image or a portion to a particular value) -------------------------------------------------------------------- img:invert([x1],[y1],[x2],[y2]) (inverts whole image or a portion) -------------------------------------------------------------------- img:marshal([x1],[y1],[x2],[y2],[funct]) (calls funct for each point defined by rect of x1,y1 x2,y2 returns value and allows setting value of each point return nil to terminate early) -------------------------------------------------------------------- img:points([x1],[y1],[x2],[y2],[dx],[dy]) (returns iterator function that steps delta-x and delta-y pixels each call returns value of pixel each call but doesn't allow setting to a new value compare to lua pairs method) -------------------------------------------------------------------- img:copy(src,[x1],[y1],[x2],[y2],[w],[h],[clip][operation][clr/funct]) (copies all or part of an image -- straight copy or special ops optionally calls funct for each point defined by rect of x1, y1, w, h and x2, y2, w, h for dest and src images returns value of dst and src and allows setting value of each point return nil to terminate early) -------------------------------------------------------------------- img:line(x1, y1, x2, y2, color) -------------------------------------------------------------------- img:ellipse(x1, y1, x2, y2, color, [fillcolor] -------------------------------------------------------------------- Fixed handling of 2-bit vertical integrated screens Added direct element access for saving / restoring native image etc. Added more data to tostring() handler and a way to access individual items Added equals method to see if two variables reference the same image address (doesn't check if two separate images contain the same 'picture') Optimized get and set routines Fixed out of bound x coord access shifting to next line Added lua include files to expose new functionality Finished image saving routine Static allocation of set_viewport struct faster + saves ram over dynamic Cleaned up code Fixed pixel get/set for 1/2 bit devices Fixed handling for 24-bit devices (32?) ------------------------------------------------------------------------- Example lua script to follow on forums ------------------------------------------------------------------------- Change-Id: I8a9ff0ff72aacf4b1662767ccb2b312fc355239c
2018-07-22Revert "Rocklua -- Extend / Fix rliImage"William Wilgus
This reverts commit 2daec3d3c3d84e7176a22bc073ca5530e8e44c6d. Change-Id: I53ea1f491e3c6d6fb759f426f203f927bd26b1e9
2018-07-22Rocklua -- Extend / Fix rliImageWilliam Wilgus
Some devices(1-bit / 2-bit displays) have packed bit formats that need to be unpacked in order to work on them at a pixel level. This caused a few issues on 1 & 2-bit devices: Greatly Oversized data arrays for bitmaps Improper handling of native image data Framebuffer data was near unusable without jumping through hoops Conversion between native addressing and per pixel addressing incurs extra overhead but it is much faster to do it on the 'C' side rather than in lua. Not to mention the advantage of a unified interface for the end programer ------------------------------------------------------------------- Adds a sane way to access each pixel of image data Adds: -------------------------------------------------------------------- img:clear([color],[x1],[y1],[x2],[y2]) (set whole image or a portion to a particular value) -------------------------------------------------------------------- img:invert([x1],[y1],[x2],[y2]) (inverts whole image or a portion) -------------------------------------------------------------------- img:marshal([x1],[y1],[x2],[y2],[funct]) (calls funct for each point defined by rect of x1,y1 x2,y2 returns value and allows setting value of each point return nil to terminate early) -------------------------------------------------------------------- img:points([x1],[y1],[x2],[y2],[dx],[dy]) (returns iterator function that steps delta-x and delta-y pixels each call returns value of pixel each call but doesn't allow setting to a new value compare to lua pairs method) -------------------------------------------------------------------- img:copy(src,[x1],[y1],[x2],[y2],[w],[h],[clip][operation][clr/funct]) (copies all or part of an image -- straight copy or special ops optionally calls funct for each point defined by rect of x1, y1, w, h and x2, y2, w, h for dest and src images returns value of dst and src and allows setting value of each point return nil to terminate early) -------------------------------------------------------------------- img:line(x1, y1, x2, y2, color) -------------------------------------------------------------------- img:ellipse(x1, y1, x2, y2, color, [fillcolor] -------------------------------------------------------------------- Fixed handling of 2-bit vertical integrated screens Added direct element access for saving / restoring native image etc. Added more data to tostring() handler and a way to access individual items Added equals method to see if two variables reference the same image address (doesn't check if two separate images contain the same 'picture') Optimized get and set routines Fixed out of bound x coord access shifting to next line Added lua include files to expose new functionality Finished image saving routine Static allocation of set_viewport struct faster + saves ram over dynamic Cleaned up code Fixed pixel get/set for 1/2 bit devices ------------------------------------------------------------------------- Example lua script to follow on forums ------------------------------------------------------------------------- Change-Id: I7b9c1fd699442fb683760f781021091786c18509
2018-06-05Fix lua failure to catch divide by zero and NaN exceptionsWilliam Wilgus
I can only assume in the course of the original conversion to fixed point math in RbLua the fact that division by zero and NaN handling was to be caught as a graceful exception by the floating point handler was overlooked. As a result lua doesn't handle these exceptions and instead results in a panic on the device. This patch fixes this handling in the lexer for compile time Inf and Nan results and in the luavm for runtime division by zero (Inf) I missed the runtime exception of n%0 added checks for that as well.. Change-Id: I7746c087ea93678e5875f15ec6fe3f29f26bdb31
2018-05-31Revert "rocklib -- Fix Red"William Wilgus
This reverts commit 37a20dffb6c285e625f049820a6aaadbbd7952aa. Change-Id: Ibf3a56f2b84e0e4af4c2ed890bc22b3555ab24ae
2018-05-31Revert "Rocklua -- Clean-up source"William Wilgus
This reverts commit 0565f671181f10e6eb38156d9f409825e2513290. Removing Typedef from rliimage Change-Id: Ib14241785c73de8ba6dc18ac76bec35eaed4661d
2018-05-28rocklib -- Fix RedWilliam Wilgus
Change-Id: I83b967a266837ebdf887e0f2c2d169a69af9e287
2018-05-28Rocklua -- Clean-up sourceWilliam Wilgus
Change-Id: I11dad15320f209655fd72c2365fe29afd65057d3
2018-05-28Lua liolibWilliam Wilgus
Add Whitespace to EOF Change-Id: Iac253e7905c59518040d39bb5033e35f0deea948
2018-05-27Fix lua lseek command / io libWilliam Wilgus
lua would not return or set arbitrary file positions file:seek("set", 0) worked file:seek("cur") worked but setting an offset or file:seek("end") failed I tracked this down to a bug checking the return of rb->lseek on error lseek returns a negative number and returns the file position otherwise, the function was checking for if(N) instead of if(N < 0) Fixed - limited size of lseek to size of signed LuaNumber Fixed - io:lines() stopped after first line containing only a newline instead of returning a blank line and continuing till EOF this fixes file:read("*l") as well Fixed - ssize_t for read() with error checking Change-Id: Ie859b288fb8f6814f1b3ae30992ecf78f2669de7