Update drone.lua
This commit is contained in:
parent
4338cb38f7
commit
449d66fddd
53
drone.lua
53
drone.lua
|
@ -12,6 +12,10 @@ local cmdacc_color = 0xFFFFFF
|
||||||
|
|
||||||
t.open(6500)
|
t.open(6500)
|
||||||
|
|
||||||
|
sendMsg(msg)
|
||||||
|
t.broadcast(commport,d.name(),"up",msg)
|
||||||
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
d.setLightColor(idle_color)
|
d.setLightColor(idle_color)
|
||||||
local evt,_,sender,port,_,name,cmd,a,b,c = computer.pullSignal()
|
local evt,_,sender,port,_,name,cmd,a,b,c = computer.pullSignal()
|
||||||
|
@ -23,11 +27,11 @@ while true do
|
||||||
end
|
end
|
||||||
if cmd == "ufw" then -- Update Firmware.
|
if cmd == "ufw" then -- Update Firmware.
|
||||||
local web_request = interweb.request(fwaddress)
|
local web_request = interweb.request(fwaddress)
|
||||||
t.broadcast(commport, "Updating firmware...")
|
sendMsg("Updating firmware...")
|
||||||
t.broadcast(commport, " Connecting...")
|
sendMsg(" Connecting...")
|
||||||
web_request.finishConnect()
|
web_request.finishConnect()
|
||||||
t.broadcast(commport, " Connected!")
|
sendMsg(" Connected!")
|
||||||
t.broadcast(commport, " Downloading new firmware...")
|
sendMsg(" Downloading new firmware...")
|
||||||
local full_response = ""
|
local full_response = ""
|
||||||
while true do
|
while true do
|
||||||
local chunk = web_request.read()
|
local chunk = web_request.read()
|
||||||
|
@ -38,20 +42,20 @@ while true do
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
t.broadcast(commport, " Firmware file downloaded!")
|
sendMsg(" Firmware file downloaded!")
|
||||||
t.broadcast(commport, " Flashing new firmware...")
|
sendMsg(" Flashing new firmware...")
|
||||||
eeprom.set(full_response)
|
eeprom.set(full_response)
|
||||||
t.broadcast(commport, " Done flashing firmware!")
|
sendMsg(" Done flashing firmware!")
|
||||||
t.broadcast(commport, "Update process done! Please reboot the drone for changes to take effect.")
|
sendMsg("Update process done! Please reboot the drone for changes to take effect.")
|
||||||
end
|
end
|
||||||
if cmd == "gst" then -- Get Status Text
|
if cmd == "gst" then -- Get Status Text
|
||||||
t.broadcast(commport, d.name(),"up",d.getStatusText())
|
sendMsg(d.getStatusText())
|
||||||
end
|
end
|
||||||
if cmd == "sst" then -- Set Status Text
|
if cmd == "sst" then -- Set Status Text
|
||||||
t.broadcast(commport, d.name(),"up",d.setStatusText(a))
|
sendMsg(d.setStatusText(a))
|
||||||
end
|
end
|
||||||
if cmd == "gpn" then -- Get Port Number
|
if cmd == "gpn" then -- Get Port Number
|
||||||
t.broadcast(commport, d.name(),"up",commport)
|
sendMsg(commport)
|
||||||
end
|
end
|
||||||
if cmd == "spn" then -- Set Port Number
|
if cmd == "spn" then -- Set Port Number
|
||||||
if a ~= nil and a ~= '' then
|
if a ~= nil and a ~= '' then
|
||||||
|
@ -62,22 +66,22 @@ while true do
|
||||||
d.move(a,b,c)
|
d.move(a,b,c)
|
||||||
end
|
end
|
||||||
if cmd == "gos" then -- Get OffSet
|
if cmd == "gos" then -- Get OffSet
|
||||||
t.broadcast(commport, d.name(),"up",d.getOffset())
|
sendMsg(d.getOffset())
|
||||||
end
|
end
|
||||||
if cmd == "gve" then -- Get VElocity
|
if cmd == "gve" then -- Get VElocity
|
||||||
t.broadcast(commport, d.name(),"up",d.getVelocity())
|
sendMsg(d.getVelocity())
|
||||||
end
|
end
|
||||||
if cmd == "gmv" then -- Get Max Velocity
|
if cmd == "gmv" then -- Get Max Velocity
|
||||||
t.send(commport, d.name(),"up",d.getMaxVelocity())
|
sendMsg(d.getMaxVelocity())
|
||||||
end
|
end
|
||||||
if cmd == "gac" then -- Get ACceleration
|
if cmd == "gac" then -- Get ACceleration
|
||||||
t.broadcast(commport, d.name(),"up",d.getAcceleration())
|
sendMsg(d.getAcceleration())
|
||||||
end
|
end
|
||||||
if cmd == "sac" then -- Set ACceleration
|
if cmd == "sac" then -- Set ACceleration
|
||||||
d.setAcceleration(a)
|
d.setAcceleration(a)
|
||||||
end
|
end
|
||||||
if cmd == "glc" then -- Get Light Color
|
if cmd == "glc" then -- Get Light Color
|
||||||
t.broadcast(commport, d.name(),"up",d.getLightColor())
|
sendMsg(d.getLightColor())
|
||||||
end
|
end
|
||||||
if cmd == "slc" then -- Set Light Color (RGB is important!)
|
if cmd == "slc" then -- Set Light Color (RGB is important!)
|
||||||
if b ~= nil and b ~= '' then
|
if b ~= nil and b ~= '' then
|
||||||
|
@ -94,31 +98,32 @@ while true do
|
||||||
end
|
end
|
||||||
if cmd == "eif" then -- External Inventory Find
|
if cmd == "eif" then -- External Inventory Find
|
||||||
local b, s = d.detect(a)
|
local b, s = d.detect(a)
|
||||||
t.broadcast(commport, d.name(),"up",b,s)
|
sendMsg(b)
|
||||||
|
sendMsg(s)
|
||||||
end
|
end
|
||||||
if cmd == "eco" then -- External inventory COmpare
|
if cmd == "eco" then -- External inventory COmpare
|
||||||
t.broadcast(commport, d.name(),"up",d.compare(a))
|
sendMsg(d.compare(a))
|
||||||
end
|
end
|
||||||
if cmd == "esu" then -- External inventory SUck
|
if cmd == "esu" then -- External inventory SUck
|
||||||
o = d.suck(a, b)
|
o = d.suck(a, b)
|
||||||
t.broadcast(commport, d.name, "up", o)
|
sendMsg(o)
|
||||||
end
|
end
|
||||||
if cmd == "edr" then -- External inventory DRop
|
if cmd == "edr" then -- External inventory DRop
|
||||||
o = d.drop(a, b)
|
o = d.drop(a, b)
|
||||||
t.broadcast(commport, d.name(), "up", o)
|
sendMsg(o)
|
||||||
end
|
end
|
||||||
if cmd == "igs" then -- Internal inventory Get Slot
|
if cmd == "igs" then -- Internal inventory Get Slot
|
||||||
t.broadcast(commport, d.name(), "up", d.select())
|
sendMsg(d.select())
|
||||||
end
|
end
|
||||||
if cmd == "iss" then -- Internal inventory Set Slot
|
if cmd == "iss" then -- Internal inventory Set Slot
|
||||||
o = d.select(a)
|
o = d.select(a)
|
||||||
--t.broadcast(commport, d.name(), "up", o)
|
sendMsg(o)
|
||||||
end
|
end
|
||||||
if cmd == "gis" then -- Get Inventory Size
|
if cmd == "gis" then -- Get Inventory Size
|
||||||
t.broadcast(commport, d.name(), "up", d.inventorySize())
|
sendMsg(d.inventorySize())
|
||||||
end
|
end
|
||||||
if cmd == "gsr" then -- Get Slot space Remaining
|
if cmd == "gsr" then -- Get Slot space Remaining
|
||||||
t.broadcast(commport, d.name(), "up", d.space(a))
|
sendMsg(d.space(a))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue