Skip to content

Commit

Permalink
Merge pull request #4780 from tonhuisman/feature/SD-card-cs-pinselect…
Browse files Browse the repository at this point in the history
…-visible

[SD-Card] Show SD-card CS GPIO pin in pin-selection
  • Loading branch information
TD-er authored Aug 28, 2023
2 parents ab251b3 + a7ddcb3 commit 244ba6d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/src/Helpers/StringGenerator_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)

bool includeI2C = true;
bool includeSPI = true;
#if FEATURE_SD
bool includeSDCard = true;
#endif
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
// FIXME TD-er: Must check whether this can be a conflict.
bool includeSerial = false;
Expand Down Expand Up @@ -241,6 +244,11 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
case PinSelectPurpose::Generic_bidir:
case PinSelectPurpose::DAC:
break;
#if FEATURE_SD
case PinSelectPurpose::SD_Card:
includeSDCard = false;
break;
#endif
}

if (includeI2C && Settings.isI2C_pin(gpio)) {
Expand All @@ -265,6 +273,10 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
}
}

#if FEATURE_SD
if (Settings.Pin_sd_cs == gpio && includeSDCard) { return F("SD-Card CS"); }
#endif // if FEATURE_SD


#if FEATURE_ETHERNET

Expand Down
5 changes: 4 additions & 1 deletion src/src/Helpers/StringGenerator_GPIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ enum class PinSelectPurpose : uint8_t {
Ethernet,
Serial_input,
Serial_output,
DAC
DAC,
#if FEATURE_SD
SD_Card,
#endif

};

Expand Down
2 changes: 1 addition & 1 deletion src/src/WebServer/HardwarePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void handle_hardware() {

#if FEATURE_SD
addFormSubHeader(F("SD Card"));
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output(F("SD Card CS")), F("sd"), Settings.Pin_sd_cs);
addFormPinSelect(PinSelectPurpose::SD_Card, formatGpioName_output(F("SD Card CS")), F("sd"), Settings.Pin_sd_cs);
#endif // if FEATURE_SD

#if FEATURE_ETHERNET
Expand Down
17 changes: 17 additions & 0 deletions src/src/WebServer/Markup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
#if FEATURE_ETHERNET
bool includeEthernet = true;
#endif // if FEATURE_ETHERNET
#if FEATURE_SD
bool includeSDCard = true;
#endif // if FEATURE_SD

switch (purpose) {
case PinSelectPurpose::SPI:
Expand Down Expand Up @@ -341,6 +344,14 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
return;
}
break;
#if FEATURE_SD
case PinSelectPurpose::SD_Card:
includeSDCard = false;
if (!output) {
return;
}
break;
#endif
}

if (includeI2C && Settings.isI2C_pin(gpio)) {
Expand All @@ -361,6 +372,12 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
disabled = true;
}
#endif // if FEATURE_ETHERNET

#if FEATURE_SD
if (includeSDCard && (Settings.Pin_sd_cs == gpio)) {
disabled = true;
}
#endif
}
}

Expand Down

0 comments on commit 244ba6d

Please sign in to comment.