TTS fixes

This commit is contained in:
romolo.manfredini@gmail.com
2012-11-15 02:10:48 +00:00
parent b3b670b55f
commit 6150cac0f5
5 changed files with 246 additions and 95 deletions
+185 -44
View File
@@ -20,7 +20,7 @@
#define NOINLINE __attribute__ ((noinline))
// Version number, sent in first byte of response
#define VERSION 0x03
#define VERSION 0x04
/*****************************************************************************/
// USI_TWI write states.
@@ -44,8 +44,19 @@
#define TSOFFSET 5
#define TSGAIN 7
// EEPROM offsets
#define EE_SECOND 1
#define EE_MINUTE 2
#define EE_HOUR 3
#define EE_DATE 4
#define EE_MONTH 5
#define EE_YEARL 6
#define EE_YEARH 7
// Bits in AdcControl
#define ADC_RUNNING 0x80
#define ADC_CALC 0x40
#define ADC_COUNT_MASK 0x0F
uint8_t AdcControl ;
@@ -54,6 +65,12 @@ int8_t T_offset ;
uint8_t T_gain ;
int16_t T_mult ;
uint8_t StoreTime ; // Flag set to cause date/time put into eeprom
uint8_t StoreState ; // Flag set to cause date/time put into eeprom
uint8_t I2CstartTime ;
uint8_t I2Crunning ;
// USI_TWI state values.
static uint8_t USI_TWI_SLAVE_Write_State;
static uint8_t USI_TWI_SLAVE_Overflow_State;
@@ -95,6 +112,7 @@ static void Disable_WatchDogTimer(void) ;
static void Init_WatchDogTimer(void) ;
void enableAdc( void ) ;
void disableAdc( void ) ;
void storeTime( void ) ;
char not_leap(void) //check for leap year
@@ -118,6 +136,10 @@ void updateTime(uint8_t amount)
if (++p->minute >= 60)
{
p->minute=0;
if ( p->hour & 1 )
{
StoreTime = 1 ; // Store date/time every 2 hours
}
if (++p->hour >= 24)
{
p->hour=0;
@@ -205,6 +227,10 @@ void checkPowerSave()
sleep_disable();
cli() ;
wdt_reset() ;
if ( StoreTime )
{
storeTime() ;
}
}
PRR = 0x39 ; // USI re-powered
Init_WatchDogTimer() ;
@@ -297,8 +323,9 @@ static void USI_TWI_SLAVE_ReadAndProcessPacket ()
CLKPR = 0x80 ; // Do inline for quick response
CLKPR = 0 ; // Full speed 8.0MHz
// Process the USI TWI start condition.
USI_TWI_SLAVE_Process_Start_Condition();
USI_TWI_SLAVE_Process_Start_Condition() ;
I2Crunning = 1 ;
I2CstartTime = TCNT0 ;
}
// Check for USI_TWI_SLAVE overflow condition.
@@ -336,6 +363,8 @@ static void USI_TWI_SLAVE_ReadAndProcessPacket ()
{
// Clear the stop condition flag.
USISR = (1<<USIPF);
I2Crunning = 0 ;
// Check for the special address to exit the bootloader.
if ( Run_boot )
{
@@ -370,8 +399,8 @@ static void USI_TWI_SLAVE_ReadAndProcessPacket ()
*q++ = p->year ;
*q++ = p->year >> 8 ;
*q++ = Temperature ;
*q++ = T_offset ;
*q++ = T_gain ;
// *q++ = T_offset ;
// *q++ = T_gain ;
// *q++ = MCUSR ;
if ( ActivityFlag < 255 )
@@ -380,26 +409,11 @@ static void USI_TWI_SLAVE_ReadAndProcessPacket ()
}
set_clock( 5 ) ; // Slow to 0.25MHz
}
checkPowerSave() ;
if ( ( AdcControl & ADC_RUNNING ) == 0 )
else // If time done, don't do ADC, minimise loop latency
{
ADMUX = TEMPERATURE ; // Internal 1.1V REF and ADCx
ADCSRA |= (1<<ADSC); // do single conversion
AdcControl |= ADC_RUNNING ;
}
else
{
if ( ( ADCSRA & (1<<ADSC) ) == 0 )
if ( ( AdcControl & ADC_RUNNING ) == 0 )
{
AdcControl &= ~ADC_RUNNING ;
AdcControl += 1 ;
if ( ( AdcControl & ADC_COUNT_MASK ) > 1 )
{ // Skip first conversion
AdcTotal += ADCW ;
}
if ( ( AdcControl & ADC_COUNT_MASK ) >= 9 )
if ( AdcControl & ADC_CALC )
{
AdcTotal += 4 ;
AdcTotal >>= 3 ;
@@ -416,32 +430,59 @@ static void USI_TWI_SLAVE_ReadAndProcessPacket ()
}
AdcControl = 0 ;
AdcTotal = 0 ;
// if (AdcTotal < 0x00f6)
// {
// Temperature=-40;
// }
// else if (AdcTotal < 0x0144)
// {
// Temperature=((AdcTotal*78)/65)-40;
// }
// else
// {
// Temperature=((((AdcTotal-324)*600)/74)+250)/10;
// }
}
else
{
ADMUX = TEMPERATURE ; // Internal 1.1V REF and ADCx
ADCSRA |= (1<<ADSC); // do single conversion
AdcControl |= ADC_RUNNING ;
}
}
else
{
if ( ( ADCSRA & (1<<ADSC) ) == 0 )
{
AdcControl &= ~ADC_RUNNING ;
AdcControl += 1 ;
if ( ( AdcControl & ADC_COUNT_MASK ) > 1 )
{ // Skip first conversion
AdcTotal += ADCW ;
}
if ( ( AdcControl & ADC_COUNT_MASK ) >= 9 )
{
AdcControl = ADC_CALC ;
}
}
}
}
if ( StoreTime )
{
storeTime() ;
}
else
{
checkPowerSave() ;
}
if ( I2Crunning )
{
if ( ( TCNT0 - I2CstartTime ) > 12 ) // 50mS
{
// Timeout I2C bus, force release of lines.
USI_TWI_SLAVE_Init() ;
}
}
} // while
// Disable_WatchDogTimer(); // After Reset the WDT state does not change
// void (*FuncPtr) (void) = (void (*)(void)) (0x0080); // Set up function pointer to address 0x0080
// FuncPtr ();
ADCSRA = 0 ;
TCCR0B = 0 ;
USICR = 0 ;
USISR = 0 ;
ASSR = 0 ;
PRR = 0 ;
CLKPR = 0x80 ; // Do inline for quick response
cli() ;
CLKPR = 0x80 ;
CLKPR = 0 ; // Full speed 8.0MHz
((void (*)(void)) (0))() ;
}
@@ -701,6 +742,7 @@ void USI_TWI_SLAVE_Process_Overflow_Condition(void)
p->date= DataBuffer[4] ;
p->month = DataBuffer[5] ;
p->year = DataBuffer[6] + ( DataBuffer[7] << 8 ) ;
StoreTime = 1 ; // Store date/time in eeprom
}
Value = 9 ;
bufferPtr = &DataBuffer[DATA_SIZE-1] ;
@@ -869,6 +911,92 @@ NOINLINE void set_clock( uint8_t speed )
*ptr = speed ;
}
int8_t eeprom_write_byte_cmp (uint8_t dat, uint16_t pointer_eeprom)
{
if ( EECR & (1<<EEPE) ) /* make sure EEPROM is ready */
{
return -1 ;
}
EEAR = pointer_eeprom;
EECR = 1<<EERE;
if(dat == EEDR)
{
return 0 ;
}
EEDR = dat;
uint8_t flags=SREG;
cli();
EECR |= 1<<EEMPE;
EECR |= 1<<EEPE;
SREG = flags;
return 0 ;
}
int16_t eepromReadByte( uint16_t pointer_eeprom )
{
if ( EECR & (1<<EEPE) ) /* make sure EEPROM is ready */
{
return -1 ;
}
EEAR = pointer_eeprom;
EECR |= 1<<EERE;
return EEDR ;
}
void storeTime()
{
switch ( StoreState )
{
case 0 :
if ( eeprom_write_byte_cmp( Time.second, EE_SECOND ) == 0 )
{
StoreState = 1 ;
}
break ;
case 1 :
if ( eeprom_write_byte_cmp( Time.minute, EE_MINUTE ) == 0 )
{
StoreState = 2 ;
}
break ;
case 2 :
if ( eeprom_write_byte_cmp( Time.hour, EE_HOUR ) == 0 )
{
StoreState = 3 ;
}
break ;
case 3 :
if ( eeprom_write_byte_cmp( Time.date, EE_DATE ) == 0 )
{
StoreState = 4 ;
}
break ;
case 4 :
if ( eeprom_write_byte_cmp( Time.month, EE_MONTH ) == 0 )
{
StoreState = 5 ;
}
break ;
case 5 :
if ( eeprom_write_byte_cmp( Time.year, EE_YEARL ) == 0 )
{
StoreState = 6 ;
}
break ;
case 6 :
if ( eeprom_write_byte_cmp( Time.year >> 8, EE_YEARH ) == 0 )
{
StoreState = 0 ;
StoreTime = 0 ;
}
break ;
}
}
/***********************************************************************/
// Main Starts from here
void main (void)
@@ -892,12 +1020,23 @@ void main (void)
t_time *p = &Time ;
FORCE_INDIRECT(p) ;
p->second = 5 ;
p->minute = 6 ;
p->hour = 16 ;
p->date= 23 ;
p->month = 9 ;
p->year = 2012 ;
p->second = eepromReadByte( EE_SECOND ) ;
p->minute = eepromReadByte( EE_MINUTE ) ;
p->hour = eepromReadByte( EE_HOUR ) ;
p->date = eepromReadByte( EE_DATE ) ;
p->month = eepromReadByte( EE_MONTH ) ;
p->year = eepromReadByte( EE_YEARL ) + ( eepromReadByte( EE_YEARH ) << 8 ) ;
if ( p->year == 0xFFFF )
{
p->second = 0 ;
p->minute = 0 ;
p->hour = 19 ;
p->date = 7 ;
p->month = 10 ;
p->year = 2012 ;
StoreTime = 1 ; // Flag set to cause date/time put into eeprom
}
bufferPtr = DataBuffer ;
@@ -927,3 +1066,5 @@ void disableAdc()
sbi( PRR, PRADC ) ; // Power Down the ADC
}
+7 -2
View File
@@ -47,7 +47,7 @@ enum GermanPrompts {
PROMPT_SECUNDE,
PROMPT_SECUNDEN,
PROMPT_UNITS_BASE = 109,
PROMPT_UNITS_BASE = 110,
PROMPT_VOLTS = PROMPT_UNITS_BASE+UNIT_VOLTS,
PROMPT_AMPS = PROMPT_UNITS_BASE+UNIT_AMPS,
PROMPT_METERS_PER_SECOND = PROMPT_UNITS_BASE+UNIT_METERS_PER_SECOND,
@@ -61,8 +61,13 @@ enum GermanPrompts {
PROMPT_WATTS = PROMPT_UNITS_BASE+UNIT_WATTS,
PROMPT_FEET = PROMPT_UNITS_BASE+UNIT_FEET,
PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS,
PROMPT_HOURS = PROMPT_UNITS_BASE+UNIT_HOURS,
PROMPT_MINUTES = PROMPT_UNITS_BASE+UNIT_MINUTES,
PROMPT_SECONDS = PROMPT_UNITS_BASE+UNIT_SECONDS,
PROMPT_RPMS = PROMPT_UNITS_BASE+UNIT_RPMS,
PROMPT_G= PROMPT_UNITS_BASE+UNIT_G,
PROMPT_LABELS_BASE = 122,
PROMPT_LABELS_BASE = 128,
PROMPT_TIMER1 = PROMPT_LABELS_BASE+TELEM_TM1,
PROMPT_TIMER2 = PROMPT_LABELS_BASE+TELEM_TM2,
PROMPT_RSSI_TX = PROMPT_LABELS_BASE+TELEM_RSSI_TX,
+7 -2
View File
@@ -73,8 +73,13 @@ enum SpanishPrompts {
PROMPT_WATTS = PROMPT_UNITS_BASE+UNIT_WATTS,
PROMPT_FEET = PROMPT_UNITS_BASE+UNIT_FEET,
PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS,
PROMPT_HOURS = PROMPT_UNITS_BASE+UNIT_HOURS,
PROMPT_MINUTES = PROMPT_UNITS_BASE+UNIT_MINUTES,
PROMPT_SECONDS = PROMPT_UNITS_BASE+UNIT_SECONDS,
PROMPT_RPMS = PROMPT_UNITS_BASE+UNIT_RPMS,
PROMPT_G= PROMPT_UNITS_BASE+UNIT_G,
PROMPT_LABELS_BASE = 134,
PROMPT_LABELS_BASE = 139,
PROMPT_TIMER1 = PROMPT_LABELS_BASE+TELEM_TM1,
PROMPT_TIMER2 = PROMPT_LABELS_BASE+TELEM_TM2,
PROMPT_RSSI_TX = PROMPT_LABELS_BASE+TELEM_RSSI_TX,
@@ -204,4 +209,4 @@ PLAY_FUNCTION(playDuration, int16_t seconds)
}
}
#endif
#endif
+1 -1
View File
@@ -74,7 +74,7 @@ enum PortuguesePrompts {
PROMPT_FEET = PROMPT_UNITS_BASE+UNIT_FEET,
PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS,
PROMPT_LABELS_BASE = 134,
PROMPT_LABELS_BASE = 140,
PROMPT_TIMER1 = PROMPT_LABELS_BASE+TELEM_TM1,
PROMPT_TIMER2 = PROMPT_LABELS_BASE+TELEM_TM2,
PROMPT_RSSI_TX = PROMPT_LABELS_BASE+TELEM_RSSI_TX,
+46 -46
View File
@@ -306,7 +306,7 @@ if __name__ == "__main__":
(u"trenta secondi", "timer30", 253),
]:
systemSounds.extend(generate(s, f, a))
for i, s in enumerate(["timer", "", "trasmissione", "ricezione", "A1", "A2", "altitudine", "motore",
for i, s in enumerate(["timer", "timer", "trasmissione", "ricezione", "A1", "A2", "altitudine", "motore",
"carburante", "temperatura", "temperatura", "velocita'", "distanza", "altitudine", "cella lipo",
"totale lipo", "tensione", "corrente", "consumo", "potenza", "accelerazione X", "accellerazione Y", "accelerazione Z",
"direzione", "variometro","minimo","massimo"]):
@@ -375,11 +375,11 @@ if __name__ == "__main__":
(u"30 sekunden", "timer30", 253),
]:
systemSounds.extend(generate(s, f, a))
for i, s in enumerate(["Timer", "", "Sendung", "Empfang", "A1", "A2", "Hoehe", "Motor",
for i, s in enumerate(["Timer", "Timer", "Sendung", "Empfang", "A1", "A2", "Hoehe", "Motor",
"Treibstoff", "Temperatur", "Temperatur", "Geschwindigkeit", "Ferne", "Hoehe", "Lipo-Zelle",
"Zellen gesamt", "Spannung", "Strom", "Verbrauch", "Power", "Beschleunigung X", "Beschleunigung Y", "Beschleunigung Z",
"Richtung", "Variometer","Minimum","Maximum"]):
systemSounds.extend(generate(s, 132+i))
systemSounds.extend(generate(s, 129+i))
for i, (s, f) in enumerate([
(u"Fahrwerk eingezogen", "gearup"),
(u"Fahrwerk ausgefahren", "geardn"),
@@ -416,7 +416,7 @@ if __name__ == "__main__":
tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
voice = "portuguese"
else:
espeakVoice = "mb-pt4"
espeakVoice = "mb-pt1+f1"
espeakspeed = "160"
voice = "portuguese"
@@ -424,68 +424,68 @@ if __name__ == "__main__":
systemSounds.extend(generate(str(i), i))
systemSounds.extend(generate("cento", 101))
systemSounds.extend(generate("duzentos", 102))
systemSounds.extend(generate("trezcentos", 103))
systemSounds.extend(generate("quatrocentoc", 104))
systemSounds.extend(generate("trezentos", 103))
systemSounds.extend(generate("quatrocentos", 104))
systemSounds.extend(generate("quinhentos", 105))
systemSounds.extend(generate("seiscentos", 106))
systemSounds.extend(generate("setecentos", 107))
systemSounds.extend(generate("oitocentos", 108))
systemSounds.extend(generate("nuevecentos", 109))
systemSounds.extend(generate("novecentos", 109))
systemSounds.extend(generate("mil", 110))
for i, s in enumerate(["virgula", "uma", "duas", "e", "menos", "hora", "horas", "minuto", "minutos", "segundo", "segundos"]):
systemSounds.extend(generate(s, 111+i))
for i, s in enumerate([u"Volt", u"ampére", u"metros por segundo", u"", u"quilômetros por hora", "metros", "graus", "cento", "miliamperes", "miliamperes por hora", "watt", "db", "estar", "nós", "horas", "minutos", "segundos", "RPM", "g"]):
for i, s in enumerate([u"Volt", u"ampére", u"metros por segundo", u"", u"quilômetros por hora", u"metros", u"graus", u"cento", u"miliamperes", u"miliamperes por hora", u"watt", u"db", u"pés", u"nós", u"horas", u"minutos", u"segundos", u"RPM", u"g"]):
systemSounds.extend(generate(s, 122+i))
for s, f, a in [(u"comando rádio inativo", "inatividade", 230),
(u"descarregamento da bateria de rádio", "mensagem LowBatt", 231),
(u"controle não motor em posição, verifique", "thralert", 232),
(u"não muda de posição, verificar", "swalert", 233),
(u"eeprom corrompido", "eebad", 0),
(u"formattazone eeprom em andamento", "eeformat", 0),
(u"erro", "erro", 0),
(u"trim centrada", "midtrim", 244),
for s, f, a in [(u"atenção, o rádio foi esquecido ligado, por favor desligue-o", "inactiv", 230),
(u"bateria do rádio fraca", "lowbatt", 231),
(u"atenção,acelerador não está no mínimo", "thralert", 232),
(u"atenção, certifique-se que os interruptores estão na posição certa", "swalert", 233),
(u"eeprom corrompida", "eebad", 0),
(u"formatação da eeprom em curso", "eeformat", 0),
(u"erro", "error", 0),
(u"trim centrado", "midtrim", 244),
(u"tada", "tada", 245),
(u"potenciómetro centrado", "midpot", 246),
(u"atingiu máximo de compensação", "endtrim", 0),
(u"3 segundos a final", "timerlt3", 250),
(u"10 segondos", "timer10", 251),
(u"20 segondos", "timer20", 252),
(u"30 segondos", "timer30", 253),
(u"trim no máximo", "endtrim", 0),
(u"3 segundos", "timerlt3", 250),
(u"10 segundos", "timer10", 251),
(u"20 segundos", "timer20", 252),
(u"30 segundos", "timer30", 253),
]:
systemSounds.extend(generate(s, f, a))
for i, s in enumerate([u"Tiempo", u"Tiempo", u"transmissão", u"recepção", u"A1", u"A2", u"altitude", u"motor",
u"Fuel", u"temperatura", u"temperatura", u"velocidade", u"distância", u"altitude", u"célula lipo"
u"Total lipo", u"tensão", u"corrente", u"consumo", u"poder", u"aceleração X", u"Y aceleração", u"aceleração Z"
u"Direção", u"vario", u"mínimo", u"máximo"]):
systemSounds.extend(generate(s, 135+i))
for i, s in enumerate([u"cronómetro", u"cronómetro", u"transmissão", u"recepção", u"A1", u"A2", u"altitude", u"motor",
u"combustível", u"temperatura", u"temperatura", u"velocidade", u"distância", u"altitude", u"célula lipo"
u"Total lipo", u"tensão", u"corrente", u"consumo", u"potência", u"aceleração X", u"aceleração Y", u"aceleração Z"
u"Direcção", u"variómetro", u"mínimo", u"máximo"]):
systemSounds.extend(generate(s, 141+i))
for i, (s, f) in enumerate([
(u"carro fechado", "GearUp")
(u"carro aberto", "geardn")
(u"trem, em cima.", "gearup"),
(u"trem, em baixo.", "geardn"),
(u"flaps recolhidos", "flapup"),
(u"flaps estendidos", "flapdn"),
(u"aterragem", "Attero"),
(u"modo principal ativo", "trnon")
(u"modo master off", "trnoff")
(u"motor desligado", "engoff")
(u"muito alto", "tohigh")
(u"aterragem", "attero"),
(u"modo de treino ligado", "trnon"),
(u"modo de treino desligado", "trnoff"),
(u"motor desligado", "engoff"),
(u"muito alto", "tohigh"),
(u"muito baixo", "tolow"),
(u"bateria fraca", "LOWBAT")
(u"corvo on", "crowon")
(u"corvo off", "crowof")
(u"sinal de rádio de baixa", "siglow")
(u"sinal de rádio crítica", "sigcrt"),
(u"modo de velocidade", "spdmod")
(u"bateria fraca", "lowbat"),
(u"crou, activo", "crowon"),
(u"crou, desligado", "crowof"),
(u"recepção de sinal muito baixa", "siglow"),
(u"recepção de sinal crítica", "sigcrt"),
(u"modo de velocidade", "spdmod"),
(u"modo de térmica", "thmmod"),
(u"modo de voo normal", "nrmmod"),
(u"fase de voo 1", "fltmd1"),
(u"fase de voo 2", "fltmd2")
(u"fase de voo 3", "fltmd3")
(u"fase de voo 4", "fltmd4")
(u"fase de voo 5", "fltmd5")
(u"fase de vôo 6", "fltmd6")
(u"fase de voo 2", "fltmd2"),
(u"fase de voo 3", "fltmd3"),
(u"fase de voo 4", "fltmd4"),
(u"fase de voo 5", "fltmd5"),
(u"fase de vôo 6", "fltmd6"),
(u"fase de voo 7", "fltmd7"),
(u"fase de voo 8", "fltmd8")
(u"fase de voo 9", "fltmd9"
(u"fase de voo 8", "fltmd8"),
(u"fase de voo 9", "fltmd9"),
]):
sounds.extend(generate(s, f, 256+i))