mirror of
https://github.com/kepler155c/opus
synced 2025-11-14 14:27:11 +00:00
cleanup
This commit is contained in:
@@ -34,9 +34,25 @@ function turtle.setGPSHome()
|
||||
local config = { }
|
||||
Config.load('gps', config)
|
||||
|
||||
if turtle.enableGPS() then
|
||||
if turtle.point.gps then
|
||||
config.home = turtle.point
|
||||
Config.update('gps', config)
|
||||
turtle.gotoPoint(turtle.point)
|
||||
else
|
||||
local pt = GPS.getPoint()
|
||||
if pt then
|
||||
local originalHeading = turtle.point.heading
|
||||
local heading = GPS.getHeading()
|
||||
if heading then
|
||||
local turns = (turtle.point.heading - originalHeading) % 4
|
||||
pt.heading = (heading - turns) % 4
|
||||
config.home = pt
|
||||
Config.update('gps', config)
|
||||
|
||||
pt = GPS.getPoint()
|
||||
pt.heading = heading
|
||||
turtle.setPoint(pt, true)
|
||||
turtle.gotoPoint(config.home)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user