Added dccd logic config

This commit is contained in:
2024-04-13 12:28:47 +03:00
parent a3d4ffd548
commit c3bc42fa18
2 changed files with 60 additions and 16 deletions

View File

@@ -6,20 +6,26 @@ using namespace logic;
/**** Private definitions ****/ /**** Private definitions ****/
/**** Private constants ****/ /**** Private constants ****/
static const uint16_t addr_btn_force = 0x0000; static const uint16_t addr_btn_force = 0x0000;
static const uint16_t addr_bmode = 0x0001; static const uint16_t addr_bmode = 0x0001;
static const uint16_t addr_pot_mode = 0x0002; static const uint16_t addr_pot_mode = 0x0002;
static const uint16_t addr_dsp_brigth = 0x0003; static const uint16_t addr_dsp_brigth = 0x0003;
static const uint16_t addr_dsp_dimm = 0x0004; static const uint16_t addr_dsp_dimm = 0x0004;
static const uint16_t addr_lock_current = 0x0005; static const uint16_t addr_brake_force = 0x0005;
static const uint16_t addr_max_hbrake_time = 0x0006;
static const uint16_t addr_lock_current = 0x0008;
static const uint8_t def_btn_force = 0; static const uint8_t def_btn_force = 0;
static const uint8_t def_pot_mode = 0; static const uint8_t def_pot_mode = 0;
static const uint8_t def_bmode = 0; static const uint8_t def_bmode = 0;
static const uint8_t def_dimm = 50; static const uint8_t def_dimm = 50;
static const uint8_t def_brigth = 100; static const uint8_t def_brigth = 100;
static const uint8_t def_brake_force = 100;
static const uint16_t def_max_hbrake_time = 1000;
static const uint16_t def_lock_current = 4500; static const uint16_t def_lock_current = 4500;
static const uint16_t max_lock_current = 6000;
/**** Private variables ****/ /**** Private variables ****/
/**** Private function declarations ****/ /**** Private function declarations ****/
/**** Public function definitions ****/ /**** Public function definitions ****/
@@ -30,7 +36,9 @@ logic::CfgMemory::CfgMemory(void)
this->mem_pot_mode = 0; this->mem_pot_mode = 0;
this->mem_dsp_brigth = 0; this->mem_dsp_brigth = 0;
this->mem_dsp_dimm = 0; this->mem_dsp_dimm = 0;
this->mem_lock_current = 0; this->mem_brake_force = 0;
this->mem_max_hbrake_time = 0;
this->mem_lock_current = 0;
this->restore(); this->restore();
} }
@@ -42,13 +50,16 @@ logic::CfgMemory::~CfgMemory(void)
void logic::CfgMemory::init(void) void logic::CfgMemory::init(void)
{ {
this->mem_btn_force = mcu::eeprom_read8b(addr_btn_force); this->mem_btn_force = mcu::eeprom_read8b(addr_btn_force);
this->mem_bmode = mcu::eeprom_read8b(addr_bmode); this->mem_bmode = mcu::eeprom_read8b(addr_bmode);
this->mem_pot_mode = mcu::eeprom_read8b(addr_pot_mode); this->mem_pot_mode = mcu::eeprom_read8b(addr_pot_mode);
this->mem_dsp_brigth = mcu::eeprom_read8b(addr_dsp_brigth); this->mem_dsp_brigth = mcu::eeprom_read8b(addr_dsp_brigth);
this->mem_dsp_dimm = mcu::eeprom_read8b(addr_dsp_dimm); this->mem_dsp_dimm = mcu::eeprom_read8b(addr_dsp_dimm);
this->mem_lock_current = mcu::eeprom_read16b(addr_lock_current); this->mem_brake_force = mcu::eeprom_read8b(addr_brake_force);
this->mem_max_hbrake_time = mcu::eeprom_read16b(addr_max_hbrake_time);
this->mem_lock_current = mcu::eeprom_read16b(addr_lock_current);
// Validate EEPROM data
if(this->mem_btn_force > 100) if(this->mem_btn_force > 100)
{ {
this->mem_btn_force = def_btn_force; this->mem_btn_force = def_btn_force;
@@ -79,7 +90,22 @@ void logic::CfgMemory::init(void)
mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm); mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm);
}; };
if(this->mem_lock_current > 6000) if(this->mem_brake_force > 100)
{
this->mem_brake_force = def_brake_force;
mcu::eeprom_write8b(addr_brake_force, this->mem_brake_force);
};
/*
No wrong value
if(this->mem_max_hbrake_time > 1000)
{
this->mem_max_hbrake_time = def_max_hbrake_time;
mcu::eeprom_write16b(addr_lock_current, this->mem_max_hbrake_time);
};
*/
if(this->mem_lock_current > max_lock_current)
{ {
this->mem_lock_current = def_lock_current; this->mem_lock_current = def_lock_current;
mcu::eeprom_write16b(addr_lock_current, this->mem_lock_current); mcu::eeprom_write16b(addr_lock_current, this->mem_lock_current);
@@ -125,10 +151,22 @@ void logic::CfgMemory::save_all(void)
mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm); mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm);
}; };
if(this->brake_force != this->mem_brake_force)
{
this->mem_brake_force = this->brake_force;
mcu::eeprom_write8b(addr_brake_force, this->mem_brake_force);
};
if(this->max_hbrake_time != this->mem_max_hbrake_time)
{
this->mem_max_hbrake_time = this->max_hbrake_time;
mcu::eeprom_write16b(addr_max_hbrake_time, this->mem_max_hbrake_time);
};
if(this->lock_current != this->mem_lock_current) if(this->lock_current != this->mem_lock_current)
{ {
this->mem_lock_current = this->lock_current; this->mem_lock_current = this->lock_current;
mcu::eeprom_write8b(addr_lock_current, this->mem_lock_current); mcu::eeprom_write16b(addr_lock_current, this->mem_lock_current);
}; };
} }
@@ -139,7 +177,9 @@ void logic::CfgMemory::restore(void)
this->pot_mode = this->mem_pot_mode; this->pot_mode = this->mem_pot_mode;
this->dsp_brigth = this->mem_dsp_brigth; this->dsp_brigth = this->mem_dsp_brigth;
this->dsp_dimm = this->mem_dsp_dimm; this->dsp_dimm = this->mem_dsp_dimm;
this->lock_current = this->mem_lock_current; this->brake_force = this->mem_brake_force;
this->max_hbrake_time = this->mem_max_hbrake_time;
this->lock_current = this->mem_lock_current;
} }
/**** Private function definitions ****/ /**** Private function definitions ****/

View File

@@ -17,6 +17,8 @@ class CfgMemory
uint8_t mem_pot_mode; uint8_t mem_pot_mode;
uint8_t mem_dsp_brigth; uint8_t mem_dsp_brigth;
uint8_t mem_dsp_dimm; uint8_t mem_dsp_dimm;
uint8_t mem_brake_force;
uint16_t mem_max_hbrake_time;
uint16_t mem_lock_current; uint16_t mem_lock_current;
public: public:
@@ -28,6 +30,8 @@ class CfgMemory
uint8_t pot_mode; uint8_t pot_mode;
uint8_t dsp_brigth; uint8_t dsp_brigth;
uint8_t dsp_dimm; uint8_t dsp_dimm;
uint8_t brake_force;
uint16_t max_hbrake_time;
uint16_t lock_current; uint16_t lock_current;
void init(void); void init(void);