-
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
local component = require( "component" )
|
local component = require( "component" )
|
||||||
local gpu = component.gpu
|
local gpu = component.gpu
|
||||||
local event = require( "event" )
|
local event = require( "event" )
|
||||||
|
|
||||||
|
local splashText = "Stromanzeige - Ultimate ROG RGB LED Edition"
|
||||||
|
local frameTitle = "Power Monitor - Klicken zum Beenden"
|
||||||
|
|
||||||
local oldW, oldH = gpu.getResolution()
|
local oldW, oldH = gpu.getResolution()
|
||||||
local newW = 160
|
local newW = 160
|
||||||
@@ -24,9 +27,8 @@ function drawLine(startX, startY, stopX, stopY, colorOfLine)
|
|||||||
gpu.setBackground(oldColor, false)
|
gpu.setBackground(oldColor, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function powerBar( label, y, x, value, maxVal, colorOfBar, show, unit )
|
function powerBar( label, y, x, value, maxVal, colorOfBar, show, unit, border)
|
||||||
local oldColor = gpu.getBackground(false)
|
local oldColor = gpu.getBackground(false)
|
||||||
local border = 3
|
|
||||||
local borderSymbol = " "
|
local borderSymbol = " "
|
||||||
local barSymbol = " "
|
local barSymbol = " "
|
||||||
local percentage = (value * 100 / maxVal)
|
local percentage = (value * 100 / maxVal)
|
||||||
@@ -112,38 +114,54 @@ function getTotal()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawDesktop()
|
function drawPanel(x, y, width, height, color)
|
||||||
drawLine(halfWidth, 3, 1, 40, 0xffffff)
|
drawLine(x, y, width, height, color)
|
||||||
drawLine(1, 43, newW, 1, 0xffffff)
|
drawLine(x + 1, y + 1, width -1, height - 1, 0x000000)
|
||||||
gpu.set(1, 42, "Speicherzellen")
|
end
|
||||||
gpu.set(halfWidth + 1, 42, "Generatoren")
|
|
||||||
gpu.set((newW - #frameTitle) / 2, 1, frameTitle)
|
function drawDesktop()
|
||||||
|
--Title
|
||||||
|
local titleHeight = 3
|
||||||
|
drawPanel(1, 1, newW, titleHeight, 0xffffff)
|
||||||
|
gpu.set((newW - #frameTitle) / 2, 2, frameTitle)
|
||||||
|
local cellsID = getCells()
|
||||||
|
local count = 0
|
||||||
|
local t = titleHeight
|
||||||
|
|
||||||
|
for i = 0,numberOfPanels - 1,+1 do
|
||||||
|
drawPanel(panelWidth*i+1, titleHeight + 1, newH - titleHeight)
|
||||||
|
if i == 0 then
|
||||||
|
for address, name in pairs(cellsID) do
|
||||||
|
local cell = component.proxy( address )
|
||||||
|
count = count + 1
|
||||||
|
t = t + 3
|
||||||
|
powerBar( name, t , panelWidth - 6, cell.getEnergyStored(), cell.getMaxEnergyStored() , 0x00bb00, true, "RF", panelWidth*i+2)
|
||||||
|
end
|
||||||
|
elseif i == 1 then
|
||||||
|
local totalPower, totalMaxPower = getTotal()
|
||||||
|
powerBar( "Gesamt", titleHeight + 1, panelWidth - 6, totalPower, totalMaxPower, 0x00bb00, true, "RF", panelWidth*i+2)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local splashText = "Supercoole Stromanzeige"
|
|
||||||
local frameTitle = "Power Monitor - Klicken zum Beenden"
|
|
||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
drawLine(1, 1, newW, 1, 0xbbbbbb)
|
drawLine(1, 1, newW, 1, 0xbbbbbb)
|
||||||
gpu.set((newW - #splashText) / 2, 24, splashText)
|
gpu.set((newW - #splashText) / 2, 24, splashText)
|
||||||
os.sleep(1)
|
os.sleep(1)
|
||||||
clearScreen()
|
clearScreen()
|
||||||
local cellsID = getCells()
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local _,_,x,y = event.pull( 1, "touch" )
|
local _,_,x,y = event.pull( 1, "touch" )
|
||||||
local count = 0
|
drawDesktop()
|
||||||
if x and y then goto quit end
|
if x < 10 and y < 10 then
|
||||||
|
numberOfPanels = numberOfPanels + 1
|
||||||
for address, name in pairs(cellsID) do
|
elseif x > 10 and Y > 10 then
|
||||||
local cell = component.proxy( address )
|
numberOfPanels = numberOfPanels - 1
|
||||||
count = count + 1
|
else
|
||||||
local t = count * 3
|
goto quit
|
||||||
powerBar( name, t , halfWidth - 6, cell.getEnergyStored(), cell.getMaxEnergyStored() , 0x00bb00, true, "RF" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local totalPower, totalMaxPower = getTotal()
|
|
||||||
powerBar( "Gesamt", 51 - count, newW - 6, totalPower, totalMaxPower, 0x00bb00, true, "RF" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user