From f6f43ee4387997f10f3b681602f6db5fe461dcaf Mon Sep 17 00:00:00 2001 From: 3djc Date: Fri, 3 Jun 2016 17:08:22 +0200 Subject: [PATCH] 3djc/tiny batt check (#3565) * Add tiny size for top bar * Fix volatage with %2.2f format * There are case where one is better than two :D --- radio/sdcard/horus/WIDGETS/BattCheck/main.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/radio/sdcard/horus/WIDGETS/BattCheck/main.lua b/radio/sdcard/horus/WIDGETS/BattCheck/main.lua index 793dd096a..915433934 100755 --- a/radio/sdcard/horus/WIDGETS/BattCheck/main.lua +++ b/radio/sdcard/horus/WIDGETS/BattCheck/main.lua @@ -157,6 +157,22 @@ local function getRangeColor(value, gvalue, rvalue) end end +-- This size is for top bar widgets +local function zoneTiny(zone) + local mySensor = getCels(zone.options.Sensor) + if type(mySensor) == "table" then + local myString = string.format("%2.1fV", getCellSum(mySensor)) + local percent = getCellPercent(getCellAvg(mySensor)) + lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y + 2, percent.."%", RIGHT + SMLSIZE + CUSTOM_COLOR) + lcd.drawText(zone.zone.x + zone.zone.w, zone.zone.y + 17, myString, RIGHT + SMLSIZE + CUSTOM_COLOR) + -- draw batt + lcd.drawRectangle(zone.zone.x, zone.zone.y + 6, 16, 25, CUSTOM_COLOR, 2) + lcd.drawFilledRectangle(zone.zone.x + 4, zone.zone.y + 4, 6, 3, CUSTOM_COLOR) + local rect_h = math.floor(25 * percent / 100) + lcd.drawFilledRectangle(zone.zone.x, zone.zone.y + 6 + 25 - rect_h , 16, rect_h, CUSTOM_COLOR) + end +end + --- Size is 160x30 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} @@ -322,6 +338,7 @@ function refresh(myZone) elseif myZone.zone.w > 180 and myZone.zone.h > 145 then zoneLarge(myZone) elseif myZone.zone.w > 170 and myZone.zone.h > 65 then zoneMedium(myZone) elseif myZone.zone.w > 150 and myZone.zone.h > 28 then zoneSmall(myZone) + elseif myZone.zone.w > 65 and myZone.zone.h > 35 then zoneTiny(myZone) end end