add weather sample
This commit is contained in:
17
samples/weather_test.lua
Normal file
17
samples/weather_test.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
function on_alarm()
|
||||
weather:get_by_hour()
|
||||
end
|
||||
|
||||
function on_weather_result(tab)
|
||||
local tab2 = {}
|
||||
|
||||
for k,v in pairs(tab) do
|
||||
table.insert(tab2, time_to_string(v.time)..": "..v.temp)
|
||||
end
|
||||
|
||||
ui:show_lines(tab2)
|
||||
end
|
||||
|
||||
function time_to_string(time)
|
||||
return os.date("%c", time)
|
||||
end
|
||||
Reference in New Issue
Block a user