Added hbrake timeout and adjustable brake force
This commit is contained in:
@@ -6,9 +6,11 @@ using namespace logic;
|
||||
|
||||
/**** Private definitions ****/
|
||||
/**** Private constants ****/
|
||||
static const uint16_t def_max_hbrake_time = 1000;
|
||||
static const uint16_t def_brake_force = 100;
|
||||
|
||||
/**** Private variables ****/
|
||||
/**** Private function declarations ****/
|
||||
|
||||
/**** Public function definitions ****/
|
||||
logic::DccdForce::DccdForce(hw::Button* btn_mode, hw::Button* sw_hbrake, hw::Button* sw_brakes)
|
||||
{
|
||||
@@ -19,6 +21,9 @@ logic::DccdForce::DccdForce(hw::Button* btn_mode, hw::Button* sw_hbrake, hw::But
|
||||
this->is_new = 0;
|
||||
this->force = 0;
|
||||
this->brake_mode = 0;
|
||||
|
||||
this->max_hbrake_time = def_max_hbrake_time;
|
||||
this->brake_force = def_brake_force;
|
||||
}
|
||||
|
||||
logic::DccdForce::~DccdForce(void)
|
||||
@@ -50,7 +55,7 @@ uint8_t logic::DccdForce::update(uint8_t user_force)
|
||||
|
||||
// Determine target force source
|
||||
uint8_t next_force = user_force;
|
||||
if(this->handbrake->state == hw::BUTTON_ON)
|
||||
if((this->handbrake->state == hw::BUTTON_ON)&&(this->handbrake->time < this->max_hbrake_time))
|
||||
{
|
||||
next_force = 0;
|
||||
}
|
||||
@@ -65,7 +70,7 @@ uint8_t logic::DccdForce::update(uint8_t user_force)
|
||||
next_force = user_force;
|
||||
|
||||
default:
|
||||
next_force = 100;
|
||||
next_force = this->brake_force;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ class DccdForce
|
||||
uint8_t brake_mode;
|
||||
uint8_t is_new_bmode;
|
||||
|
||||
uint16_t max_hbrake_time;
|
||||
uint8_t brake_force;
|
||||
|
||||
uint8_t update(uint8_t user_force);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
static const uint16_t dsp_lock_bmode = 1000;
|
||||
static const uint16_t dsp_lock_force = 50;
|
||||
|
||||
static const uint16_t cfg_max_hbrake_time = 1000;
|
||||
static const uint8_t cfg_brake_force = 100;
|
||||
|
||||
/**** Private variables ****/
|
||||
static logic::CfgMemory cfg_mem = logic::CfgMemory();
|
||||
|
||||
@@ -35,6 +38,8 @@ int main(void)
|
||||
|
||||
button_force.force = cfg_mem.btn_force;
|
||||
dccd_force.brake_mode = cfg_mem.bmode;
|
||||
dccd_force.max_hbrake_time = cfg_max_hbrake_time;
|
||||
dccd_force.brake_force = cfg_brake_force;
|
||||
|
||||
// Super loop
|
||||
while(1)
|
||||
|
||||
Reference in New Issue
Block a user