1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-27 02:05:16 +03:00

90 bytes saved on the channel order array + access functions

This commit is contained in:
bsongis 2012-02-05 10:27:21 +00:00
parent 8be03cd80d
commit d3c4cb2534
4 changed files with 17 additions and 16 deletions

View file

@ -271,7 +271,7 @@ void menuProcSetup(uint8_t event)
uint8_t attr = sub==subN?INVERS:0;
lcd_puts_P(0, y,STR_RXCHANNELORD);// RAET->AETR
for (uint8_t i=1; i<=4; i++)
putsChnLetter((16+i)*FW, y, CHANNEL_ORDER(i), attr);
putsChnLetter((16+i)*FW, y, channel_order(i), attr);
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23);
if((y+=FH)>7*FH) return;
}subN++;
@ -408,7 +408,7 @@ void menuProcTrainer(uint8_t event)
blink = (s_editMode>0) ? BLINK : INVERS ;
for (uint8_t i=0; i<NUM_STICKS; i++) {
uint8_t chan = pgm_read_byte(chout_ar+g_eeGeneral.templateSetup*4+i); // G: Issue 30.
uint8_t chan = channel_order(i+1);
volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1];

View file

@ -56,15 +56,16 @@ int8_t safetyCh[NUM_CHNOUT];
const pm_char s_charTab[] PROGMEM = "_-.,";
//R=1
//E=2
//T=3
//A=4
const pm_uint8_t chout_ar[] PROGMEM = { //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 pm_uint8_t bchout_ar[] PROGMEM = {
0x1B, 0x1E, 0x27, 0x2D, 0x36, 0x39,
0x4B, 0x4E, 0x63, 0x6C, 0x72, 0x78,
0x87, 0x8D, 0x93, 0x9C, 0xB1, 0xB4,
0xC6, 0xC9, 0xD2, 0xD8, 0xE1, 0xE4 };
uint8_t channel_order(uint8_t x)
{
return ( ((pgm_read_byte(bchout_ar + g_eeGeneral.templateSetup) >> (6-(x-1) * 2)) & 3 ) + 1 );
}
/*
mode1 rud ele thr ail
@ -78,7 +79,6 @@ const pm_uint8_t modn12x3[] PROGMEM = {
4, 2, 3, 1,
4, 3, 2, 1 };
char idx2char(int8_t idx)
{
if (idx == 0) return ' ';

View file

@ -255,18 +255,19 @@ extern uint16_t DEBUG2;
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
extern const pm_uint8_t chout_ar[24*4];
extern const pm_uint8_t modn12x3[4*4];
extern const pm_uint8_t bchout_ar[];
extern const pm_uint8_t modn12x3[];
//convert from mode 1 to mode g_eeGeneral.stickMode
//NOTICE! => 1..4 -> 1..4
#define CONVERT_MODE(x) (((x)<=4) ? pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + (x)-1) : (x) )
#define CHANNEL_ORDER(x) pgm_read_byte(chout_ar + 4*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)
extern uint8_t channel_order(uint8_t x);
enum EnumKeys {
KEY_MENU ,
KEY_EXIT ,

View file

@ -67,7 +67,7 @@ inline void applyDefaultTemplate()
MixData *md = mixaddress(i);
md->destCh = i+1;
md->weight = 100;
md->srcRaw = CHANNEL_ORDER(i+1);
md->srcRaw = channel_order(i+1);
}
STORE_MODELVARS;