summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lua/include_lua
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-11-01 14:20:33 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2018-11-02 18:00:06 +0100
commitf6e10b84882387e304467f22ea2f6126cbaa1264 (patch)
tree1dd56d2d7d524abd66ce286968d83b2b2302500e /apps/plugins/lua/include_lua
parentbb025e3962225491785cc8e73e89190adbacaa4e (diff)
downloadrockbox-f6e10b84882387e304467f22ea2f6126cbaa1264.tar.gz
rockbox-f6e10b84882387e304467f22ea2f6126cbaa1264.tar.bz2
rockbox-f6e10b84882387e304467f22ea2f6126cbaa1264.zip
Lua optimize combine and rework similar functions
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
Diffstat (limited to 'apps/plugins/lua/include_lua')
-rw-r--r--apps/plugins/lua/include_lua/rbcompat.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/apps/plugins/lua/include_lua/rbcompat.lua b/apps/plugins/lua/include_lua/rbcompat.lua
new file mode 100644
index 0000000000..377bc2e4e0
--- /dev/null
+++ b/apps/plugins/lua/include_lua/rbcompat.lua
@@ -0,0 +1,60 @@
+--[[ Lua RB Compatibility Operations
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2018 William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+]]
+
+-- [[ compatibility with old functions ]]
+if rb.strncasecmp then rb.strcasecmp = function(s1, s2) return rb.strncasecmp(s1, s2) end end
+
+if rb.backlight_brightness_set then
+ rb.backlight_set_brightness = function(brightness) rb.backlight_brightness_set(brightness) end
+ rb.backlight_brightness_use_setting = function() rb.backlight_brightness_set(nil) end
+end
+
+if rb.buttonlight_brightness_set then
+ rb.buttonlight_set_brightness = function(brightness) rb.buttonlight_brightness_set(brightness) end
+ rb.buttonlight_brightness_use_setting = function() rb.buttonlight_brightness_set(nil) end
+end
+
+if rb.mixer_frequency then
+ rb.mixer_set_frequency = function(freq) rb.mixer_frequency(freq) end
+ rb.mixer_get_frequency = function() return rb.mixer_frequency(nil) end
+end
+
+if rb.backlight_onoff then
+ rb.backlight_on = function() rb.backlight_onoff(true) end
+ rb.backlight_off = function() rb.backlight_onoff(false) end
+end
+
+if rb.buttonlight_brightness_set then
+ rb.buttonlight_set_brightness = function(brightness) rb.buttonlight_brightness_set(brightness) end
+ rb.buttonlight_brightness_use_setting = function() rb.buttonlight_brightness_set(nil) end
+end
+
+if rb.touchscreen_mode then
+ rb.touchscreen_set_mode = function(mode) rb.touchscreen_mode(mode) end
+ rb.touchscreen_get_mode = function() return rb.touchscreen_mode(nil) end
+end
+
+if rb.schedule_cpu_boost then
+ rb.trigger_cpu_boost = function() rb.schedule_cpu_boost(true) end
+ rb.cancel_cpu_boost = function() rb.schedule_cpu_boost(false) end
+end