-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |