Huge ram saving (320bytes) + expos order change
This commit is contained in:
@@ -366,7 +366,7 @@ void menuProcTrainer(uint8_t event)
|
||||
blink = s_editMode ? BLINK : INVERS ;
|
||||
|
||||
for (uint8_t i=0; i<4; i++) {
|
||||
uint8_t chan = chout_ar[g_eeGeneral.templateSetup][i]; // G: Issue 30.
|
||||
uint8_t chan = pgm_read_byte(chout_ar+g_eeGeneral.templateSetup*4+i); // G: Issue 30.
|
||||
|
||||
volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1];
|
||||
|
||||
|
||||
+24
-4
@@ -63,6 +63,22 @@ const prog_char APM modi12x3[]=
|
||||
|
||||
const prog_char APM s_charTab[] = "_-.,";
|
||||
|
||||
//R=1
|
||||
//E=2
|
||||
//T=3
|
||||
//A=4
|
||||
const prog_uint8_t APM chout_ar[24][4] = { //First number is 0..23 -> template setup, Second is relevant channel out
|
||||
{1,2,3,4},{1,2,4,3},{1,3,2,4},{1,3,4,2},{1,4,2,3},{1,4,3,2},
|
||||
{2,1,3,4},{2,1,4,3},{2,3,1,4},{2,3,4,1},{2,4,1,3},{2,4,3,1},
|
||||
{3,1,2,4},{3,1,4,2},{3,2,1,4},{3,2,4,1},{3,4,1,2},{3,4,2,1},
|
||||
{4,1,2,3},{4,1,3,2},{4,2,1,3},{4,2,3,1},{4,3,1,2},{4,3,2,1} };
|
||||
|
||||
const prog_uint8_t APM modn12x3[4][4]= {
|
||||
{1, 2, 3, 4},
|
||||
{1, 3, 2, 4},
|
||||
{4, 2, 3, 1},
|
||||
{4, 3, 2, 1} };
|
||||
|
||||
#ifdef TRANSLATIONS
|
||||
int8_t char2idx(char c)
|
||||
{
|
||||
@@ -245,9 +261,12 @@ void applyExpos(int16_t *anas)
|
||||
|
||||
uint8_t phase = getFlightPhase();
|
||||
|
||||
int8_t cur_chn = -1;
|
||||
for (uint8_t i=0; i<DIM(g_model.expoData); i++) {
|
||||
ExpoData &ed = g_model.expoData[i];
|
||||
if (ed.mode==0) break; // end of list
|
||||
if (ed.chn == cur_chn)
|
||||
continue;
|
||||
if (ed.phase != 0) {
|
||||
if (ed.negPhase) {
|
||||
if (phase+1 == -ed.phase)
|
||||
@@ -259,17 +278,18 @@ void applyExpos(int16_t *anas)
|
||||
}
|
||||
}
|
||||
if (getSwitch(ed.swtch, 1)) {
|
||||
int16_t v = anas2[ed.chn];
|
||||
cur_chn = ed.chn;
|
||||
int16_t v = anas2[cur_chn];
|
||||
if((v<0 && ed.mode&1) || (v>=0 && ed.mode&2)) {
|
||||
int16_t k = ed.expo;
|
||||
if (IS_THROTTLE(ed.chn) && g_model.thrExpo)
|
||||
if (IS_THROTTLE(cur_chn) && g_model.thrExpo)
|
||||
v = 2*expo((v+RESX)/2, k);
|
||||
else
|
||||
v = expo(v, k);
|
||||
if (ed.curve) v = applyCurve(v, ed.curve, 0);
|
||||
v = ((int32_t)v * ed.weight) / 100;
|
||||
if (IS_THROTTLE(ed.chn) && g_model.thrExpo) v -= RESX;
|
||||
anas[ed.chn] = v;
|
||||
if (IS_THROTTLE(cur_chn) && g_model.thrExpo) v -= RESX;
|
||||
anas[cur_chn] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-22
@@ -254,31 +254,17 @@ extern uint16_t DEBUG2;
|
||||
|
||||
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
|
||||
|
||||
const uint8_t modn12x3[4][4]= {
|
||||
{1, 2, 3, 4},
|
||||
{1, 3, 2, 4},
|
||||
{4, 2, 3, 1},
|
||||
{4, 3, 2, 1} };
|
||||
|
||||
//R=1
|
||||
//E=2
|
||||
//T=3
|
||||
//A=4
|
||||
|
||||
const uint8_t chout_ar[24][4] = { //First number is 0..23 -> template setup, Second is relevant channel out
|
||||
{1,2,3,4},{1,2,4,3},{1,3,2,4},{1,3,4,2},{1,4,2,3},{1,4,3,2},
|
||||
{2,1,3,4},{2,1,4,3},{2,3,1,4},{2,3,4,1},{2,4,1,3},{2,4,3,1},
|
||||
{3,1,2,4},{3,1,4,2},{3,2,1,4},{3,2,4,1},{3,4,1,2},{3,4,2,1},
|
||||
{4,1,2,3},{4,1,3,2},{4,2,1,3},{4,2,3,1},{4,3,1,2},{4,3,2,1} };
|
||||
extern const prog_uint8_t APM chout_ar[24][4];
|
||||
extern const prog_uint8_t APM modn12x3[4][4];
|
||||
|
||||
//convert from mode 1 to mode g_eeGeneral.stickMode
|
||||
//NOTICE! => 1..4 -> 1..4
|
||||
#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[g_eeGeneral.stickMode][((x)-1)] : (x))
|
||||
#define CHANNEL_ORDER(x) (chout_ar[g_eeGeneral.templateSetup][(x)-1])
|
||||
#define THR_STICK (2-(g_eeGeneral.stickMode&1))
|
||||
#define ELE_STICK (1+(g_eeGeneral.stickMode&1))
|
||||
#define AIL_STICK ((g_eeGeneral.stickMode&2) ? 0 : 3)
|
||||
#define RUD_STICK ((g_eeGeneral.stickMode&2) ? 3 : 0)
|
||||
#define CONVERT_MODE(x) (((x)<=4) ? pgm_read_byte(modn12x3+g_eeGeneral.stickMode*4+(x)-1) : (x))
|
||||
#define CHANNEL_ORDER(x) pgm_read_byte(chout_ar+g_eeGeneral.templateSetup*4+(x)-1)
|
||||
#define THR_STICK (2-(g_eeGeneral.stickMode&1))
|
||||
#define ELE_STICK (1+(g_eeGeneral.stickMode&1))
|
||||
#define AIL_STICK ((g_eeGeneral.stickMode&2) ? 0 : 3)
|
||||
#define RUD_STICK ((g_eeGeneral.stickMode&2) ? 3 : 0)
|
||||
|
||||
enum EnumKeys {
|
||||
KEY_MENU ,
|
||||
|
||||
+1
-1
@@ -1806,7 +1806,7 @@ void menuProcTemplates(uint8_t event)
|
||||
|
||||
//write mix names here
|
||||
lcd_outdezNAtt(3*FW, y, k+1, (sub==k ? INVERS : 0)|LEADING0, 2);
|
||||
lcd_putsAtt( 4*FW, y, n_Templates[k],BSS | (s_noHi ? 0 : (sub==k ? INVERS : 0)));
|
||||
lcd_putsnAtt(4*FW, y, PSTR(TEMPLATES_STR)+TEMPLATES_LEN*k, TEMPLATES_LEN, (s_noHi ? 0 : (sub==k ? INVERS : 0)));
|
||||
y+=FH;
|
||||
}
|
||||
if(y>7*FH) return;
|
||||
|
||||
+5
-4
@@ -142,13 +142,14 @@ uint8_t Translate()
|
||||
EEPROM_V4::ExpoData expo4[4];
|
||||
memcpy(&expo4[0], &v4->expoData[0], sizeof(expo4));
|
||||
memset(&g_model.expoData[0], 0, sizeof(expo4));
|
||||
// expos conversion
|
||||
uint8_t e = 0;
|
||||
for (uint8_t ch=0; ch<4 && e<MAX_EXPOS; ch++) {
|
||||
for (int8_t dr=2; dr>=0 && e<MAX_EXPOS; dr--) {
|
||||
if ((dr==2 && !expo4[ch].drSw1) ||
|
||||
(dr==1 && !expo4[ch].drSw2) ||
|
||||
(dr==0 && !expo4[ch].expo[0][0][0] && !expo4[ch].expo[0][0][1] && !expo4[ch].expo[0][1][0] && !expo4[ch].expo[2][1][1])) continue;
|
||||
g_model.expoData[e].swtch = (dr == 0 ? expo4[ch].drSw1 : (dr == 1 ? expo4[ch].drSw2 : 0));
|
||||
if ((dr==2 && !expo4[ch].drSw2) ||
|
||||
(dr==1 && !expo4[ch].drSw1) ||
|
||||
(dr==0 && !expo4[ch].expo[0][0][0] && !expo4[ch].expo[0][0][1] && !expo4[ch].expo[0][1][0] && !expo4[ch].expo[0][1][1])) continue;
|
||||
g_model.expoData[e].swtch = (dr == 2 ? expo4[ch].drSw2 : (dr == 1 ? expo4[ch].drSw1 : 0));
|
||||
g_model.expoData[e].chn = ch;
|
||||
g_model.expoData[e].expo = expo4[ch].expo[dr][0][0];
|
||||
g_model.expoData[e].weight = 100 + expo4[ch].expo[dr][1][0];
|
||||
|
||||
+3
-15
@@ -58,9 +58,6 @@
|
||||
#define STK_P1 5
|
||||
#define STK_P2 6
|
||||
#define STK_P3 7
|
||||
#define NUM_TEMPLATES DIM(n_Templates)
|
||||
#define NUM_TEMPLATE_MIX 8
|
||||
#define TEMPLATE_NLEN 15
|
||||
|
||||
#define TRIM_ON 0
|
||||
#define TRIM_OFF 1
|
||||
@@ -73,18 +70,9 @@
|
||||
#define CURVE5(x) ((x)-1)
|
||||
#define CURVE9(x) (MAX_CURVE5+(x)-1)
|
||||
|
||||
const char n_Templates[][TEMPLATE_NLEN] = {
|
||||
"Simple 4-CH",
|
||||
"T-Cut",
|
||||
"V-Tail",
|
||||
"Elevon\\Delta",
|
||||
"eCCPM",
|
||||
"Heli Setup",
|
||||
"Servo Test"
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define TEMPLATES_STR "Simple 4-CH ""T-Cut ""V-Tail ""Elevon\\Delta""eCCPM ""Heli Setup ""Servo Test "
|
||||
#define TEMPLATES_LEN 12
|
||||
#define NUM_TEMPLATES 7
|
||||
|
||||
void clearMixes();
|
||||
void clearCurves();
|
||||
|
||||
Reference in New Issue
Block a user