nets about 5k on clipzip (less on mono, more on others)
to move rockboxlogo to .initdata section
Remove show_logo completely and move to main.c
remove plugin stub
give credits plugin its own copy
credit fallback is now show_info()
Change-Id: Id9ed787e605ed29e7ab1e7a74d3821cd0f840ed4
Allow a clean shutdown to end in either power off or reboot. Add a
new event SYS_REBOOT to signal it and sys_reboot() to trigger the
event. SYS_REBOOT signals a reboot request and should be listened
for alongside SYS_POWEROFF events.
Change-Id: I99ba7fb5feed2bb5a0a40a274e8466ad74fe3a43
temp loader allows some lua requires to be loaded and
later garbage collected unfortunately the module needs to be formatted
in such a way to pass back a call table in order to keep the functions
within from being garbage collected too early
BE AWARE this bypasses the module loader which would allow code reuse
so if you aren't careful this memory saving tool could spell disaster
for free RAM if you load the same code multiple times
Change-Id: I0b6f81e481b8c779edbd620c8403794f8353926f
bring custom keyboard layouts to lua
conversion to the proper format requires create_kbd_layout.lua
just pass a lua string with your desired layout
Change-Id: I14a392410846311a4f3cf8dda0e88d39834d0418
* pcm_get_bytes_remaining()
* pcm_calculate_peaks()
* pcm_get_peak_buffer()
Nothing in-tree uses these at all (except for the lua plugin wrapper)
Change-Id: I971b7beed6760250c8b1ce58f401a601e1e2d585
Nothing in the core has used it for some time. It's exported to the
plugin API but the last plugins to use it were switched to the mixer API
back in 2011.
This allows us to get rid of pcm_play_dma_pause() from all audio drivers
Change-Id: Ic3fa02592316f84963e41d792d1cabb436d1ff6b
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
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
'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
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
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
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
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
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
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
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
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
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
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
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
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
d54659b572
Change-Id: I21d6dcfa32523877efd9f70fb0f88f2a02872649
track elapsed is needed to use fast-forward and rewind effectively
track length might as well be added too..
Change-Id: I906c92eb5260164c6177d8c0a8ff879b1fad7898
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
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
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
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
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
Removes unneeded functions from kbd_input
Consolidates message filling function for gui_syncyesno_run & do_menu
Change-Id: If3c3cea3cbf37a8dc52983c0db174de6d54b35f8
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
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
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
allows rocklib_img to be excluded if needed
stops rocklib_aux from generating redundant prototypes for
lcd_mono_bitmap[_part]
Change-Id: Ie208ad71ab5f9a7deb026dc01a5b0a0631a0d29c
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
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
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