Skip to content

Commit

Permalink
ported Horus script to the new file structure/split
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Feb 8, 2017
1 parent 39c00e4 commit cfbf57a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ tmp_install: $(tmp_dirs)
cp common/*.lua tmp/SCRIPTS/BF

.PHONY: all
all: X7 X9
all: X7 X9 Horus

.PHONY: X7
X7: tmp_install
cp X7.lua tmp/SCRIPTS/TELEMETRY/BF.lua
cd tmp && zip ../BFSetup-X7-$(VERSION).zip SCRIPTS/BF/* SCRIPTS/TELEMETRY/*
cd tmp && zip ../BFSetup-X7-$(VERSION).zip SCRIPTS/BF/ui.lua SCRIPTS/BF/msp_sp.lua SCRIPTS/TELEMETRY/BF.lua

.PHONY: X9
X9: tmp_install
cp X9.lua tmp/SCRIPTS/TELEMETRY/BF.lua
cd tmp && zip ../BFSetup-X9-$(VERSION).zip SCRIPTS/BF/* SCRIPTS/TELEMETRY/*
cd tmp && zip ../BFSetup-X9-$(VERSION).zip SCRIPTS/BF/ui.lua SCRIPTS/BF/msp_sp.lua SCRIPTS/TELEMETRY/BF.lua

.PHONY: Horus
Horus: tmp_install
cp Horus.lua tmp/SCRIPTS/BF.lua
cd tmp && zip ../BFSetup-Horus-$(VERSION).zip SCRIPTS/BF/ui.lua SCRIPTS/BF/msp_sp.lua SCRIPTS/BF.lua
59 changes: 42 additions & 17 deletions common/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ local saveTimeout = 0
local saveRetries = 0
local saveMaxRetries = 0

backgroundFill = backgroundFill or ERASE
foregroundColor = foregroundColor or SOLID
globalTextOptions = globalTextOptions or 0

local function saveSettings(new)
local page = SetupPages[currentPage]
if page.values then
Expand Down Expand Up @@ -153,21 +157,26 @@ local function requestPage(page)
end
end

function drawScreenTitle(screen_title)
lcd.drawFilledRectangle(0, 0, LCD_W, 10, SOLID)
lcd.drawText(1,1,screen_title,INVERS)
end

local function drawScreen(page,page_locked)

local screen_title = page.title

lcd.drawText(1,1,"Betaflight / "..screen_title,INVERS)
drawScreenTitle("Betaflight / "..screen_title)

for i=1,#(page.text) do
local f = page.text[i]
lcd.drawText(f.x, f.y, f.t, text_options)
lcd.drawText(f.x, f.y, f.t, globalTextOptions)
end

for i=1,#(page.fields) do
local f = page.fields[i]

local text_options = 0
local text_options = globalTextOptions
if i == currentLine then
text_options = INVERS
if gState == EDITING then
Expand All @@ -178,7 +187,7 @@ local function drawScreen(page,page_locked)
local spacing = 20

if f.t ~= nil then
lcd.drawText(f.x, f.y, f.t .. ":", 0)
lcd.drawText(f.x, f.y, f.t .. ":", globalTextOptions)

-- draw some value
if f.sp ~= nil then
Expand Down Expand Up @@ -231,16 +240,17 @@ local function drawMenu()
local h_line = MenuBox.h_line
local h_offset = MenuBox.h_offset
local h = #(menuList) * h_line + h_offset*2
lcd.drawFilledRectangle(x,y,w,h,ERASE)
lcd.drawRectangle(x,y,w-1,h-1,SOLID)
lcd.drawText(x+h_line/2,y+h_offset,"Menu:")

lcd.drawFilledRectangle(x,y,w,h,backgroundFill)
lcd.drawRectangle(x,y,w-1,h-1,foregroundColor)
lcd.drawText(x+h_line/2,y+h_offset,"Menu:",globalTextOptions)

for i,e in ipairs(menuList) do
local text_options = globalTextOptions
if menuActive == i then
lcd.drawText(x+MenuBox.x_offset,y+(i-1)*h_line+h_offset,e.t,INVERS)
else
lcd.drawText(x+MenuBox.x_offset,y+(i-1)*h_line+h_offset,e.t)
text_options = text_options + INVERS
end
lcd.drawText(x+MenuBox.x_offset,y+(i-1)*h_line+h_offset,e.t,text_options)
end
end

Expand Down Expand Up @@ -271,9 +281,15 @@ local function run_ui(event)
mspProcessTxQ()

-- navigation
if (event == EVT_MENU_LONG) then
if (event == EVT_MENU_LONG) then -- Taranis QX7 / X9
menuActive = 1
gState = MENU_DISP

elseif EVT_PAGEUP_FIRST and (event == EVT_ENTER_LONG) then -- Horus
menuActive = 1
killEnterBreak = 1
gState = MENU_DISP

-- menu is currently displayed
elseif gState == MENU_DISP then
if event == EVT_EXIT_BREAK then
Expand All @@ -283,12 +299,18 @@ local function run_ui(event)
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
incMenu(1)
elseif event == EVT_ENTER_BREAK then
gState = PAGE_DISPLAY
menuList[menuActive].f()
if killEnterBreak == 1 then
killEnterBreak = 0
else
gState = PAGE_DISPLAY
menuList[menuActive].f()
end
end
-- normal page viewing
elseif gState <= PAGE_DISPLAY then
if event == EVT_MENU_BREAK then
if event == EVT_PAGEUP_FIRST then
incPage(-1)
elseif event == EVT_MENU_BREAK or event == EVT_PAGEDN_FIRST then
incPage(1)
elseif event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
incLine(-1)
Expand Down Expand Up @@ -324,21 +346,24 @@ local function run_ui(event)

-- draw screen
lcd.clear()
if TEXT_BGCOLOR then
lcd.drawFilledRectangle(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR)
end
drawScreen(page,page_locked)

-- do we have valid telemetry data?
if getValue("RSSI") == 0 then
-- No!
lcd.drawText(NoTelem[1],NoTelem[2],NoTelem[3],NoTelem[4])
invalidatePages()
--invalidatePages()
end

if gState == MENU_DISP then
drawMenu()
elseif gState == PAGE_SAVING then
lcd.drawFilledRectangle(SaveBox.x,SaveBox.y,SaveBox.w,SaveBox.h,ERASE)
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)
lcd.drawText(SaveBox.x+SaveBox.x_offset,SaveBox.y+SaveBox.h_offset,"Saving...",DBLSIZE + BLINK + (globalTextOptions))
end

processMspReply(mspPollReply())
Expand Down

1 comment on commit cfbf57a

@AJZOMBIE
Copy link

@AJZOMBIE AJZOMBIE commented on cfbf57a Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to add new band.
i want L band, i new line with this script.
File ui.lua

local freqLookup = {
    { 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, -- Boscam A
    { 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, -- Boscam B
    { 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945 }, -- Boscam E
    { 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880 }, -- FatShark F
    { 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917 }, -- RaceBand
	{ 5362, 5399, 5436, 5473, 5510, 5547, 5584, 5621 }, -- L Band
	{ 5325, 5348, 5366, 5384, 5402, 5420, 5438, 5456 }, -- U Band	
	{ 5474, 5492, 5510, 5528, 5546, 5564, 5582, 5600 }, -- O Band
	{ 5653, 5693, 5733, 5773, 5813, 5853, 5893, 5933 }, -- H Band
}

and File BF.lua

  title = "VTX",
  text = {},
  fields = {
     -- Super Rate
     { t = "Band",    x = 25,  y = 14, sp = 50, i=2, min=1, max=9, table = { "A", "B", "E", "F", "R", "L", "U", "O", "H" } },
     { t = "Channel", x = 25,  y = 24, sp = 50, i=3, min=1, max=8 },
     { t = "Power",   x = 25,  y = 34, sp = 50, i=4, min=1 },
     { t = "Pit",     x = 25,  y = 44, sp = 50, i=5, min=0, max=1, table = { [0]="OFF", "ON" } },
     { t = "Dev",     x = 100, y = 14, sp = 32, i=1, ro=true, table = {[3]="SmartAudio",[4]="Tramp",[255]="None"} },
     { t = "Freq",    x = 100, y = 24, sp = 32, i="f", ro=true },
  },

!!!!! but i can't save with L band ?

help me please.

Please sign in to comment.