Fix timer displays in telem view (#7146)
Fix timer displays in telem view
This commit is contained in:
@@ -875,6 +875,44 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawTimerWithMode(coord_t x, coord_t y, uint8_t index, LcdFlags att)
|
||||||
|
{
|
||||||
|
const TimerData &timer = g_model.timers[index];
|
||||||
|
|
||||||
|
if (timer.mode) {
|
||||||
|
const TimerState &timerState = timersStates[index];
|
||||||
|
const uint8_t negative = (timerState.val < 0 ? BLINK | INVERS : 0);
|
||||||
|
if (timerState.val < 60 * 60) { // display MM:SS
|
||||||
|
div_t qr = div((int) abs(timerState.val), 60);
|
||||||
|
lcdDrawNumber(x - 5, y, qr.rem, att | LEADING0 | negative, 2);
|
||||||
|
lcdDrawText(lcdLastLeftPos, y, ":", att | BLINK | negative);
|
||||||
|
lcdDrawNumber(lcdLastLeftPos, y, qr.quot, att | negative);
|
||||||
|
if (negative)
|
||||||
|
lcdDrawText(lcdLastLeftPos, y, "-", att | negative);
|
||||||
|
}
|
||||||
|
else if (timerState.val < (99 * 60 * 60) + (59 * 60)) { // display HHhMM
|
||||||
|
div_t qr = div((int) (abs(timerState.val) / 60), 60);
|
||||||
|
lcdDrawNumber(x - 5, y, qr.rem, att | LEADING0, 2);
|
||||||
|
lcdDrawText(lcdLastLeftPos, y, "h", att);
|
||||||
|
lcdDrawNumber(lcdLastLeftPos, y, qr.quot, att);
|
||||||
|
if (negative)
|
||||||
|
lcdDrawText(lcdLastLeftPos, y, "-", att);
|
||||||
|
}
|
||||||
|
else { //display HHHH for crazy large persistent timers
|
||||||
|
lcdDrawText(x - 5, y, "h", att);
|
||||||
|
lcdDrawNumber(lcdLastLeftPos, y, timerState.val / 3600, att);
|
||||||
|
}
|
||||||
|
uint8_t xLabel = (negative ? x - 56 : x - 49);
|
||||||
|
uint8_t len = zlen(timer.name, LEN_TIMER_NAME);
|
||||||
|
if (len > 0) {
|
||||||
|
lcdDrawSizedText(xLabel, y + FH, timer.name, len, RIGHT | ZCHAR);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTimerMode(xLabel, y + FH, timer.mode, RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void drawTelemScreenDate(coord_t x, coord_t y, source_t sensor, LcdFlags att)
|
void drawTelemScreenDate(coord_t x, coord_t y, source_t sensor, LcdFlags att)
|
||||||
{
|
{
|
||||||
y+=3;
|
y+=3;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len, L
|
|||||||
void lcdDrawText(coord_t x, coord_t y, const char * s);
|
void lcdDrawText(coord_t x, coord_t y, const char * s);
|
||||||
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len);
|
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len);
|
||||||
void lcdDrawTextAlignedLeft(coord_t y, const char * s);
|
void lcdDrawTextAlignedLeft(coord_t y, const char * s);
|
||||||
|
void drawTimerWithMode(coord_t x, coord_t y, uint8_t index, LcdFlags att);
|
||||||
|
|
||||||
#define lcdDrawTextAlignedCenter(y, s) lcdDrawText((LCD_W-sizeof(s)*FW+FW+1)/2, y, s)
|
#define lcdDrawTextAlignedCenter(y, s) lcdDrawText((LCD_W-sizeof(s)*FW+FW+1)/2, y, s)
|
||||||
|
|
||||||
|
|||||||
@@ -177,45 +177,6 @@ void displayTrims(uint8_t phase)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTimerWithMode(coord_t x, coord_t y, uint8_t index)
|
|
||||||
{
|
|
||||||
const TimerData & timer = g_model.timers[index];
|
|
||||||
|
|
||||||
if (timer.mode) {
|
|
||||||
const TimerState & timerState = timersStates[index];
|
|
||||||
const uint8_t negative = (timerState.val<0 ? BLINK | INVERS : 0);
|
|
||||||
LcdFlags att = RIGHT | DBLSIZE;
|
|
||||||
if (timerState.val < 60 * 60) { // display MM:SS
|
|
||||||
div_t qr = div((int)abs(timerState.val), 60);
|
|
||||||
lcdDrawNumber(x - 5, y, qr.rem, att | LEADING0 | negative, 2);
|
|
||||||
lcdDrawText(lcdLastLeftPos, y, ":", att|BLINK | negative);
|
|
||||||
lcdDrawNumber(lcdLastLeftPos, y, qr.quot, att | negative);
|
|
||||||
if (negative)
|
|
||||||
lcdDrawText(lcdLastLeftPos, y, "-", att | negative);
|
|
||||||
}
|
|
||||||
else if (timerState.val < (99 * 60 * 60) + (59 * 60)) { // display HHhMM
|
|
||||||
div_t qr = div((int)(abs(timerState.val) / 60), 60);
|
|
||||||
lcdDrawNumber(x - 5, y, qr.rem, att | LEADING0, 2);
|
|
||||||
lcdDrawText(lcdLastLeftPos, y, "h", att);
|
|
||||||
lcdDrawNumber(lcdLastLeftPos, y, qr.quot, att);
|
|
||||||
if (negative)
|
|
||||||
lcdDrawText(lcdLastLeftPos, y, "-", att);
|
|
||||||
}
|
|
||||||
else { //display HHHH for crazy large persistent timers
|
|
||||||
lcdDrawText(x - 5, y, "h", att);
|
|
||||||
lcdDrawNumber(lcdLastLeftPos, y, timerState.val / 3600, att);
|
|
||||||
}
|
|
||||||
uint8_t xLabel = (negative ? x-56 : x-49);
|
|
||||||
uint8_t len = zlen(timer.name, LEN_TIMER_NAME);
|
|
||||||
if (len > 0) {
|
|
||||||
lcdDrawSizedText(xLabel, y+FH, timer.name, len, RIGHT | ZCHAR);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
drawTimerMode(xLabel, y+FH, timer.mode, RIGHT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void displayBattVoltage()
|
void displayBattVoltage()
|
||||||
{
|
{
|
||||||
#if defined(BATTGRAPH)
|
#if defined(BATTGRAPH)
|
||||||
@@ -461,7 +422,7 @@ void menuMainView(event_t event)
|
|||||||
displayVoltageOrAlarm();
|
displayVoltageOrAlarm();
|
||||||
|
|
||||||
// Timer 1
|
// Timer 1
|
||||||
drawTimerWithMode(125, 2*FH, 0);
|
drawTimerWithMode(125, 2*FH, 0, RIGHT | DBLSIZE);
|
||||||
|
|
||||||
// Trims sliders
|
// Trims sliders
|
||||||
displayTrims(mode);
|
displayTrims(mode);
|
||||||
@@ -599,7 +560,7 @@ void menuMainView(event_t event)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Timer2
|
// Timer2
|
||||||
drawTimerWithMode(87, 5*FH, 1);
|
drawTimerWithMode(87, 5*FH, 1, RIGHT | DBLSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And ! in case of unexpected shutdown
|
// And ! in case of unexpected shutdown
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ void displayRssiLine()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t barCoord(int16_t value, int16_t min, int16_t max)
|
uint8_t barCoord(int16_t value, int16_t min, int16_t max)
|
||||||
{
|
{
|
||||||
if (value <= min)
|
if (value <= min)
|
||||||
@@ -57,7 +55,6 @@ uint8_t barCoord(int16_t value, int16_t min, int16_t max)
|
|||||||
return ((int32_t)(BAR_WIDTH-1) * (value - min)) / (max - min);
|
return ((int32_t)(BAR_WIDTH-1) * (value - min)) / (max - min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool displayGaugesTelemetryScreen(TelemetryScreenData & screen)
|
bool displayGaugesTelemetryScreen(TelemetryScreenData & screen)
|
||||||
{
|
{
|
||||||
// Custom Screen with gauges
|
// Custom Screen with gauges
|
||||||
@@ -125,9 +122,11 @@ bool displayNumbersTelemetryScreen(TelemetryScreenData & screen)
|
|||||||
if (field) {
|
if (field) {
|
||||||
LcdFlags att = (i==3 ? RIGHT|NO_UNIT : RIGHT|MIDSIZE|NO_UNIT);
|
LcdFlags att = (i==3 ? RIGHT|NO_UNIT : RIGHT|MIDSIZE|NO_UNIT);
|
||||||
coord_t pos[] = {0, 65, 130};
|
coord_t pos[] = {0, 65, 130};
|
||||||
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER && i!=3) {
|
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER && i != 3) {
|
||||||
// there is not enough space on LCD for displaying "Tmr1" or "Tmr2" and still see the - sign, we write "T1" or "T2" instead
|
// there is not enough space on LCD for displaying "Tmr1" or "Tmr2" and still see the - sign, we write "T1" or "T2" instead
|
||||||
drawStringWithIndex(pos[j], 1+FH+2*FH*i, "T", field-MIXSRC_FIRST_TIMER+1, 0);
|
drawStringWithIndex(pos[j], 1+FH+2*FH*i, "T", field-MIXSRC_FIRST_TIMER+1, 0);
|
||||||
|
drawTimerWithMode(pos[j+1] + 2, 1+FH+2*FH*i, field - MIXSRC_FIRST_TIMER, RIGHT | DBLSIZE);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (field >= MIXSRC_FIRST_TELEM && isGPSSensor(1+(field-MIXSRC_FIRST_TELEM)/3) && telemetryItems[(field-MIXSRC_FIRST_TELEM)/3].isAvailable()) {
|
else if (field >= MIXSRC_FIRST_TELEM && isGPSSensor(1+(field-MIXSRC_FIRST_TELEM)/3) && telemetryItems[(field-MIXSRC_FIRST_TELEM)/3].isAvailable()) {
|
||||||
// we don't display GPS name, no space for it
|
// we don't display GPS name, no space for it
|
||||||
@@ -146,7 +145,8 @@ bool displayNumbersTelemetryScreen(TelemetryScreenData & screen)
|
|||||||
att |= INVERS|BLINK;
|
att |= INVERS|BLINK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isSensorUnit(1+(field-MIXSRC_FIRST_TELEM)/3, UNIT_DATETIME) && field >= MIXSRC_FIRST_TELEM) {
|
|
||||||
|
if (isSensorUnit(1+(field-MIXSRC_FIRST_TELEM)/3, UNIT_DATETIME) && field >= MIXSRC_FIRST_TELEM) {
|
||||||
drawTelemScreenDate(pos[j+1]-36, 6+FH+2*FH*i, field, SMLSIZE|NO_UNIT);
|
drawTelemScreenDate(pos[j+1]-36, 6+FH+2*FH*i, field, SMLSIZE|NO_UNIT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user