initialize
This commit is contained in:
commit
5b23ea99fd
43 changed files with 2336 additions and 0 deletions
140
dash_old/modules/clock.lua
Normal file
140
dash_old/modules/clock.lua
Normal file
|
@ -0,0 +1,140 @@
|
|||
local ascii_digits = {
|
||||
{
|
||||
" 0000 ",
|
||||
"00 00",
|
||||
"00 00",
|
||||
"00 00",
|
||||
" 0000 "
|
||||
},
|
||||
{
|
||||
"1111 ",
|
||||
" 11 ",
|
||||
" 11 ",
|
||||
" 11 ",
|
||||
"111111"
|
||||
},
|
||||
{
|
||||
" 2222 ",
|
||||
"22 22",
|
||||
" 22 ",
|
||||
" 22 ",
|
||||
"222222",
|
||||
},
|
||||
{
|
||||
" 3333 ",
|
||||
"33 33",
|
||||
" 333",
|
||||
"33 33",
|
||||
" 3333 ",
|
||||
},
|
||||
{
|
||||
"44 44",
|
||||
"44 44",
|
||||
"444444",
|
||||
" 44",
|
||||
" 44"
|
||||
},
|
||||
{
|
||||
"555555",
|
||||
"55 ",
|
||||
"55555 ",
|
||||
" 55",
|
||||
"55555"
|
||||
},
|
||||
{
|
||||
" 6666 ",
|
||||
"66 ",
|
||||
"66666 ",
|
||||
"66 66",
|
||||
" 6666 "
|
||||
},
|
||||
{
|
||||
"777777",
|
||||
" 77 ",
|
||||
" 77 ",
|
||||
" 77 ",
|
||||
"77 "
|
||||
},
|
||||
{
|
||||
" 8888 ",
|
||||
"88 88",
|
||||
" 8888 ",
|
||||
"88 88",
|
||||
" 8888 "
|
||||
},
|
||||
{
|
||||
" 9999 ",
|
||||
"99 99",
|
||||
" 99999",
|
||||
" 99",
|
||||
" 9999 "
|
||||
}
|
||||
}
|
||||
local seperator = {
|
||||
" ",
|
||||
" # ",
|
||||
" ",
|
||||
" # ",
|
||||
" ",
|
||||
}
|
||||
|
||||
local function draw_time(x, y, monitor)
|
||||
local date = os.date("%b %d")
|
||||
local h, m = tostring(os.date("%H")), tostring(os.date("%M"))
|
||||
local h1, h2 = tonumber(string.sub(h, 1, 1)), tonumber(string.sub(h, 2, 2))
|
||||
local m1, m2 = tonumber(string.sub(m, 1, 1)), tonumber(string.sub(m, 2, 2))
|
||||
|
||||
local s = os.date("%S")
|
||||
|
||||
monitor.setCursorPos(x, y)
|
||||
monitor.blit(date, "eeef00", "ffffff")
|
||||
monitor.setCursorPos(x, y + 1)
|
||||
|
||||
for i = 1, 5 do
|
||||
monitor.setCursorPos(x, select(2, monitor.getCursorPos()) + 1)
|
||||
monitor.write(ascii_digits[h1 + 1][i] .. " " .. ascii_digits[h2 + 1][i] .. seperator[i] .. ascii_digits[m1 + 1][i] .. " " .. ascii_digits[m2 + 1][i])
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_timezone(x, y, tz_name, utc_offset, tz_monitor)
|
||||
--[[
|
||||
/SYD\
|
||||
|22:34|
|
||||
\_ _/
|
||||
]]
|
||||
if #tz_name ~= 3 then error("Invalid timezone name (not 3 letters)") end
|
||||
local utc = os.date("!*t")
|
||||
local tz_hour = utc.hour + utc_offset
|
||||
if tz_hour > 23 then
|
||||
tz_hour = -24 + tz_hour end
|
||||
|
||||
|
||||
local day_part = {
|
||||
["day"] = "☼",
|
||||
["night"] = "☾"
|
||||
}
|
||||
local tz_symbol
|
||||
if (tz_hour > 20 or tz_hour < 7) then tz_symbol = day_part["night"] else tz_symbol = day_part["day"] end
|
||||
|
||||
tz_monitor.setCursorPos(x, y)
|
||||
tz_monitor.blit(" /" .. tz_name .. "\\", "f04440", "ffffff")
|
||||
tz_monitor.setCursorPos(x, y + 1)
|
||||
tz_monitor.write("|" .. tostring(utc.hour + utc_offset) .. ":" .. tostring(utc.min) .. "|")
|
||||
tz_monitor.setCursorPos(x, y + 2)
|
||||
tz_monitor.blit(" \\_" .. tz_symbol .. "_/ ", "f00400f", "fffffff")
|
||||
end
|
||||
|
||||
local clock = {}
|
||||
clock.new = function (monitor_wrap)
|
||||
local self = {}
|
||||
local monitor = monitor_wrap or peripheral.find("monitor")
|
||||
|
||||
function self.update()
|
||||
draw_time(2, 2, monitor)
|
||||
draw_timezone(2, 11, "SYD", 10, monitor)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
return clock
|
25
dash_old/modules/rss.lua
Normal file
25
dash_old/modules/rss.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
|
||||
local rss_feed = {}
|
||||
rss_feed.new = function (monitor_wrap)
|
||||
local self = {}
|
||||
|
||||
local monitor = monitor_wrap or peripheral.find("monitor")
|
||||
|
||||
local function move_line()
|
||||
monitor.setCursorPos(1, select(2, monitor.getCursorPos()) + 1)
|
||||
if select(2, monitor.getCursorPos()) >= select(2, monitor.getSize()) then
|
||||
monitor.scroll(1)
|
||||
monitor.setCursorPos(1, select(2, monitor.getCursorPos()) - 1)
|
||||
end
|
||||
end
|
||||
|
||||
function self.update()
|
||||
--monitor.write("[TASS] Joeee biden!")
|
||||
--move_line()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
return rss_feed
|
36
dash_old/smart_monitor.lua
Normal file
36
dash_old/smart_monitor.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
--[[
|
||||
Programme for large smart screen in my base
|
||||
|
||||
- RSS feed
|
||||
- Modular functions
|
||||
- Time
|
||||
|
||||
Screen is 8 by 4 blocls
|
||||
8
|
||||
#############
|
||||
############# 4
|
||||
#############
|
||||
#############
|
||||
]]
|
||||
local monitor_main = peripheral.find("monitor")
|
||||
local x_max, y_max = monitor_main.getSize()
|
||||
|
||||
local monitor_clock = window.create(monitor_main, 1, 1, x_max / 8 * 3, y_max / 2)
|
||||
local monitor_rss = window.create(monitor_main, x_max - x_max / 4, 1, x_max, y_max, true)
|
||||
|
||||
local modules = {
|
||||
require("modules.clock").new(monitor_clock),
|
||||
require("modules.rss").new(monitor_rss)
|
||||
}
|
||||
|
||||
while true do
|
||||
local calls = {}
|
||||
for i, module in pairs(modules) do
|
||||
--module.update()
|
||||
table.insert(calls, module.update())
|
||||
end
|
||||
parallel.waitForAll(table.unpack(calls))
|
||||
|
||||
sleep(0.05)
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue