Voice corrections for stock / gruvin9x board

Minor corrections for curves
Changes in Function Switches to allow a duration there. It allows again a +1/-1 step in Safety functions
This commit is contained in:
bsongis
2012-07-26 18:51:59 +00:00
parent 6ed367834b
commit 71f71357c2
11 changed files with 111 additions and 56 deletions
+4
View File
@@ -175,5 +175,9 @@ void pushPrompt(uint16_t prompt)
bool isPlaying()
{
#if defined(SIMU)
return false;
#else
return TIMSK4 & (1<<OCIE4A);
#endif
}
+2 -2
View File
@@ -31,8 +31,8 @@
*
*/
#define PROMPT_SYSTEM_BASE 300
#define PROMPT_CUSTOM_BASE 400
#define PROMPT_SYSTEM_BASE 170
#define PROMPT_CUSTOM_BASE 200
extern void pushPrompt(uint16_t prompt);
extern bool isPlaying();
+36
View File
@@ -384,6 +384,41 @@ void lcd_hline(uint8_t x, uint8_t y, uint8_t w, uint8_t att)
lcd_hlineStip(x, y, w, 0xff, att);
}
#if 0
// allows the att parameter... perhaps will be needed later!
void lcd_vlineStip(uint8_t x, int8_t y, int8_t h, uint8_t pat, uint8_t att)
{
if (x >= DISPLAY_W) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > DISPLAY_H) { h = DISPLAY_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
y = y % 8;
if (y) {
assert(p >= displayBuf && p < DISPLAY_END);
uint8_t msk = ~(BITMASK(y)-1);
h -= 8-y;
if (h < 0)
msk -= ~(BITMASK(8+h)-1);
lcd_mask(p, msk & pat, att);
p += DISPLAY_W;
}
while (h>=8) {
assert(p >= displayBuf && p < DISPLAY_END);
lcd_mask(p, pat, att);
p += DISPLAY_W;
h -= 8;
}
if (h>0) {
assert(p >= displayBuf && p < DISPLAY_END);
lcd_mask(p, (BITMASK(h)-1) & pat, att);
}
}
#else
void lcd_vlineStip(uint8_t x, int8_t y, int8_t h, uint8_t pat)
{
if (x >= DISPLAY_W) return;
@@ -415,6 +450,7 @@ void lcd_vlineStip(uint8_t x, int8_t y, int8_t h, uint8_t pat)
*p ^= ~(BITMASK(h)-1) & pat;
}
}
#endif
void lcd_vline(uint8_t x, int8_t y, int8_t h)
{
+38 -28
View File
@@ -1085,22 +1085,30 @@ int16_t curveFn(int16_t x)
}
#endif
void DrawCurve(FnFuncP fn)
void DrawCurve(FnFuncP fn, uint8_t offset=0)
{
lcd_vlineStip(X0, 0, DISPLAY_H, 0xee);
lcd_hlineStip(X0-WCHART, Y0, WCHART*2, 0xee);
lcd_vlineStip(X0-offset, 0, DISPLAY_H, 0xee);
lcd_hlineStip(X0-WCHART-offset, Y0, WCHART*2, 0xee);
for (int8_t xv=-WCHART+1; xv<WCHART; xv++) {
uint8_t prev_yv = 255;
for (int8_t xv=-WCHART+1; xv<=WCHART; xv++) {
uint16_t yv = (RESX + fn(xv * (RESX/WCHART))) / 2;
yv = (DISPLAY_H-1) - yv * (DISPLAY_H-1) / RESX;
lcd_plot(X0+xv, yv, BLACK);
if (prev_yv != 255) {
if (abs((int8_t)yv-prev_yv) <= 1)
lcd_plot(X0+xv-offset, prev_yv, BLACK);
else
lcd_vline(X0+xv-offset, prev_yv < yv ? yv : yv+1, prev_yv-yv);
}
prev_yv = yv;
}
}
#if defined(CURVES)
bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0)
{
if (g_model.curves[MAX_CURVES-1] + shift > NUM_POINTS-CURVES_OFFSET_SHIFT(MAX_CURVES)) {
if (g_model.curves[MAX_CURVES-1] + shift > NUM_POINTS-5*MAX_CURVES) {
AUDIO_WARNING2();
return false;
}
@@ -1112,7 +1120,7 @@ bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0)
}
int8_t *nextCrv = curveaddress(index+1);
memmove(nextCrv+shift, nextCrv, CURVES_OFFSET_SHIFT(MAX_CURVES-index-1)+g_model.curves[MAX_CURVES-1]);
memmove(nextCrv+shift, nextCrv, 5*(MAX_CURVES-index-1)+g_model.curves[MAX_CURVES-1]);
if (shift < 0) memclear(&g_model.points[NUM_POINTS-1] + shift, -shift);
while (index<MAX_CURVES)
g_model.curves[index++] += shift;
@@ -1147,7 +1155,7 @@ void menuProcCurveOne(uint8_t event)
// no break
#endif
case EVT_KEY_BREAK(KEY_MENU):
if (s_editMode == 0)
if (s_editMode <= 0)
m_posHorz = 0;
if (s_editMode == 1 && crv.custom/* && m_posHorz>0 && m_posHorz<points-1*/)
s_editMode = 2;
@@ -1155,7 +1163,7 @@ void menuProcCurveOne(uint8_t event)
s_editMode = 1;
break;
case EVT_KEY_LONG(KEY_MENU):
if (s_editMode == 0) {
if (s_editMode <= 0) {
if (++m_posHorz > 4)
m_posHorz = -4;
for (uint8_t i=0; i<crv.points; i++)
@@ -1166,7 +1174,7 @@ void menuProcCurveOne(uint8_t event)
break;
case EVT_KEY_FIRST(KEY_EXIT):
killEvents(event);
if (s_editMode>0) {
if (s_editMode > 0) {
if (--s_editMode == 0)
m_posHorz = 0;
}
@@ -1176,7 +1184,7 @@ void menuProcCurveOne(uint8_t event)
case EVT_KEY_REPT(KEY_LEFT):
case EVT_KEY_FIRST(KEY_LEFT):
if (s_editMode==1 && m_posHorz>0) m_posHorz--;
if (s_editMode==0) {
if (s_editMode <= 0) {
if (crv.custom) {
moveCurve(s_curveChan, -crv.points+2);
}
@@ -1192,7 +1200,7 @@ void menuProcCurveOne(uint8_t event)
case EVT_KEY_REPT(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_RIGHT):
if (s_editMode==1 && m_posHorz<(crv.points-1)) m_posHorz++;
if (s_editMode==0) {
if (s_editMode <= 0) {
if (!crv.custom) {
moveCurve(s_curveChan, crv.points-2, crv.points);
}
@@ -1214,20 +1222,26 @@ void menuProcCurveOne(uint8_t event)
}
lcd_putsLeft(7*FH, PSTR("Type"));
uint8_t attr = (s_editMode==0 ? INVERS : 0);
uint8_t attr = (s_editMode <= 0 ? INVERS : 0);
lcd_outdezAtt(5*FW-2, 7*FH, crv.points, LEFT|attr);
lcd_putsAtt(lcdLastPos, 7*FH, crv.custom ? PSTR("pt'") : PSTR("pt"), attr);
DrawCurve(curveFn);
for (uint8_t i=0; i<crv.points; i++) {
uint8_t xx = X0-1-WCHART+i*WCHART/(crv.points/2);
uint8_t yy = (DISPLAY_H-1) - (100 + crv.crv[i]) * (DISPLAY_H-1) / 200;
if (crv.custom && i>0 && i<crv.points-1)
xx = X0-1-WCHART + (100 + crv.crv[crv.points+i-1]) * (2*WCHART) / 200;
xx = X0-1-WCHART + (100 + (100 + crv.crv[crv.points+i-1]) * (2*WCHART)) / 200;
lcd_filled_rect(xx, yy-1, 3, 3); // do markup square
lcd_filled_rect(xx, yy-1, 3, 3, SOLID, BLACK); // do markup square
if (s_editMode>0 && m_posHorz==i) {
if (s_editMode==1 || !BLINK_ON_PHASE) lcd_filled_rect(xx-1, yy-2, 5, 5); // do selection square
if (s_editMode==1 || !BLINK_ON_PHASE) {
// do selection square
lcd_filled_rect(xx-1, yy-2, 5, 5, SOLID, BLACK);
lcd_filled_rect(xx, yy-1, 3, 3, SOLID);
}
int8_t x = -100 + 200*i/(crv.points-1);
if (crv.custom && i>0 && i<crv.points-1) x = crv.crv[crv.points+i-1];
@@ -1242,8 +1256,6 @@ void menuProcCurveOne(uint8_t event)
CHECK_INCDEC_MODELVAR(event, crv.crv[crv.points+i-1], i==1 ? -99 : crv.crv[crv.points+i-2]+1, i==crv.points-2 ? 99 : crv.crv[crv.points+i]-1); // edit X on left/right
}
}
DrawCurve(curveFn);
}
#endif
@@ -2187,7 +2199,7 @@ void menuProcCurvesAll(uint8_t event)
}
s_curveChan = sub;
DrawCurve(curveFn);
DrawCurve(curveFn, 25);
}
#endif
@@ -2475,11 +2487,11 @@ void menuProcFunctionSwitches(uint8_t event)
uint8_t active = (attr && (s_editMode>0 || p1valdiff));
switch (j) {
case 0:
if (sd->func <= FUNC_SAFETY_CH16 && (FSW_PARAM(sd) & 1)) {
if (sd->func <= FUNC_SAFETY_CH16 && sd->delay) {
if (sd->swtch > MAX_SWITCH+1) sd->swtch -= (MAX_SWITCH+1);
if (sd->swtch < -MAX_SWITCH-1) sd->swtch += (MAX_SWITCH+1);
}
putsSwitches(3, y, sd->swtch, SWONOFF | attr | ((abs(sd->swtch) <= (MAX_SWITCH+1) && getSwitch(sd->swtch, 0) && (sd->func >= 16 || (FSW_PARAM(sd) & 1))) ? BOLD : 0));
putsSwitches(3, y, sd->swtch, SWONOFF | attr | ((abs(sd->swtch) <= (MAX_SWITCH+1) && getSwitch(sd->swtch, 0) && (sd->func >= 16 || sd->delay)) ? BOLD : 0));
if (active) {
CHECK_INCDEC_MODELSWITCH( event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1);
}
@@ -2578,10 +2590,8 @@ void menuProcFunctionSwitches(uint8_t event)
lcd_putsiAtt(15*FW, y, STR_VFSWRESET, FSW_PARAM(sd), attr);
}
else if (sd->func <= FUNC_SAFETY_CH16) {
int8_t value = ((int8_t)FSW_PARAM(sd) >> 1);
lcd_outdezAtt(18*FW, y, limit((int8_t)-125, (int8_t)(value * 2), (int8_t)125), attr);
if (active) FSW_PARAM(sd) = (FSW_PARAM(sd) & 1) + (checkIncDecModel(event, value, -63, 63) << 1);
break;
val_min = -125; val_max = 125;
lcd_outdezAtt(18*FW, y, FSW_PARAM(sd), attr);
}
else {
if (attr) m_posHorz = 0;
@@ -2600,11 +2610,11 @@ void menuProcFunctionSwitches(uint8_t event)
case 3:
if (sd->swtch && sd->func <= FUNC_SAFETY_CH16) {
#if defined(GRAPHICS)
menu_lcd_onoff(20*FW, y, (FSW_PARAM(sd) & 1), attr ) ;
menu_lcd_onoff(20*FW, y, sd->delay, attr ) ;
#else
menu_lcd_onoff(18*FW+2, y, (FSW_PARAM(sd) & 1), attr ) ;
menu_lcd_onoff(18*FW+2, y, sd->delay, attr ) ;
#endif
if (active) FSW_PARAM(sd) = (FSW_PARAM(sd) & 0xfe) + checkIncDecModel(event, FSW_PARAM(sd) & 1, 0, 1);
if (active) CHECK_INCDEC_MODELVAR(event, sd->delay, 0, 1);
}
else if (attr) {
m_posHorz = 0;
+5 -2
View File
@@ -350,12 +350,15 @@ PACK(typedef struct t_FuncSwData { // Function Switches data
int8_t swtch; //input
uint8_t func;
char param[6];
uint8_t delay;
uint8_t spare;
}) FuncSwData;
#define FSW_PARAM(p) (*((uint32_t*)(p)->param))
#else
PACK(typedef struct t_FuncSwData { // Function Switches data
int8_t swtch; //input
uint8_t func;
uint8_t func:5;
uint8_t delay:3;
uint8_t param;
}) FuncSwData;
#define FSW_PARAM(p) ((p)->param)
@@ -593,7 +596,7 @@ PACK(typedef struct t_PhaseData {
#if defined(PCBARM)
#define MAX_CURVES 16
#define NUM_POINTS 512
#define CURVTYPE uint16_t
#define CURVTYPE int16_t
#else
#define MAX_CURVES 8
#define NUM_POINTS (112-MAX_CURVES)
+2 -9
View File
@@ -162,17 +162,10 @@ LimitData *limitaddress(uint8_t idx)
return &g_model.limitData[idx];
}
#if defined(PCBARM)
int8_t *curveaddress(uint8_t idx)
{
return &g_model.points[idx==0 ? 0 : g_model.curves[idx-1]];
}
#else
int8_t *curveaddress(uint8_t idx)
{
return &g_model.points[idx==0 ? 0 : 5*idx+g_model.curves[idx-1]];
}
#endif
CurveInfo curveinfo(uint8_t idx)
{
@@ -1798,8 +1791,8 @@ void evalFunctions()
swtch += MAX_SWITCH+1;
}
if (getSwitch(swtch, 0)) {
if (sd->func < FUNC_TRAINER && (FSW_PARAM(sd) & 1)) {
safetyCh[sd->func] = limit((int8_t)-125, (int8_t)(((int8_t)FSW_PARAM(sd) >> 1) * 2), (int8_t)125);
if (sd->func < FUNC_TRAINER && sd->delay) {
safetyCh[sd->func] = FSW_PARAM(sd);
}
if (~activeFunctions & function_mask) {
-6
View File
@@ -819,12 +819,6 @@ struct CurveInfo {
};
extern CurveInfo curveinfo(uint8_t idx);
#if defined(PCBARM)
#define CURVES_OFFSET_SHIFT(x) (0)
#else
#define CURVES_OFFSET_SHIFT(x) (5*(x))
#endif
extern void deleteExpoMix(uint8_t expo, uint8_t idx);
extern void incSubtrim(uint8_t idx, int16_t inc);
+2
View File
@@ -175,7 +175,9 @@ void *main_thread(void *)
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
if (main_thread_running == 1) {
#if defined(SPLASH)
doSplash();
#endif
#if !defined(PCBARM)
checkLowEEPROM();
+4
View File
@@ -50,6 +50,10 @@ void putVoiceQueueUpper( uint8_t value )
void pushPrompt( uint8_t value )
{
#ifdef SIMU
printf("playFile(\"%04d.ad4\")\n", value); fflush(stdout);
#endif
struct t_voice *vptr;
vptr = voiceaddress();
+6 -2
View File
@@ -48,8 +48,8 @@
#define V_WAIT_BUSY_OFF 4
#define V_WAIT_BUSY_DELAY 5
#define PROMPT_SYSTEM_BASE 300
#define PROMPT_CUSTOM_BASE 400
#define PROMPT_SYSTEM_BASE 170
#define PROMPT_CUSTOM_BASE 200
struct t_voice
{
@@ -74,7 +74,11 @@ extern struct t_voice Voice ;
inline bool isPlaying()
{
#if defined(SIMU)
return false;
#else
return Voice.VoiceState != V_IDLE;
#endif
}
/*
+12 -7
View File
@@ -133,9 +133,9 @@ if __name__ == "__main__":
systemSounds.extend(generate(s, 40+i))
for i, s in enumerate(["volts", "amps", "meters per second", "", "km per hour", "meters", "degrees", "percent", "milliamps", "milliamps per hour", "watts", "", "feet", "knots"]):
systemSounds.extend(generate(s, 50+i))
for s, f, a in [(u"trim center", "midtrim", 314),
for s, f, a in [(u"trim center", "midtrim", 184),
(u"maximum trim reached", "endtrim", 0),
(u"transmitter battery low", "lowbatt", 301),
(u"transmitter battery low", "lowbatt", 171),
]:
systemSounds.extend(generate(s, f, a))
for i, (s, f) in enumerate([
@@ -167,7 +167,7 @@ if __name__ == "__main__":
(u"flight mode eight", "fltmd8"),
(u"flight mode nine", "fltmd9"),
]):
sounds.extend(generate(s, f, 400+i))
sounds.extend(generate(s, f, 200+i))
elif "fr" in sys.argv:
@@ -203,7 +203,7 @@ if __name__ == "__main__":
(u"fin écolage", "trnoff"),
(u"moteur coupé", "engoff"),
]):
sounds.extend(generate(s, f, 400+i))
sounds.extend(generate(s, f, 200+i))
elif "it" in sys.argv:
if "sapi" in sys.argv:
tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
@@ -221,9 +221,9 @@ if __name__ == "__main__":
systemSounds.extend(generate(s, 103+i))
for i, s in enumerate(["volt", "amper", "meetri per secondo", "", "chilomeetri ora", "meetri", "gradi", "percento", "milliamper", "milliamper ora", "watt", "", "piedi", "nodi"]):
systemSounds.extend(generate(s, 112+i))
for a, s, f in [(u"trim centrato", "midtrim", 314),
for a, s, f in [(u"trim centrato", "midtrim", 184),
(u"massimo trim raggiunto", "endtrim", 0),
(u"batteria della radio scarica", "lowbatt", 301),
(u"batteria della radio scarica", "lowbatt", 171),
]:
systemSounds.extend(generate(s, f, a))
for i, s in enumerate(["timer", "", "tensione", "tensione", "trasmissione", "ricezione", "altitudine", "motore",
@@ -260,8 +260,13 @@ if __name__ == "__main__":
(u"fase di volo 8", "fltmd8"),
(u"fase di volo 9", "fltmd9"),
]):
sounds.extend(generate(s, f, 400+i))
sounds.extend(generate(s, f, 200+i))
if 'ad4' in sys.argv:
voice += "-stock"
else:
voice += "-sky9x"
if "csv" in sys.argv:
csvFile = file(voice + ".csv", "w")
for f, s in systemSounds: