Commit 60b19611 authored by Pavel Semerad's avatar Pavel Semerad
Browse files

add more Multi-Positions 8/6/4/4

parent c089937b
*0.6.0 ()
increased model memories by using FLASH also
added more Multi-Positions
*0.5.1 (26 Apr 2012)
added possibility to connect potentiometer instead of CH3 button
......
......@@ -24,7 +24,7 @@ Flashing firmware
- load firmware "gt3b-VERSION.s19"
- program it with "Program -> Address Range..."
- set "Start @" to "8000"
- set "End @" to "E4FF" (it is possible to find place where zeroes
- set "End @" to "E70F" (it is possible to find place where zeroes
will start and use last non-zero address)
- press "OK"
- if "Program -> Current tab" will be used, all models stored at FLASH
......@@ -34,7 +34,7 @@ Flashing firmware
Global characteristics:
=======================
- 72 model memories, first 8 in EEPROM, rest in FLASH
- 67 model memories, first 8 in EEPROM, rest in FLASH
> numbers 10-19 will show with Right-Arrow
> numbers 20-29 will show with Left-Arrow
> numbers 30-39 will show with Left+Right-Arrows
......@@ -149,6 +149,8 @@ Standard menu:
-100% means 100% reduce on front steering/throttle (eg. no steering)
> for 4WS press ENTER and select crab (CR1) or no-crab (CR0)
for Multi-Position:
> there are 4 Multi-Positions identified by numbers 1..4, they have
8/6/4/4 positions
> press ENTER and choose channel for this function or OFF
- channel can be "D" also, which means map to DIG function
> press ENTER and set channel value for first position
......@@ -381,12 +383,15 @@ DRS, DRF, DRB - dualrate of steering/forward/back
EXS, EXF, EXB - expo of steering/forward/back
CHn - change channel "n" value in range -100...100
STn - subtrim of channel "n"
4WS - 4 wheel steering mix -100...100%
DIG - DIG throttle mix -100...100%
MP0 - Multi-Position 0, switches position up/down
SST - steering speed turn 1...100%
SSR - steering speed return 1...100%
CSn - channel speed for channel "n" 1...100%
4WS - 4 wheel steering mix -100...100%
DIG - DIG throttle mix -100...100%
MP1 - Multi-Position 1, switches position up/down
MP2 - Multi-Position 2, switches position up/down
MP3 - Multi-Position 3, switches position up/down
MP4 - Multi-Position 4, switches position up/down
......@@ -404,8 +409,14 @@ CnR - reset value of channel "n" to centre
DIG - switch DIG mix between -100 and 100 (more useable when using
return to previous val key setting)
DGR - reset DIG mix to centre
MP0 - Multi-Position 0, switches position up (at END back to 1.)
MR0 - Multi-Position 0 Reset, switches position to first one
MP1 - Multi-Position 1, switches position up (at END back to 1.)
MR1 - Multi-Position 1 Reset, switches position to first one
MP2 - Multi-Position 2, switches position up (at END back to 1.)
MR2 - Multi-Position 2 Reset, switches position to first one
MP3 - Multi-Position 3, switches position up (at END back to 1.)
MR3 - Multi-Position 3 Reset, switches position to first one
MP4 - Multi-Position 4, switches position up (at END back to 1.)
MR4 - Multi-Position 4 Reset, switches position to first one
T1S - start/pause timer1
T1R - stop + reset timer1
T2S - start/pause timer2
......
? more multi-positions - 2 for 6ch, 4 for 8ch, 4-pos is enought
? PPM input for head tracking gyro
- pin PD7 TLI non-maskable interrupt at signal edge
- or pin PD1 (SWIM), PD5, PD6 with pin change interrupt at signal edge
......
......@@ -143,9 +143,19 @@ void config_model_set_default(void) {
cm.channel_4WS = 0;
cm.channel_DIG = 0;
cm.channel_MP0 = 0;
memset(cm.multi_position0, (u8)MULTI_POSITION_END, sizeof(cm.multi_position0));
cm.multi_position0[0]= -100;
cm.channel_MP1 = 0;
memset(cm.multi_position1, (u8)MULTI_POSITION_END, sizeof(cm.multi_position1));
cm.multi_position1[0]= -100;
cm.channel_MP2 = 0;
memset(cm.multi_position2, (u8)MULTI_POSITION_END, sizeof(cm.multi_position2));
cm.multi_position2[0]= -100;
cm.channel_MP3 = 0;
memset(cm.multi_position3, (u8)MULTI_POSITION_END, sizeof(cm.multi_position3));
cm.multi_position3[0]= -100;
memcpy(&cm.key_mapping, &default_key_mapping, sizeof(config_key_mapping_s));
if (cg.ch3_pot) {
......@@ -155,7 +165,6 @@ void config_model_set_default(void) {
cm.unused = 0;
cm.unused2 = 0;
cm.unused3 = 0;
memset(cm.reserve, 0, sizeof(cm.reserve));
}
......@@ -287,6 +296,21 @@ u8 config_get_MP(u8 index, u8 *pchannel_MP, s8 **pmulti_position) {
*pchannel_MP = cm.channel_MP0;
*pmulti_position = cm.multi_position0;
return NUM_MULTI_POSITION0;
case 1:
// multi position 1
*pchannel_MP = cm.channel_MP1;
*pmulti_position = cm.multi_position1;
return NUM_MULTI_POSITION1;
case 2:
// multi position 2
*pchannel_MP = cm.channel_MP2;
*pmulti_position = cm.multi_position2;
return NUM_MULTI_POSITION2;
case 3:
// multi position 3
*pchannel_MP = cm.channel_MP3;
*pmulti_position = cm.multi_position3;
return NUM_MULTI_POSITION3;
}
// shouldn't come here
return 0;
......
......@@ -127,8 +127,11 @@ typedef struct {
config_et_map_s et_map[NUM_TRIMS];
} config_key_mapping_s;
#define MP_COUNT 1
#define MP_COUNT 4
#define NUM_MULTI_POSITION0 8
#define NUM_MULTI_POSITION1 6
#define NUM_MULTI_POSITION2 4
#define NUM_MULTI_POSITION3 4
#define MULTI_POSITION_END -128
#define MP_DIG 0x0f
......@@ -139,7 +142,7 @@ typedef struct {
// also add code to setting default values
// length must by multiple of 4 because of EEPROM/FLASH Word programming
// 54(30 reserved) + 22(keys) + channels * 4 bytes = 108 for 8-channel fw
#define CONFIG_MODEL_MAGIC (0xe018 | (MAX_CHANNELS - 1))
#define CONFIG_MODEL_MAGIC (0xd820 | (MAX_CHANNELS - 1))
typedef struct {
u8 name[3];
u8 reverse; // bit for each channel
......@@ -160,23 +163,28 @@ typedef struct {
#define expo_steering expo[0]
#define expo_forward expo[1]
#define expo_back expo[2]
s8 multi_position0[NUM_MULTI_POSITION0]; // values for MultiPosition
s8 multi_position0[NUM_MULTI_POSITION0]; // values for MultiPosition 0
s8 multi_position1[NUM_MULTI_POSITION1]; // values for MultiPosition 1
s8 multi_position2[NUM_MULTI_POSITION2]; // values for MultiPosition 2
s8 multi_position3[NUM_MULTI_POSITION3]; // values for MultiPosition 3
u8 channels:3; // number of channels for this model - 1
u8 brake_off:1; // don't use brake side of throttle
u8 channel_4WS:4; // channel for 4WS mix or 0 when off
u8 channel_DIG:4; // channel for DIG mix or 0 when off
u8 channel_MP0:4; // channel for MultiPosition or 0 when off
u8 channel_MP0:4; // channel for MultiPosition0 or 0 when off
u8 channel_MP1:4; // channel for MultiPosition1 or 0 when off
u8 channel_MP2:4; // channel for MultiPosition2 or 0 when off
u8 channel_MP3:4; // channel for MultiPosition3 or 0 when off
u8 thspd_onlyfwd:1; // throttle speed only at forward side
u8 abs_type:2;
u8 unused:5;
u8 unused:1;
u16 unused2;
u16 unused3;
config_key_mapping_s key_mapping;
u8 reserve[26];
u8 reserve[13];
} config_model_s;
extern @near config_model_s config_model;
......
......@@ -90,9 +90,17 @@ void menu_load_model(void) {
menu_4WS_mix = 0;
menu_4WS_crab = 0;
menu_DIG_mix = 0;
memset(menu_MP_index, 0, sizeof(menu_MP_index));
if (cm.channel_MP0 && cm.channel_MP0 != MP_DIG)
menu_channel3_8[cm.channel_MP0 - 3] = cm.multi_position0[0];
if (cm.channel_MP1 && cm.channel_MP1 != MP_DIG)
menu_channel3_8[cm.channel_MP1 - 3] = cm.multi_position1[0];
if (cm.channel_MP2 && cm.channel_MP2 != MP_DIG)
menu_channel3_8[cm.channel_MP2 - 3] = cm.multi_position2[0];
if (cm.channel_MP3 && cm.channel_MP3 != MP_DIG)
menu_channel3_8[cm.channel_MP3 - 3] = cm.multi_position3[0];
menu_brake = 0;
// set state of buttons to do initialize
......
......@@ -136,6 +136,15 @@ static void mix_DIG(u8 action) {
case 0:
cm.channel_MP0 = val;
break;
case 1:
cm.channel_MP1 = val;
break;
case 2:
cm.channel_MP2 = val;
break;
case 3:
cm.channel_MP3 = val;
break;
}
}
static void mix_MultiPosition(u8 action) {
......@@ -146,6 +155,15 @@ static void mix_MultiPosition(u8 action) {
u8 channel_MP;
u8 num_MP = config_get_MP(mp_id, &channel_MP, &multi_position);
// check if this MP is allowed at set number of channels
if ((u8)(mp_id + 3) > channels) {
lcd_7seg(L7_P);
lcd_char(LCHR1, (u8)(mp_id + '1'));
lcd_chars2("NA");
menu_blink &= (u8)~MCB_CHR1;
return;
}
if (action == MLA_CHG) {
// change value
if (menu_set == 0) {
......@@ -191,7 +209,7 @@ static void mix_MultiPosition(u8 action) {
lcd_7seg(L7_P);
if (menu_set == 0) {
// show MP id
lcd_char(LCHR1, (u8)(mp_id + '0'));
lcd_char(LCHR1, (u8)(mp_id + '1'));
lcd_char(LCHR2, ' ');
// channel number/OFF
lcd_char(LCHR3, (u8)(channel_MP == MP_DIG ? 'D' : (u8)(channel_MP + '0')));
......@@ -230,6 +248,9 @@ static const menu_list_t mix_funcs[] = {
mix_4WS,
mix_DIG,
mix_MultiPosition,
mix_MultiPosition,
mix_MultiPosition,
mix_MultiPosition,
mix_brake_off,
};
......
......@@ -121,7 +121,7 @@ static void show_trim2(u8 *name, s16 val) {
// multi-position show and set value
static void show_MP(u8 *name, s16 val) {
u8 mp_id = (u8)(name[2] - '0');
u8 mp_id = (u8)(name[2] - '1');
s8 *multi_position;
u8 channel_MP;
u8 num_MP = config_get_MP(mp_id, &channel_MP, &multi_position);
......@@ -141,7 +141,7 @@ static void show_MP(u8 *name, s16 val) {
lcd_char_num3(multi_position[menu_MP_index[mp_id]]);
}
static void set_MP(u8 *name, s16 *aval, u8 rotate) {
u8 mp_id = (u8)(name[2] - '0');
u8 mp_id = (u8)(name[2] - '1');
s8 *multi_position;
u8 channel_MP;
u8 num_MP = config_get_MP(mp_id, &channel_MP, &multi_position);
......@@ -244,8 +244,14 @@ static const et_functions_s et_functions[] = {
4, &menu_4WS_mix, -100, 100, 0, MIX_FAST, NULL, NULL, NULL },
{ 37, "DIG", LM_EPO, EF_BLINK | EF_PERCENT | EF_NOCHANNEL | EF_NOCONFIG | EF_NO2CHANNELS,
L7_D, &menu_DIG_mix, -100, 100, 0, MIX_FAST, NULL, NULL, NULL },
{ 38, "MP0", 0, EF_LIST | EF_NOCONFIG | EF_NO2CHANNELS, 0, &menu_MP_index[0],
{ 38, "MP1", 0, EF_LIST | EF_NOCONFIG, 3, &menu_MP_index[0],
0, NUM_MULTI_POSITION0 - 1, 0, 1, set_MP, show_MP, NULL },
{ 39, "MP2", 0, EF_LIST | EF_NOCONFIG, 4, &menu_MP_index[1],
0, NUM_MULTI_POSITION1 - 1, 0, 1, set_MP, show_MP, NULL },
{ 40, "MP3", 0, EF_LIST | EF_NOCONFIG, 5, &menu_MP_index[2],
0, NUM_MULTI_POSITION2 - 1, 0, 1, set_MP, show_MP, NULL },
{ 41, "MP4", 0, EF_LIST | EF_NOCONFIG, 6, &menu_MP_index[3],
0, NUM_MULTI_POSITION3 - 1, 0, 1, set_MP, show_MP, NULL },
};
#define ET_FUNCTIONS_SIZE (sizeof(et_functions) / sizeof(et_functions_s))
......@@ -786,7 +792,7 @@ static void kf_brake(u8 *id, u8 *param, u8 flags, s16 *prev_val) {
// table of key functions
static const key_functions_s key_functions[] = {
{ 0, "OFF", KF_NONE, NULL, NULL, 0 },
{ 23, "BLS", KF_NOSHOW, kf_battery_low_shutup, NULL, 0 }, // default END-long
{ 29, "BLS", KF_NOSHOW, kf_battery_low_shutup, NULL, 0 }, // default END-long
{ 1, "CH3", KF_2STATE, kf_set_switch, NULL, 3 },
{ 7, "C3R", KF_NONE, kf_reset, "CH3", 3 },
#if MAX_CHANNELS >= 4
......@@ -812,13 +818,20 @@ static const key_functions_s key_functions[] = {
{ 13, "4WS", KF_2STATE, kf_4ws, NULL, 3 },
{ 14, "DIG", KF_2STATE, kf_set_switch, NULL, 3 },
{ 15, "DGR", KF_NONE, kf_reset, "DIG", 3 },
{ 16, "MP0", KF_NONE, kf_multi_position, (u8 *)0, 3 },
{ 17, "MR0", KF_NONE, kf_multi_position_reset, (u8 *)0, 3 },
{ 18, "T1S", KF_NOSHOW, kf_menu_timer_start, (u8 *)0, 0 },
{ 19, "T1R", KF_NOSHOW, kf_menu_timer_reset, (u8 *)0, 0 },
{ 20, "T2S", KF_NOSHOW, kf_menu_timer_start, (u8 *)1, 0 },
{ 21, "T2R", KF_NOSHOW, kf_menu_timer_reset, (u8 *)1, 0 },
{ 22, "BRK", KF_2STATE, kf_brake, NULL, 0 },
{ 16, "MP1", KF_NONE, kf_multi_position, (u8 *)0, 3 },
{ 17, "MR1", KF_NONE, kf_multi_position_reset, (u8 *)0, 3 },
{ 18, "MP2", KF_NONE, kf_multi_position, (u8 *)1, 4 },
{ 19, "MR2", KF_NONE, kf_multi_position_reset, (u8 *)1, 4 },
{ 20, "MP3", KF_NONE, kf_multi_position, (u8 *)2, 5 },
{ 21, "MR3", KF_NONE, kf_multi_position_reset, (u8 *)2, 5 },
{ 22, "MP4", KF_NONE, kf_multi_position, (u8 *)3, 6 },
{ 23, "MR4", KF_NONE, kf_multi_position_reset, (u8 *)3, 6 },
{ 24, "T1S", KF_NOSHOW, kf_menu_timer_start, (u8 *)0, 0 },
{ 25, "T1R", KF_NOSHOW, kf_menu_timer_reset, (u8 *)0, 0 },
{ 26, "T2S", KF_NOSHOW, kf_menu_timer_start, (u8 *)1, 0 },
{ 27, "T2R", KF_NOSHOW, kf_menu_timer_reset, (u8 *)1, 0 },
{ 28, "BRK", KF_2STATE, kf_brake, NULL, 0 },
// beware of BLS with last id
};
#define KEY_FUNCTIONS_SIZE (sizeof(key_functions) / sizeof(key_functions_s))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment