board profiles: pre-configured pin layouts #11

This commit is contained in:
proddy
2021-03-27 10:30:28 +01:00
parent 6d3feaf81c
commit cafc6103ea
7 changed files with 52 additions and 41 deletions

View File

@@ -230,11 +230,9 @@ void System::start(uint32_t heap_start) {
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
hostname(networkSettings.hostname.c_str());
LOG_INFO(F("System %s booted (EMS-ESP version %s)"), networkSettings.hostname.c_str(), EMSESP_APP_VERSION); // print boot message
LOG_INFO(F("System %s booted (EMS-ESP version %s) "), networkSettings.hostname.c_str(), EMSESP_APP_VERSION); // print boot message
});
LOG_INFO("Loaded Board profile: %s", board_profile_.c_str());
commands_init(); // console & api commands
led_init(false); // init LED
adc_init(false); // analog ADC
@@ -833,14 +831,12 @@ void System::console_commands(Shell & shell, unsigned int context) {
flash_string_vector{F_(set), F_(board_profile)},
flash_string_vector{F_(name_mandatory)},
[](Shell & shell, const std::vector<std::string> & arguments) {
// check for valid profile
std::vector<uint8_t> data; // led, dallas, rx, tx, button
std::string board_profile = Helpers::toUpper(arguments.front());
if (!load_board_profile(data, board_profile)) {
shell.println(F("Invalid board profile"));
return;
}
shell.printfln("Loaded board profile %s with %d,%d,%d,%d,%d", board_profile.c_str(), data[0], data[1], data[2], data[3], data[4]);
EMSESP::webSettingsService.update(
[&](WebSettings & settings) {
settings.board_profile = board_profile.c_str();
@@ -1040,6 +1036,7 @@ bool System::command_test(const char * value, const int8_t id) {
// takes a board profile and populates a data array with GPIO configurations
// data = led, dallas, rx, tx, button
// returns false if profile is not found, and uses default
bool System::load_board_profile(std::vector<uint8_t> & data, const std::string & board_profile) {
if (board_profile == "S32") {
data = {2, 3, 23, 5, 0}; // Gateway S32
@@ -1058,6 +1055,7 @@ bool System::load_board_profile(std::vector<uint8_t> & data, const std::string &
} else if (board_profile == "TLK110") {
data = {2, 4, 5, 17, 33}; // Ethernet (TLK110)
} else {
data = {EMSESP_DEFAULT_LED_GPIO, EMSESP_DEFAULT_DALLAS_GPIO, EMSESP_DEFAULT_RX_GPIO, EMSESP_DEFAULT_TX_GPIO, EMSESP_DEFAULT_PBUTTON_GPIO};
return false;
}