diff --git a/src/Makefile b/src/Makefile index acb9e79d8..e83ccdb2c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,6 +55,10 @@ AUTOSWITCH = NO # Values = YES, NO AUDIO = NO +# VOICE Mods +# Values = YES, NO +VOICE = NO + # HAPTIC Mods # Values = YES, NO HAPTIC = NO @@ -113,9 +117,6 @@ DSM2 = NO #IR protocols (SILV / TRAC09 / PICZ / SWIFT) IRPROTOS = NO -# SOMO-14D module (V4 board only) -SOMO = NO - # TRANSLATIONS # Values = cz, de, en, fr, it, se TRANSLATIONS = EN @@ -194,7 +195,6 @@ OBJDUMP = $(TRGT)objdump SIZE = $(TRGT)size NM = $(TRGT)nm -AVRDUDE = avrdude REMOVE = rm -f REMOVEDIR = rm -rf @@ -355,7 +355,7 @@ RUN_FROM_FLASH = 1 ifeq ($(PCB), ARM) # V4 ARM, so ... OPT = 2 - CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 + CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DVOICE -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable BOARDSRC = board_ersky9x.cpp SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c @@ -385,9 +385,9 @@ ifeq ($(PCB), V4) EXTRABOARDSRC += FatFs/ff.c FatFs/option/ccsbcs.c endif - ifeq ($(SOMO), YES) + ifeq ($(VOICE), YES) CPPSRC += gruvin9x/somo14d.cpp - CPPDEFS += -DSOMO + CPPDEFS += -DVOICE endif ifeq ($(EXTRA_ROTARY_ENCODERS), YES) @@ -412,6 +412,11 @@ ifeq ($(PCB), STD) CPPSRC += beeper.cpp endif + ifeq ($(VOICE), YES) + CPPSRC += stock/voice.cpp + CPPDEFS += -DVOICE + endif + ifeq ($(HAPTIC), YES) CPPDEFS += -DHAPTIC CPPSRC += haptic.cpp @@ -569,7 +574,7 @@ stamp_header: @echo "#define VERS_STR \"$(MAJ_VER).$(MIN_VER)-$(MODS)\"" >> stamp-open9x.h @echo "#define SVN_STR \"open9x-r$(SVNREV)\"" >> stamp-open9x.h @cat stamp-open9x.h - + stock-stamp: @echo "#define DATE_STR \"`date +%Y-%m-%d`\"" > stamp-open9x-stock.txt @echo "#define TIME_STR \"`date +%H:%M:%S`\"" >> stamp-open9x-stock.txt @@ -583,7 +588,7 @@ v4-stamp: @echo "#define VERS_STR \"$(MAJ_VER).$(MIN_VER)\"" >> stamp-open9x-v4.txt @echo "#define SVN_VERS \"open9x-r$(SVNREV)\"" >> stamp-open9x-v4.txt @cat stamp-open9x-v4.txt - + arm-stamp: @echo "#define DATE_STR \"`date +%Y-%m-%d`\"" > stamp-open9x-arm.txt @echo "#define TIME_STR \"`date +%H:%M:%S`\"" >> stamp-open9x-arm.txt @@ -711,10 +716,10 @@ endif allsrc.cpp: Makefile $(BOARDSRC) $(CPPSRC) $(EXTRABOARDSRC) @rm -f allsrc.cpp for f in $(BOARDSRC) $(CPPSRC) $(EXTRABOARDSRC) ; do echo "# 1 \"$$f\"" >> allsrc.cpp; cat "$$f" >> allsrc.cpp; done - + remallsrc: $(REMOVE) allsrc.cpp - + # Link: create ELF output file from object files. ifeq ($(PCB), ARM) %.o: %.c @@ -731,7 +736,7 @@ else @echo $(MSG_COMPILING) $@ $(CC) $(AVRCPPFLAGS) $< --output $@ $(LDFLAGS) endif - + # Target: clean project. clean: begin clean_list end @@ -808,4 +813,3 @@ gtest_main.a : gtest-all.o gtest_main.o gtests: $(CPPSRC) gtests.cpp simpgmspace.cpp *.h gtest_main.a g++ $(CPPSRC) gtests.cpp simpgmspace.cpp $(CPPFLAGS) -I$(GTEST_DIR) $(ARCH) -o gtests -lpthread -MD -DSIMU gtest_main.a - diff --git a/src/beeper.h b/src/beeper.h index 4cf6e3517..96adb9628 100644 --- a/src/beeper.h +++ b/src/beeper.h @@ -57,6 +57,7 @@ inline void _beep(uint8_t b) { extern void beep(uint8_t val); +#define AUDIO_TADA() #define AUDIO_KEYPAD_UP() beep(0) #define AUDIO_KEYPAD_DOWN() beep(0) #define AUDIO_MENUS() beep(0) @@ -68,7 +69,7 @@ extern void beep(uint8_t val); #define AUDIO_TIMER_30() { beepAgain=2; beep(2); } #define AUDIO_TIMER_20() { beepAgain=1; beep(2); } #define AUDIO_TIMER_10() beep(2) -#define AUDIO_TIMER_LT3() beep(2) +#define AUDIO_TIMER_LT3(x) beep(2) #define AUDIO_MINUTE_BEEP() beep(2) #define AUDIO_INACTIVITY() beep(3) #define AUDIO_MIX_WARNING_1() beep(1) diff --git a/src/ersky9x/audio.h b/src/ersky9x/audio.h index fd4ed89d0..385b050f8 100644 --- a/src/ersky9x/audio.h +++ b/src/ersky9x/audio.h @@ -107,6 +107,7 @@ extern "C" void retrieveAvailableAudioFiles(); void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ); +#define AUDIO_TADA() audioEvent(AU_TADA) #define AUDIO_KEYPAD_UP() audioEvent(AU_KEYPAD_UP) #define AUDIO_KEYPAD_DOWN() audioEvent(AU_KEYPAD_DOWN) #define AUDIO_MENUS() audioEvent(AU_MENUS) @@ -118,7 +119,7 @@ void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ); #define AUDIO_TIMER_30() audioEvent(AU_TIMER_30) #define AUDIO_TIMER_20() audioEvent(AU_TIMER_20) #define AUDIO_TIMER_10() audioEvent(AU_TIMER_10) -#define AUDIO_TIMER_LT3() audioEvent(AU_TIMER_LT3) +#define AUDIO_TIMER_LT3(x) audioEvent(AU_TIMER_LT3) #define AUDIO_MINUTE_BEEP() audioEvent(AU_WARNING1) #define AUDIO_INACTIVITY() audioEvent(AU_INACTIVITY) #define AUDIO_MIX_WARNING_1() audioEvent(AU_MIX_WARNING_1) diff --git a/src/gruvin9x/somo14d.h b/src/gruvin9x/somo14d.h index 587b30e64..1e3e7b368 100644 --- a/src/gruvin9x/somo14d.h +++ b/src/gruvin9x/somo14d.h @@ -31,7 +31,8 @@ * */ -#define PROMPT_CUSTOM_BASE 100 +#define PROMPT_SYSTEM_BASE 300 +#define PROMPT_CUSTOM_BASE 400 extern void pushPrompt(uint16_t prompt); extern bool isPlaying(); diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 5db974b01..b104234d1 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -1587,8 +1587,14 @@ void menuProcExpoOne(uint8_t event) if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, ed->expo, -100, 100, 0, STR_DREXPO); break; case EXPO_FIELD_CURVE: +#if defined(XCURVES) + putsCurve(6*FW+5, y, ed->curve, attr); + if (attr) CHECK_INCDEC_MODELVAR(event, ed->curve, 0, MAX_CURVES+7-1); +#else putsCurve(6*FW+5, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0), attr); if (attr) CHECK_INCDEC_MODELVAR(event, ed->curve, 0, 15); +#endif + if (attr && ed->curve>=CURVE_BASE && event==EVT_KEY_FIRST(KEY_MENU)) { s_curveChan = ed->curve - (ed->curve >= CURVE_BASE+4 ? CURVE_BASE-4 : CURVE_BASE); pushMenu(menuProcCurveOne); @@ -1985,7 +1991,11 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_) #endif putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch, 0); // normal switches if (ed->mode!=3) lcd_putc(17*FW, y, ed->mode == 2 ? 126 : 127);//'|' : (stkVal[i] ? '<' : '>'),0);*/ +#if defined(XCURVES) + if (ed->curve) putsCurve(18*FW+2, y, ed->curve); +#else if (ed->curve) putsCurve(18*FW+2, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0)); +#endif } } else { @@ -2694,7 +2704,7 @@ void menuProcFunctionSwitches(uint8_t event) putsChnRaw(17*FW, y, val_displayed+1, attr); } #endif -#if defined(SOMO) +#if defined(VOICE) else if (sd->func == FUNC_PLAY_TRACK) { lcd_outdezAtt(21*FW, y, val_displayed, attr); } diff --git a/src/myeeprom.h b/src/myeeprom.h index dacb246de..c4fcb259b 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -330,9 +330,9 @@ enum Functions { FUNC_HAPTIC, FUNC_RESET, FUNC_VARIO, -#if !defined(PCBSTD) FUNC_PLAY_TRACK, FUNC_PLAY_VALUE, +#if !defined(PCBSTD) FUNC_LOGS, #endif #if defined(PCBARM) diff --git a/src/open9x.cpp b/src/open9x.cpp index 59ba689d2..f6d25394f 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -484,7 +484,11 @@ void applyExpos(int16_t *anas) int16_t k = ed.expo; v = expo(v, k); uint8_t ed_curve = ed.curve; +#if defined(XCURVES) + if (ed_curve) v = applyCurve(v, ed_curve); +#else if (ed_curve) v = applyCurve(v, ed_curve > 10 ? ed_curve + 4 : ed_curve); +#endif v = ((int32_t)v * ed.weight) / 100; anas[cur_chn] = v; } @@ -977,6 +981,10 @@ void checkBacklight() BACKLIGHT_ON; else BACKLIGHT_OFF; + +#if defined(PCBSTD) && defined(VOICE) + Voice.voice_process(); +#endif } void backlightOn() @@ -999,6 +1007,8 @@ void doSplash() lcd_img(0, 0, splash_lbm, 0, 0); refreshDisplay(); + AUDIO_TADA(); + #if defined(PCBSTD) lcdSetRefVolt(g_eeGeneral.contrast); #else @@ -1676,7 +1686,7 @@ void testFunc() uint16_t activeFunctions = 0; MASK_FSW_TYPE activeFunctionSwitches = 0; -#if defined(PCBARM) || defined(SOMO) +#if defined(VOICE) void playValue(uint8_t idx) { int16_t val = getValue(idx); @@ -1888,7 +1898,7 @@ void evalFunctions() else if (sd->func == FUNC_VOLUME) { requiredSpeakerVolume = ((1024 + getValue(FSW_PARAM(sd))) * NUM_VOL_LEVELS) / 2048; } -#elif defined(SOMO) +#elif defined(VOICE) else if (sd->func == FUNC_PLAY_TRACK || sd->func == FUNC_PLAY_VALUE) { if (!isPlaying()) { static uint16_t s_last_play = 0; @@ -2452,7 +2462,7 @@ inline void doMixerCalculations(uint16_t tmr10ms, uint8_t tick10ms) if(s_timerVal[0]==30) AUDIO_TIMER_30(); //beep three times if(s_timerVal[0]==20) AUDIO_TIMER_20(); //beep two times if(s_timerVal[0]==10) AUDIO_TIMER_10(); - if(s_timerVal[0]<= 3) AUDIO_TIMER_LT3(); + if(s_timerVal[0]<= 3) AUDIO_TIMER_LT3(s_timerVal[0]); } if (g_eeGeneral.minuteBeep && (((g_model.timers[0].val ? g_model.timers[0].val-s_timerVal[0] : s_timerVal[0])%60)==0)) { // short beep every minute diff --git a/src/open9x.h b/src/open9x.h index add6497a1..007a47594 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -232,7 +232,7 @@ extern void board_init(); # define INP_B_Trainer 5 # define INP_B_ID2 4 -#ifdef SOMO +#if defined(VOICE) # define OUT_H_14DCLK 4 # define OUT_H_14DDATA 5 # define OUT_H_14DBUSY 6 @@ -526,7 +526,7 @@ void readKeysAndTrims(); uint16_t evalChkSum(); -#if defined(PCBARM) || defined(SOMO) +#if defined(VOICE) #define MESSAGE_SOUND_ARG , uint8_t sound #define MESSAGE(title, msg, info, sound) message(title, msg, info, sound) #define ALERT(title, msg, sound) alert(title, msg, sound) @@ -646,8 +646,8 @@ extern uint8_t s_eeDirtyMsk; extern void backlightOn(); #if defined (PCBARM) -#define BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright) -#define BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100) +#define __BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright) +#define __BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100) #ifdef REVB #define NUMBER_ANALOG 9 #else @@ -658,14 +658,22 @@ void read_9_adc(void ) ; #elif defined (PCBV4) #define SPEAKER_ON TCCR0A |= (1 << COM0A0) #define SPEAKER_OFF TCCR0A &= ~(1 << COM0A0) -#define BACKLIGHT_ON PORTC |= (1 << OUT_C_LIGHT) -#define BACKLIGHT_OFF PORTC &= ~(1 << OUT_C_LIGHT) +#define __BACKLIGHT_ON PORTC |= (1 << OUT_C_LIGHT) +#define __BACKLIGHT_OFF PORTC &= ~(1 << OUT_C_LIGHT) #elif defined(SP22) -#define BACKLIGHT_ON PORTB &= ~(1 << OUT_B_LIGHT) -#define BACKLIGHT_OFF PORTB |= (1 << OUT_B_LIGHT) +#define __BACKLIGHT_ON PORTB &= ~(1 << OUT_B_LIGHT) +#define __BACKLIGHT_OFF PORTB |= (1 << OUT_B_LIGHT) #else -#define BACKLIGHT_ON PORTB |= (1 << OUT_B_LIGHT) -#define BACKLIGHT_OFF PORTB &= ~(1 << OUT_B_LIGHT) +#define __BACKLIGHT_ON PORTB |= (1 << OUT_B_LIGHT) +#define __BACKLIGHT_OFF PORTB &= ~(1 << OUT_B_LIGHT) +#endif + +#if defined(PCBSTD) && defined(VOICE) +#define BACKLIGHT_ON (Voice.Backlight = 1) +#define BACKLIGHT_OFF (Voice.Backlight = 0) +#else +#define BACKLIGHT_ON __BACKLIGHT_ON +#define BACKLIGHT_OFF __BACKLIGHT_OFF #endif #define BUZZER_ON PORTE |= (1 << OUT_E_BUZZER) @@ -913,7 +921,7 @@ extern uint16_t jeti_keys; enum AUDIO_SOUNDS { AU_INACTIVITY, AU_TX_BATTERY_LOW, -#if defined(PCBARM) || defined(SOMO) +#if defined(VOICE) AU_THROTTLE_ALERT, AU_SWITCH_ALERT, AU_BAD_EEPROM, @@ -956,6 +964,7 @@ enum AUDIO_SOUNDS { AU_FRSKY_TICK, AU_FRSKY_LAST, }; + #if defined(AUDIO) #if defined(PCBARM) #include "ersky9x/audio.h" @@ -966,6 +975,14 @@ enum AUDIO_SOUNDS { #include "beeper.h" #endif +#if defined(PCBSTD) && defined(VOICE) +#include "stock/voice.h" +#endif + +#if defined(PCBV4) && defined(VOICE) +#include "gruvin9x/somo14d.h" +#endif + #if defined(HAPTIC) #include "haptic.h" #endif @@ -974,10 +991,6 @@ enum AUDIO_SOUNDS { #include "sdcard.h" #endif -#if defined(SOMO) -#include "gruvin9x/somo14d.h" -#endif - #if defined(PCBV4) #include "gruvin9x/rtc.h" extern uint8_t g_ms100; // global to allow time set function to reset to zero diff --git a/src/stock/audio.h b/src/stock/audio.h index 8c02266f3..d07d240de 100644 --- a/src/stock/audio.h +++ b/src/stock/audio.h @@ -116,19 +116,28 @@ void audioDefevent(uint8_t e); #define AUDIO_MENUS() audioDefevent(AU_MENUS) #define AUDIO_WARNING1() audioDefevent(AU_WARNING1) #define AUDIO_WARNING2() audioDefevent(AU_WARNING2) -#define AUDIO_TX_BATTERY_LOW() audioDefevent(AU_TX_BATTERY_LOW) #define AUDIO_ERROR() audioDefevent(AU_ERROR) -#if defined(SOMO) -#define AUDIO_ERROR_MESSAGE(e) audioDefevent(e) +#if defined(VOICE) +#define AUDIO_TADA() pushPrompt(PROMPT_SYSTEM_BASE+AU_TADA) +#define AUDIO_TX_BATTERY_LOW() pushPrompt(PROMPT_SYSTEM_BASE+AU_TX_BATTERY_LOW) +#define AUDIO_INACTIVITY() pushPrompt(PROMPT_SYSTEM_BASE+AU_INACTIVITY) +#define AUDIO_ERROR_MESSAGE(e) pushPrompt(PROMPT_SYSTEM_BASE+e) +#define AUDIO_TIMER_30() pushPrompt(PROMPT_SYSTEM_BASE+AU_TIMER_30) +#define AUDIO_TIMER_20() pushPrompt(PROMPT_SYSTEM_BASE+AU_TIMER_20) +#define AUDIO_TIMER_10() pushPrompt(PROMPT_SYSTEM_BASE+AU_TIMER_10) +#define AUDIO_TIMER_LT3(x) pushPrompt(PROMPT_SYSTEM_BASE+AU_TIMER_LT3) #else +#define AUDIO_TADA() audioDefevent(AU_TADA) +#define AUDIO_TX_BATTERY_LOW() audioDefevent(AU_TX_BATTERY_LOW) +#define AUDIO_INACTIVITY() audioDefevent(AU_INACTIVITY) #define AUDIO_ERROR_MESSAGE(e) audioDefevent(AU_ERROR) -#endif #define AUDIO_TIMER_30() audioDefevent(AU_TIMER_30) #define AUDIO_TIMER_20() audioDefevent(AU_TIMER_20) #define AUDIO_TIMER_10() audioDefevent(AU_TIMER_10) -#define AUDIO_TIMER_LT3() audioDefevent(AU_TIMER_LT3) +#define AUDIO_TIMER_LT3(x) audioDefevent(AU_TIMER_LT3) +#endif + #define AUDIO_MINUTE_BEEP() audioDefevent(AU_WARNING1) -#define AUDIO_INACTIVITY() audioDefevent(AU_INACTIVITY) #define AUDIO_MIX_WARNING_1() audioDefevent(AU_MIX_WARNING_1) #define AUDIO_MIX_WARNING_2() audioDefevent(AU_MIX_WARNING_2) #define AUDIO_MIX_WARNING_3() audioDefevent(AU_MIX_WARNING_3) diff --git a/src/stock/voice.cpp b/src/stock/voice.cpp new file mode 100644 index 000000000..e34a6db1d --- /dev/null +++ b/src/stock/voice.cpp @@ -0,0 +1,149 @@ +/* + * 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" + +struct t_voice Voice ; +static uint8_t v_ctr ; +uint8_t v_first[8] ; + +void putVoiceQueueUpper( uint8_t value ) +{ + struct t_voice *vptr; + vptr = voiceaddress(); + + if (vptr->VoiceQueueCount < VOICE_Q_LENGTH - 1) { + pushPrompt(0xFF); + pushPrompt(value); + } +} + +void pushPrompt( uint8_t value ) +{ + struct t_voice *vptr; + vptr = voiceaddress(); + + if (vptr->VoiceQueueCount < VOICE_Q_LENGTH) { + vptr->VoiceQueue[vptr->VoiceQueueInIndex++] = value; + vptr->VoiceQueueInIndex &= (VOICE_Q_LENGTH - 1); + vptr->VoiceQueueCount += 1; + } + if (v_ctr < 8) { + v_first[v_ctr] = value; + v_ctr += 1; + } +} + +struct t_voice *voiceaddress() +{ + return &Voice ; +} + +void t_voice::voice_process(void) +{ + if (Backlight) + VoiceLatch |= BACKLIGHT_BIT; + else + VoiceLatch &= ~BACKLIGHT_BIT; + + if (VoiceState == V_IDLE) { + PORTB |= (1 << OUT_B_LIGHT); // Latch clock high + if (VoiceQueueCount) { + VoiceLatch &= ~VOICE_CLOCK_BIT; + PORTA_LCD_DAT = VoiceLatch; // Latch data set + PORTB &= ~(1 << OUT_B_LIGHT); // Latch clock low + VoiceSerial = VoiceQueue[VoiceQueueOutIndex++]; + VoiceQueueOutIndex &= (VOICE_Q_LENGTH - 1); + VoiceQueueCount -= 1; + if (VoiceShift) { + VoiceShift = 0; + VoiceSerial += 260; + } + VoiceTimer = 16; + if ((VoiceSerial & 0x00FF) >= 0xF0) { + if (VoiceSerial == 0xFF) { + VoiceShift = 1; + return; + } + VoiceSerial |= 0xFF00; + VoiceTimer = 40; + } + VoiceCounter = 31; + VoiceState = V_CLOCKING; + } + else { + PORTA_LCD_DAT = VoiceLatch; // Latch data set + PORTB &= ~(1 << OUT_B_LIGHT); // Latch clock low + } + } + else if (VoiceState == V_STARTUP) { + if (g_blinkTmr10ms > 120) // Give module 1.2 secs to initialise + { + VoiceState = V_IDLE; + } + } + else if (VoiceState != V_CLOCKING) { + uint8_t busy; + PORTA_LCD_DAT = VoiceLatch; // Latch data set + PORTB |= (1 << OUT_B_LIGHT); // Drive high,pullup enabled + DDRB &= ~(1 << OUT_B_LIGHT); // Change to input + asm(" nop"); + asm(" nop"); + // delay to allow input to settle + busy = PINB & 0x80; + DDRB |= (1 << OUT_B_LIGHT); // Change to output + // The next bit guarantees the backlight output gets clocked out + if (VoiceState == V_WAIT_BUSY_ON) { // check for busy processing here + if (busy == 0) { // Busy is active + VoiceState = V_WAIT_BUSY_OFF; + } + else { + if (--VoiceTimer == 0) { + VoiceState = V_WAIT_BUSY_OFF; + } + } + } + else if (VoiceState == V_WAIT_BUSY_OFF) { // check for busy processing here + if (busy) { // Busy is inactive + VoiceTimer = 2; + VoiceState = V_WAIT_BUSY_DELAY; + } + } + else if (VoiceState == V_WAIT_BUSY_DELAY) { + if (--VoiceTimer == 0) { + VoiceState = V_IDLE; + } + } + PORTB &= ~(1 << OUT_B_LIGHT); // Latch clock low + } +} diff --git a/src/stock/voice.h b/src/stock/voice.h new file mode 100644 index 000000000..f81cce7fd --- /dev/null +++ b/src/stock/voice.h @@ -0,0 +1,78 @@ +/* + * 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. + * + */ + + +// Bits in VoiceLatch +#define VOICE_CLOCK_BIT 0x01 +#define VOICE_DATA_BIT 0x02 +#define BACKLIGHT_BIT 0x04 +#define SPARE_BIT 0x08 + +#define VOICE_Q_LENGTH 16 + +// Voice states +#define V_STARTUP 0 +#define V_IDLE 1 +#define V_CLOCKING 2 +#define V_WAIT_BUSY_ON 3 +#define V_WAIT_BUSY_OFF 4 +#define V_WAIT_BUSY_DELAY 5 + +#define PROMPT_SYSTEM_BASE 300 +#define PROMPT_CUSTOM_BASE 400 + +struct t_voice +{ + uint8_t Backlight ; + uint8_t VoiceLatch ; + uint8_t VoiceCounter ; + uint8_t VoiceTimer ; + uint16_t VoiceSerial ; + uint8_t VoiceState ; + uint8_t VoiceShift ; + uint8_t VoiceQueueCount ; + uint8_t VoiceQueueInIndex ; + uint8_t VoiceQueueOutIndex ; + uint8_t VoiceQueue[VOICE_Q_LENGTH] ; + + void voice_process( void ) ; +}; + +extern void pushPrompt( uint8_t value ); +extern struct t_voice *voiceaddress( void ) ; +extern struct t_voice Voice ; + +inline bool isPlaying() +{ + return Voice.VoiceState != V_IDLE; +} diff --git a/src/translations.h b/src/translations.h index be708d597..d2f18024c 100644 --- a/src/translations.h +++ b/src/translations.h @@ -444,7 +444,7 @@ extern const pm_char STR_RENAME_FILE[]; extern const pm_char STR_REMOVED[]; -#if defined(SOMO) || defined(PCBARM) +#if defined(VOICE) void playNumber(int16_t number, uint8_t unit=0, uint8_t att=0); void playDuration(int16_t seconds); #endif diff --git a/src/translations/cz.h b/src/translations/cz.h index c9b9c6a9f..2319ac206 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -131,7 +131,7 @@ #else #define TR_SDCLOGS "[Logování SD]" #endif -#if defined(SOMO) +#if defined(VOICE) #define TR_PLAY_TRACK "Hr\200t Stopu\0 " #define TR_PLAY_VALUE "Hr\200t Hodnotu\0" #else diff --git a/src/translations/de.h b/src/translations/de.h index 2afda9729..3dd15b576 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -131,7 +131,7 @@ #else #define TR_SDCLOGS "[SDcard Logs]" #endif -#if defined(SOMO) +#if defined(VOICE) #define TR_PLAY_TRACK "Play Track\0 " #define TR_PLAY_VALUE "Play Value\0 " #else diff --git a/src/translations/en.h b/src/translations/en.h index 79f5950c3..8590ee5e1 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -114,16 +114,21 @@ #else #define TR_HAPTIC "[Haptic]\0 " #endif -#if defined(PCBARM) -#if defined(SDCARD) -#define TR_SDCLOGS "SDCARD Logs\0 " + +#if defined(VOICE) #define TR_PLAY_TRACK "Play Track\0 " #define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SDCLOGS "[SDCARD Logs]" #define TR_PLAY_TRACK "[Play Track]\0" #define TR_PLAY_VALUE "[Play Value]\0" #endif + +#if defined(PCBARM) +#if defined(SDCARD) +#define TR_SDCLOGS "SDCARD Logs\0 " +#else +#define TR_SDCLOGS "[SDCARD Logs]" +#endif #define TR_FSW_VOLUME "Volume\0 " #elif defined(PCBV4) #if defined(SDCARD) @@ -131,18 +136,9 @@ #else #define TR_SDCLOGS "[SDCARD Logs]" #endif -#if defined(SOMO) -#define TR_PLAY_TRACK "Play Track\0 " -#define TR_PLAY_VALUE "Play Value\0 " -#else -#define TR_PLAY_TRACK "[Play Track]\0" -#define TR_PLAY_VALUE "[Play Value]\0" -#endif #define TR_FSW_VOLUME #else #define TR_SDCLOGS -#define TR_PLAY_TRACK -#define TR_PLAY_VALUE #define TR_FSW_VOLUME #endif diff --git a/src/translations/fr.h b/src/translations/fr.h index 0d06b288c..113cdbc65 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -126,7 +126,7 @@ #else #define TR_SDCLOGS "[Logs SD] " #endif -#if defined(SOMO) +#if defined(VOICE) #define TR_PLAY_TRACK "Jouer fichier" #define TR_PLAY_VALUE "Jouer valeur " #else diff --git a/src/translations/it.h b/src/translations/it.h index 408dabc4d..df071ffc7 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -131,7 +131,7 @@ #else #define TR_SDCLOGS "[SDCARD Logs]" #endif -#if defined(SOMO) +#if defined(VOICE) #define TR_PLAY_TRACK "Brano\0 " #define TR_PLAY_VALUE "Play Value\0 " #else diff --git a/src/translations/se.h b/src/translations/se.h index 747885a3d..e770e3e26 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -126,7 +126,7 @@ #else #define TR_SDCLOGS "[SDCARD Logg]" #endif -#if defined(SOMO) +#if defined(VOICE) #define TR_PLAY_TRACK "Spela Sp\200r\0 " #define TR_PLAY_VALUE "Spela V\201rde\0 " #else diff --git a/src/translations/tts_en.cpp b/src/translations/tts_en.cpp index 39516d94e..df78c021b 100644 --- a/src/translations/tts_en.cpp +++ b/src/translations/tts_en.cpp @@ -70,7 +70,7 @@ enum EnglishPrompts { PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS, }; -#if defined(SOMO) || defined(PCBARM) +#if defined(VOICE) void playNumber(int16_t number, uint8_t unit, uint8_t att) { diff --git a/src/translations/tts_fr.cpp b/src/translations/tts_fr.cpp index e086f5228..96f56ef8b 100644 --- a/src/translations/tts_fr.cpp +++ b/src/translations/tts_fr.cpp @@ -99,7 +99,7 @@ enum FrenchPrompts { }; -#if defined(SOMO) || defined(PCBARM) +#if defined(VOICE) #define FEMININ 0x80 diff --git a/src/translations/tts_it.cpp b/src/translations/tts_it.cpp index 1ec470147..d338d2349 100644 --- a/src/translations/tts_it.cpp +++ b/src/translations/tts_it.cpp @@ -93,7 +93,7 @@ enum ItalianPrompts { }; -#if defined(SOMO) || defined(PCBARM) +#if defined(VOICE) void playNumber(int16_t number, uint8_t unit, uint8_t att) {