Commit 8582b3c1 authored by Pavel Semerad's avatar Pavel Semerad
Browse files

added DIG to MultiPosition

parent d17e8359
......@@ -4,6 +4,7 @@
minimum battery voltage set to 6V
CH3 key set default to OFF
added DGR key function to reset DIG mix to centre
added posibility to select DIG instead of channel number at MultiPosition
*0.4.0 (18 Jul 2011)
......
......@@ -108,6 +108,7 @@ typedef struct {
#define NUM_MULTI_POSITION 8
#define MULTI_POSITION_END -128
#define MP_DIG 0x0f
// change MAGIC number when changing model config
// also add code to setting default values
......
......@@ -150,9 +150,11 @@ static u8 mix_MultiPosition(u8 val_id, u8 action) {
// channel number/off
val = cm.channel_MP;
if (!val) val = 2;
val = (u8)menu_change_val(val, 2, MAX_CHANNELS, 1, 1);
if (val == 2) cm.channel_MP = 0;
else cm.channel_MP = val;
else if (val == MP_DIG) val = MAX_CHANNELS + 1;
val = (u8)menu_change_val(val, 2, MAX_CHANNELS + 1, 1, 1);
if (val == 2) cm.channel_MP = 0;
else if (val == MAX_CHANNELS + 1) cm.channel_MP = MP_DIG;
else cm.channel_MP = val;
}
else {
// position value + END state (END not for first position)
......@@ -176,31 +178,31 @@ static u8 mix_MultiPosition(u8 val_id, u8 action) {
|| ++id > (NUM_MULTI_POSITION + 1)) id = 1;
}
// allow forcing channel value
if (id > 1 && cm.channel_MP) {
if (id > 1 && cm.channel_MP && cm.channel_MP <= MAX_CHANNELS) {
menu_force_value_channel = cm.channel_MP;
}
else menu_force_value_channel = 0;
}
// set forced value
if (menu_force_value_channel) {
val = cm.multi_position[id - 2];
if (val == MULTI_POSITION_END) val = -100;
}
// show value
lcd_7seg(L7_P);
if (id == 1) {
// channel number/OFF
if (!cm.channel_MP) lcd_chars("OFF");
else lcd_char_num3(cm.channel_MP);
if (!cm.channel_MP) lcd_chars("OFF");
else if (cm.channel_MP == MP_DIG)
lcd_chars("DIG");
else lcd_char_num3(cm.channel_MP);
}
else {
// position value
val = cm.multi_position[id - 2];
if (val == MULTI_POSITION_END) lcd_chars("END");
else lcd_char_num3(val);
menu_force_value = val * PPM(5);
if (val == MULTI_POSITION_END) {
lcd_chars("END");
val = -100;
}
else lcd_char_num3(val);
if (cm.channel_MP == MP_DIG) menu_DIG_mix = val;
else menu_force_value = val * PPM(5);
}
return id;
......
......@@ -117,7 +117,9 @@ static void show_trim2(s16 val) {
// multi-position show and set value
static void show_MP(s16 val) {
lcd_7seg(cm.channel_MP); // show also selected channel
// show also selected channel/DIG
if (cm.channel_MP == MP_DIG) lcd_7seg(L7_D);
else lcd_7seg(cm.channel_MP);
lcd_char_num3(cm.multi_position[menu_MP_index]);
}
static void set_MP(s16 *aval, u8 rotate) {
......@@ -134,8 +136,10 @@ static void set_MP(s16 *aval, u8 rotate) {
else (*aval)--; // no rotate, return back to previous index
}
// set value of channel
if (cm.channel_MP)
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[*aval];
if (cm.channel_MP) {
if (cm.channel_MP == MP_DIG) menu_DIG_mix = cm.multi_position[*aval];
else menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[*aval];
}
}
......@@ -667,24 +671,34 @@ static void kf_multi_position(u8 *id, u8 *param, u8 flags, s16 *prev_val) {
if (++menu_MP_index >= NUM_MULTI_POSITION ||
cm.multi_position[menu_MP_index] == MULTI_POSITION_END)
menu_MP_index = 0;
if (cm.channel_MP)
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[menu_MP_index];
if (cm.channel_MP) {
if (cm.channel_MP == MP_DIG)
menu_DIG_mix = cm.multi_position[menu_MP_index];
else
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[menu_MP_index];
}
if (flags & FF_SHOW) {
if (!menu_MP_index) BEEP_RESET;
lcd_7seg(cm.channel_MP);
if (cm.channel_MP == MP_DIG) lcd_7seg(L7_D);
else lcd_7seg(cm.channel_MP);
lcd_segment(LS_SYM_CHANNEL, LS_ON);
lcd_char_num3(cm.multi_position[menu_MP_index]);
}
}
static void kf_multi_position_reset(u8 *id, u8 *param, u8 flags, s16 *pv) {
menu_MP_index = 0;
if (cm.channel_MP)
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[0];
if (cm.channel_MP) {
if (cm.channel_MP == MP_DIG)
menu_DIG_mix = cm.multi_position[0];
else
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[0];
}
if (flags & FF_SHOW) {
BEEP_RESET;
lcd_7seg(cm.channel_MP);
if (cm.channel_MP == MP_DIG) lcd_7seg(L7_D);
else lcd_7seg(cm.channel_MP);
lcd_segment(LS_SYM_CHANNEL, LS_ON);
lcd_char_num3(cm.multi_position[0]);
}
......
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