Voice added on stock (completely untested)
Issue 50 fixed Tada sound added Corrections on expos curves
This commit is contained in:
+15
-6
@@ -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)
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - 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;
|
||||
}
|
||||
Reference in New Issue
Block a user