Skip to content

Commit

Permalink
ThingSet: Add xPresetLTO function and always return 1 on success
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjaeger committed Jul 23, 2024
1 parent 22f1e95 commit 754d407
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/data_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ THINGSET_ADD_FN_INT32(APP_ID_CONF, APP_ID_CONF_PRESET_LFP, "xPresetLFP", &bat_pr
THINGSET_ADD_ITEM_FLOAT(APP_ID_CONF_PRESET_LFP, APP_ID_CONF_PRESET_LFP_CAPACITY, "fCapacity_Ah",
&new_capacity, 1, THINGSET_ANY_RW, 0);

THINGSET_ADD_FN_INT32(APP_ID_CONF, APP_ID_CONF_PRESET_LTO, "xPresetLTO", &bat_preset_lto,
THINGSET_ANY_RW);
THINGSET_ADD_ITEM_FLOAT(APP_ID_CONF_PRESET_LTO, APP_ID_CONF_PRESET_LTO_CAPACITY, "fCapacity_Ah",
&new_capacity, 1, THINGSET_ANY_RW, 0);

// MEAS DATA ////////////////////////////////////////////////////////////

THINGSET_ADD_GROUP(TS_ID_ROOT, APP_ID_MEAS, "Meas", THINGSET_NO_CALLBACK);
Expand Down Expand Up @@ -280,7 +285,9 @@ int32_t bat_preset(enum bms_cell_type type)
}
#endif

return ret;
// Always return 1 in case of success, as the flags returned by bms_ic_configure can be
// confusing for end users in the App. Actually applied config can be retrieved via ThingSet.
return ret > 0 ? 1 : ret;
}

int32_t bat_preset_nmc()
Expand All @@ -293,6 +300,11 @@ int32_t bat_preset_lfp()
return bat_preset(CELL_TYPE_LFP);
}

int32_t bat_preset_lto()
{
return bat_preset(CELL_TYPE_LTO);
}

void print_registers()
{
bms_ic_debug_print_mem(bms.ic_dev);
Expand Down
7 changes: 7 additions & 0 deletions app/src/data_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#define APP_ID_CONF_PRESET_NMC_CAPACITY 0xA1
#define APP_ID_CONF_PRESET_LFP 0xA2
#define APP_ID_CONF_PRESET_LFP_CAPACITY 0xA3
#define APP_ID_CONF_PRESET_LTO 0xA4
#define APP_ID_CONF_PRESET_LTO_CAPACITY 0xA5
#define APP_ID_CONF_OCV_POINTS 0xB0
#define APP_ID_CONF_SOC_POINTS 0xB1

Expand Down Expand Up @@ -103,6 +105,11 @@ int32_t bat_preset_nmc();
*/
int32_t bat_preset_lfp();

/**
* Callback function to apply preset parameters for LTO type via ThingSet
*/
int32_t bat_preset_lto();

/**
* Callback to read and print common BMS registers via ThingSet
*/
Expand Down

0 comments on commit 754d407

Please sign in to comment.