-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…6c2e56] [skip ci]
- Loading branch information
Travis CI
committed
Oct 30, 2017
1 parent
86c2e56
commit be5c40f
Showing
2 changed files
with
2 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
supportedProtocols={smartPort={transport=SCRIPT_HOME.."/MSP/sp.lua",rssi=function()return getValue("RSSI")end,exitFunc=function()return 0 end,push=sportTelemetryPush,maxTxBufferSize=6,maxRxBufferSize=6,saveMaxRetries=2,saveTimeout=150},crsf={transport=SCRIPT_HOME.."/MSP/crsf.lua",rssi=function()return getValue("TQly")end,exitFunc=function()return"/CROSSFIRE/crossfire.lua"end,push=crossfireTelemetryPush,maxTxBufferSize=8,maxRxBufferSize=58,saveMaxRetries=2,saveTimeout=150}}function getProtocol()if supportedProtocols.smartPort.push()then return supportedProtocols.smartPort elseif supportedProtocols.crsf.push()then return supportedProtocols.crsf end end;local a=getProtocol()if not a then error("Telemetry protocol not supported!")end;return a | ||
supportedProtocols={smartPort={transport=SCRIPT_HOME.."/MSP/sp.lua",rssi=function()return getValue("RSSI")end,exitFunc=function()return 0 end,push=sportTelemetryPush,maxTxBufferSize=6,maxRxBufferSize=6,saveMaxRetries=2,saveTimeout=300},crsf={transport=SCRIPT_HOME.."/MSP/crsf.lua",rssi=function()return getValue("TQly")end,exitFunc=function()return"/CROSSFIRE/crossfire.lua"end,push=crossfireTelemetryPush,maxTxBufferSize=8,maxRxBufferSize=58,saveMaxRetries=2,saveTimeout=150}}function getProtocol()if supportedProtocols.smartPort.push()then return supportedProtocols.smartPort elseif supportedProtocols.crsf.push()then return supportedProtocols.crsf end end;local a=getProtocol()if not a then error("Telemetry protocol not supported!")end;return a |
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 |
---|---|---|
@@ -1 +1 @@ | ||
local a=assert(loadScript(SCRIPT_HOME.."/events.lua"))()local b={display=2,editing=3,saving=4,displayMenu=5}local c={reboot=68,eepromWrite=250}local d=b.display;local e=80;local f=1;local g=1;local h=0;local i=0;local j=0;local k=0;local l=false;local m=false;local n=false;local o=0;local p=0;Page=nil;backgroundFill=backgroundFill or ERASE;foregroundColor=foregroundColor or SOLID;globalTextOptions=globalTextOptions or 0;local function q(r)if Page.values then if Page.preSave then Page.preSave(Page)end;protocol.mspWrite(Page.write,Page.values)h=getTime()if d==b.saving then j=j+1 else d=b.saving;j=0;k=protocol.saveMaxRetries or 2;i=protocol.saveTimeout or 150 end end end;local function s()Page=nil;d=b.display;h=0 end;local function t()protocol.mspRead(c.reboot)s()end;local function u()protocol.mspRead(c.eepromWrite)end;local v={{t="save page",f=q},{t="reload",f=s},{t="reboot",f=t}}local function w(x,y)if x==nil or y==nil then return end;if x==Page.write then if Page.eepromWrite then u()end;l=false;return end;if x==c.eepromWrite then if Page.reboot then t()end;s()d=b.display;h=0;return end;if x~=Page.read then return end;if#y>0 then Page.values={}for z=1,#y do Page.values[z]=y[z]end;if Page.postLoad then Page.postLoad(Page)end end end;local function A()return#Page.fields end;local function B(C)f=f+C;if f>#PageFiles then f=1 elseif f<1 then f=#PageFiles end;g=1 end;local function D(C)g=g+C;if g>A()then g=1 elseif g<1 then g=A()end end;local function E(C)n=n+C;if n>#v then n=1 elseif n<1 then n=#v end end;local function F()if Page.read and(Page.reqTS==nil or Page.reqTS+e<=getTime())then Page.reqTS=getTime()protocol.mspRead(Page.read)end end;function drawScreenTitle(G)lcd.drawFilledRectangle(0,0,LCD_W,10)lcd.drawText(1,1,G,INVERS)end;local function H()local G=Page.title;drawScreenTitle("Betaflight / "..G)for z=1,#Page.text do local I=Page.text[z]if I.to==nil then lcd.drawText(I.x,I.y,I.t,globalTextOptions)else lcd.drawText(I.x,I.y,I.t,I.to)end end;local J="---"for z=1,#Page.fields do local I=Page.fields[z]local K=I.to or globalTextOptions;local L=K;local M=K;if z==g then M=K+INVERS;if d==b.editing then M=M+BLINK end end;local N=20;if I.t~=nil then lcd.drawText(I.x,I.y,I.t,L)if I.sp~=nil then N=I.sp end else N=0 end;if Page.values then if(#Page.values or 0)>=Page.minBytes then if not I.value and I.vals then for O=1,#I.vals do I.value=bit32.bor(I.value or 0,bit32.lshift(Page.values[I.vals[O]],(O-1)*8))end;I.value=I.value/(I.scale or 1)end end end;if I.value then if I.upd and Page.values then I.upd(Page)end;J=I.value;if I.table and I.table[I.value]then J=I.table[I.value]end end;lcd.drawText(I.x+N,I.y,J,M)end end;local function P(J,Q,R)if J<Q then J=Q elseif J>R then J=R end;return J end;local function S()return Page.fields[g]end;local function T(C)local I=Page.fields[g]local O=I.i or g;local U=I.scale or 1;I.value=P(I.value+C*(I.mult or 1)/U,I.min/U or 0,I.max/U or 255)for O=1,#I.vals do Page.values[I.vals[O]]=bit32.rshift(I.value*U,(O-1)*8)end;if I.upd and Page.values then I.upd(Page)end end;local function V()local W=MenuBox.x;local X=MenuBox.y;local Y=MenuBox.w;local Z=MenuBox.h_line;local _=MenuBox.h_offset;local a0=#v*Z+_*2;lcd.drawFilledRectangle(W,X,Y,a0,backgroundFill)lcd.drawRectangle(W,X,Y-1,a0-1,foregroundColor)lcd.drawText(W+Z/2,X+_,"Menu:",globalTextOptions)for z,a1 in ipairs(v)do local K=globalTextOptions;if n==z then K=K+INVERS end;lcd.drawText(W+MenuBox.x_offset,X+(z-1)*Z+_,a1.t,K)end end;function run_ui(a2)local a3=getTime()if o+50<a3 then s()end;o=a3;if d==b.saving then if h+i<a3 then if j<k then q()else d=b.display;s()end end end;mspProcessTxQ()if a2==a.longPress.menu then n=1;d=b.displayMenu elseif a.press.pageUp and a2==a.longPress.enter then n=1;p=1;d=b.displayMenu elseif d==b.displayMenu then if a2==a.release.exit then d=b.display elseif a2==a.release.plus or a2==a.dial.left then E(-1)elseif a2==a.release.minus or a2==a.dial.right then E(1)elseif a2==a.release.enter then if p==1 then p=0 else d=b.display;v[n].f()end end elseif d<=b.display then if a2==a.press.pageUp then Page=nil;B(-1)elseif a2==a.release.menu or a2==a.press.pageDown then Page=nil;B(1)elseif a2==a.release.plus or a2==a.dial.left then D(-1)elseif a2==a.release.minus or a2==a.dial.right then D(1)elseif a2==a.release.enter then local a4=Page.fields[g]local O=a4.i or g;if Page.values and Page.values[O]and a4.ro~=true then d=b.editing end elseif a2==a.release.exit then return protocol.exitFunc()end elseif d==b.editing then if a2==a.release.exit or a2==a.release.enter then d=b.display elseif a2==a.press.plus or a2==a.repeatPress.plus or a2==a.dial.right then T(1)elseif a2==a.press.minus or a2==a.repeatPress.minus or a2==a.dial.left then T(-1)end end;if Page==nil then Page=assert(loadScript(radio.templateHome..PageFiles[f]))()end;if not Page.values and d==b.display then F()end;lcd.clear()if TEXT_BGCOLOR then lcd.drawFilledRectangle(0,0,LCD_W,LCD_H,TEXT_BGCOLOR)end;H()if protocol.rssi()==0 then lcd.drawText(NoTelem[1],NoTelem[2],NoTelem[3],NoTelem[4])end;if d==b.displayMenu then V()elseif d==b.saving then lcd.drawFilledRectangle(SaveBox.x,SaveBox.y,SaveBox.w,SaveBox.h,backgroundFill)lcd.drawRectangle(SaveBox.x,SaveBox.y,SaveBox.w,SaveBox.h,SOLID)lcd.drawText(SaveBox.x+SaveBox.x_offset,SaveBox.y+SaveBox.h_offset,"Saving...",DBLSIZE+BLINK+globalTextOptions)end;w(mspPollReply())return 0 end;return run_ui | ||
local a=assert(loadScript(SCRIPT_HOME.."/events.lua"))()local b={display=2,editing=3,saving=4,displayMenu=5}local c={reboot=68,eepromWrite=250}local d=b.display;local e=80;local f=1;local g=1;local h=0;local i=0;local j=0;local k=0;local l=false;local m=false;local n=false;local o=0;local p=0;Page=nil;backgroundFill=backgroundFill or ERASE;foregroundColor=foregroundColor or SOLID;globalTextOptions=globalTextOptions or 0;local function q(r)if Page.values then if Page.preSave then Page.preSave(Page)end;protocol.mspWrite(Page.write,Page.values)h=getTime()if d==b.saving then j=j+1 else d=b.saving;j=0;k=protocol.saveMaxRetries or 2;i=protocol.saveTimeout or 150 end end end;local function s()Page=nil;d=b.display;h=0 end;local function t()protocol.mspRead(c.reboot)s()end;local function u()protocol.mspRead(c.eepromWrite)end;local v={{t="save page",f=q},{t="reload",f=s},{t="reboot",f=t}}local function w(x,y)if x==nil or y==nil then return end;if x==Page.write then if Page.eepromWrite then u()else s()d=b.display;h=0 end;l=false;return end;if x==c.eepromWrite then if Page.reboot then t()end;s()d=b.display;h=0;return end;if x~=Page.read then return end;if#y>0 then Page.values={}for z=1,#y do Page.values[z]=y[z]end;if Page.postLoad then Page.postLoad(Page)end end end;local function A()return#Page.fields end;local function B(C)f=f+C;if f>#PageFiles then f=1 elseif f<1 then f=#PageFiles end;g=1 end;local function D(C)g=g+C;if g>A()then g=1 elseif g<1 then g=A()end end;local function E(C)n=n+C;if n>#v then n=1 elseif n<1 then n=#v end end;local function F()if Page.read and(Page.reqTS==nil or Page.reqTS+e<=getTime())then Page.reqTS=getTime()protocol.mspRead(Page.read)end end;function drawScreenTitle(G)lcd.drawFilledRectangle(0,0,LCD_W,10)lcd.drawText(1,1,G,INVERS)end;local function H()local G=Page.title;drawScreenTitle("Betaflight / "..G)for z=1,#Page.text do local I=Page.text[z]if I.to==nil then lcd.drawText(I.x,I.y,I.t,globalTextOptions)else lcd.drawText(I.x,I.y,I.t,I.to)end end;local J="---"for z=1,#Page.fields do local I=Page.fields[z]local K=I.to or globalTextOptions;local L=K;local M=K;if z==g then M=K+INVERS;if d==b.editing then M=M+BLINK end end;local N=20;if I.t~=nil then lcd.drawText(I.x,I.y,I.t,L)if I.sp~=nil then N=I.sp end else N=0 end;if Page.values then if(#Page.values or 0)>=Page.minBytes then if not I.value and I.vals then for O=1,#I.vals do I.value=bit32.bor(I.value or 0,bit32.lshift(Page.values[I.vals[O]],(O-1)*8))end;I.value=I.value/(I.scale or 1)end end end;if I.value then if I.upd and Page.values then I.upd(Page)end;J=I.value;if I.table and I.table[I.value]then J=I.table[I.value]end end;lcd.drawText(I.x+N,I.y,J,M)end end;local function P(J,Q,R)if J<Q then J=Q elseif J>R then J=R end;return J end;local function S()return Page.fields[g]end;local function T(C)local I=Page.fields[g]local O=I.i or g;local U=I.scale or 1;I.value=P(I.value+C*(I.mult or 1)/U,I.min/U or 0,I.max/U or 255)for O=1,#I.vals do Page.values[I.vals[O]]=bit32.rshift(I.value*U,(O-1)*8)end;if I.upd and Page.values then I.upd(Page)end end;local function V()local W=MenuBox.x;local X=MenuBox.y;local Y=MenuBox.w;local Z=MenuBox.h_line;local _=MenuBox.h_offset;local a0=#v*Z+_*2;lcd.drawFilledRectangle(W,X,Y,a0,backgroundFill)lcd.drawRectangle(W,X,Y-1,a0-1,foregroundColor)lcd.drawText(W+Z/2,X+_,"Menu:",globalTextOptions)for z,a1 in ipairs(v)do local K=globalTextOptions;if n==z then K=K+INVERS end;lcd.drawText(W+MenuBox.x_offset,X+(z-1)*Z+_,a1.t,K)end end;function run_ui(a2)local a3=getTime()if o+50<a3 then s()end;o=a3;if d==b.saving then if h+i<a3 then if j<k then q()else d=b.display;s()end end end;mspProcessTxQ()if a2==a.longPress.menu then n=1;d=b.displayMenu elseif a.press.pageUp and a2==a.longPress.enter then n=1;p=1;d=b.displayMenu elseif d==b.displayMenu then if a2==a.release.exit then d=b.display elseif a2==a.release.plus or a2==a.dial.left then E(-1)elseif a2==a.release.minus or a2==a.dial.right then E(1)elseif a2==a.release.enter then if p==1 then p=0 else d=b.display;v[n].f()end end elseif d<=b.display then if a2==a.press.pageUp then Page=nil;B(-1)elseif a2==a.release.menu or a2==a.press.pageDown then Page=nil;B(1)elseif a2==a.release.plus or a2==a.dial.left then D(-1)elseif a2==a.release.minus or a2==a.dial.right then D(1)elseif a2==a.release.enter then local a4=Page.fields[g]local O=a4.i or g;if Page.values and Page.values[O]and a4.ro~=true then d=b.editing end elseif a2==a.release.exit then return protocol.exitFunc()end elseif d==b.editing then if a2==a.release.exit or a2==a.release.enter then d=b.display elseif a2==a.press.plus or a2==a.repeatPress.plus or a2==a.dial.right then T(1)elseif a2==a.press.minus or a2==a.repeatPress.minus or a2==a.dial.left then T(-1)end end;if Page==nil then Page=assert(loadScript(radio.templateHome..PageFiles[f]))()end;if not Page.values and d==b.display then F()end;lcd.clear()if TEXT_BGCOLOR then lcd.drawFilledRectangle(0,0,LCD_W,LCD_H,TEXT_BGCOLOR)end;H()if protocol.rssi()==0 then lcd.drawText(NoTelem[1],NoTelem[2],NoTelem[3],NoTelem[4])end;if d==b.displayMenu then V()elseif d==b.saving then lcd.drawFilledRectangle(SaveBox.x,SaveBox.y,SaveBox.w,SaveBox.h,backgroundFill)lcd.drawRectangle(SaveBox.x,SaveBox.y,SaveBox.w,SaveBox.h,SOLID)if j<=0 then lcd.drawText(SaveBox.x+SaveBox.x_offset,SaveBox.y+SaveBox.h_offset,"Saving...",DBLSIZE+BLINK+globalTextOptions)else lcd.drawText(SaveBox.x+SaveBox.x_offset,SaveBox.y+SaveBox.h_offset,"Retrying",DBLSIZE+globalTextOptions)end end;w(mspPollReply())return 0 end;return run_ui |