├── .gitignore ├── DOCS └── images │ ├── telemetry-page-script-main-overview.PNG │ ├── telemetry-page-script-main.PNG │ ├── telemetry-page-script-percentage-notifications.PNG │ └── telemetry-screens-custom.PNG ├── KISS.lua ├── KISSQ7.lua ├── README.md └── sounds └── batcrit.wav /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !KISSdata.lua 4 | 5 | !*/ 6 | -------------------------------------------------------------------------------- /DOCS/images/telemetry-page-script-main-overview.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DynamikArray/KISS_Battery_Monitor/0784f15817665801077dbc5670d71d723fd6ec97/DOCS/images/telemetry-page-script-main-overview.PNG -------------------------------------------------------------------------------- /DOCS/images/telemetry-page-script-main.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DynamikArray/KISS_Battery_Monitor/0784f15817665801077dbc5670d71d723fd6ec97/DOCS/images/telemetry-page-script-main.PNG -------------------------------------------------------------------------------- /DOCS/images/telemetry-page-script-percentage-notifications.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DynamikArray/KISS_Battery_Monitor/0784f15817665801077dbc5670d71d723fd6ec97/DOCS/images/telemetry-page-script-percentage-notifications.PNG -------------------------------------------------------------------------------- /DOCS/images/telemetry-screens-custom.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DynamikArray/KISS_Battery_Monitor/0784f15817665801077dbc5670d71d723fd6ec97/DOCS/images/telemetry-screens-custom.PNG -------------------------------------------------------------------------------- /KISS.lua: -------------------------------------------------------------------------------- 1 | local versionInfo = "KISS Telemetry Data - v1.3.1" 2 | 3 | local blnMenuMode = 0 4 | 5 | -- mahTarget is used to set our target mah consumption and mahAlertPerc is used for division of alerts 6 | local mahTarget = 900 7 | local mahAlertPerc = 10 8 | 9 | -- OpenTX 2.0 - Percent Unit = 8 // OpenTx 2.1 - Percent Unit = 13 10 | -- see: https://opentx.gitbooks.io/opentx-lua-reference-guide/content/general/playNumber.html 11 | local percentUnit = 13 12 | 13 | local lastMahAlert = 0 14 | 15 | -- Fixes mahAlert not appearing after battery disconnect 16 | local lastKnownMah = 0 17 | 18 | ---------------------------------------------------------------- 19 | -- Custom Functions 20 | ---------------------------------------------------------------- 21 | local function getTelemetryId(name) 22 | field = getFieldInfo(name) 23 | if getFieldInfo(name) then return field.id end 24 | return -1 25 | end 26 | 27 | local data = {} 28 | data.fuelUsed = getTelemetryId("Fuel") 29 | 30 | 31 | ------------------------------------------------------------------------- 32 | -- Utilities 33 | ------------------------------------------------------------------------- 34 | -- Rounding Function 35 | local function round(val, decimal) 36 | local exp = decimal and 10^decimal or 1 37 | return math.ceil(val * exp - 0.5) / exp 38 | end 39 | 40 | --MahAlert and Logging of last Value Played 41 | local function playMahPerc(percVal) 42 | playNumber(percVal,percentUnit) 43 | lastMahAlert = percVal -- Set our lastMahAlert 44 | end 45 | 46 | local function playCritical(percVal) 47 | playFile("batcrit.wav") 48 | lastMahAlert = percVal -- Set our lastMahAlert 49 | end 50 | 51 | 52 | 53 | 54 | 55 | local function playAlerts() 56 | 57 | percVal = 0 58 | curMah = getValue(data.fuelUsed) 59 | 60 | if curMah ~= 0 then 61 | percVal = round(((curMah/mahTarget) * 100),0) 62 | 63 | if percVal ~= lastMahAlert then 64 | -- Alert the user we are in critical alert 65 | if percVal > 100 then 66 | playCritical(percVal) 67 | elseif percVal > 90 and percVal < 100 then 68 | playMahPerc(percVal) 69 | elseif percVal % mahAlertPerc == 0 then 70 | playMahPerc(percVal) 71 | end 72 | end 73 | end 74 | 75 | end 76 | 77 | local function drawAlerts() 78 | 79 | percVal = 0 80 | 81 | -- Added to fix mah reseting to Zero on battery disconnects 82 | tmpMah = getValue(data.fuelUsed) 83 | 84 | if tmpMah ~= 0 then 85 | lastKnownMah = tmpMah 86 | end 87 | 88 | -- The display of MAH data is now pulled from the lastKnownMah var which will only 89 | -- be reset on Telemetry reset now. 90 | 91 | percVal = round(((lastKnownMah/mahTarget) * 100),0) 92 | lcd.drawText(5, 10, "USED: "..lastKnownMah.."mah" , MIDSIZE) 93 | lcd.drawText(90, 30, percVal.." %" , MIDSIZE) 94 | 95 | end 96 | 97 | 98 | local function doMahAlert() 99 | playAlerts() 100 | drawAlerts() 101 | end 102 | 103 | local function draw() 104 | drawAlerts() 105 | end 106 | 107 | 108 | ---------------------------------------------------------------- 109 | -- 110 | ---------------------------------------------------------------- 111 | local function init_func() 112 | doMahAlert() 113 | end 114 | -------------------------------- 115 | 116 | 117 | ---------------------------------------------------------------- 118 | -- Should handle any flow needed when the screen is NOT visible 119 | ---------------------------------------------------------------- 120 | local function bg_func() 121 | playAlerts() 122 | end 123 | -------------------------------- 124 | 125 | 126 | ---------------------------------------------------------------- 127 | -- Should handle any flow needed when the screen is visible 128 | -- All screen updating should be done by as little (one) function 129 | -- outside of this run_func 130 | ---------------------------------------------------------------- 131 | local function run_func(event) 132 | 133 | 134 | 135 | 136 | if blnMenuMode == 1 then 137 | --We are in our menu mode 138 | 139 | if event == 32 then 140 | --Take us out of menu mode 141 | blnMenuMode = 0 142 | end 143 | 144 | -- Respond to user KeyPresses for mahSetup 145 | if event == EVT_PLUS_FIRST then 146 | mahAlertPerc = mahAlertPerc + 1 147 | end 148 | 149 | -- Long Presses 150 | if event == 68 then 151 | mahAlertPerc = mahAlertPerc + 1 152 | end 153 | 154 | if event == EVT_MINUS_FIRST then 155 | mahAlertPerc = mahAlertPerc - 1 156 | end 157 | 158 | -- Long Presses 159 | if event == 69 then 160 | mahAlertPerc = mahAlertPerc - 1 161 | end 162 | 163 | 164 | lcd.clear() 165 | 166 | lcd.drawScreenTitle(versionInfo,2,2) 167 | lcd.drawText(35,10, "Set Percentage Notification") 168 | lcd.drawText(70,20,"Every "..mahAlertPerc.." %",MIDSIZE) 169 | lcd.drawText(66, 35, "Use +/- to change",SMLSIZE) 170 | 171 | lcd.drawText(60, 55, "Press [MENU] to return",SMLSIZE) 172 | 173 | else 174 | 175 | if event == 32 then 176 | --Put us in menu mode 177 | blnMenuMode = 1 178 | end 179 | 180 | -- Respond to user KeyPresses for mahSetup 181 | if event == EVT_PLUS_FIRST then 182 | mahTarget = mahTarget + 1 183 | end 184 | 185 | if event == 68 then 186 | mahTarget = mahTarget + 1 187 | end 188 | 189 | if event == EVT_MINUS_FIRST then 190 | mahTarget = mahTarget - 1 191 | end 192 | 193 | if event == 69 then 194 | mahTarget = mahTarget - 1 195 | end 196 | 197 | 198 | --Update our screen 199 | lcd.clear() 200 | 201 | lcd.drawScreenTitle(versionInfo,1,2) 202 | 203 | lcd.drawGauge(6, 25, 70, 20, percVal, 100) 204 | lcd.drawText(130, 10, "Target mAh : ",MIDSIZE) 205 | lcd.drawText(160, 25, mahTarget,MIDSIZE) 206 | lcd.drawText(130, 40, "Use +/- to change",SMLSIZE) 207 | 208 | lcd.drawText(30, 55, "Press [MENU] for more options",SMLSIZE) 209 | 210 | draw() 211 | doMahAlert() 212 | end 213 | 214 | end 215 | -------------------------------- 216 | 217 | return {run=run_func, background=bg_func, init=init_func } 218 | -------------------------------------------------------------------------------- /KISSQ7.lua: -------------------------------------------------------------------------------- 1 | local versionInfo = "KISS Telemetry - v1.4" 2 | 3 | local blnMenuMode = 0 4 | 5 | local editMahMode = 0 6 | 7 | -- mahTarget is used to set our target mah consumption and mahAlertPerc is used for division of alerts 8 | local mahTarget = 1200 9 | local mahAlertPerc = 90 10 | 11 | -- OpenTX 2.0 - Percent Unit = 8 // OpenTx 2.1 - Percent Unit = 13 12 | -- see: https://opentx.gitbooks.io/opentx-lua-reference-guide/content/general/playNumber.html 13 | local percentUnit = 13 14 | 15 | local lastMahAlert = 0 16 | 17 | -- Fixes mahAlert not appearing after battery disconnect 18 | local lastKnownMah = 0 19 | 20 | local minV = 100.0 21 | 22 | ---------------------------------------------------------------- 23 | -- Custom Functions 24 | ---------------------------------------------------------------- 25 | local function getTelemetryId(name) 26 | field = getFieldInfo(name) 27 | if getFieldInfo(name) then return field.id end 28 | return -1 29 | end 30 | 31 | local data = {} 32 | data.fuelUsed = getTelemetryId("Fuel") 33 | 34 | 35 | ------------------------------------------------------------------------- 36 | -- Utilities 37 | ------------------------------------------------------------------------- 38 | -- Rounding Function 39 | local function round(val, decimal) 40 | local exp = decimal and 10^decimal or 1 41 | return math.ceil(val * exp - 0.5) / exp 42 | end 43 | 44 | --MahAlert and Logging of last Value Played 45 | local function playMahPerc(percVal) 46 | playNumber(percVal,percentUnit) 47 | lastMahAlert = percVal -- Set our lastMahAlert 48 | end 49 | 50 | local function playCritical(percVal) 51 | playFile("batcrit.wav") 52 | lastMahAlert = percVal -- Set our lastMahAlert 53 | end 54 | 55 | 56 | 57 | 58 | 59 | local function playAlerts() 60 | 61 | percVal = 0 62 | curMah = getValue(data.fuelUsed) 63 | 64 | if curMah ~= 0 then 65 | percVal = round(((curMah/mahTarget) * 100),0) 66 | 67 | if percVal ~= lastMahAlert then 68 | -- Alert the user we are in critical alert 69 | if percVal > 100 then 70 | playCritical(percVal) 71 | elseif percVal > 90 and percVal < 100 then 72 | playMahPerc(percVal) 73 | elseif percVal % mahAlertPerc == 0 then 74 | playMahPerc(percVal) 75 | end 76 | end 77 | end 78 | 79 | end 80 | 81 | local function drawAlerts() 82 | 83 | percVal = 0 84 | 85 | -- Added to fix mah reseting to Zero on battery disconnects 86 | tmpMah = getValue(data.fuelUsed) 87 | 88 | if tmpMah ~= 0 then 89 | lastKnownMah = tmpMah 90 | end 91 | 92 | -- The display of MAH data is now pulled from the lastKnownMah var which will only 93 | -- be reset on Telemetry reset now. 94 | 95 | percVal = round(((lastKnownMah/mahTarget) * 100),0) 96 | lcd.drawText(5, 9, "USED: "..lastKnownMah.."mah" , MIDSIZE) 97 | lcd.drawText(90, 23, percVal.." %" , MIDSIZE) 98 | 99 | end 100 | 101 | 102 | local function doMahAlert() 103 | playAlerts() 104 | drawAlerts() 105 | end 106 | 107 | local function draw() 108 | drawAlerts() 109 | end 110 | 111 | 112 | ---------------------------------------------------------------- 113 | -- 114 | ---------------------------------------------------------------- 115 | local function init_func() 116 | doMahAlert() 117 | end 118 | -------------------------------- 119 | 120 | 121 | ---------------------------------------------------------------- 122 | -- Should handle any flow needed when the screen is NOT visible 123 | ---------------------------------------------------------------- 124 | local function bg_func() 125 | playAlerts() 126 | end 127 | -------------------------------- 128 | 129 | function round(num, decimals) 130 | local mult = 10^(decimals or 0) 131 | return math.floor(num * mult + 0.5) / mult 132 | end 133 | 134 | ---------------------------------------------------------------- 135 | -- Should handle any flow needed when the screen is visible 136 | -- All screen updating should be done by as little (one) function 137 | -- outside of this run_func 138 | ---------------------------------------------------------------- 139 | local function run_func(event) 140 | 141 | 142 | 143 | 144 | if blnMenuMode == 1 then 145 | --We are in our menu mode 146 | 147 | if event == 32 then 148 | --Take us out of menu mode 149 | blnMenuMode = 0 150 | end 151 | 152 | -- Respond to user KeyPresses for mahSetup 153 | if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then 154 | mahAlertPerc = mahAlertPerc + 5 155 | end 156 | 157 | -- Long Presses 158 | if event == 68 then 159 | mahAlertPerc = mahAlertPerc + 1 160 | end 161 | 162 | if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then 163 | mahAlertPerc = mahAlertPerc - 5 164 | end 165 | 166 | -- Long Presses 167 | if event == 69 then 168 | mahAlertPerc = mahAlertPerc - 1 169 | end 170 | 171 | 172 | lcd.clear() 173 | 174 | lcd.drawScreenTitle(versionInfo,2,2) 175 | lcd.drawText(20,15, "Set Notification") 176 | lcd.drawText(25,28,"Every "..mahAlertPerc.." %",MIDSIZE) 177 | lcd.drawText(20,45, "Use wheel to change",SMLSIZE) 178 | 179 | lcd.drawText(15, 58, "Press [MENU] to return",SMLSIZE) 180 | 181 | else 182 | 183 | if event == 32 then 184 | --Put us in menu mode 185 | blnMenuMode = 1 186 | editMahMode = 0 187 | end 188 | 189 | if event == EVT_ENTER_BREAK then 190 | if editMahMode == 1 then 191 | editMahMode = 0 192 | else 193 | editMahMode = 1 194 | end 195 | end 196 | 197 | -- Respond to user KeyPresses for mahSetup 198 | if editMahMode == 1 and event == EVT_ROT_RIGHT then 199 | mahTarget = mahTarget + 25 200 | end 201 | 202 | if editMahMode == 1 and event == EVT_ROT_LEFT then 203 | mahTarget = mahTarget - 25 204 | end 205 | 206 | 207 | --Update our screen 208 | lcd.clear() 209 | 210 | lcd.drawScreenTitle(versionInfo,1,2) 211 | 212 | lcd.drawGauge(6, 23, 70, 15, percVal, 100) 213 | lcd.drawText(6, 41, "Target mAh : ",SMLSIZE) 214 | if editMahMode == 0 then 215 | lcd.drawText(65, 41, mahTarget,SMLSIZE) 216 | else 217 | lcd.drawText(65, 41, mahTarget,INVERS) 218 | end 219 | 220 | local vfas = getValue("VFAS") 221 | if vfas < 0 then vfas = 0 end 222 | lcd.drawText(95, 41, round(vfas, 2).."V", SMLSIZE) 223 | 224 | if vfas > 0 and vfas < minV then minV = vfas end 225 | 226 | if(minV < 100) then 227 | lcd.drawText(76, 49, "min:"..round(minV, 2).."V", SMLSIZE) 228 | else 229 | lcd.drawText(76, 49, "min:0V", SMLSIZE) 230 | end 231 | 232 | lcd.drawText(7, 58, "Press [MENU] for more",SMLSIZE) 233 | 234 | draw() 235 | doMahAlert() 236 | end 237 | 238 | end 239 | -------------------------------- 240 | 241 | return {run=run_func, background=bg_func, init=init_func } 242 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Version 1.3.2 2 | 3 | # LATEST UPDATES 4 | 1.3.2 - adds qx7 support 5 | 6 | 7 | # KISS_Battery_Monitor 8 | Open TX Telemetry Script for reading and announcing battery mAh consumption. Uses the mAh consumption as reported from KISS 24a ESC as Telemetry data and accepts a configurable user Target mAH and Percentage Notification. The pilot can target how much mAh they intend to use that flight, adjust this value as needed, and this will be used as the "Battery". The Percentage Notification allow for the pilot to receive verbal indication of the "Battery" at the desired intervals. During the final 10% of the "Battery" an indication is given at every 1%. After 100% usage of the "Battery" each additional % used will trigger a "Battery Critical" alarm. 9 | 10 | # SCREENSHOTS 11 | See the WIKI for more detailed information and screenshots on installation, and usage. https://github.com/DynamikArray/KISS_Battery_Monitor/wiki 12 | 13 | 14 | # REQUIREMENTS 15 | * KISS 24a ESC 16 | * OPEN TX 2.1 Firmware on Taranis 17 | 18 | # INSTALLATION: 19 | Download the latest release from the https://github.com/DynamikArray/KISS_Battery_Monitor/releases and place the file (KISS.lua) or (KISSQ7.lua for Qx7 users) in the following directory on the SD_CARD of your Taranis. 20 | ``` SCRIPTS\TELEMETRY``` (if the TELEMETRY folder does not exist then you may need to create it). 21 | 22 | ADDITIONAL STEPS FOR SOME USERS 23 | * Some users reported not having the battery critcal alarm sound file. Since release https://github.com/DynamikArray/KISS_Battery_Monitor/tree/v1.2.3 this issue has been addressed with the inclusion of the batcrit.wav file. If your not getting the battery critical alarm, place the (batcrit.wav) if the ``` SOUNDS\en ``` of your SD Card. (Or apporiate region ```SOUNDS\fr, SOUNDS\de, SOUNDS\nl, etc..```) 24 | 25 | * If you are having issues after installation with sound playbacks not saying percentage, instead saying "miles per hour", "feet", or something other than "Percentage" then ensure you have the correct Open TX 2.1.X SOUND/SYSTEM files installed. Open TX sound packs are available for download here: http://voices-21.open-tx.org/ 26 | 27 | # SETUP: 28 | Attach this script to one of your TELEMETRY screens inside your radio. 29 | 30 | # USAGE 31 | There are two parameters the Pilot may adjust as needed. 32 | * Target mAh = The amount of mAh the pilot wants to consume. 33 | * Notification Percentage = The Percentages the pilot wants the verbal alerts to trigger. 34 | 35 | On the main screen of the script, you may adjust the target mAh at anytime using by holding down either of the +/- keys to adjust the value. 36 | 37 | Percentages Notification adjust may be accessed by pressing the [MENU] key. On the Percentages Notification Screen you may adjust the Percentage using the +/- keys. Pressing the [MENU] key again will bring you back to the main screen of this script. 38 | 39 | # KNOWN ISSUES 40 | - OpenTx2.2 imposed a 6 Charachter limit on the filename, so the .lua file needs to be renamed - fixed in v.1.3.1 41 | - The Telemetry data is not visible for viewing after RSSI loss (ie pilot lands and disconnects battery from multi rotor) - fixed in v.1.3.0 42 | -------------------------------------------------------------------------------- /sounds/batcrit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DynamikArray/KISS_Battery_Monitor/0784f15817665801077dbc5670d71d723fd6ec97/sounds/batcrit.wav --------------------------------------------------------------------------------