Set up ldoc and lua-language-server, write some module stubs

custom
jacqueline 1 year ago
parent 0cae95a71e
commit 51d1cee3d7
  1. 6
      .luarc.json
  2. 3
      config.ld
  3. 14
      src/lua/stubs/bluetooth.lua
  4. 11
      src/lua/stubs/playback.lua
  5. 18
      src/lua/stubs/power.lua
  6. 27
      src/lua/stubs/types.lua

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"workspace.library": ["lib/luavgl/src", "src/lua/stubs"],
"runtime.version": "Lua 5.4",
}

@ -0,0 +1,3 @@
file = {'src/lua/stubs'}
project = "Tangara"
description = "Lua modules provided by Tangara's firmware"

@ -0,0 +1,14 @@
--- Properties and functions for handling Bluetooth connectivity
-- @module bluetooth
local bluetooth = {}
-- Whether or not the Bluetooth stack is currently enabled. This property is writeable, and can be used to enable or disable Bluetooth.
-- @treturn types.Property a boolean property
function bluetooth.enabled() end
--- Whether or not there is an active connection to another Bluetooth device.
-- @treturn types.Property a boolean property
function bluetooth.connected() end
return bluetooth

@ -0,0 +1,11 @@
--- Properties for interacting with the audio playback system
-- @module playback
local playback = {}
--- Whether or not any audio is *allowed* to be played. If there is a current track, then this is essentially an indicator of whether playback is paused or unpaused.
--- This value isn't meaningful if there is no current track.
-- @treturn types.Property a boolean property
function playback.playing() end
return playback

@ -0,0 +1,18 @@
--- Properties and functions that deal with the device's battery and power state
-- @module power
local power = {}
--- battery_pct returns the battery's current charge as a percentage
-- @treturn types.Property an integer property, from 0 to 100
function power.battery_pct() end
--- battery_millivolts returns the battery's current voltage in millivolts
-- @treturn types.Property an integer property, typically from about 3000 to about 4200.
function power.battery_millivolts() end
--- plugged_in returns whether or not the device is currently receiving external power
-- @treturn types.Property a boolean property
function power.plugged_in() end
return power

@ -0,0 +1,27 @@
--- Userdata-based types used throughout the rest of the API. These types are
--- not generally constructable within Lua code.
-- @module types
--- A value sourced from the C++ firmware.
-- @type Property
local Property = {}
--- Gets the current value
-- @return The property's current value.
function Property:get() end
--- Sets a new value. Not all properties may be set from within Lua code. For
--- example, it makes little sense to attempt to override the current battery
--- level.
-- @param val The new value. This should generally be of the same type as the existing value.
-- @return true if the new value was applied, or false if the backing C++ code rejected the new value (e.g. if it was out of range, or the wrong type).
function Property:set(val) end
--- Invokes the given function once immediately with the current value, and then again whenever the value changes.
--- The function is invoked for *all* changes; both from the underlying C++ data, and from calls to `set` (if this is a Lua-writeable property).
--- The binding will be active **only** so long as the given function remains in scope.
-- @param fn callback function to apply property values. Must accept one argument; the updated value.
-- @return fn, for more ergonmic use with anonymous closures.
function Property:bind(fn) end
return Property
Loading…
Cancel
Save