diff --git a/controller-client/camshader.glsl b/controller-client/camshader.glsl new file mode 100644 index 0000000..0e40218 --- /dev/null +++ b/controller-client/camshader.glsl @@ -0,0 +1,8 @@ +#pragma lannguage glsl1 + +vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords) +{ + vec4 textureColor = Texel(tex, texture_coords); + vec4 result = vec4(textureColor[2], textureColor[1], textureColor[0], textureColor[3]); + return result * color; +} diff --git a/controller-client/draw.lua b/controller-client/draw.lua index 221b513..0079224 100644 --- a/controller-client/draw.lua +++ b/controller-client/draw.lua @@ -22,11 +22,13 @@ function love.draw2() 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 diff --git a/controller-client/main.lua b/controller-client/main.lua index e56432a..1c8c56d 100644 --- a/controller-client/main.lua +++ b/controller-client/main.lua @@ -2,6 +2,8 @@ package.loaded["draw"] = nil require("draw") +CamShader = nil + BotState = { lastMessage = 0, cpuBattery = nil, @@ -38,6 +40,8 @@ function formatSafe(format, value, ...) end function love.load() + CamShader = love.graphics.newShader("client/camshader.glsl") + love.graphics.setFont(love.graphics.newFont(20)) love.window.setFullscreen(true) love.mqtt.subscribe("telemetry/#") diff --git a/controller-host/mqttthread.lua b/controller-host/mqttthread.lua index 5e4d875..9b416f6 100644 --- a/controller-host/mqttthread.lua +++ b/controller-host/mqttthread.lua @@ -48,7 +48,7 @@ end local function main() client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "mqtt_controller-" .. math.random(0, maxClientId), + id = "mqtt_controller-" .. math.random(0, maxClientId), clean = true, reconnect = 5, } diff --git a/get-image.lua b/get-image.lua index 12f3b7f..9cce0fc 100644 --- a/get-image.lua +++ b/get-image.lua @@ -35,8 +35,8 @@ end client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "tools", - clean = true, + username = "tool-get-image", + id = true, reconnect = 5, version = mqtt.v311, } diff --git a/get-ip.lua b/get-ip.lua index 18a1971..12880a3 100644 --- a/get-ip.lua +++ b/get-ip.lua @@ -29,7 +29,7 @@ end client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "tools", + id = "tool-get-ip", clean = true, reconnect = 5, } diff --git a/spider-cam/spider-cam.py b/spider-cam/spider-cam.py index f7b539f..49eb97d 100644 --- a/spider-cam/spider-cam.py +++ b/spider-cam/spider-cam.py @@ -21,15 +21,16 @@ def handle_camera_event(cm): def sendImage(plane): image = Image.frombytes("RGBA", (800, 600), plane.tobytes()) pngBytes = io.BytesIO() - image.save(pngBytes, "png") + image.convert("RGB").save(pngBytes, "jpeg") mqttc.publish("spider/telemetry/camfeed", pngBytes.getvalue()) + #mqttc.publish("spider/telemetry/camfeed", plane.tobytes()) def process_request(request): global camera, image_count global mqttc image_count += 1 - if image_count > 1: + if image_count > 0: image_count = 0 print(f'Request completed: {request}') diff --git a/test-image.lua b/test-image.lua index 1f9039f..81c262a 100644 --- a/test-image.lua +++ b/test-image.lua @@ -1,34 +1,33 @@ package.path = package.path .. ';./controller-host/?/init.lua;./controller-host/?.lua' local mqtt = require("mqtt") +local socket = require("socket") local client +local fh = io.open("spider-image.bin", "rb") +local contents = fh:read("a") +fh:close() + local function onConnect(connack) if connack.rc ~= 0 then print("Connection to broker failed:", connack:reason_string()) os.exit(1) end - - --local length = 1000000 - -- 500000 - local length = 1000000 - -- 100000 - --while true do - local payload = string.rep("b", length) - --length = length + 100000 - assert(client:publish { - topic = "spider/telemetry/camfeed", - payload = payload, - qos = 0 - }) - --end + while true do + assert(client:publish { + topic = "spider/telemetry/camfeed", + payload = contents, + qos = 0 + }) + socket.sleep(1) + end print("Connected and subscribed") end client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "tools", + id = "tool-test-image", clean = true, reconnect = 5, version = mqtt.v311, diff --git a/upload-controller.lua b/upload-controller.lua index 39b84c8..856b74b 100644 --- a/upload-controller.lua +++ b/upload-controller.lua @@ -41,7 +41,7 @@ end client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "mqtt_controller", + username = "tool-upload-controller", clean = true, reconnect = 5, }