/* * Authors (alphabetical order) * - Andre Bernet * - Andreas Weitl * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * - Cameron Weeks * - Erez Raviv * - Gabriel Birkus * - Jean-Pierre Parisy * - Karl Szmutny * - Michael Blandford * - Michal Hlavinka * - Pat Mackenzie * - Philip Moss * - Rob Thomson * - Romolo Manfredini * - Thomas Husterer * * opentx is based on code named * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, * er9x by Erez Raviv: http://code.google.com/p/er9x/, * and the original (and ongoing) project by * Thomas Husterer, th9x: http://code.google.com/p/th9x/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include "../../opentx.h" void menuGeneralDiagAna(uint8_t event) { #if defined(PCBSKY9X) && !defined(REVA) #define ANAS_ITEMS_COUNT 4 #elif defined(PCBSKY9X) #define ANAS_ITEMS_COUNT 3 #else #define ANAS_ITEMS_COUNT 2 #endif SIMPLE_MENU(STR_MENUANA, menuTabGeneral, e_Ana, ANAS_ITEMS_COUNT); STICK_SCROLL_DISABLE(); for (uint8_t i=0; i 9 coord_t y = MENU_HEADER_HEIGHT + 1 + (i/3)*FH; const uint8_t x_coord[] = {0, 70, 154}; uint8_t x = x_coord[i%3]; lcd_outdezNAtt(x, y, i+1, LEADING0|LEFT, 2); lcd_putc(x+2*FW-2, y, ':'); #else coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; putsStrIdx(x, y, PSTR("A"), i+1); lcd_putc(lcdNextPos, y, ':'); #endif lcd_outhex4(x+3*FW-1, y, anaIn(i)); lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256); } #if !defined(CPUARM) // Display raw BandGap result (debug) lcd_puts(64+5, MENU_HEADER_HEIGHT+1+3*FH, STR_BG); lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0); #endif #if defined(PCBSKY9X) lcd_putsLeft(MENU_HEADER_HEIGHT+1+4*FH, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; batCalV /= 55296; putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_HEADER_HEIGHT+1+4*FH, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBGRUVIN9X) lcd_putsLeft(6*FH-2, STR_BATT_CALIB); // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed static uint16_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; // running average, sourced directly (to avoid unending debate :P) uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap; lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0)); #else lcd_putsLeft(6*FH-2, STR_BATT_CALIB); putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); #endif if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); #if defined(PCBSKY9X) && !defined(REVA) lcd_putsLeft(6*FH+1, STR_CURRENT_CALIB); putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ; if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49); #endif #if defined(PCBSKY9X) lcd_putsLeft(7*FH+1, STR_TEMP_CALIB); putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_TEMPERATURE, (m_posVert==3 ? INVERS : 0)) ; if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100); #endif }