storage.read¶
since 1.1.0
Read a value from the current storage.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
label |
string | yes |
Returns¶
The value read
Examples¶
local function read(widget)
widget.source = storage.read("source") -- a saved Source comes back as a Source
widget.threshold = storage.read("threshold") or 33 -- default for widgets saved by an older version
end
Use it inside read callbacks of widgets, tasks and sources. Values live in the model file. See Saving settings.
Used in¶
- Background alert task
- Battery gauge widget
- Lua source
- Timer control
- Telemetry value widget
- lazy-loading
- source
- task
- widget-gauge
- widget-jet
Real-world usage¶
Called 16 times across 3 open-source Ethos Lua projects. A few short excerpts:
local function read(widget)
widget.discIdx = storage.read("discIdx") or widget.discIdx
widget.certIdx = storage.read("certIdx") or widget.certIdx
widget.trigSwitch = storage.read("trigSwitch") or widget.trigSwitch
widget.rstSwitch = storage.read("rstSwitch") or widget.rstSwitch
widget.repSwitch = storage.read("repSwitch") or widget.repSwitch
end