void menuGeneralDiagAna(uint8_t event) { SIMPLE_MENU(STR_MENUANA, menuTabGeneral, e_Ana, 1); STICK_SCROLL_DISABLE(); for (int i=0; i<NUM_STICKS+NUM_POTS; i++) { #if (NUM_STICKS+NUM_POTS) > 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); } lcd_putsLeft(MENU_HEADER_HEIGHT+1+5*FH, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; uint32_t batCalV = (adcBatt + (adcBatt*g_eeGeneral.txVoltageCalibration)/128) * BATT_SCALE; batCalV >>= 11; batCalV += 2; // because of the diode putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_HEADER_HEIGHT+1+5*FH, batCalV, s_editMode > 0 ? BLINK|INVERS : INVERS); if (s_editMode > 0) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127); }
void menuGeneralDiagAna(uint8_t event) { #if defined(TX_CAPACITY_MEASUREMENT) #define ANAS_ITEMS_COUNT 4 #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<NUM_STICKS+NUM_POTS; i++) { #if (NUM_STICKS+NUM_POTS) > 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]; lcdDrawNumberNAtt(x, y, i+1, LEADING0|LEFT, 2); lcdDrawChar(x+2*FW-2, y, ':'); #else coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; lcdDrawStringWithIndex(x, y, PSTR("A"), i+1); lcdDrawChar(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); } // Display raw BandGap result (debug) lcdDrawText(64+5, MENU_HEADER_HEIGHT+1+3*FH, STR_BG); lcdDrawNumberAttUnit(64+5+6*FW-3, 1+4*FH, BandGap, 0); #if defined(PCBGRUVIN9X) lcdDrawTextLeft(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.txVoltageCalibration)/8) / BandGap; lcdDrawNumberNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(menuVerticalPosition==1 ? INVERS : 0)); #else lcdDrawTextLeft(6*FH-2, STR_BATT_CALIB); lcdPutsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (menuVerticalPosition==1 ? INVERS : 0)); #endif if (menuVerticalPosition==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127); #if defined(TX_CAPACITY_MEASUREMENT) lcdDrawTextLeft(6*FH+1, STR_CURRENT_CALIB); lcdPutsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (menuVerticalPosition==2 ? INVERS : 0)) ; if (menuVerticalPosition==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txCurrentCalibration, -49, 49); #endif }
void doMainScreenGraphics() { int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)]; if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK) calibStickVert = -calibStickVert; drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert); calibStickVert = calibratedStick[CONVERT_MODE(2)]; if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK) calibStickVert = -calibStickVert; drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert); drawPotsBars(); }
void displayTrims(uint8_t phase) { for (uint8_t i=0; i<4; i++) { static coord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X}; static uint8_t vert[4] = {0,1,1,0}; coord_t xm, ym; uint8_t stickIndex = CONVERT_MODE(i); xm = x[stickIndex]; uint8_t att = ROUND; int16_t val = getTrimValue(phase, i); #if !defined(CPUM64) || !defined(FRSKY) int16_t dir = val; bool exttrim = false; if (val < TRIM_MIN || val > TRIM_MAX) { exttrim = true; } #endif if (val < -(TRIM_LEN+1)*4) { val = -(TRIM_LEN+1); } else if (val > (TRIM_LEN+1)*4) { val = TRIM_LEN+1; } else { val /= 4; } if (vert[i]) { ym = 31; lcd_vline(xm, ym-TRIM_LEN, TRIM_LEN*2); if (i!=2 || !g_model.thrTrim) { lcd_vline(xm-1, ym-1, 3); lcd_vline(xm+1, ym-1, 3); } ym -= val; #if !defined(CPUM64) || !defined(FRSKY) drawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); if (dir >= 0) { lcd_hline(xm-1, ym-1, 3); } if (dir <= 0) { lcd_hline(xm-1, ym+1, 3); } if (exttrim) { lcd_hline(xm-1, ym, 3); } #endif #if defined(CPUARM) if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) { if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) { lcd_outdezAtt(dir>0 ? 22 : 54, xm-2, -abs(dir/5), TINSIZE|VERTICAL); } } #endif } else { ym = 60; lcd_hline(xm-TRIM_LEN, ym, TRIM_LEN*2); lcd_hline(xm-1, ym-1, 3); lcd_hline(xm-1, ym+1, 3); xm += val; #if !defined(CPUM64) || !defined(FRSKY) drawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); if (dir >= 0) { lcd_vline(xm+1, ym-1, 3); } if (dir <= 0) { lcd_vline(xm-1, ym-1, 3); } if (exttrim) { lcd_vline(xm, ym-1, 3); } #endif #if defined(CPUARM) if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) { if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) { lcd_outdezAtt((stickIndex==0 ? TRIM_LH_X : TRIM_RH_X)+(dir>0 ? -11 : 20), ym-2, -abs(dir/5), TINSIZE); } } #endif } lcd_square(xm-3, ym-3, 7, att); } }
uint8_t getSticksNavigationEvent() { uint8_t evt = 0; if (StickScrollAllowed) { if ( StickScrollTimer ) { static uint8_t repeater; uint8_t direction; uint8_t value; if ( repeater < 128 ) { repeater += 1; } value = calcStickScroll(CONVERT_MODE(THR_STICK)); direction = value & 0x80; value &= 0x7F; if ( value ) { if ( repeater > value ) { repeater = 0; if ( evt == 0 ) { if ( direction ) { evt = KEY_UP; } else { evt = KEY_DOWN; } } } } else { value = calcStickScroll(CONVERT_MODE(AIL_STICK)); direction = value & 0x80; value &= 0x7F; if ( value ) { if ( repeater > value ) { repeater = 0; if ( evt == 0 ) { if ( direction ) { evt = KEY_RIGHT; } else { evt = KEY_LEFT; } } } } } } } else { StickScrollTimer = 0; // Seconds } StickScrollAllowed = 1 ; return evt; }
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, menuTabDiag, e_Ana, ANAS_ITEMS_COUNT); STICK_SCROLL_DISABLE(); for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { uint8_t y = 1+FH+(i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; putsStrIdx(x, y, PSTR("A"), i+1); lcd_putc(x+2*FWNUM, y, ':'); lcd_outhex4(x+3*FW-1, y, anaIn(i)); lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i+1)-1]*25/256); } #if !defined(CPUARM) // Display raw BandGap result (debug) lcd_puts(64+5, 1+4*FH, STR_BG); lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0); #endif #if defined(PCBTARANIS) lcd_putsLeft(6*FH+1, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(8)) / 8; uint32_t batCalV = (adcBatt + (adcBatt*g_eeGeneral.vBatCalib)/128) * BATT_SCALE; batCalV >>= 11; batCalV += 2; // because of the diode putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBSKY9X) lcd_putsLeft(5*FH+1, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; batCalV /= 55296; putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, 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(7)) / 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); putsTelemetryValue(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); putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_DEGREES, (m_posVert==3 ? INVERS : 0)) ; if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100); #endif }