63 lines
1.8 KiB
Lua
63 lines
1.8 KiB
Lua
|
|
local function getTextY(line)
|
|
return 15 + 25 * line
|
|
end
|
|
|
|
function love.draw2()
|
|
local width, height = love.graphics.getDimensions()
|
|
|
|
-- Set background
|
|
love.graphics.setBackgroundColor(0, 0, 0)
|
|
love.graphics.setColor(1, 1, 1)
|
|
|
|
-- Draw camera feed
|
|
if BotState.camfeed then
|
|
local imageWidth = BotState.camfeed:getWidth()
|
|
local imageHeight = BotState.camfeed:getHeight()
|
|
|
|
local scaleWidth = width / imageWidth
|
|
local scaleHeight = height / imageHeight
|
|
local scale = math.min(scaleWidth, scaleHeight)
|
|
|
|
local scaledWidth = imageWidth * scale
|
|
local scaledHeight = imageHeight * scale
|
|
|
|
love.graphics.setShader(CamShader)
|
|
love.graphics.draw(BotState.camfeed,
|
|
(width - scaledWidth) / 2, (height - scaledHeight) / 2,
|
|
0,
|
|
scale, scale
|
|
)
|
|
love.graphics.setShader(nil)
|
|
end
|
|
|
|
-- Draw time
|
|
local time
|
|
if BotState.lastMessage == 0 then
|
|
time = "Never"
|
|
else
|
|
time = math.floor(love.timer.getTime() - BotState.lastMessage) .. "s ago"
|
|
end
|
|
love.graphics.print("Last message received: " .. time, 5, 5)
|
|
|
|
-- Draw cpu battery
|
|
if BotState.cpuBatteryCorrected == nil or BotState.cpuBatteryCorrected <= 3 then
|
|
love.graphics.setColor(1, 0, 0)
|
|
else
|
|
love.graphics.setColor(1, 1, 1)
|
|
end
|
|
love.graphics.print("CPU Batt: " .. formatSafe("%.02f (%.02f) V", BotState.cpuBattery, BotState.cpuBatteryCorrected), 5, getTextY(1))
|
|
|
|
-- Draw servo battery
|
|
if BotState.servoBatteryCorrected == nil or BotState.servoBatteryCorrected <= 3 then
|
|
love.graphics.setColor(1, 0, 0)
|
|
else
|
|
love.graphics.setColor(1, 1, 1)
|
|
end
|
|
love.graphics.print("Servo Batt: " .. formatSafe("%.02f (%.02f) V", BotState.servoBattery, BotState.servoBatteryCorrected), 5, getTextY(2))
|
|
|
|
-- Draw latency
|
|
love.graphics.setColor(1, 1, 1)
|
|
love.graphics.print("Latency: " .. Ping.latency, 5, getTextY(3))
|
|
end
|