Skip to content

Commit

Permalink
Update portduino test to use new SPI selection scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Apr 28, 2024
1 parent fe6a27d commit 6413ce7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/Test/build_test/platformio_native.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build_flags = -O0 -xc++ -std=c++14


[env:native-portduino]
platform = https://github.com/meshtastic/platform-native.git#659e49346aa33008b150dfb206b1817ddabc7132
platform = https://github.com/meshtastic/platform-native.git#2ef818943157a3ebea7cbbc283d124fb67c0ffc1
framework = arduino
board = cross_platform
;build_src_filter = +<**/*.cpp> -<main/>
Expand Down
6 changes: 4 additions & 2 deletions examples/Test/build_test/portduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ void setup()
initGPIOPin(25, "gpiochip4");
initGPIOPin(24, "gpiochip4");

DisplaySPI = new HardwareSPI;
DisplaySPI->begin("/dev/spidev0.0");
Wire.begin(1);
display = new LGFX();
display->init();
Expand All @@ -18,6 +16,10 @@ void setup()
canvas.setFont(&fonts::lgfxJapanMinchoP_32);
canvas.setTextWrap(false); // 右端到達時のカーソル折り返しを禁止
canvas.createSprite(display->width(), 36);
canvas.clear();
canvas.setCursor(0, 0);
canvas.printf("Touch to start\n");
canvas.pushSprite(display, 0, 0);
}


Expand Down
7 changes: 5 additions & 2 deletions examples/Test/build_test/portduino/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "PortduinoGPIO.h"
#include <iostream>

HardwareSPI *DisplaySPI;
int initGPIOPin(int pinNum, std::string gpioChipName);

class LGFX : public lgfx::LGFX_Device
Expand All @@ -25,7 +24,11 @@ class LGFX : public lgfx::LGFX_Device
auto buscfg = _bus_instance.config();
buscfg.spi_mode = 0;
buscfg.pin_dc = 25;
_bus_instance.spi_device(DisplaySPI);

// to use spidevX.Y
int x = 0;
int y = 0;
buscfg.spi_host = x + y << 4;
_bus_instance.config(buscfg); // applies the set value to the bus.
_panel_instance.setBus(&_bus_instance); // set the bus on the panel.
}
Expand Down

0 comments on commit 6413ce7

Please sign in to comment.