1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 22:35:12 +03:00

Use only CUSTOM_COLOR, (#3523)

* Use only CUSTOM_COLOR, seem to have no interaction with the rest of the system, albeit issue reports where neither very precise or reproductible

* Fix Xlarge

* Fix medium and large
This commit is contained in:
3djc 2016-05-22 20:42:06 +02:00 committed by Bertrand Songis
parent 8bcbd0f7f6
commit 4765984900

View file

@ -162,12 +162,12 @@ local function zoneSmall(zone)
local myBatt = {["x"]=0, ["y"]=0, ["w"]=75, ["h"]=28, ["segments_w"]=15, ["color"]=WHITE, ["cath_w"]=6, ["cath_h"]=20} local myBatt = {["x"]=0, ["y"]=0, ["w"]=75, ["h"]=28, ["segments_w"]=15, ["color"]=WHITE, ["cath_w"]=6, ["cath_h"]=20}
local mySensor = getCels(zone.options.Sensor) local mySensor = getCels(zone.options.Sensor)
lcd.setColor(TEXT_COLOR, zone.options.Color) lcd.setColor(CUSTOM_COLOR, zone.options.Color)
if type(mySensor) == "table" then if type(mySensor) == "table" then
local myString = tostring(getCellSum(mySensor)).."V ("..getCellCount(mySensor).."S)" local myString = tostring(getCellSum(mySensor)).."V ("..getCellCount(mySensor).."S)"
local percent = getCellPercent(getCellAvg(mySensor)) local percent = getCellPercent(getCellAvg(mySensor))
lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y + 22, myString, RIGHT + SMLSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y + 22, myString, RIGHT + SMLSIZE + CUSTOM_COLOR)
lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y, percent.."%", RIGHT + MIDSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y, percent.."%", RIGHT + MIDSIZE + CUSTOM_COLOR)
-- fils batt -- fils batt
lcd.setColor(CUSTOM_COLOR, getPercentColor(percent)) lcd.setColor(CUSTOM_COLOR, getPercentColor(percent))
lcd.drawGauge(zone.zone.x+2, zone.zone.y+2, 75, zone.zone.h - 4, percent, 100, CUSTOM_COLOR) lcd.drawGauge(zone.zone.x+2, zone.zone.y+2, 75, zone.zone.h - 4, percent, 100, CUSTOM_COLOR)
@ -179,7 +179,7 @@ local function zoneSmall(zone)
lcd.drawRectangle(zone.zone.x + myBatt.x + i, zone.zone.y + myBatt.y, myBatt.segments_w, myBatt.h, CUSTOM_COLOR, 1) lcd.drawRectangle(zone.zone.x + myBatt.x + i, zone.zone.y + myBatt.y, myBatt.segments_w, myBatt.h, CUSTOM_COLOR, 1)
end end
else else
lcd.drawText(zone.zone.x, zone.zone.y+10, "No Cels sensor data", LEFT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x, zone.zone.y+10, "No Cels sensor data", LEFT + SMLSIZE + INVERS + CUSTOM_COLOR)
end end
return return
end end
@ -189,23 +189,24 @@ local function zoneMedium(zone)
local myBatt = {["x"]=0, ["y"]=0, ["w"]=75, ["h"]=32, ["segments_w"]=15, ["color"]=WHITE, ["cath_w"]=6, ["cath_h"]=20} local myBatt = {["x"]=0, ["y"]=0, ["w"]=75, ["h"]=32, ["segments_w"]=15, ["color"]=WHITE, ["cath_w"]=6, ["cath_h"]=20}
local mySensor = getCels(zone.options.Sensor) local mySensor = getCels(zone.options.Sensor)
lcd.setColor(TEXT_COLOR, zone.options.Color) lcd.setColor(CUSTOM_COLOR, zone.options.Color)
if type(mySensor) == "table" then if type(mySensor) == "table" then
local percent = getCellPercent(getCellAvg(mySensor)) local percent = getCellPercent(getCellAvg(mySensor))
lcd.drawText(zone.zone.x+102, zone.zone.y, percent.."%", LEFT + DBLSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+102, zone.zone.y, percent.."%", LEFT + DBLSIZE + CUSTOM_COLOR)
-- fils batt -- fils batt
lcd.setColor(CUSTOM_COLOR, getPercentColor(percent)) lcd.setColor(CUSTOM_COLOR, getPercentColor(percent))
lcd.drawGauge(zone.zone.x + myBatt.x +myBatt.cath_w, zone.zone.y + myBatt.y, myBatt.w, myBatt.h, percent, 100, CUSTOM_COLOR) lcd.drawGauge(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y, myBatt.w, myBatt.h, percent, 100, CUSTOM_COLOR)
-- draw cells -- draw cells
local pos = {{x=2, y=38}, {x=60, y=38}, {x=118, y=38}, {x=2, y=57}, {x=60, y=57}, {x=118, y=57}} local pos = {{x=2, y=38}, {x=60, y=38}, {x=118, y=38}, {x=2, y=57}, {x=60, y=57}, {x=118, y=57}}
for i=1, getCellCount(mySensor), 1 do for i=1, getCellCount(mySensor), 1 do
lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2)) lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2))
lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR)
lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i])) lcd.setColor(CUSTOM_COLOR, WHITE)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20) lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i]), CUSTOM_COLOR)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20, CUSTOM_COLOR,1)
end end
else else
lcd.drawText(zone.zone.x, zone.zone.y+35, "No Cels sensor data", LEFT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x, zone.zone.y+35, "No Cels sensor data", LEFT + SMLSIZE + INVERS + CUSTOM_COLOR)
end end
-- draws bat -- draws bat
lcd.setColor(CUSTOM_COLOR, WHITE) lcd.setColor(CUSTOM_COLOR, WHITE)
@ -222,13 +223,12 @@ local function zoneLarge(zone)
local myBatt = {["x"]=0, ["y"]=18, ["w"]=76, ["h"]=121, ["segments_h"]=30, ["color"]=WHITE, ["cath_w"]=30, ["cath_h"]=10} local myBatt = {["x"]=0, ["y"]=18, ["w"]=76, ["h"]=121, ["segments_h"]=30, ["color"]=WHITE, ["cath_w"]=30, ["cath_h"]=10}
local mySensor = getCels(zone.options.Sensor) local mySensor = getCels(zone.options.Sensor)
lcd.setColor(TEXT_COLOR, zone.options.Color) lcd.setColor(CUSTOM_COLOR, zone.options.Color)
if type(mySensor) == "table" then if type(mySensor) == "table" then
local percent = getCellPercent(getCellAvg(mySensor)) local percent = getCellPercent(getCellAvg(mySensor))
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y, percent.."%", RIGHT + XXLSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y, percent.."%", RIGHT + XXLSIZE + CUSTOM_COLOR)
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y+44, tostring(getCellSum(mySensor)).."V", RIGHT + MIDSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y+44, tostring(getCellSum(mySensor)).."V", RIGHT + MIDSIZE + CUSTOM_COLOR)
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y+65, getCellCount(mySensor).."S", RIGHT + MIDSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y+65, getCellCount(mySensor).."S", RIGHT + MIDSIZE + CUSTOM_COLOR)
lcd.setColor(CUSTOM_COLOR, getPercentColor(percent))
-- fils batt -- fils batt
lcd.setColor(CUSTOM_COLOR, getPercentColor(percent)) lcd.setColor(CUSTOM_COLOR, getPercentColor(percent))
lcd.drawFilledRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.h + myBatt.cath_h - math.floor(percent/100 * myBatt.h), myBatt.w, math.floor(percent/100 * myBatt.h), CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.h + myBatt.cath_h - math.floor(percent/100 * myBatt.h), myBatt.w, math.floor(percent/100 * myBatt.h), CUSTOM_COLOR)
@ -237,11 +237,12 @@ local function zoneLarge(zone)
for i=1, getCellCount(mySensor), 1 do for i=1, getCellCount(mySensor), 1 do
lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2)) lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2))
lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR)
lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i])) lcd.setColor(CUSTOM_COLOR, WHITE)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20) lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i]), CUSTOM_COLOR)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20, CUSTOM_COLOR, 1)
end end
else else
lcd.drawText(zone.zone.x+5, zone.zone.y, "No Cels sensor data", LEFT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x+5, zone.zone.y, "No Cels sensor data", LEFT + SMLSIZE + INVERS + CUSTOM_COLOR)
end end
-- draws bat -- draws bat
lcd.setColor(CUSTOM_COLOR, WHITE) lcd.setColor(CUSTOM_COLOR, WHITE)
@ -258,35 +259,37 @@ local function zoneXLarge(zone)
local myBatt = {["x"]=10, ["y"]=20, ["w"]=80, ["h"]=121, ["segments_h"]=30, ["color"]=WHITE, ["cath_w"]=30, ["cath_h"]=10} local myBatt = {["x"]=10, ["y"]=20, ["w"]=80, ["h"]=121, ["segments_h"]=30, ["color"]=WHITE, ["cath_w"]=30, ["cath_h"]=10}
local mySensor = getCels(zone.options.Sensor) local mySensor = getCels(zone.options.Sensor)
lcd.setColor(TEXT_COLOR, zone.options.Color) lcd.setColor(CUSTOM_COLOR, zone.options.Color)
if type(mySensor) == "table" then if type(mySensor) == "table" then
local percent = getCellPercent(getCellAvg(mySensor)) local percent = getCellPercent(getCellAvg(mySensor))
-- fils batt -- fils batt
lcd.setColor(CUSTOM_COLOR, getPercentColor(percent)) lcd.setColor(CUSTOM_COLOR, getPercentColor(percent))
lcd.drawFilledRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.h + myBatt.cath_h - math.floor(percent/100 * myBatt.h), myBatt.w, math.floor(percent/100 * myBatt.h), CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.h + myBatt.cath_h - math.floor(percent/100 * myBatt.h), myBatt.w, math.floor(percent/100 * myBatt.h), CUSTOM_COLOR)
local percent = getCellPercent(getCellAvg(mySensor))
-- draw right text section -- draw right text section
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y, percent.."%", RIGHT + XXLSIZE + TEXT_COLOR) lcd.setColor(CUSTOM_COLOR, zone.options.Color)
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y + 67, tostring(getCellSum(mySensor)).."V", RIGHT + MIDSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y, percent.."%", RIGHT + XXLSIZE + CUSTOM_COLOR)
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y + 110, getCellCount(mySensor).."S", RIGHT + MIDSIZE + TEXT_COLOR) lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y + 63, tostring(getCellSum(mySensor)).."V", RIGHT + MIDSIZE + CUSTOM_COLOR)
lcd.drawText(zone.zone.x+zone.zone.w, zone.zone.y + myBatt.y + 105, getCellCount(mySensor).."S", RIGHT + MIDSIZE + CUSTOM_COLOR)
-- draw cells -- draw cells
local pos = {{x=110, y=38}, {x=160, y=38}, {x=210, y=38}, {x=110, y=57}, {x=160, y=57}, {x=210, y=57}} local pos = {{x=111, y=38}, {x=164, y=38}, {x=217, y=38}, {x=111, y=57}, {x=164, y=57}, {x=217, y=57}}
for i=1, getCellCount(mySensor), 1 do for i=1, getCellCount(mySensor), 1 do
lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2)) lcd.setColor(CUSTOM_COLOR, getRangeColor(mySensor[i], getCellMax(mySensor), getCellMax(mySensor) - 0.2))
lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 53, 20, CUSTOM_COLOR)
lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i])) lcd.setColor(CUSTOM_COLOR, WHITE)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20) lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", mySensor[i]), CUSTOM_COLOR)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 54, 20, CUSTOM_COLOR, 1)
end end
-- draw cells for lowest cells -- draw cells for lowest cells
local pos = {{x=110, y=110}, {x=160, y=110}, {x=210, y=110}, {x=110, y=129}, {x=160, y=129}, {x=210, y=129}} local pos = {{x=111, y=110}, {x=164, y=110}, {x=217, y=110}, {x=111, y=129}, {x=164, y=129}, {x=217, y=129}}
for i=1, getCellCount(mySensor), 1 do for i=1, getCellCount(mySensor), 1 do
lcd.setColor(CUSTOM_COLOR, getRangeColor(histCellData[i], mySensor[i], mySensor[i] - 0.3)) lcd.setColor(CUSTOM_COLOR, getRangeColor(histCellData[i], mySensor[i], mySensor[i] - 0.3))
lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 58, 20, CUSTOM_COLOR) lcd.drawFilledRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 53, 20, CUSTOM_COLOR)
lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", histCellData[i])) lcd.setColor(CUSTOM_COLOR, WHITE)
lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 59, 20) lcd.drawRectangle(zone.zone.x + pos[i].x, zone.zone.y + pos[i].y, 54, 20, CUSTOM_COLOR, 1)
lcd.drawText(zone.zone.x + pos[i].x+10, zone.zone.y + pos[i].y, string.format("%.2f", histCellData[i]), CUSTOM_COLOR)
end end
else else
lcd.drawText(zone.zone.x+5, zone.zone.y, "No Cels sensor data", LEFT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x+5, zone.zone.y, "No Cels sensor data", LEFT + SMLSIZE + INVERS + CUSTOM_COLOR)
end end
-- draws bat -- draws bat
lcd.setColor(CUSTOM_COLOR, WHITE) lcd.setColor(CUSTOM_COLOR, WHITE)
@ -296,10 +299,10 @@ local function zoneXLarge(zone)
lcd.drawRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.cath_h + i, myBatt.w, myBatt.segments_h, CUSTOM_COLOR, 1) lcd.drawRectangle(zone.zone.x + myBatt.x, zone.zone.y + myBatt.y + myBatt.cath_h + i, myBatt.w, myBatt.segments_h, CUSTOM_COLOR, 1)
end end
-- draw middle rectangles -- draw middle rectangles
lcd.drawRectangle(zone.zone.x + 110, zone.zone.y + 38, 160, 40, CUSTOM_COLOR, 1) lcd.drawRectangle(zone.zone.x + 110, zone.zone.y + 38, 161, 40, CUSTOM_COLOR, 1)
lcd.drawText(zone.zone.x + 270, zone.zone.y + 21, "Live data", RIGHT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x + 270, zone.zone.y + 21, "Live data", RIGHT + SMLSIZE + INVERS + CUSTOM_COLOR)
lcd.drawRectangle(zone.zone.x + 110, zone.zone.y + 110, 160, 40, CUSTOM_COLOR, 1) lcd.drawRectangle(zone.zone.x + 110, zone.zone.y + 110, 161, 40, CUSTOM_COLOR, 1)
lcd.drawText(zone.zone.x + 270, zone.zone.y + 93, "Lowest data", RIGHT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(zone.zone.x + 270, zone.zone.y + 93, "Lowest data", RIGHT + SMLSIZE + INVERS + CUSTOM_COLOR)
return return
end end
@ -311,7 +314,7 @@ end
function refresh(myZone) function refresh(myZone)
if myZone.options.Sensor == 1 then if myZone.options.Sensor == 1 then
lcd.drawText(myZone.zone.x+2, myZone.zone.y+2, "BattCheck not configured", LEFT + SMLSIZE + INVERS + TEXT_COLOR) lcd.drawText(myZone.zone.x+2, myZone.zone.y+2, "BattCheck not configured", LEFT + SMLSIZE + INVERS + CUSTOM_COLOR)
return return
end end
if myZone.zone.w > 380 and myZone.zone.h > 165 then zoneXLarge(myZone) if myZone.zone.w > 380 and myZone.zone.h > 165 then zoneXLarge(myZone)