Commit b7fe332c authored by Pavel Semerad's avatar Pavel Semerad
Browse files

added config_key_mapping to model config

removed channels from model config
global config:
    removed trim_step, autorepeat, ch3_momentary
    added inactivity_alarm
parent 96155131
*0.0.1
*0.1.0
added special chars "-1" and "10" to be able to display values -199...1099
both trims-long now only resets, before there was 1 press of first button
changed EEPROM init to eliminate broken initialization
in menu: use ENTER to switch items and END/ENTER-long to end of edit of item
added key mapping to configuration of model and removed coresponding
global settings (trim_step, autorepeat, ch3_momentary)
*0.0.0 (25 May 2011)
......
......@@ -20,16 +20,16 @@ You can backup your original firmware and config, use tabs "PROGRAM MEMORY" and
Global characteristics:
=======================
- up to 40 models memory (will be less at the future after adding more
- up to 22 models memory (will be less at the future after adding more
functions and more channels)
> numbers 10-19 will show with Right-Arrow
> numbers 20-29 will show with Left-Arrow
> numbers 30-39 will show with both arrows
> numbers 20-21 will show with Left-Arrow
- added Subtrims
- added SaveAs to save model config to another memory location
- added Global Setup menu to change function features, including backlight time,
CH3 behavior, etc.
battery low voltage, etc.
- dead zone for steering and throttle
- added key mapping specific for each model memory
- calibrate menu will be automatically invoked after first power-on with
this firmware, so 6 menu items will start to blink
......@@ -38,17 +38,20 @@ Buttons:
========
- it is now possible to differentiate between long press (>1 second) to
normal button press (short) and it will be recognized like "ENTER-long"
- buttons of CH3 trims are now also used for steering trim
- Trims and DualRate
> now shows changed value only temporaly (5 seconds or till another
key press), values are saved to EEPROm automatically when it disappears
> when autorepeat disabled on trims (default), reset trim to 0
by pressing both trim keys together for long
(eg. TRIM_LEFT-long + TRIM_RIGHT-long and similar for channel 2)
> while value is showed, it is possible to change it with rotate
encoder also
Standard menu:
==============
- swapped behaviour of ENTER and END when editing items, ENTER now select
next value and END (+ ENTER-long) will end editing items
- Trims are now only for steering and throttle
- Expo
> value for channel 2 is splitted to forward and back and is indicated
......@@ -69,6 +72,49 @@ Standard menu:
> menu TRIM will blink
> set subtrims for each channel
> press ENTER/BACK to end this submenu
- Key mapping specific for each model:
> choose menu REV and press ENTER-long
> menu REV will blink
> choose trims (id 1 2 3 d) or other keys (CH3-C, Back-b, End-E) or
if trim is OFF, then also trim keys (id 1 2 3 d with left/right arrow)
> press ENTER and modify first setting
> press ENTER and modify next setting
> ....
-----
steps of settings of trims (1 2 3 and D/R):
- sequence: function -> buttons -> step -> reverse -> opposite_reset
id: % % V V V blinking
- function: selected function listed at the end of manual
- buttons: MOM - momentary, hold left/right trim key to get end values,
when nothing pressed, servo is at centre
NOL - no long keys, long press is the same as short press
RPT - autorepeat is on
RES - long press of one of trim keys will reset to
centre/reset value
END - long press of trim key will set to coresponding end
value
- step: select trim step for one trim key press (1, 2, ... 100, 200),
not available when buttons MOM
- reverse: NOR - no change
REV - swap left/right trim keys - NOR/REV
- opposite_reset: when trim key is pressed and value is at opposite
side of centre/reset, set value to centre/reset,
not available when buttons MOM
-----
steps of setting of keys (C b E 1< 1> 2< 2> 3< 3> d< d>):
- sequence: function -> momentary -> reverse -> function_long
id: % V % V
- function: selected function listed at the end of manual
- momentary: only available for 2-state functions (channel, ...)
SWI - press will switch something (channel value, ...)
MOM - value change will be active only while pressed
- reverse: only available when momentary MOM
NOR - no change
REV - swap press/no-press behaviour
- function_long: function applied when long press of key happens,
choose from the same list as function
Calibrate menu:
......@@ -119,13 +165,9 @@ Global setup menu:
2.4GHz HF module limitation
This danger zone will be indicated with a flashing "d" symbol
for values greater than 120%
TRIM + S trim step for trim buttons 1...20
1 dead zone for steering 0...50
2 dead zone for throttle 0...50
3 CH3 buttons is momentary OFF/ON
b key beep OFF/ON
TRIM + A autorepeat for trim buttons OFF/ON
D/R + A autorepeat for dualrate buttons OFF/ON
r + ALL global reset - change to YES to set global configuration
and all models to default values
r + MOD all models reset - change to YES to set all models
......@@ -135,10 +177,35 @@ Global setup menu:
Return to original (and modified) firmware:
===========================================
- flash original firmware
- delete whole EEPROM (tab DATA MEMORY in STVP and write those empty zeroes)
or return back your saved config (also tab DATA MEMORY in STVP, read
your saved config from disk and write it to radio)
- calibrate steering and throttle (not needed when You returned back saved
config)
- flash original firmware
- delete whole EEPROM (tab DATA MEMORY in STVP and write those empty zeroes)
or return back your saved config (also tab DATA MEMORY in STVP, read
your saved config from disk and write it to radio)
- calibrate steering and throttle (not needed when You returned back saved
config)
Functions assignable to trims:
==============================
OFF - nothing, it is possible to assign each button as keys
TR1, TR2 - trim of channel 1/2
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"
Functions assignable to keys:
=============================
OFF - nothing
CHn - switch channel "n" value from one end value to opposite end
value. There is special handling for CH3 button. When using
3-position switch instead of CH3 button and momentary is
selected for this button, then centre 3-pos value will also
be detected and set to servo (but this was not tested yet,
I wouldn't do this modification to my radio).
key mapping to model config:
- add config_key_mapping to model config
- remove channels from model config
- remove trim_step, autorepeat, ch3_momentary from global config
- add alarm 10min when radio not used to global config
- merge model/key_beep in global config
more hysteresis on low-power check
Some suggestions taken from manuals of other radios:
assign functions to buttons
? global/model specific
? use one(more) button as SHIFT/SHIFT-LOCK
steering 4WS mixes
dig steering
timer - up/down/lap/lap navigate
......
......@@ -49,11 +49,9 @@ u8 config_global_set_default(void) {
cg.backlight_time = 30;
cg.battery_calib = 672;
cg.battery_low = 92; // 9.2 V
cg.trim_step = 1;
cg.endpoint_max = 120;
cg.autorepeat = BTN_DR_ALL;
cg.inactivity_alarm = 0;
cg.key_beep = 1;
cg.ch3_momentary = 0;
// set calibrate values only when they are out of limits
cc |= check_val(&cg.calib_steering_left, 0, CALIB_ST_LOW_MID, 0);
......@@ -68,6 +66,23 @@ u8 config_global_set_default(void) {
// default model key mapping
static const config_key_mapping_s default_key_mapping = {
{
{ 1, 0 }, // CH3 to channel 3
{ 0, 0 },
{ 0, 0 }
},
{
{ 1, 0, 0, 0, 0 }, // trim1 to steering trim
{ 2, 0, 0, 0, 0 }, // trim2 to throttle trim
{ 1, 0, 0, 0, 0 }, // trim3 to steering trim
{ 3, 0, 0, 1, 0 } // trim4(DR) to steering dualrate, autorepeat
},
0,
0
};
// set default name to given pointer
static void default_model_name(u8 model, u8 *name) {
*name++ = 'M';
......@@ -78,7 +93,6 @@ static void default_model_name(u8 model, u8 *name) {
// set model configuration to default
void config_model_set_default(void) {
cm.channels = 3;
default_model_name(cg.model, cm.name);
cm.reverse = 0;
memset(cm.subtrim, 0, MAX_CHANNELS);
......@@ -92,6 +106,7 @@ void config_model_set_default(void) {
cm.expo_forward = 0;
cm.expo_back = 0;
cm.abs_type = 0;
memcpy(&cm.key_mapping, &default_key_mapping, sizeof(config_key_mapping_s));
}
......@@ -108,7 +123,7 @@ void config_model_read(void) {
// return model name for given model number
u8 *config_model_name(u8 model) {
@near static u8 fake_name[3];
u8 *addr = EEPROM_CONFIG_MODEL + 1 + sizeof(config_model_s) * model;
u8 *addr = EEPROM_CONFIG_MODEL + sizeof(config_model_s) * model;
if (*addr == CONFIG_MODEL_EMPTY) {
default_model_name(model, fake_name);
addr = fake_name;
......
......@@ -30,8 +30,8 @@
// change MAGIC number when changing global config
// also add code to setting default values
// 29 bytes
#define CONFIG_GLOBAL_MAGIC 0xfd02
// 28 bytes
#define CONFIG_GLOBAL_MAGIC 0xfc03
typedef struct {
u8 steering_dead_zone;
u8 throttle_dead_zone;
......@@ -47,11 +47,9 @@ typedef struct {
u8 model; // selected model
u16 battery_calib; // raw ADC value for 10 Volts
u8 battery_low; // low battery threshold in .1 Volts
u8 trim_step;
u8 endpoint_max;
u8 autorepeat; // at what TRIM+DR is autorepeat on
u16 inactivity_alarm; // time (sec) of inactivity warning
u8 key_beep:1;
u8 ch3_momentary:1;
} config_global_s;
extern config_global_s config_global;
......@@ -97,10 +95,9 @@ typedef struct {
// change MAGIC number when changing model config
// also add code to setting default values
// 14 + channels * 3 bytes
#define CONFIG_MODEL_MAGIC (0xff20 | (MAX_CHANNELS - 1))
// 13 + 13 + channels * 3 bytes
#define CONFIG_MODEL_MAGIC (0xfe20 | (MAX_CHANNELS - 1))
typedef struct {
u8 channels; // number of channels for this model
u8 name[3];
u8 reverse; // bit for each channel
s8 subtrim[MAX_CHANNELS];
......@@ -109,8 +106,8 @@ typedef struct {
u8 dualrate[3]; // for steering and throttle
s8 expo[3]; // steering/forward/back
u8 abs_type;
config_key_mapping_s key_mapping;
} config_model_s;
extern config_key_mapping_s config_key_mapping; // XXX temporary
extern config_model_s config_model;
#define cm config_model
......@@ -121,8 +118,7 @@ extern config_model_s config_model;
#define expo_forward expo[1]
#define expo_back expo[2]
#define ck config_key_mapping
//#define ck cm.key_mapping
#define ck cm.key_mapping
......
......@@ -34,7 +34,7 @@
// maximum number of channels
#ifndef MAX_CHANNELS
#define MAX_CHANNELS 3
#define MAX_CHANNELS 6
#endif
......
......@@ -93,7 +93,6 @@ void menu_load_model(void) {
// apply global setting to variables
void apply_global_config(void) {
button_autorepeat(cg.autorepeat);
backlight_set_default(cg.backlight_time);
backlight_on();
// compute raw value for battery low voltage
......@@ -839,6 +838,8 @@ static void menu_key_mapping(void) {
lcd_set_blink(LMENU, LB_SPC);
lcd_segment(LS_SYM_MODELNO, LS_OFF);
lcd_segment(LS_SYM_LEFT, LS_OFF);
lcd_segment(LS_SYM_RIGHT, LS_OFF);
lcd_7seg(key_ids[0]);
lcd_set_blink(L7SEG, LB_SPC);
km_trim_key(0, 1, 0); // show first setting for first trim
......
......@@ -126,20 +126,6 @@ static void gs_battery_low(u8 change) {
}
static void gs_trim_step(u8 change) {
u8 *addr = &cg.trim_step;
if (change == 0xff) {
lcd_segment(LS_MENU_TRIM, LS_OFF);
lcd_set(L7SEG, LB_EMPTY);
return;
}
if (change) *addr = (u8)menu_change_val(*addr, 1, 20, 2, 0);
lcd_segment(LS_MENU_TRIM, LS_ON);
lcd_7seg(5);
lcd_char_num3(*addr);
}
static void gs_endpoint_max(u8 change) {
u8 *addr = &cg.endpoint_max;
if (change == 0xff) {
......@@ -172,18 +158,6 @@ static void gs_key_beep(u8 change) {
}
static void gs_ch3_momentary(u8 change) {
if (change == 0xff) {
lcd_set(L7SEG, LB_EMPTY);
return;
}
if (change) cg.ch3_momentary ^= 1;
lcd_7seg(3);
if (cg.ch3_momentary) lcd_chars("ON ");
else lcd_chars("OFF");
}
static void gs_steering_dead(u8 change) {
u8 *addr = &cg.steering_dead_zone;
if (change == 0xff) {
......@@ -208,42 +182,6 @@ static void gs_throttle_dead(u8 change) {
}
static void gs_trim_autorepeat(u8 change) {
if (change == 0xff) {
lcd_segment(LS_MENU_TRIM, LS_OFF);
lcd_set(L7SEG, LB_EMPTY);
return;
}
if (change) {
if (cg.autorepeat & BTN_TRIM_LEFT)
cg.autorepeat &= (u8)(~BTN_TRIM_ALL);
else cg.autorepeat |= BTN_TRIM_ALL;
}
lcd_segment(LS_MENU_TRIM, LS_ON);
lcd_7seg(L7_A);
if (cg.autorepeat & BTN_TRIM_LEFT) lcd_chars("ON ");
else lcd_chars("OFF");
}
static void gs_dr_autorepeat(u8 change) {
if (change == 0xff) {
lcd_segment(LS_MENU_DR, LS_OFF);
lcd_set(L7SEG, LB_EMPTY);
return;
}
if (change) {
if (cg.autorepeat & BTN_DR_L)
cg.autorepeat &= (u8)(~BTN_DR_ALL);
else cg.autorepeat |= BTN_DR_ALL;
}
lcd_segment(LS_MENU_DR, LS_ON);
lcd_7seg(L7_A);
if (cg.autorepeat & BTN_DR_L) lcd_chars("ON ");
else lcd_chars("OFF");
}
static _Bool gs_reset_flag;
static void gs_reset_all(u8 change) {
if (change == 0xff) {
......@@ -291,13 +229,9 @@ static const global_setup_t gs_config[] = {
gs_backlight_time,
gs_battery_low,
gs_endpoint_max,
gs_trim_step,
gs_steering_dead,
gs_throttle_dead,
gs_ch3_momentary,
gs_key_beep,
gs_trim_autorepeat,
gs_dr_autorepeat,
gs_reset_all,
gs_reset_model_all,
};
......
......@@ -33,27 +33,6 @@
// XXX temporary, will be in model config, default button mappings
config_key_mapping_s config_key_mapping = {
{
{ 1, 0 },
{ 0, 0 },
{ 0, 0 }
},
{
{ 1, 0, 0, 0, 0 },
{ 2, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 0 },
{ 3, 0, 0, 1, 0 }
},
0,
0
};
// ********************* TRIMS ****************************
......@@ -109,30 +88,42 @@ static const et_functions_s et_functions[] = {
-EXPO_MAX, EXPO_MAX, 0, EXPO_FAST, NULL },
{ 13, "CH3", 0, EF_NONE, 3, &menu_channel3, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 17, "ST1", LM_TRIM, EF_BLINK, 1, &cm.subtrim[0], -SUBTRIM_MAX,
{ 19, "ST1", LM_TRIM, EF_BLINK, 1, &cm.subtrim[0], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
{ 18, "ST2", LM_TRIM, EF_BLINK, 2, &cm.subtrim[1], -SUBTRIM_MAX,
{ 20, "ST2", LM_TRIM, EF_BLINK, 2, &cm.subtrim[1], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
{ 19, "ST3", LM_TRIM, EF_BLINK, 3, &cm.subtrim[2], -SUBTRIM_MAX,
{ 21, "ST3", LM_TRIM, EF_BLINK, 3, &cm.subtrim[2], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#if MAX_CHANNELS >= 4
{ 14, "CH4", 0, EF_NONE, 4, &menu_channel4, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 20, "ST4", LM_TRIM, EF_BLINK, 4, &cm.subtrim[3], -SUBTRIM_MAX,
{ 22, "ST4", LM_TRIM, EF_BLINK, 4, &cm.subtrim[3], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#if MAX_CHANNELS >= 5
{ 15, "CH5", 0, EF_NONE, 5, &menu_channel5, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 21, "ST5", LM_TRIM, EF_BLINK, 5, &cm.subtrim[4], -SUBTRIM_MAX,
{ 23, "ST5", LM_TRIM, EF_BLINK, 5, &cm.subtrim[4], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#if MAX_CHANNELS >= 6
{ 16, "CH6", 0, EF_NONE, 6, &menu_channel6, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 22, "ST6", LM_TRIM, EF_BLINK, 6, &cm.subtrim[5], -SUBTRIM_MAX,
{ 24, "ST6", LM_TRIM, EF_BLINK, 6, &cm.subtrim[5], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#if MAX_CHANNELS >= 7
{ 17, "CH7", 0, EF_NONE, 7, &menu_channel7, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 25, "ST7", LM_TRIM, EF_BLINK, 7, &cm.subtrim[6], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#if MAX_CHANNELS >= 8
{ 18, "CH8", 0, EF_NONE, 8, &menu_channel8, -100, 100, 0, CHANNEL_FAST,
NULL },
{ 26, "ST8", LM_TRIM, EF_BLINK, 8, &cm.subtrim[7], -SUBTRIM_MAX,
SUBTRIM_MAX, 0, SUBTRIM_FAST, NULL },
#endif
#endif
#endif
#endif
#endif
};
#define ET_FUNCTIONS_SIZE (sizeof(et_functions) / sizeof(et_functions_s))
......@@ -396,6 +387,12 @@ static const key_functions_s key_functions[] = {
{ 3, "CH5", KF_2STATE, kf_channel, 5 },
#if MAX_CHANNELS >= 6
{ 4, "CH6", KF_2STATE, kf_channel, 6 },
#if MAX_CHANNELS >= 7
{ 5, "CH7", KF_2STATE, kf_channel, 7 },
#if MAX_CHANNELS >= 8
{ 6, "CH8", KF_2STATE, kf_channel, 8 },
#endif
#endif
#endif
#endif
#endif
......
......@@ -21,7 +21,7 @@
#define _VERSION_INCLUDED
#define VERSION "001"
#define VERSION "010"
#endif
......
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