-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from iNavFlight/crsf-replay
Update log name usage for EdgeTX
- Loading branch information
Showing
8 changed files
with
264 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- Log loader for EdgeTX | ||
|
||
local config, data, FILE_PATH = ... | ||
|
||
-- Load config for model | ||
fh = io.open(FILE_PATH .. "cfg/" .. model.getInfo().name .. ".dat") | ||
if fh ~= nil then | ||
for i = 1, #config do | ||
local tmp = io.read(fh, config[i].c) | ||
if tmp ~= "" then | ||
config[i].v = config[i].d == nil and math.min(tonumber(tmp), config[i].x == nil and 1 or config[i].x) or tmp * 0.1 | ||
end | ||
end | ||
io.close(fh) | ||
end | ||
|
||
-- Look for language override | ||
fh = io.open(FILE_PATH .. "cfg/lang.dat") | ||
if fh ~= nil then | ||
local tmp = io.read(fh, 2) | ||
io.close(fh) | ||
data.lang = tmp | ||
data.voice = tmp | ||
end | ||
|
||
local log = getDateTime() | ||
config[34].x = -1 | ||
|
||
-- From EdgeTX 2.7.1 (at least) we don't need to translate spaces | ||
local mbase = model.getInfo().name .. "-20" | ||
local mblen = string.len(mbase) | ||
local tempf = {} | ||
local tempi = 0 | ||
for fname in dir("/LOGS") do | ||
if string.find(fname, mbase, 1, true) == 1 then | ||
local dstr = string.sub(fname, mblen+1, -5) | ||
local lyr = tonumber(string.sub(dstr, 1, 2))+2000 | ||
local lmo = tonumber(string.sub(dstr, 4, 5)) | ||
local lda = tonumber(string.sub(dstr, 7, 8)) | ||
tdiff = 366*(log.year-lyr) + (log.mon-lmo)*31 + log.day - lda | ||
if tdiff < 16 then | ||
tempi = tempi + 1 | ||
tempf[tempi] = dstr | ||
end | ||
end | ||
end | ||
table.sort( tempf ) | ||
for i = #tempf, 1, -1 do | ||
config[34].x = config[34].x + 1 | ||
config[34].l[config[34].x] = tempf[i] | ||
collectgarbage() | ||
if config[34].x == 5 then break end | ||
end | ||
collectgarbage() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- OpenTX log loader | ||
|
||
local config, data, FILE_PATH = ... | ||
|
||
-- Load config for model | ||
fh = io.open(FILE_PATH .. "cfg/" .. model.getInfo().name .. ".dat") | ||
if fh ~= nil then | ||
for i = 1, #config do | ||
local tmp = io.read(fh, config[i].c) | ||
if tmp ~= "" then | ||
config[i].v = config[i].d == nil and math.min(tonumber(tmp), config[i].x == nil and 1 or config[i].x) or tmp * 0.1 | ||
end | ||
end | ||
io.close(fh) | ||
end | ||
|
||
-- Look for language override | ||
fh = io.open(FILE_PATH .. "cfg/lang.dat") | ||
if fh ~= nil then | ||
local tmp = io.read(fh, 2) | ||
io.close(fh) | ||
data.lang = tmp | ||
data.voice = tmp | ||
end | ||
|
||
local log = getDateTime() | ||
|
||
config[34].x = -1 | ||
local path = "/LOGS/" .. string.gsub(model.getInfo().name, " ", "_") .. "-20" | ||
for days = 1, 15 do | ||
local logDate = string.sub(log.year, 3) .. "-" .. string.sub("0" .. log.mon, -2) .. "-" .. string.sub("0" .. log.day, -2) | ||
local fh = io.open(path .. logDate .. ".csv") | ||
if fh ~= nil then | ||
io.close(fh) | ||
config[34].x = config[34].x + 1 | ||
config[34].l[config[34].x] = logDate | ||
collectgarbage() | ||
if config[34].x == 5 then break end | ||
end | ||
log.day = log.day - 1 | ||
if log.day == 0 then | ||
log.day = 31 | ||
log.mon = log.mon - 1 | ||
if log.mon == 0 then | ||
log.mon = 12 | ||
log.year = log.year - 1 | ||
end | ||
end | ||
end | ||
return |
Oops, something went wrong.