Adding the ability to set default configuration for specific hardware such as a 16mhz crystal for the Lilygo T-2CAN

This commit is contained in:
Matt Holmes 2025-08-22 20:25:12 +01:00
parent 4e0ea84fad
commit 588c78f1d6
3 changed files with 12 additions and 0 deletions

View file

@ -33,6 +33,8 @@ void init_stored_settings() {
settings.putBool("EQUIPMENT_STOP", datalayer.system.settings.equipment_stop_active);
#endif // LOAD_SAVED_SETTINGS_ON_BOOT
esp32hal->set_default_configuration_values();
char tempSSIDstring[63]; // Allocate buffer with sufficient size
size_t lengthSSID = settings.getString("SSID", tempSSIDstring, sizeof(tempSSIDstring));
if (lengthSSID > 0) { // Successfully read the string from memory. Set it to SSID!

View file

@ -7,6 +7,7 @@
#include "../../../src/devboard/utils/events.h"
#include "../../../src/devboard/utils/logging.h"
#include "../../../src/devboard/utils/types.h"
#include <src/communication/nvm/comm_nvm.h>
// Hardware Abstraction Layer base class.
// Derive a class to define board-specific parameters such as GPIO pin numbers
@ -24,6 +25,8 @@ class Esp32Hal {
virtual int MODBUS_CORE() { return 0; }
virtual int WIFICORE() { return 0; }
virtual void set_default_configuration_values(){}
template <typename... Pins>
bool alloc_pins(const char* name, Pins... pins) {
std::vector<gpio_num_t> requested_pins = {static_cast<gpio_num_t>(pins)...};

View file

@ -7,6 +7,13 @@ class LilyGo2CANHal : public Esp32Hal {
public:
const char* name() { return "LilyGo T_2CAN"; }
virtual void set_default_configuration_values() {
BatteryEmulatorSettingsStore settings;
if(!settings.settingExists("CANFREQ")){
settings.saveUInt("CANFREQ", 16);
}
}
virtual gpio_num_t CAN_TX_PIN() { return GPIO_NUM_7; }
virtual gpio_num_t CAN_RX_PIN() { return GPIO_NUM_6; }