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

add BRK button function to override throttle and apply full brake

parent 616d74d5
......@@ -4,6 +4,7 @@
model, less channels means less delay
poweron warn when not-centered now has separate global option
added up/down timers with throttle trigger start
added BRK button function to override throttle and apply full brake
*0.4.2 (13 Apr 2012)
added global setting to disable center/reset value beep
......
......@@ -341,5 +341,6 @@ T1S - start/pause timer1
T1R - stop + reset timer1
T2S - start/pause timer2
T2R - stop + reset timer2
BRK - switch on full brake, this overrides throttle position
BLS - battery low shutup, stop beeping, predefined to END-long
......@@ -344,11 +344,14 @@ static void calc_loop(void) {
// throttle
val = channel_calib(adc_throttle,
cg.calib_throttle_fwd << ADC_OVS_SHIFT,
cg.calib_throttle_mid << ADC_OVS_SHIFT,
cg.calib_throttle_bck << ADC_OVS_SHIFT,
cg.throttle_dead_zone << ADC_OVS_SHIFT);
if (menu_brake)
val = PPM(500); // brake button overrides throttle
else
val = channel_calib(adc_throttle,
cg.calib_throttle_fwd << ADC_OVS_SHIFT,
cg.calib_throttle_mid << ADC_OVS_SHIFT,
cg.calib_throttle_bck << ADC_OVS_SHIFT,
cg.throttle_dead_zone << ADC_OVS_SHIFT);
if (cm.brake_off && val > 0) val = 0; // throttle brake cut off
val = expo(val, (u8)(val < 0 ? cm.expo_forward : cm.expo_back));
if (cm.abs_type) {
......
......@@ -67,6 +67,7 @@ extern s8 menu_4WS_mix; // mix -100..100
extern _Bool menu_4WS_crab; // when 1, crab steering
extern s8 menu_DIG_mix; // mix -100..100
extern u8 menu_MP_index; // index of MultiPosition channel
extern _Bool menu_brake; // when 1, full brake is applied
......
......@@ -38,6 +38,7 @@ s8 menu_4WS_mix; // mix -100..100
_Bool menu_4WS_crab; // when 1, crab steering
s8 menu_DIG_mix; // mix -100..100
u8 menu_MP_index; // index of MultiPosition channel
_Bool menu_brake; // when 1, full brake is applied
......@@ -92,6 +93,7 @@ void menu_load_model(void) {
menu_MP_index = 0;
if (cm.channel_MP)
menu_channel3_8[cm.channel_MP - 3] = cm.multi_position[0];
menu_brake = 0;
// set state of buttons to do initialize
menu_buttons_initialize();
......
......@@ -738,13 +738,26 @@ static void kf_battery_low_shutup(u8 *id, u8 *param, u8 flags, s16 *pv) {
buzzer_off();
}
// change menu_brake bit
static void kf_brake(u8 *id, u8 *param, u8 flags, s16 *prev_val) {
if (flags & FF_ON)
menu_brake = (u8)(flags & FF_REVERSE ? 0 : 1);
else
menu_brake = (u8)(flags & FF_REVERSE ? 1 : 0);
if (flags & FF_SHOW) {
lcd_7seg(L7_B);
lcd_chars(menu_brake ? "BRK" : "OFF");
}
}
// table of key functions
static const key_functions_s key_functions[] = {
{ 0, "OFF", KF_NONE, NULL, NULL, 0 },
{ 22, "BLS", KF_NOSHOW, kf_battery_low_shutup, NULL, 0 }, // default END-long
{ 23, "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
......@@ -776,6 +789,7 @@ static const key_functions_s key_functions[] = {
{ 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 },
};
#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