From 1144d93c438d7d3a14a41b144540763d42be7037 Mon Sep 17 00:00:00 2001 From: bsongis Date: Sat, 17 Mar 2012 11:39:05 +0000 Subject: [PATCH] Timers in Status Bar of Custom Telemetry View now well displayed --- src/Makefile | 9 ++++---- src/frsky.cpp | 7 +++++-- src/model_menus.cpp | 16 ++++++++------- src/open9x.cpp | 30 +++------------------------ src/stockboard.cpp | 46 +++++++++++++++++++++++++++++++++++++++++ src/v4board.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 41 deletions(-) create mode 100644 src/stockboard.cpp create mode 100644 src/v4board.cpp diff --git a/src/Makefile b/src/Makefile index ade44f2f9..e5554bf41 100644 --- a/src/Makefile +++ b/src/Makefile @@ -53,7 +53,7 @@ TEMPLATES = YES # POT2 (menus scroll), # POT3 (cursor down/up), # POTS (POT1, POT2, POT3), -# RE1 (Rotary encoder 1, on V3/V4 boards) +# RE1 (Rotary encoder 1, on V4 boards) ifeq ($(PCB), V4) NAVIGATION = RE1 else @@ -132,12 +132,11 @@ REV = $(shell echo $$(( $(AREV) + 1 ))) # MCU name ifeq ($(PCB), STD) MCU = atmega64 -endif -ifeq ($(PCB), V3) -MCU = atmega2561 +CPPSRC = stockboard.cpp endif ifeq ($(PCB), V4) MCU = atmega2560 +CPPSRC = v4board.cpp endif # Processor frequency. @@ -153,7 +152,7 @@ TARGET = open9x OBJDIR = obj # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = open9x.cpp pulses.cpp stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp pers.cpp file.cpp lcd.cpp drivers.cpp o9xstrings.cpp +CPPSRC += open9x.cpp pulses.cpp stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp pers.cpp file.cpp lcd.cpp drivers.cpp o9xstrings.cpp ifeq ($(EXT), JETI) CPPSRC += jeti.cpp diff --git a/src/frsky.cpp b/src/frsky.cpp index 15869eacb..2579df4d1 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -69,7 +69,7 @@ struct FrskyAlarm { struct FrskyAlarm frskyAlarms[4]; #if defined(FRSKY_HUB) || defined(WS_HOW_HIGH) -FrskyHubData frskyHubData; // TODO initialization? +FrskyHubData frskyHubData; enum BarThresholdIdx { THLD_ALT, THLD_RPM, @@ -900,7 +900,10 @@ void menuProcFrsky(uint8_t event) } if (field) { if (field >= TELEM_TM1) { - putsTime(j?74:10, 1+FH+2*FH*i, s_timerVal[field-TELEM_TM1], DBLSIZE, DBLSIZE); + uint8_t x, att; + if (i==3) { x = j?80:20; att = 0; } + else { x = j?74:10; att = DBLSIZE; } + putsTime(x, 1+FH+2*FH*i, s_timerVal[field-TELEM_TM1], att, att); } else { int16_t value = getValue(CSW_CHOUT_BASE+NUM_CHNOUT+MAX_TIMERS+field-1); diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 72c09e8ad..f4d6ea121 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -2031,12 +2031,13 @@ void menuProcTelemetry(uint8_t event) subN++; for (uint8_t j=0; j<4; j++) { + uint8_t barSource = g_model.frsky.bars[j].source; if (s_pgOfs0 || p1valdiff)) { switch (m_posHorz) { case 0: - CHECK_INCDEC_MODELVAR(event, g_model.frsky.bars[j].source, 0, TELEM_BAR_MAX); + CHECK_INCDEC_MODELVAR(event, barSource, 0, TELEM_BAR_MAX); if (checkIncDec_Ret) { + g_model.frsky.bars[j].source = barSource; g_model.frsky.bars[j].barMin = 0; - g_model.frsky.bars[j].barMax = 51 - (maxTelemValue(g_model.frsky.bars[j].source) / 5); + g_model.frsky.bars[j].barMax = 51 - (maxTelemValue(barSource) / 5); } break; case 1: CHECK_INCDEC_MODELVAR(event, g_model.frsky.bars[j].barMin, 0, 50-g_model.frsky.bars[j].barMax); break; case 2: - g_model.frsky.bars[j].barMax = 51 - checkIncDec(event, 51 - g_model.frsky.bars[j].barMax, g_model.frsky.bars[j].barMin+1, maxTelemValue(g_model.frsky.bars[j].source) / 5, EE_MODEL); + g_model.frsky.bars[j].barMax = 51 - checkIncDec(event, 51 - g_model.frsky.bars[j].barMax, g_model.frsky.bars[j].barMin+1, maxTelemValue(barSource) / 5, EE_MODEL); break; } } diff --git a/src/open9x.cpp b/src/open9x.cpp index 7a6740df6..a0a0ce5a0 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -645,7 +645,7 @@ void checkTHR() void checkAlarm() // added by Gohst { if (g_eeGeneral.disableAlarmWarning) return; - if (g_eeGeneral.beeperMode == -2/*TODO constant*/) alert(STR_ALARMSDISABLED); + if (g_eeGeneral.beeperMode == e_mode_quiet) alert(STR_ALARMSDISABLED); } void checkSwitches() @@ -2101,29 +2101,7 @@ uint16_t stack_free() int main(void) { - // Set up I/O port data directions and initial states - DDRA = 0xff; PORTA = 0x00; // LCD data - -#if defined (PCBV4) - DDRB = 0b11000111; PORTB = 0b00111111; // 7:SPKR, 6:PPM_OUT, 5:TrainSW, 4:IDL2_SW, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS] - DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1], 0:BackLight - DDRD = 0b11000000; PORTD = 0b11111100; // 7:VIB, 6:LED BL, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL - DDRE = 0b00001010; PORTE = 0b11110101; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX - DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0 - DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw - DDRH = 0b00110000; PORTH = 0b11011111; // 7:0 Spare port [6:SOMO14D-BUSY 5:SOMO14D-DATA 4:SOMO14D-CLK] [2:VIB_OPTION -- setting to input for now] - DDRJ = 0x00; PORTJ = 0xff; // 7-0:Trim switch inputs - DDRK = 0x00; PORTK = 0x00; // anain. No pull-ups! - DDRL = 0x80; PORTL = 0x7f; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs -#else - DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc - DDRC = 0x3e; PORTC = 0xc1; //pullups nc - DDRD = 0x00; PORTD = 0xff; //pullups keys - DDRE = (1< + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x 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 "open9x.h" + +inline void board_init() +{ + // Set up I/O port data directions and initial states + DDRA = 0xff; PORTA = 0x00; // LCD data + DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc + DDRC = 0x3e; PORTC = 0xc1; //pullups nc + DDRD = 0x00; PORTD = 0xff; //pullups keys + DDRE = (1< + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x 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 "open9x.h" + +inline void board_init() +{ + // Set up I/O port data directions and initial states + DDRA = 0xff; PORTA = 0x00; // LCD data + DDRB = 0b11000111; PORTB = 0b00111111; // 7:SPKR, 6:PPM_OUT, 5:TrainSW, 4:IDL2_SW, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS] + DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1], 0:BackLight + DDRD = 0b11000000; PORTD = 0b11111100; // 7:VIB, 6:LED BL, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL + DDRE = 0b00001010; PORTE = 0b11110101; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX + DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0 + DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw + DDRH = 0b00110000; PORTH = 0b11011111; // 7:0 Spare port [6:SOMO14D-BUSY 5:SOMO14D-DATA 4:SOMO14D-CLK] [2:VIB_OPTION -- setting to input for now] + DDRJ = 0x00; PORTJ = 0xff; // 7-0:Trim switch inputs + DDRK = 0x00; PORTK = 0x00; // anain. No pull-ups! + DDRL = 0x80; PORTL = 0x7f; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs +}