mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-01 10:19:59 +00:00
Move native to spi_host to indicate spidev for LovyanGFX
This commit is contained in:
parent
5095efc55f
commit
45c1b46bd0
@ -24,7 +24,7 @@ lib_deps =
|
|||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
${networking_base.lib_deps}
|
${networking_base.lib_deps}
|
||||||
rweather/Crypto@^0.4.0
|
rweather/Crypto@^0.4.0
|
||||||
https://github.com/lovyan03/LovyanGFX.git#d35e60f269dfecbb18a8cb0fd07d594c2fb7e7a8
|
https://github.com/lovyan03/LovyanGFX.git#5a39989aa2c9492572255b22f033843ec8900233
|
||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${arduino_base.build_flags}
|
${arduino_base.build_flags}
|
||||||
|
@ -356,7 +356,7 @@ class LGFX : public lgfx::LGFX_Device
|
|||||||
_panel_instance = new lgfx::Panel_ILI9341;
|
_panel_instance = new lgfx::Panel_ILI9341;
|
||||||
auto buscfg = _bus_instance.config();
|
auto buscfg = _bus_instance.config();
|
||||||
buscfg.spi_mode = 0;
|
buscfg.spi_mode = 0;
|
||||||
_bus_instance.spi_device(DisplaySPI);
|
buscfg.spi_host = settingsMap[displayspidev];
|
||||||
|
|
||||||
buscfg.pin_dc = settingsMap[displayDC]; // Set SPI DC pin number (-1 = disable)
|
buscfg.pin_dc = settingsMap[displayDC]; // Set SPI DC pin number (-1 = disable)
|
||||||
|
|
||||||
@ -397,6 +397,8 @@ class LGFX : public lgfx::LGFX_Device
|
|||||||
touch_cfg.offset_rotation = 1;
|
touch_cfg.offset_rotation = 1;
|
||||||
if (settingsMap[touchscreenI2CAddr] != -1) {
|
if (settingsMap[touchscreenI2CAddr] != -1) {
|
||||||
touch_cfg.i2c_addr = settingsMap[touchscreenI2CAddr];
|
touch_cfg.i2c_addr = settingsMap[touchscreenI2CAddr];
|
||||||
|
} else {
|
||||||
|
touch_cfg.spi_host = settingsMap[touchscreenspidev];
|
||||||
}
|
}
|
||||||
|
|
||||||
_touch_instance->config(touch_cfg);
|
_touch_instance->config(touch_cfg);
|
||||||
|
@ -729,7 +729,7 @@ void setup()
|
|||||||
if (settingsMap[use_sx1262]) {
|
if (settingsMap[use_sx1262]) {
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||||
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
settingsMap[busy]);
|
settingsMap[busy]);
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
@ -743,7 +743,7 @@ void setup()
|
|||||||
} else if (settingsMap[use_rf95]) {
|
} else if (settingsMap[use_rf95]) {
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||||
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
settingsMap[busy]);
|
settingsMap[busy]);
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
@ -758,7 +758,7 @@ void setup()
|
|||||||
} else if (settingsMap[use_sx1280]) {
|
} else if (settingsMap[use_sx1280]) {
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||||
rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
settingsMap[busy]);
|
settingsMap[busy]);
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
@ -773,7 +773,7 @@ void setup()
|
|||||||
} else if (settingsMap[use_sx1268]) {
|
} else if (settingsMap[use_sx1268]) {
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
LOG_DEBUG("Attempting to activate sx1268 radio on SPI port %s\n", settingsStrings[spidev].c_str());
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(*LoraSPI, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||||
rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
rIf = new SX1268Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
settingsMap[busy]);
|
settingsMap[busy]);
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
HardwareSPI *DisplaySPI;
|
|
||||||
HardwareSPI *LoraSPI;
|
|
||||||
std::map<configNames, int> settingsMap;
|
std::map<configNames, int> settingsMap;
|
||||||
std::map<configNames, std::string> settingsStrings;
|
std::map<configNames, std::string> settingsStrings;
|
||||||
char *configPath = nullptr;
|
char *configPath = nullptr;
|
||||||
@ -173,6 +171,15 @@ void portduinoSetup()
|
|||||||
gpioChipName += std::to_string(settingsMap[gpiochip]);
|
gpioChipName += std::to_string(settingsMap[gpiochip]);
|
||||||
|
|
||||||
settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as<std::string>("spidev0.0");
|
settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as<std::string>("spidev0.0");
|
||||||
|
if (settingsStrings[spidev].length() == 14) {
|
||||||
|
int x = settingsStrings[spidev].at(11) - '0';
|
||||||
|
int y = settingsStrings[spidev].at(13) - '0';
|
||||||
|
if (x >= 0 && x < 10 && y >= 0 && y < 10) {
|
||||||
|
settingsMap[spidev] = x + y << 4;
|
||||||
|
settingsMap[displayspidev] = settingsMap[spidev];
|
||||||
|
settingsMap[touchscreenspidev] = settingsMap[spidev];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (yamlConfig["GPIO"]) {
|
if (yamlConfig["GPIO"]) {
|
||||||
settingsMap[user] = yamlConfig["GPIO"]["User"].as<int>(RADIOLIB_NC);
|
settingsMap[user] = yamlConfig["GPIO"]["User"].as<int>(RADIOLIB_NC);
|
||||||
@ -222,6 +229,14 @@ void portduinoSetup()
|
|||||||
settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as<int>(40000000);
|
settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as<int>(40000000);
|
||||||
if (yamlConfig["Display"]["spidev"]) {
|
if (yamlConfig["Display"]["spidev"]) {
|
||||||
settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as<std::string>("spidev0.1");
|
settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as<std::string>("spidev0.1");
|
||||||
|
if (settingsStrings[displayspidev].length() == 14) {
|
||||||
|
int x = settingsStrings[displayspidev].at(11) - '0';
|
||||||
|
int y = settingsStrings[displayspidev].at(13) - '0';
|
||||||
|
if (x >= 0 && x < 10 && y >= 0 && y < 10) {
|
||||||
|
settingsMap[displayspidev] = x + y << 4;
|
||||||
|
settingsMap[touchscreenspidev] = settingsMap[displayspidev];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settingsMap[touchscreenModule] = no_touchscreen;
|
settingsMap[touchscreenModule] = no_touchscreen;
|
||||||
@ -241,6 +256,13 @@ void portduinoSetup()
|
|||||||
settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as<int>(-1);
|
settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as<int>(-1);
|
||||||
if (yamlConfig["Touchscreen"]["spidev"]) {
|
if (yamlConfig["Touchscreen"]["spidev"]) {
|
||||||
settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as<std::string>("");
|
settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as<std::string>("");
|
||||||
|
if (settingsStrings[touchscreenspidev].length() == 14) {
|
||||||
|
int x = settingsStrings[touchscreenspidev].at(11) - '0';
|
||||||
|
int y = settingsStrings[touchscreenspidev].at(13) - '0';
|
||||||
|
if (x >= 0 && x < 10 && y >= 0 && y < 10) {
|
||||||
|
settingsMap[touchscreenspidev] = x + y << 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (yamlConfig["Input"]) {
|
if (yamlConfig["Input"]) {
|
||||||
@ -319,27 +341,9 @@ void portduinoSetup()
|
|||||||
if (settingsMap[touchscreenIRQ] > 0)
|
if (settingsMap[touchscreenIRQ] > 0)
|
||||||
initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName);
|
initGPIOPin(settingsMap[touchscreenIRQ], gpioChipName);
|
||||||
}
|
}
|
||||||
|
if (settingsStrings[spidev] != "") {
|
||||||
// if we specify a touchscreen dev, that is SPI.
|
|
||||||
// else if we specify a screen dev, that is SPI
|
|
||||||
// else if we specify a LoRa dev, that is SPI.
|
|
||||||
if (settingsStrings[touchscreenspidev] != "") {
|
|
||||||
SPI.begin(settingsStrings[touchscreenspidev].c_str());
|
|
||||||
DisplaySPI = new HardwareSPI;
|
|
||||||
DisplaySPI->begin(settingsStrings[displayspidev].c_str());
|
|
||||||
LoraSPI = new HardwareSPI;
|
|
||||||
LoraSPI->begin(settingsStrings[spidev].c_str());
|
|
||||||
} else if (settingsStrings[displayspidev] != "") {
|
|
||||||
SPI.begin(settingsStrings[displayspidev].c_str());
|
|
||||||
DisplaySPI = &SPI;
|
|
||||||
LoraSPI = new HardwareSPI;
|
|
||||||
LoraSPI->begin(settingsStrings[spidev].c_str());
|
|
||||||
} else {
|
|
||||||
SPI.begin(settingsStrings[spidev].c_str());
|
SPI.begin(settingsStrings[spidev].c_str());
|
||||||
LoraSPI = &SPI;
|
|
||||||
DisplaySPI = &SPI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,4 @@ enum { level_error, level_warn, level_info, level_debug };
|
|||||||
|
|
||||||
extern std::map<configNames, int> settingsMap;
|
extern std::map<configNames, int> settingsMap;
|
||||||
extern std::map<configNames, std::string> settingsStrings;
|
extern std::map<configNames, std::string> settingsStrings;
|
||||||
int initGPIOPin(int pinNum, std::string gpioChipname);
|
int initGPIOPin(int pinNum, std::string gpioChipname);
|
||||||
extern HardwareSPI *DisplaySPI;
|
|
||||||
extern HardwareSPI *LoraSPI;
|
|
Loading…
Reference in New Issue
Block a user