From d3c4cb2534c391cb46b41fbcda0bf93b445bf07f Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 5 Feb 2012 10:27:21 +0000 Subject: [PATCH] 90 bytes saved on the channel order array + access functions --- src/general_menus.cpp | 4 ++-- src/open9x.cpp | 20 ++++++++++---------- src/open9x.h | 7 ++++--- src/pers.cpp | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 3d36295df..e4345142c 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -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 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 ' '; diff --git a/src/open9x.h b/src/open9x.h index 14553ddb8..f96c50fd5 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -255,18 +255,19 @@ extern uint16_t DEBUG2; #define SLAVE_MODE (PING & (1< 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 , diff --git a/src/pers.cpp b/src/pers.cpp index 609794a23..558dd8411 100644 --- a/src/pers.cpp +++ b/src/pers.cpp @@ -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;