Skip to content

Commit 244ba6d

Browse files
authored
Merge pull request #4780 from tonhuisman/feature/SD-card-cs-pinselect-visible
[SD-Card] Show SD-card CS GPIO pin in pin-selection
2 parents ab251b3 + a7ddcb3 commit 244ba6d

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

src/src/Helpers/StringGenerator_GPIO.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
207207

208208
bool includeI2C = true;
209209
bool includeSPI = true;
210+
#if FEATURE_SD
211+
bool includeSDCard = true;
212+
#endif
210213
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
211214
// FIXME TD-er: Must check whether this can be a conflict.
212215
bool includeSerial = false;
@@ -241,6 +244,11 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
241244
case PinSelectPurpose::Generic_bidir:
242245
case PinSelectPurpose::DAC:
243246
break;
247+
#if FEATURE_SD
248+
case PinSelectPurpose::SD_Card:
249+
includeSDCard = false;
250+
break;
251+
#endif
244252
}
245253

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

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

269281
#if FEATURE_ETHERNET
270282

src/src/Helpers/StringGenerator_GPIO.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ enum class PinSelectPurpose : uint8_t {
2727
Ethernet,
2828
Serial_input,
2929
Serial_output,
30-
DAC
30+
DAC,
31+
#if FEATURE_SD
32+
SD_Card,
33+
#endif
3134

3235
};
3336

src/src/WebServer/HardwarePage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void handle_hardware() {
227227

228228
#if FEATURE_SD
229229
addFormSubHeader(F("SD Card"));
230-
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output(F("SD Card CS")), F("sd"), Settings.Pin_sd_cs);
230+
addFormPinSelect(PinSelectPurpose::SD_Card, formatGpioName_output(F("SD Card CS")), F("sd"), Settings.Pin_sd_cs);
231231
#endif // if FEATURE_SD
232232

233233
#if FEATURE_ETHERNET

src/src/WebServer/Markup.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
280280
#if FEATURE_ETHERNET
281281
bool includeEthernet = true;
282282
#endif // if FEATURE_ETHERNET
283+
#if FEATURE_SD
284+
bool includeSDCard = true;
285+
#endif // if FEATURE_SD
283286

284287
switch (purpose) {
285288
case PinSelectPurpose::SPI:
@@ -341,6 +344,14 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
341344
return;
342345
}
343346
break;
347+
#if FEATURE_SD
348+
case PinSelectPurpose::SD_Card:
349+
includeSDCard = false;
350+
if (!output) {
351+
return;
352+
}
353+
break;
354+
#endif
344355
}
345356

346357
if (includeI2C && Settings.isI2C_pin(gpio)) {
@@ -361,6 +372,12 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
361372
disabled = true;
362373
}
363374
#endif // if FEATURE_ETHERNET
375+
376+
#if FEATURE_SD
377+
if (includeSDCard && (Settings.Pin_sd_cs == gpio)) {
378+
disabled = true;
379+
}
380+
#endif
364381
}
365382
}
366383

0 commit comments

Comments
 (0)