galjonsfigur 6926c66b16 Polish Lua examples (#2846)
* Add missing globals from luacheck config

* Fix luacheck warnings in all lua files

* Re-enable luacheck in Travis

* Speed up Travis by using preinstalled LuaRocks

* Fix more luacheck warnings in httpserver lua module

* Fix DCC module and add appropriate definitions to luacheck config.

* Change inline comments from ignoring block to only ignore specific line

* Add Luacheck for Windows and enable it for both Windows and Linux

* Change luacheck exceptions and fix errors from 1st round of polishing

* Add retry and timeout params to wget
2020-06-09 22:26:52 +02:00

43 lines
989 B
Lua

-- ****************************************************************************
-- Play file with pcm module.
--
-- Upload jump_8k.u8 to spiffs before running this script.
--
-- ****************************************************************************
local function cb_drained()
print("drained "..node.heap())
file.seek("set", 0)
-- uncomment the following line for continuous playback
--d:play(pcm.RATE_8K)
end
local function cb_stopped()
print("playback stopped")
file.seek("set", 0)
end
local function cb_paused()
print("playback paused")
end
do
file.open("jump_8k.u8", "r")
local drv = pcm.new(pcm.SD, 1)
-- fetch data in chunks of FILE_READ_CHUNK (1024) from file
drv:on("data", function(driver) return file.read() end) -- luacheck: no unused
-- get called back when all samples were read from the file
drv:on("drained", cb_drained)
drv:on("stopped", cb_stopped)
drv:on("paused", cb_paused)
-- start playback
drv:play(pcm.RATE_8K)
end