From 6bc2ddc3d456a023fb46de27dc2eb5bb679591b9 Mon Sep 17 00:00:00 2001 From: bsongis Date: Sat, 14 Apr 2012 11:32:40 +0000 Subject: [PATCH] Issue 19 solved Revert the last Haptic changes (was unfinished, no more spare time during the week-end, sorry!) Revert my last modification on main views (offset not displayed in Bar Graphs, I was wrong) PPM Center now configurable for each servo No mean on the Batt voltage when in the calibration menu to have a faster response when calibrating SD card Backup / Restore Models feature started Some french translations fixed --- src/Makefile | 23 ++---- src/audio.cpp | 164 ++++++++++++++++++++++++++------------- src/audio.h | 24 +++++- src/board_ersky9x.cpp | 1 - src/board_ersky9x.h | 38 +++++++++ src/ersky9x/haptic.cpp | 61 --------------- src/ersky9x/haptic.h | 40 ---------- src/ersky9x/sound.cpp | 24 ++++++ src/ersky9x/sound.h | 2 + src/general_menus.cpp | 11 +-- src/haptic.cpp | 171 ----------------------------------------- src/haptic.h | 115 --------------------------- src/main_views.cpp | 4 +- src/menus.cpp | 40 ++++++++++ src/menus.h | 7 ++ src/model_menus.cpp | 90 ++++++++++++++++------ src/myeeprom.h | 1 + src/o9xstrings.cpp | 7 ++ src/o9xstrings.h | 8 ++ src/open9x.cpp | 25 +----- src/open9x.h | 5 -- src/pulses_avr.cpp | 7 +- src/translations/en.h | 4 + src/translations/fr.h | 8 +- src/translations/se.h | 4 + util/compile.py | 2 +- 26 files changed, 357 insertions(+), 529 deletions(-) delete mode 100644 src/ersky9x/haptic.cpp delete mode 100644 src/ersky9x/haptic.h delete mode 100644 src/haptic.cpp delete mode 100644 src/haptic.h diff --git a/src/Makefile b/src/Makefile index 6970be166..c29fad972 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,7 +81,7 @@ WS_HOW_HIGH = YES # SDCARD Logs # Values = YES, NO -LOGS = YES +SDCARD = NO # PXX (FrSky PCM) protocol PXX = NO @@ -102,7 +102,7 @@ TRANSLATIONS = EN # EEPROM_PROGRESS_BAR # Values = YES, NO EEPROM_PROGRESS_BAR = NO - + # Enable extra rotary encoders (V4 board only) # Values = YES, NO MOD_EXTRA_ROTARY_ENCODERS = NO @@ -275,13 +275,11 @@ ifeq ($(PCB), ARM) EXTRAINCDIRS += ersky9x BOARDSRC = board_ersky9x.cpp EXTRABOARDSRC = ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c - # ersky9x/ff.c ersky9x/diskio_sam3s.c ersky9x/Media.c ersky9x/ccsbcs.c ersky9x/MEDSdcard.c + # ersky9x/ff.c ersky9x/diskio_sam3s.c ersky9x/Media.c ersky9x/ccsbcs.c ersky9x/sdcard.c ersky9x/MEDSdcard.c EEPROMSRC = eeprom_arm.cpp PULSESSRC = pulses_arm.cpp CPPSRC += audio.cpp CPPSRC += ersky9x/sound.cpp - CPPSRC += haptic.cpp - CPPSRC += ersky9x/haptic.cpp endif ifeq ($(PCB), V4) @@ -293,20 +291,19 @@ ifeq ($(PCB), V4) EEPROMSRC = eeprom_avr.cpp PULSESSRC = pulses_avr.cpp CPPSRC += audio.cpp - CPPSRC += haptic.cpp CPPSRC += gruvin9x/gtime.cpp CPPSRC += gruvin9x/rtc.cpp CPPSRC += gruvin9x/ff.cpp CPPSRC += gruvin9x/diskio.cpp - + ifeq ($(NAVIGATION), RE1) CPPDEFS += -DNAVIGATION_RE1 endif - ifeq ($(LOGS), YES) + ifeq ($(SDCARD), YES) + CPPDEFS += -DSDCARD CPPSRC += gruvin9x/logs.cpp - CPPDEFS += -DLOGS - MODS:=${MODS}L + MODS:=${MODS}S endif ifeq ($(SOMO), YES) @@ -335,12 +332,6 @@ ifeq ($(PCB), STD) else CPPSRC += beeper.cpp endif - - ifeq ($(HAPTIC), YES) - CPPDEFS += -DHAPTIC - CPPSRC += haptic.cpp - endif - endif ### Global Build-Option Directives ### diff --git a/src/audio.cpp b/src/audio.cpp index c057008be..8bbb27a5a 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -41,6 +41,10 @@ audioQueue::audioQueue() t_queueRidx = 0; t_queueWidx = 0; +#ifdef HAPTIC + hapticTick = 0; + hapticSpinUpTime = 0; +#endif } #if 0 @@ -67,10 +71,26 @@ void audioQueue::heartbeat() toneTimeLeft = 0; //time gets counted down } + +#if defined(HAPTIC) + + if (toneHaptic) { + hapticOn((g_eeGeneral.hapticStrength * 2) * 10); + hapticSpinUpTime = HAPTIC_SPINUP; //min time haptic runs for. Might be worth a config option in system prefs to allow user to set to suit motor? + } + +#endif } else { - +#if defined(HAPTIC) + if(hapticSpinUpTime > 0){ + hapticSpinUpTime--; + } else { + hapticOff(); + } +#endif + if (tonePause) { if (queueTone(0, tonePause * 10, 0)) { tonePause = 0; //time gets counted down @@ -82,6 +102,8 @@ void audioQueue::heartbeat() toneTimeLeft = queueToneLength[t_queueRidx]; toneFreqIncr = queueToneFreqIncr[t_queueRidx]; tonePause = queueTonePause[t_queueRidx]; + toneHaptic = queueToneHaptic[t_queueRidx]; + hapticTick = 0; if (!queueToneRepeat[t_queueRidx]--) { t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH; } @@ -99,10 +121,22 @@ void audioQueue::heartbeat() toneTimeLeft--; //time gets counted down toneFreq += toneFreqIncr; +#if defined(HAPTIC) + if (toneHaptic){ + if (hapticTick-- > 0) { + HAPTIC_ON; // haptic output 'high' + } + else { + HAPTIC_OFF; // haptic output 'low' + hapticTick = g_eeGeneral.hapticStrength; + } + } +#endif } else { SPEAKER_OFF; - + HAPTIC_OFF; + if (tonePause > 0) { tonePause--; } @@ -111,7 +145,9 @@ void audioQueue::heartbeat() toneTimeLeft = queueToneLength[t_queueRidx]; toneFreqIncr = queueToneFreqIncr[t_queueRidx]; tonePause = queueTonePause[t_queueRidx]; - +#if defined(HAPTIC) + toneHaptic = queueToneHaptic[t_queueRidx]; +#endif if (!queueToneRepeat[t_queueRidx]--) { t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH; } @@ -133,30 +169,38 @@ inline uint8_t audioQueue::getToneLength(uint8_t tLen) } bool s_beeper; - +#if defined(HAPTIC) +bool s_haptic; +#endif void audioQueue::playNow(uint8_t tFreq, uint8_t tLen, uint8_t tPause, - uint8_t tRepeat, int8_t tFreqIncr) + uint8_t tRepeat, uint8_t tHaptic, int8_t tFreqIncr) { toneFreq = ((s_beeper && tFreq) ? tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET : 0); // add pitch compensator toneTimeLeft = getToneLength(tLen); tonePause = tPause; +#if defined(HAPTIC) + toneHaptic = s_haptic ? tHaptic : 0; +#endif toneFreqIncr = tFreqIncr; t_queueWidx = t_queueRidx; if (tRepeat) { - playASAP(tFreq, tLen, tPause, tRepeat-1, tFreqIncr); + playASAP(tFreq, tLen, tPause, tRepeat-1, tHaptic, tFreqIncr); } } void audioQueue::playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, - uint8_t tRepeat, int8_t tFreqIncr) + uint8_t tRepeat, uint8_t tHaptic, int8_t tFreqIncr) { uint8_t next_queueWidx = (t_queueWidx + 1) % AUDIO_QUEUE_LENGTH; if (next_queueWidx != t_queueRidx) { queueToneFreq[t_queueWidx] = ((s_beeper && tFreq) ? tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET : 0); // add pitch compensator queueToneLength[t_queueWidx] = getToneLength(tLen); queueTonePause[t_queueWidx] = tPause; +#if defined(HAPTIC) + queueToneHaptic[t_queueWidx] = s_haptic ? tHaptic : 0; +#endif queueToneRepeat[t_queueWidx] = tRepeat; queueToneFreqIncr[t_queueWidx] = tFreqIncr; t_queueWidx = next_queueWidx; @@ -166,6 +210,9 @@ void audioQueue::playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, void audioQueue::event(uint8_t e, uint8_t f) { s_beeper = (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_WARNING1) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)); +#if defined(HAPTIC) + s_haptic = (g_eeGeneral.hapticMode>0 || (g_eeGeneral.hapticMode==0 && e>=AU_WARNING1) || (g_eeGeneral.hapticMode>=-1 && e<=AU_ERROR)); +#endif if (g_eeGeneral.flashBeep && (e <= AU_ERROR || e >= AU_WARNING1)) g_LightOffCounter = FLASH_DURATION; // we got an event do we need to flash the display ? if (e < AU_FRSKY_FIRST || empty()) { switch (e) { @@ -176,25 +223,25 @@ void audioQueue::event(uint8_t e, uint8_t f) // low battery in tx case AU_TX_BATTERY_LOW: if (empty()) { - playASAP(60, 20, 3, 2, 1); - playASAP(80, 20, 3, 2, -1); + playASAP(60, 20, 3, 2, 0, 1); + playASAP(80, 20, 3, 2, 1, -1); } break; // error case AU_ERROR: - playNow(BEEP_DEFAULT_FREQ, 40, 1, 0); + playNow(BEEP_DEFAULT_FREQ, 40, 1, 0, 1); break; // keypad up (seems to be used when going left/right through system menu options. 0-100 scales etc) case AU_KEYPAD_UP: - playNow(BEEP_KEY_UP_FREQ, 10, 1, 0); + playNow(BEEP_KEY_UP_FREQ, 10, 1, 0, 1); break; // keypad down (seems to be used when going left/right through system menu options. 0-100 scales etc) case AU_KEYPAD_DOWN: - playNow(BEEP_KEY_DOWN_FREQ, 10, 1, 0); + playNow(BEEP_KEY_DOWN_FREQ, 10, 1, 0, 1); break; // menu display (also used by a few generic beeps) case AU_MENUS: - playNow(BEEP_DEFAULT_FREQ, 10, 2, 0); + playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 1); break; // trim move case AU_TRIM_MOVE: @@ -202,23 +249,19 @@ void audioQueue::event(uint8_t e, uint8_t f) break; // trim center case AU_TRIM_MIDDLE: - playNow(BEEP_DEFAULT_FREQ, 10, 2, 0); - hapticDefevent(1); + playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 1); break; // warning one case AU_WARNING1: - playNow(BEEP_DEFAULT_FREQ, 10, 1, 0); - hapticDefevent(1); + playNow(BEEP_DEFAULT_FREQ, 10, 1, 0, 1); break; // warning two case AU_WARNING2: - playNow(BEEP_DEFAULT_FREQ, 20, 1, 0); - hapticDefevent(1); + playNow(BEEP_DEFAULT_FREQ, 20, 1, 0, 1); break; // warning three case AU_WARNING3: - playNow(BEEP_DEFAULT_FREQ, 30, 1, 0); - hapticDefevent(1); + playNow(BEEP_DEFAULT_FREQ, 30, 1, 0, 1); break; // startup tune case AU_TADA: @@ -228,63 +271,63 @@ void audioQueue::event(uint8_t e, uint8_t f) break; // pot/stick center case AU_POT_STICK_MIDDLE: - playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 0); + playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 0, 0); break; // mix warning 1 case AU_MIX_WARNING_1: - playNow(BEEP_DEFAULT_FREQ + 50, 6, 0, 0); + playNow(BEEP_DEFAULT_FREQ + 50, 6, 0, 0, 1); break; // mix warning 2 case AU_MIX_WARNING_2: - playNow(BEEP_DEFAULT_FREQ + 52, 6, 0, 0); + playNow(BEEP_DEFAULT_FREQ + 52, 6, 0, 0, 1); break; // mix warning 3 case AU_MIX_WARNING_3: - playNow(BEEP_DEFAULT_FREQ + 54, 6, 0, 0); + playNow(BEEP_DEFAULT_FREQ + 54, 6, 0, 0, 1); break; // time 30 seconds left case AU_TIMER_30: - playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 3); + playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 3, 1); break; // time 20 seconds left case AU_TIMER_20: - playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 2); + playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 2, 1); break; // time 10 seconds left case AU_TIMER_10: - playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 1); + playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 1, 1); break; // time <3 seconds left case AU_TIMER_LT3: - playNow(BEEP_DEFAULT_FREQ, 20, 25, 1); + playNow(BEEP_DEFAULT_FREQ, 20, 25, 1, 1); break; case AU_FRSKY_WARN1: - playASAP(BEEP_DEFAULT_FREQ+20,15,5,2); + playASAP(BEEP_DEFAULT_FREQ+20,15,5,2,1); break; case AU_FRSKY_WARN2: - playASAP(BEEP_DEFAULT_FREQ+30,15,5,2); + playASAP(BEEP_DEFAULT_FREQ+30,15,5,2,1); break; case AU_FRSKY_CHEEP: - playASAP(BEEP_DEFAULT_FREQ+30,10,2,2,2); + playASAP(BEEP_DEFAULT_FREQ+30,10,2,2,1,2); break; case AU_FRSKY_RING: - playASAP(BEEP_DEFAULT_FREQ+25,5,2,10); - playASAP(BEEP_DEFAULT_FREQ+25,5,10,1); - playASAP(BEEP_DEFAULT_FREQ+25,5,2,10); + playASAP(BEEP_DEFAULT_FREQ+25,5,2,10,1); + playASAP(BEEP_DEFAULT_FREQ+25,5,10,1,1); + playASAP(BEEP_DEFAULT_FREQ+25,5,2,10,1); break; case AU_FRSKY_SCIFI: - playASAP(80,10,3,2,-1); - playASAP(60,10,3,2,1); - playASAP(70,10,1,0); + playASAP(80,10,3,2,0,-1); + playASAP(60,10,3,2,0,1); + playASAP(70,10,1,0,2); break; case AU_FRSKY_ROBOT: - playASAP(70,5,1,1); - playASAP(50,15,2,1); - playASAP(80,15,2,1); + playASAP(70,5,1,1,1); + playASAP(50,15,2,1,1); + playASAP(80,15,2,1,1); break; case AU_FRSKY_CHIRP: - playASAP(BEEP_DEFAULT_FREQ+40,5,1,2); - playASAP(BEEP_DEFAULT_FREQ+54,5,1,3); + playASAP(BEEP_DEFAULT_FREQ+40,5,1,2,1); + playASAP(BEEP_DEFAULT_FREQ+54,5,1,3,1); break; case AU_FRSKY_TADA: playASAP(50,5,5); @@ -292,25 +335,40 @@ void audioQueue::event(uint8_t e, uint8_t f) playASAP(110,3,4,2); break; case AU_FRSKY_CRICKET: - playASAP(80,5,10,3); - playASAP(80,5,20,1); - playASAP(80,5,10,3); + playASAP(80,5,10,3,1); + playASAP(80,5,20,1,1); + playASAP(80,5,10,3,1); break; case AU_FRSKY_SIREN: - playASAP(10,20,5,2,1); + playASAP(10,20,5,2,1,1); break; case AU_FRSKY_ALARMC: - playASAP(50,4,10,2); - playASAP(70,8,20,1); - playASAP(50,8,10,2); - playASAP(70,4,20,1); + playASAP(50,4,10,2,1); + playASAP(70,8,20,1,1); + playASAP(50,8,10,2,1); + playASAP(70,4,20,1,1); break; case AU_FRSKY_RATATA: - playASAP(BEEP_DEFAULT_FREQ+50,5,10,10); + playASAP(BEEP_DEFAULT_FREQ+50,5,10,10,1); break; case AU_FRSKY_TICK: - playASAP(BEEP_DEFAULT_FREQ+50,5,50,2); + playASAP(BEEP_DEFAULT_FREQ+50,5,50,2,1); break; +#ifdef HAPTIC + case AU_FRSKY_HAPTIC1: + playASAP(0,30,10,0,1); + playASAP(0,10,50,0,1); + break; + case AU_FRSKY_HAPTIC2: + playASAP(0,30,10,0,1); + playASAP(0,10,10,0,1); + playASAP(0,10,30,0,1); + break; + case AU_FRSKY_HAPTIC3: + playASAP(0,30,10,0,1); + playASAP(0,10,10,2,1); + break; +#endif default: break; } diff --git a/src/audio.h b/src/audio.h index 53cd3b656..1647274e7 100644 --- a/src/audio.h +++ b/src/audio.h @@ -34,6 +34,12 @@ #ifndef audio_h #define audio_h +//#define ISER9X //enable this define for er9x. comment out for open9x + +#if defined(ISER9X) +#define HAPTIC +#define PCBSTD +#endif #if defined(PCBARM) #include "ersky9x/sound.h" @@ -87,6 +93,11 @@ enum AUDIO_SOUNDS { AU_FRSKY_ALARMC, AU_FRSKY_RATATA, AU_FRSKY_TICK, +#ifdef HAPTIC + AU_FRSKY_HAPTIC1, + AU_FRSKY_HAPTIC2, + AU_FRSKY_HAPTIC3, +#endif AU_FRSKY_LAST, }; @@ -98,9 +109,9 @@ class audioQueue // only difference between these two functions is that one does the // interupt queue (Now) and the other queues for playing ASAP. - void playNow(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, int8_t tFreqIncr=0); + void playNow(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, uint8_t tHaptic=0, int8_t tFreqIncr=0); - void playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, int8_t tFreqIncr=0); + void playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, uint8_t tHaptic=0, int8_t tFreqIncr=0); inline bool busy() { return (toneTimeLeft > 0); } @@ -173,7 +184,12 @@ class audioQueue uint8_t queueTonePause[AUDIO_QUEUE_LENGTH]; uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH]; - +#ifdef HAPTIC + uint8_t toneHaptic; + uint8_t hapticTick; + uint8_t queueToneHaptic[AUDIO_QUEUE_LENGTH]; + uint8_t hapticSpinUpTime; +#endif #if defined(PCBSTD) uint8_t toneCounter; @@ -185,6 +201,8 @@ extern audioQueue audio; void audioDefevent(uint8_t e); +#define HAPTIC_SPINUP (10); + #define AUDIO_KEYPAD_UP() audioDefevent(AU_KEYPAD_UP) #define AUDIO_KEYPAD_DOWN() audioDefevent(AU_KEYPAD_DOWN) #define AUDIO_MENUS() audioDefevent(AU_MENUS) diff --git a/src/board_ersky9x.cpp b/src/board_ersky9x.cpp index 486ac345c..17da1ef00 100644 --- a/src/board_ersky9x.cpp +++ b/src/board_ersky9x.cpp @@ -652,7 +652,6 @@ void configure_pins( uint32_t pins, uint16_t config ) } } - void board_init() { // register uint32_t goto_usb ; diff --git a/src/board_ersky9x.h b/src/board_ersky9x.h index 31b43b4bc..a455998ed 100644 --- a/src/board_ersky9x.h +++ b/src/board_ersky9x.h @@ -1,3 +1,39 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - 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. + * + */ + +#ifndef board_ersky9x_h +#define board_ersky9x_h + #ifdef REVA #include "ersky9x/AT91SAM3S2.h" #else @@ -30,3 +66,5 @@ uint16_t getCurrent(); extern uint16_t Temperature ; // Raw temp reading extern uint16_t maxTemperature ; // Raw temp reading + +#endif diff --git a/src/ersky9x/haptic.cpp b/src/ersky9x/haptic.cpp deleted file mode 100644 index a46006ab4..000000000 --- a/src/ersky9x/haptic.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2011 by Michael Blandford. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the author nor the names of its contributors may -* be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -**************************************************************************** -* History: -* -****************************************************************************/ - -#include "../open9x.h" - - -void hapticOff() -{ - PWM->PWM_DIS = PWM_DIS_CHID2 ; // Disable channel 2 - PWM->PWM_OOV &= ~0x00040000 ; // Force low - PWM->PWM_OSS |= 0x00040000 ; // Force low -} - -// pwmPercent 0-100 -void hapticOn( uint32_t pwmPercent ) -{ - register Pwm *pwmptr ; - - pwmptr = PWM ; - - if ( pwmPercent > 100 ) - { - pwmPercent = 100 ; - } - pwmptr->PWM_CH_NUM[2].PWM_CDTYUPD = pwmPercent ; // Duty - pwmptr->PWM_ENA = PWM_ENA_CHID2 ; // Enable channel 2 - pwmptr->PWM_OSC = 0x00040000 ; // Enable output -} - - diff --git a/src/ersky9x/haptic.h b/src/ersky9x/haptic.h deleted file mode 100644 index 51fdd4f14..000000000 --- a/src/ersky9x/haptic.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2011 by Michael Blandford. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the author nor the names of its contributors may -* be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -**************************************************************************** -* History: -* -****************************************************************************/ - -extern void hapticOff(void) ; -extern void hapticOn( uint32_t pwmPercent ) ; - - - - diff --git a/src/ersky9x/sound.cpp b/src/ersky9x/sound.cpp index 8487858b4..f41cd3ccd 100644 --- a/src/ersky9x/sound.cpp +++ b/src/ersky9x/sound.cpp @@ -423,3 +423,27 @@ extern "C" void TWI0_IRQHandler() } } +void hapticOff() +{ + PWM->PWM_DIS = PWM_DIS_CHID2 ; // Disable channel 2 + PWM->PWM_OOV &= ~0x00040000 ; // Force low + PWM->PWM_OSS |= 0x00040000 ; // Force low +} + +// pwmPercent 0-100 +void hapticOn( uint32_t pwmPercent ) +{ + register Pwm *pwmptr ; + + pwmptr = PWM ; + + if ( pwmPercent > 100 ) + { + pwmPercent = 100 ; + } + pwmptr->PWM_CH_NUM[2].PWM_CDTYUPD = pwmPercent ; // Duty + pwmptr->PWM_ENA = PWM_ENA_CHID2 ; // Enable channel 2 + pwmptr->PWM_OSC = 0x00040000 ; // Enable output +} + + diff --git a/src/ersky9x/sound.h b/src/ersky9x/sound.h index ae55b474e..2e0d8d10d 100644 --- a/src/ersky9x/sound.h +++ b/src/ersky9x/sound.h @@ -55,6 +55,8 @@ extern void init_twi( void ) ; extern void set_volume( register uint8_t volume ) ; extern "C" void TWI0_IRQHandler (void) ; extern void audioDefevent( uint8_t e ) ; +extern void hapticOff(void) ; +extern void hapticOn( uint32_t pwmPercent ) ; extern void sound_5ms( void ) ; diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 1fc07a6fc..3d0638c5b 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -84,7 +84,6 @@ enum menuProcSetupItems { #ifdef HAPTIC ITEM_SETUP_HAPTIC_MODE, ITEM_SETUP_HAPTIC_STRENGTH, - ITEM_SETUP_HAPTIC_LENGTH, #endif #ifdef SPLASH ITEM_SETUP_SPLASH, @@ -108,7 +107,7 @@ void menuProcSetup(uint8_t event) #define AUDIO_ZEROS #endif #ifdef HAPTIC -#define HAPTIC_ZEROS 0, 0, 0, +#define HAPTIC_ZEROS 0, 0, #else #define HAPTIC_ZEROS #endif @@ -195,14 +194,6 @@ void menuProcSetup(uint8_t event) } if((y+=FH)>7*FH) return; }subN++; - - if(s_pgOfs7*FH) return; - }subN++; - #endif // TODO port onoffMenuItem here to save flash diff --git a/src/haptic.cpp b/src/haptic.cpp deleted file mode 100644 index 8e96c82c0..000000000 --- a/src/haptic.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Authors (alphabetical order) - * - Bertrand Songis - * - 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" - -hapticQueue::hapticQueue() -{ - buzzTimeLeft = 0; - buzzPause = 0; - - t_queueRidx = 0; - t_queueWidx = 0; - - hapticTick = 0; - - -} - -#if 0 -bool hapticQueue::freeslots(uint8_t slots) -{ - return HAPTIC_QUEUE_LENGTH - ((t_queueWidx + HAPTIC_QUEUE_LENGTH - t_queueRidx) % HAPTIC_QUEUE_LENGTH) >= slots; -} -#endif - -void hapticQueue::heartbeat() -{ -#if defined(SIMU) - return; -#endif - -#if defined(PCBARM) - - - if (buzzTimeLeft > 0) { - buzzTimeLeft--; //time gets counted down - hapticOn((g_eeGeneral.hapticStrength * 2) * 10); - } - else { - hapticOff(); - - if (buzzPause > 0) { - buzzPause--; - } - else if (t_queueRidx != t_queueWidx) { - buzzTimeLeft = queueHapticLength[t_queueRidx]; - buzzPause = queueHapticPause[t_queueRidx]; - if (!queueHapticRepeat[t_queueRidx]--) { - t_queueRidx = (t_queueRidx + 1) % HAPTIC_QUEUE_LENGTH; - } - } - } - - - -#else - - if (buzzTimeLeft > 0) { - - buzzTimeLeft--; //time gets counted down - //if (buzzHaptic){ - if (hapticTick-- > 0) { - HAPTIC_ON; // haptic output 'high' - } - else { - HAPTIC_OFF; // haptic output 'high' - hapticTick = g_eeGeneral.hapticStrength; - } - //} - } - else { - HAPTIC_OFF; // haptic output 'high' - - if (buzzPause > 0) { - buzzPause--; - } - else if (t_queueRidx != t_queueWidx) { - buzzTimeLeft = queueHapticLength[t_queueRidx]; - buzzPause = queueHapticPause[t_queueRidx]; - if (!queueHapticRepeat[t_queueRidx]--) { - t_queueRidx = (t_queueRidx + 1) % HAPTIC_QUEUE_LENGTH; - } - } - } - - -#endif - -} - -inline uint8_t hapticQueue::getHapticLength(uint8_t tLen) -{ - - return ((g_eeGeneral.hapticLength * 2) + tLen) * 2; - -} - -void hapticQueue::playNow(uint8_t tLen, uint8_t tPause, uint8_t tRepeat) -{ - buzzTimeLeft = getHapticLength(tLen); - buzzPause = tPause; - t_queueWidx = t_queueRidx; - - if (tRepeat) { - playASAP(tLen, tPause, tRepeat-1); - } -} - -void hapticQueue::playASAP(uint8_t tLen, uint8_t tPause, uint8_t tRepeat) -{ - uint8_t next_queueWidx = (t_queueWidx + 1) % HAPTIC_QUEUE_LENGTH; - if (next_queueWidx != t_queueRidx) { - queueHapticLength[t_queueWidx] = getHapticLength(tLen); - queueHapticPause[t_queueWidx] = tPause; - queueHapticRepeat[t_queueWidx] = tRepeat-1; - t_queueWidx = next_queueWidx; - } -} - -void hapticQueue::event(uint8_t e) -{ - - switch (e) { - case 1: //one buzz - playASAP(10,2,1); - break; - case 2: // two buzz - playASAP(10,2,2); - break; - case 3: // three buzz - playASAP(10,2,3); - break; - default: - break; - } -} - -void hapticDefevent(uint8_t e) -{ - haptic.event(e); -} diff --git a/src/haptic.h b/src/haptic.h deleted file mode 100644 index e465cd371..000000000 --- a/src/haptic.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Authors (alphabetical order) - * - Bertrand Songis - * - 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. - * - */ - -#ifndef haptic_h -#define haptic_h - - -#if defined(PCBARM) -#include "ersky9x/haptic.h" -#endif - - -//haptic -#define HAPTIC_QUEUE_LENGTH (8) //8 seems to suit most alerts - - - - -class hapticQueue -{ - public: - - hapticQueue(); - - // only difference between these two functions is that one does the - // interupt queue (Now) and the other queues for playing ASAP. - void playNow(uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0); - - void playASAP(uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0); - - inline bool busy() { return (buzzTimeLeft > 0); } - - void event(uint8_t e); - - - - // heartbeat is responsibile for issueing the haptic buzzs and general square waves - // it is essentially the life of the class. - void heartbeat(); - - // bool freeslots(uint8_t slots); - - inline bool empty() { - return (t_queueRidx == t_queueWidx); - } - - protected: - inline uint8_t getHapticLength(uint8_t tLen); - - private: - uint8_t t_queueRidx; - uint8_t t_queueWidx; - - - uint8_t buzzTimeLeft; - uint8_t buzzPause; - - // queue arrays - uint8_t queueHapticLength[HAPTIC_QUEUE_LENGTH]; - uint8_t queueHapticPause[HAPTIC_QUEUE_LENGTH]; - uint8_t queueHapticRepeat[HAPTIC_QUEUE_LENGTH]; - uint8_t buzzHaptic; - uint8_t hapticTick; - - -#if defined(PCBSTD) - uint8_t buzzCounter; -#endif -}; - -//wrapper function - dirty but results in a space saving!!! -extern hapticQueue haptic; - -void hapticDefevent(uint8_t e); - -#define HAPTIC_SPINUP (10); - - - -#define IS_HAPTIC_BUSY() haptic.busy() - - -#define HAPTIC_HEARTBEAT() haptic.heartbeat() - -#endif // haptic_h diff --git a/src/main_views.cpp b/src/main_views.cpp index 6c2a93bfd..2f718252c 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -239,8 +239,8 @@ void menuMainView(uint8_t event) for(uint8_t i=0; i<8; i++) { uint8_t x0,y0; - int16_t val = ex_chans[i]; - //val += g_model.limitData[i].revert ? g_model.limitData[i].offset : -g_model.limitData[i].offset; + int16_t val = g_chans512[i]; + switch(view_base) { case e_outputValues: diff --git a/src/menus.cpp b/src/menus.cpp index 6c3458357..8dc7bc86f 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -527,6 +527,46 @@ void displayConfirmation(uint8_t event) } } +#if defined(SDCARD) +const pm_char * s_menu[MENU_MAX_LINES] = { 0, 0, 0, 0 }; +uint8_t s_menu_item = 0; +uint8_t s_menu_count = 0; +const pm_char * displayMenu(uint8_t event) +{ + const pm_char * result = NULL; + + lcd_filled_rect(10, 16, 108, s_menu_count * (FH+1) + 2, SOLID, WHITE); + lcd_rect(10, 16, 108, s_menu_count * (FH+1) + 2); + + for (uint8_t i=0; i 0) s_menu_item--; + break; + case EVT_KEY_FIRST(KEY_DOWN): + if (s_menu_item < s_menu_count - 1) s_menu_item++; + break; + case EVT_KEY_FIRST(KEY_EXIT): + killEvents(event); + s_menu_item = 0; + s_menu_count = 0; + break; + case EVT_KEY_FIRST(KEY_MENU): + killEvents(event); + result = s_menu[s_menu_item]; + s_menu_count = 0; + s_menu_item = 0; + break; + } + + return result; +} +#endif + #ifdef NAVIGATION_RE1 int8_t *s_inflight_value = NULL; int8_t s_inflight_min; diff --git a/src/menus.h b/src/menus.h index 0b7c6c47a..885835e26 100644 --- a/src/menus.h +++ b/src/menus.h @@ -186,4 +186,11 @@ void displayPopup(const pm_char * pstr); void displayWarning(uint8_t event); void displayConfirmation(uint8_t event); +#if defined(SDCARD) +#define MENU_MAX_LINES 4 +extern const pm_char * s_menu[]; +extern uint8_t s_menu_count; +const pm_char * displayMenu(uint8_t event); +#endif + #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 896b20238..003409a4a 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -131,7 +131,11 @@ void menuProcModelSelect(uint8_t event) s_copyMode = 0; } - uint8_t _event = (s_warning ? 0 : event); +#if defined(SDCARD) + uint8_t _event = (s_warning || s_menu_count) ? 0 : event; +#else + uint8_t _event = s_warning ? 0 : event; +#endif uint8_t _event_ = (IS_RE1_EVT(_event) ? 0 : _event); if (s_copyMode || !eeModelExists(g_eeGeneral.currModel)) { @@ -223,16 +227,27 @@ void menuProcModelSelect(uint8_t event) #ifdef NAVIGATION_RE1 s_editMode = -1; #endif - displayPopup(STR_LOADINGMODEL); - eeCheck(true); // force writing of current model data before this is changed - if (g_eeGeneral.currModel != sub) { - g_eeGeneral.currModel = sub; - STORE_GENERALVARS; - eeLoadModel(sub); - } s_copyMode = 0; killEvents(event); - return; + if (g_eeGeneral.currModel != sub) { +#if defined(SDCARD) + s_menu[s_menu_count++] = STR_LOAD_MODEL; + if (eeModelExists(sub)) { + s_menu[s_menu_count++] = STR_ARCHIVE_MODEL; + s_menu[s_menu_count++] = STR_DELETE_MODEL;; + } + else { + s_menu[s_menu_count++] = STR_RESTORE_MODEL;; + } +#else + displayPopup(STR_LOADINGMODEL); + eeCheck(true); // force writing of current model data before this is changed + eeLoadModel(sub); + g_eeGeneral.currModel = sub; + STORE_GENERALVARS; + return; +#endif + } } else if (eeModelExists(sub)) { s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE); @@ -333,6 +348,32 @@ void menuProcModelSelect(uint8_t event) s_warning_info_len = sizeof(g_model.name); displayConfirmation(event); } + +#if defined(SDCARD) + if (s_menu_count) { + const pm_char * result = displayMenu(event); + if (result) { + if (result == STR_LOAD_MODEL) { + displayPopup(STR_LOADINGMODEL); + eeCheck(true); // force writing of current model data before this is changed + if (g_eeGeneral.currModel != sub) { + g_eeGeneral.currModel = sub; + STORE_GENERALVARS; + eeLoadModel(sub); + } + } + else if (result == STR_ARCHIVE_MODEL) { + // TODO + } + else if (result == STR_RESTORE_MODEL) { + // TODO + } + else if (result == STR_DELETE_MODEL) { + s_warning = STR_DELETEMODEL; + } + } + } +#endif } void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, bool active, uint8_t & cur) @@ -1301,7 +1342,8 @@ inline void displayMixerLine(uint8_t row, uint8_t mix, uint8_t ch, uint8_t idx, cs = (cs =='S' ? '*' : 'D'); lcd_putcAtt(18*FW+7, y, cs, 0); - putsFlightPhase(20*FW+2, y, md->phase, CONDENSED); + if (md->phase) + putsFlightPhase(20*FW+2, y, md->phase, CONDENSED); if (s_copyMode) { if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && mix == (s_copySrcIdx + (s_copyTgtOfs<0))) { @@ -1554,7 +1596,7 @@ void menuProcMixAll(uint8_t event) void menuProcLimits(uint8_t event) { - MENU(STR_MENULIMITS, menuTabModel, e_Limits, 1+NUM_CHNOUT+1, {0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0}); + MENU(STR_MENULIMITS, menuTabModel, e_Limits, 1+NUM_CHNOUT+1, {0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0}); int8_t sub = m_posVert - 1; @@ -1575,17 +1617,11 @@ void menuProcLimits(uint8_t event) } LimitData *ld = limitaddress(k) ; - int16_t v = (ld->revert) ? -ld->offset : ld->offset; - - char swVal = '-'; // '-', '<', '>' - if((g_chans512[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! - if((g_chans512[k] - v) < -50) swVal = (ld->revert ? 126 : 127); - putsChn(0, y, k+1, 0); - lcd_putcAtt(12*FW+5, y, swVal, 0); - int8_t limit = (g_model.extendedLimits ? 125 : 100); - for (uint8_t j=0; j<4; j++) { + putsChn(0, y, k+1, 0); + + for (uint8_t j=0; j<5; j++) { uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t active = (attr && (s_editMode>0 || p1valdiff)) ; switch(j) @@ -1593,7 +1629,7 @@ void menuProcLimits(uint8_t event) case 0: lcd_outdezAtt( 8*FW, y, ld->offset, attr|PREC1); if (active) { - ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL); + ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL|NO_INCDEC_MARKS); } else if (attr && event==EVT_KEY_LONG(KEY_MENU)) { int16_t zero = g_chans512[k]; @@ -1603,23 +1639,29 @@ void menuProcLimits(uint8_t event) } break; case 1: - lcd_outdezAtt(12*FW, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min)); + lcd_outdezAtt(12*FW+1, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min)); if (active) { CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, limit, +100, STR_MINLIMIT); } break; case 2: - lcd_outdezAtt(17*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max)); + lcd_outdezAtt(16*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max)); if (active) { CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -limit, limit, -100, STR_MAXLIMIT); } break; case 3: - lcd_putsiAtt(18*FW, y, STR_MMMINV, ld->revert, attr); + lcd_putcAtt(17*FW-2, y, ld->revert ? 127 : 126, attr); if (active) { CHECK_INCDEC_MODELVAR(event, ld->revert, 0, 1); } break; + case 4: + lcd_outdezAtt(21*FW+2, y, 1500+g_model.servoCenter[k], attr); + if (active) { + CHECK_INCDEC_MODELVAR(event, g_model.servoCenter[k], -125, +125); + } + break; } } } diff --git a/src/myeeprom.h b/src/myeeprom.h index 54a7ea87a..077e05a74 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -497,6 +497,7 @@ PACK(typedef struct t_ModelData { uint8_t modelId; uint8_t frskyLines[4]; uint16_t frskyLinesXtra; + int8_t servoCenter[NUM_CHNOUT]; }) ModelData; extern EEGeneral g_eeGeneral; diff --git a/src/o9xstrings.cpp b/src/o9xstrings.cpp index caed01e4e..9d5104d6d 100644 --- a/src/o9xstrings.cpp +++ b/src/o9xstrings.cpp @@ -300,6 +300,13 @@ const pm_char STR_CURRENT_CALIB[] PROGMEM = TR_CURRENT_CALIB; const pm_char STR_CURRENT[] PROGMEM = TR_CURRENT; #endif +#if defined(SDCARD) +const pm_char STR_LOAD_MODEL[] PROGMEM = TR_LOAD_MODEL; +const pm_char STR_ARCHIVE_MODEL[] PROGMEM = TR_ARCHIVE_MODEL; +const pm_char STR_DELETE_MODEL[] PROGMEM = TR_DELETE_MODEL; +const pm_char STR_RESTORE_MODEL[] PROGMEM = TR_RESTORE_MODEL; +#endif + const pm_uchar font[] PROGMEM = { #include "font.lbm" #ifdef TRANSLATIONS_SE diff --git a/src/o9xstrings.h b/src/o9xstrings.h index 74c687238..4ad9a340a 100644 --- a/src/o9xstrings.h +++ b/src/o9xstrings.h @@ -361,5 +361,13 @@ extern const pm_char STR_CURRENT_CALIB[]; extern const pm_char STR_CURRENT[]; #endif +#if defined(SDCARD) +extern const pm_char STR_LOAD_MODEL[]; +extern const pm_char STR_ARCHIVE_MODEL[]; +extern const pm_char STR_DELETE_MODEL[]; +extern const pm_char STR_RESTORE_MODEL[]; +#endif + extern const pm_uchar font[]; extern const pm_uchar font_dblsize[]; + diff --git a/src/open9x.cpp b/src/open9x.cpp index 57d2f8ff5..b98883aa6 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -64,11 +64,6 @@ uint16_t g_time_per10; audioQueue audio; #endif -#ifdef HAPTIC -//new audio object -hapticQueue haptic; -#endif - uint8_t heartbeat; uint8_t stickMode; @@ -880,8 +875,6 @@ uint8_t checkTrim(uint8_t event) beepTrim = true; } } - - if ((beforeTRIM_MAX) || (before>after && afterswtch) { uint16_t mask = (sd->func >= FUNC_TRAINER ? (1 << (sd->func-FUNC_TRAINER)) : 0); if (getSwitch(sd->swtch, 0)) { - if (sd->func < FUNC_TRAINER && (g_menuStack[0] != menuProcFunctionSwitches || m_posVert != i+1 || m_posHorz > 1)) { + if (sd->func < FUNC_TRAINER && (g_menuStack[g_menuStackPtr] != menuProcFunctionSwitches || m_posVert != (i+1) || m_posHorz > 1)) { safetyCh[sd->func] = (int8_t)sd->param; } @@ -2036,7 +2023,7 @@ void perMain() #else instant_vbat = (instant_vbat*16 + instant_vbat*g_eeGeneral.vBatCalib/8) / BandGap; #endif - if (g_vbat100mV == 0 || g_menuStack[0] != menuMainView) g_vbat100mV = instant_vbat; + if (g_vbat100mV == 0 || g_menuStack[g_menuStackPtr] != menuMainView) g_vbat100mV = instant_vbat; g_vbat100mV = (instant_vbat + g_vbat100mV*7) / 8; static uint8_t s_batCheck; @@ -2050,11 +2037,8 @@ void perMain() #if defined(PCBARM) AUDIO_HEARTBEAT(); // the queue processing - HAPTIC_HEARTBEAT(); #endif - - } int16_t g_ppmIns[8]; uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1 @@ -2112,8 +2096,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer #endif sei(); - - #if defined (PCBSTD) && defined (AUDIO) AUDIO_DRIVER(); @@ -2124,7 +2106,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer #endif AUDIO_HEARTBEAT(); - HAPTIC_HEARTBEAT(); #ifdef DEBUG // Record start time from TCNT1 to record excution time diff --git a/src/open9x.h b/src/open9x.h index 3a09fa73e..9c4a6b33a 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -812,11 +812,6 @@ extern uint16_t jeti_keys; #include "beeper.h" #endif -#if defined(HAPTIC) -#include "haptic.h" -#endif - - #ifdef LOGS #include "logs.h" #endif diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index cdf1c6f45..03a8c3e6a 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -193,9 +193,10 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation #endif +#define PPM_CENTER 1500 + FORCEINLINE void setupPulsesPPM() { -#define PPM_CENTER 1500*2 int16_t PPM_range = g_model.extendedLimits ? 640*2 : 512*2; //range of 0.7..1.7msec //Total frame length = 22.5msec @@ -211,7 +212,7 @@ FORCEINLINE void setupPulsesPPM() uint16_t rest = 22500u*2-q; //Minimum Framelen=22.5 ms rest += (int16_t(g_model.ppmFrameLength))*1000; for (uint8_t i=0; i