fix native compilation for linux PCs

This commit is contained in:
mverch67 2024-05-15 08:10:52 +02:00
parent 5da798c625
commit 49a9aa3e36

View File

@ -283,7 +283,7 @@ void portduinoSetup()
} }
for (configNames i : GPIO_lines) { for (configNames i : GPIO_lines) {
if (settingsMap[i] > max_GPIO) if (settingsMap.count(i) && settingsMap[i] > max_GPIO)
max_GPIO = settingsMap[i]; max_GPIO = settingsMap[i];
} }
@ -342,6 +342,7 @@ void portduinoSetup()
if (settingsMap[touchscreenIRQ] > 0) if (settingsMap[touchscreenIRQ] > 0)
initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName); initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName);
} }
if (settingsStrings[spidev] != "") { if (settingsStrings[spidev] != "") {
SPI.begin(settingsStrings[spidev].c_str()); SPI.begin(settingsStrings[spidev].c_str());
} }
@ -350,6 +351,7 @@ void portduinoSetup()
int initGPIOPin(int pinNum, const std::string gpioChipName) int initGPIOPin(int pinNum, const std::string gpioChipName)
{ {
#ifdef PORTDUINO_LINUX_HARDWARE
std::string gpio_name = "GPIO" + std::to_string(pinNum); std::string gpio_name = "GPIO" + std::to_string(pinNum);
try { try {
GPIOPin *csPin; GPIOPin *csPin;
@ -362,4 +364,7 @@ int initGPIOPin(int pinNum, const std::string gpioChipName)
std::cout << "Warning, cannot claim pin " << gpio_name << (p ? p.__cxa_exception_type()->name() : "null") << std::endl; std::cout << "Warning, cannot claim pin " << gpio_name << (p ? p.__cxa_exception_type()->name() : "null") << std::endl;
return ERRNO_DISABLED; return ERRNO_DISABLED;
} }
#else
return ERRNO_OK;
#endif
} }