Skip to content

Commit

Permalink
added portduino to CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Apr 24, 2024
1 parent a4960a3 commit 31139c0
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/PlatformioBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
- { board: seeed_wio_terminal, platform-version: default, ... }
- { board: adafruit_pybadge_m4, platform-version: default, ... }
- { board: pico, platform-version: default, ... }
- { board: native, platform-version: portduino, ... }

fail-fast: false

Expand Down Expand Up @@ -101,4 +102,6 @@ jobs:
export pio_ver=${{ matrix.platform-version }}
export pio_env="${pio_ver//./_}"
pio pkg install -e ${{ matrix.board }}-$pio_env --no-save --library file://$(realpath ../../../)
[[ "$pio_env" == "native" ]] && { sudo apt update; sudo apt-get install libgpiod-dev; }
[[ "$pio_env" == "native" ]] && export PLATFORMIO_SRC_DIR=portduino
pio run -e ${{ matrix.board }}-$pio_env
1 change: 1 addition & 0 deletions examples/Test/build_test/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extra_configs = platformio_esp8266.ini
platformio_esp32.ini
platformio_atmelsam.ini
platformio_rpipico.ini
platformio_native.ini

[env]
framework = arduino
Expand Down
44 changes: 44 additions & 0 deletions examples/Test/build_test/platformio_native.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

[env:native-default]
platform = https://github.com/geeksville/platform-native.git
;build_flags = ${env.build_flags} -O0 -lgpiod
; framework = arduino
board = linux_hardware

; build_src_filter =
; -<platform/esp32/>
; -<nimble/>
; -<platform/nrf52/>
; -<platform/stm32wl/>
; -<platform/rp2040>
; -<modules/esp32>
; -<modules/Telemetry/EnvironmentTelemetry.cpp>
; -<modules/Telemetry/AirQualityTelemetry.cpp>
; -<modules/Telemetry/Sensor>
; +<../variants/portduino>

; lib_deps = LovyanGFX

;build_flags = -fPIC -Isrc/platform/portduino -O0 -lgpiod
build_flags = -O0 -xc++ -std=c++14


[env:native-portduino]
platform = https://github.com/meshtastic/platform-native.git#659e49346aa33008b150dfb206b1817ddabc7132
framework = arduino
board = cross_platform
;build_src_filter = +<**/*.cpp> -<main/>



build_flags =
${env.build_flags}
-lgpiod
-DPORTDUINO_LINUX_HARDWARE
-DARCH_PORTDUINO
-O0

lib_deps =
SPI
Wire
LovyanGFX
53 changes: 53 additions & 0 deletions examples/Test/build_test/portduino/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

#include "main.h"


void setup()
{
gpioInit();
initGPIOPin(25, "gpiochip4");
initGPIOPin(24, "gpiochip4");

DisplaySPI = new HardwareSPI;
DisplaySPI->begin("/dev/spidev0.0");
Wire.begin(1);
display = new LGFX();
display->init();

canvas.setColorDepth(8);
canvas.setFont(&fonts::lgfxJapanMinchoP_32);
canvas.setTextWrap(false); // 右端到達時のカーソル折り返しを禁止
canvas.createSprite(display->width(), 36);
}


void loop()
{
if (display->touch()) {
canvas.clear();
canvas.setCursor(0, 0);
lgfx::touch_point_t tp;
auto blah = display->getTouchRaw(&tp, 1);
if (blah > 0) {
canvas.printf("Touch %i, %i\n", tp.x, tp.y);
canvas.pushSprite(display, 0, 0);
}
}
}


int initGPIOPin(int pinNum, std::string gpioChipName)
{
std::string gpio_name = "GPIO" + std::to_string(pinNum);
try {
GPIOPin *csPin;
csPin = new LinuxGPIOPin(pinNum, gpioChipName.c_str(), pinNum, gpio_name.c_str());
csPin->setSilent();
gpioBind(csPin);
return 1;
} catch (...) {
std::exception_ptr p = std::current_exception();
std::cout << "Warning, cannot claim pin " << gpio_name << (p ? p.__cxa_exception_type()->name() : "null") << std::endl;
return 0;
}
}
62 changes: 62 additions & 0 deletions examples/Test/build_test/portduino/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "LovyanGFX.h"
#include "Arduino.h"
#include <stdio.h>
#include <SPI.h>
#include "linux/gpio/LinuxGPIOPin.h"
#include "PortduinoGPIO.h"
#include <iostream>

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

class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ILI9341 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Touch_FT5x06 _touch_instance;

public:
LGFX(void)
{
{
// Create I2C

//Init the TFT and touch
auto buscfg = _bus_instance.config();
buscfg.spi_mode = 0;
buscfg.pin_dc = 25;
_bus_instance.spi_device(DisplaySPI);
_bus_instance.config(buscfg); // applies the set value to the bus.
_panel_instance.setBus(&_bus_instance); // set the bus on the panel.
}
{
auto cfg = _panel_instance.config(); // Gets a structure for display panel settings.

cfg.panel_width = 240;
cfg.panel_height = 320;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0; // Rotation direction value offset 0~7 (4~7 is mirrored)
cfg.invert = 0;

_panel_instance.config(cfg);
}
{
auto touch_cfg = _touch_instance.config();
touch_cfg.x_min = 0;
touch_cfg.x_max = 319;
touch_cfg.y_min = 0;
touch_cfg.y_max = 239;
touch_cfg.pin_int = 24;
touch_cfg.bus_shared = true;
touch_cfg.offset_rotation = 1;
touch_cfg.i2c_addr = 0x38;
_touch_instance.config(touch_cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance); // Sets the panel to use.
}
};

LGFX *display;
LGFX_Sprite canvas;

0 comments on commit 31139c0

Please sign in to comment.