Skip to content

Commit

Permalink
Merge pull request #19 from Links2004/ST7789
Browse files Browse the repository at this point in the history
add ST7789 support
  • Loading branch information
Links2004 authored Jan 17, 2021
2 parents 9273144 + 7b87829 commit 8a5cd70
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 14 deletions.
63 changes: 63 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
BasedOnStyle: Google
AccessModifierOffset: '-2'
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Left
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: 'true'
AllowShortLoopsOnASingleLine: 'true'
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'false'
BinPackParameters: 'true'
BreakAfterJavaFieldAnnotations: 'false'
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: 'false'
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: 'false'
ColumnLimit: '0'
CompactNamespaces: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
IndentCaseLabels: 'true'
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
JavaScriptQuotes: Single
JavaScriptWrapImports: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
ObjCBlockIndentWidth: '4'
ObjCSpaceAfterProperty: 'false'
ObjCSpaceBeforeProtocolList: 'false'
PointerAlignment: Middle
SortIncludes: 'false'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: Never
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '4'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
TabWidth: '4'
UseTab: Never

...
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ jobs:
source $GITHUB_WORKSPACE/travis/common.sh
clone_library https://github.com/Links2004/Adafruit_ILI9341
- name: download TFT_eSPI
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
source $GITHUB_WORKSPACE/travis/common.sh
clone_library https://github.com/Bodmer/TFT_eSPI
- name: download esp8266
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -171,6 +177,7 @@ jobs:
- name: copy code
run: |
mkdir -p $HOME/Arduino/libraries/
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoVNC
- name: config IDE
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ Video:
- ZLIB

##### Supported Hardware #####
- ESP8266 [Arduino for ESP8266](https://github.com/Links2004/Arduino)

- ESP8266 [Arduino for ESP8266](https://github.com/esp8266/Arduino)
- ESP32 [Arduino for ESP32](https://github.com/espressif/arduino-esp32)
may run on Arduino DUE too.

##### Supported Displays #####
- ILI9341 [library](https://github.com/Links2004/Adafruit_ILI9341)
- ST7789 [library](https://github.com/Bodmer/TFT_eSPI)

more possible using ```VNCdisplay``` Interface

Expand Down
78 changes: 78 additions & 0 deletions examples/VNC_ST7789/VNC_ST7789.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* VNC_ST7789.ino
*
* Created on: 17.01.2021
*
* required librarys:
* - SPI (arduino core)
* - WiFi (arduino core)
* - arduinoVNC (https://github.com/Links2004/arduinoVNC)
* - TFT_eSPI (https://github.com/Bodmer/TFT_eSPI)
*/

#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <SPI.h>

#include <TFT_eSPI.h>
#include <VNC_ST7789.h>
#include <VNC.h>

const char * vnc_ip = "192.168.1.12";
const uint16_t vnc_port = 5900;
const char * vnc_pass = "12345678";

const char* ssid = "your-ssid";
const char* password = "your-password";

ST7789VNC tft = ST7789VNC();
arduinoVNC vnc = arduinoVNC(&tft);

void setup(void) {
tft.begin();
Serial.begin(115200);

tft.setRotation(0);
tft.setTextSize(2);
tft.setCursor(0, 0, 1);
tft.println("Ready");

Serial.setDebugOutput(true);
Serial.println();
Serial.println();
Serial.println();

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

Serial.println(F("[SETUP] VNC..."));

vnc.begin(vnc_ip, vnc_port);
//vnc.setPassword(vnc_pass); // check for vnc server settings
}

void loop() {
if(WiFi.status() != WL_CONNECTED) {
vnc.reconnect();
delay(100);
} else {
vnc.loop();
if(!vnc.connected()) {
delay(5000);
}
}
}
28 changes: 17 additions & 11 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
"name": "arduinoVNC",
"keywords": "VNC, rfbproto, client, image, rfb",
"description": "VNC Client for Arduino",
"repository":
{
"repository": {
"type": "git",
"url": "https://github.com/Links2004/arduinoVNC.git"
},
"exclude": "tests",
"frameworks": "arduino",
"platforms": "esp8266",
"authors":
{
"name": "Markus Sattler",
"url": "https://github.com/Links2004",
"maintainer": true
}
}
"platforms": "esp8266, espressif32",
"authors": [
{
"maintainer": true,
"name": "Markus Sattler",
"url": "https://github.com/Links2004"
}
],
"export": {
"exclude": [
"tests"
]
},
"version": "1.4",
"license": "GPL-2.0-or-later"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=arduinoVNC
version=1.3
version=1.4
author=Markus Sattler
maintainer=Markus Sattler
sentence=VNC Client for Arduino
Expand Down
2 changes: 2 additions & 0 deletions src/VNC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ void arduinoVNC::begin(char *_host, uint16_t _port, bool _onlyFullUpdate) {
opt.h_offset = 0;
opt.v_offset = 0;

display->vnc_options_override(&opt);

setMaxFPS(100);
}

Expand Down
1 change: 1 addition & 0 deletions src/VNC.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class VNCdisplay {
virtual void area_update_data(char *data, uint32_t pixel) = 0;
virtual void area_update_end(void) = 0;

virtual void vnc_options_override(dfb_vnc_options * opt) {};
};

class arduinoVNC {
Expand Down
82 changes: 82 additions & 0 deletions src/VNC_ST7789.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* @file VNC_ST7789.cpp
* @date 17.01.2021
* @author Markus Sattler
*
* based on the work of modi12jin
*
* Copyright (c) 2021 Markus Sattler. All rights reserved.
* This file is part of the VNC client for Arduino.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, a copy can be downloaded from
* http://www.gnu.org/licenses/gpl.html, or obtained by writing to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*
*/

#include "VNC_config.h"

#ifdef VNC_ST7789

#include "VNC.h"

#include <SPI.h>
#include <TFT_eSPI.h>

#include "VNC_ST7789.h"

ST7789VNC::ST7789VNC() {
TFT_eSPI();
}

bool ST7789VNC::hasCopyRect(void) {
return false;
}

uint32_t ST7789VNC::getHeight(void) {
return 240;
}

uint32_t ST7789VNC::getWidth(void) {
return 240;
}

void ST7789VNC::draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * data) {
TFT_eSPI::pushImage(x, y, w, h, (uint16_t *)data);
}

void ST7789VNC::draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color) {
TFT_eSPI::fillRect(x, y, w, h, ((((color)&0xff) << 8) | (((color) >> 8))));
}

void ST7789VNC::copy_rect(uint32_t src_x, uint32_t src_y, uint32_t dest_x, uint32_t dest_y, uint32_t w, uint32_t h) {
}

void ST7789VNC::area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
TFT_eSPI::setAddrWindow(x, y, w, h);
}

void ST7789VNC::area_update_data(char * data, uint32_t pixel) {
TFT_eSPI::pushPixels((uint8_t *)data, pixel);
}

void ST7789VNC::area_update_end(void) {
}

void ST7789VNC::vnc_options_override(dfb_vnc_options * opt) {
// TODO: may need to be swaped for ESP8266
opt->client.bigendian = 1;
}
#endif
62 changes: 62 additions & 0 deletions src/VNC_ST7789.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* @file VNC_ST7789.h
* @date 17.01.2021
* @author Markus Sattler
*
* based on the work of modi12jin
*
* Copyright (c) 2021 Markus Sattler. All rights reserved.
* This file is part of the VNC client for Arduino.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, a copy can be downloaded from
* http://www.gnu.org/licenses/gpl.html, or obtained by writing to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*
*/

#ifndef VNC_ST7789_H_
#define VNC_ST7789_H_

#include "VNC_config.h"
#include <TFT_eSPI.h>
#include "VNC_ST7789.h"
#include "VNC.h"

class ST7789VNC : public VNCdisplay, public TFT_eSPI {
public:
ST7789VNC();

bool hasCopyRect(void);

uint32_t getHeight(void);
uint32_t getWidth(void);

void draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * data);

void draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color);

void copy_rect(uint32_t src_x, uint32_t src_y, uint32_t dest_x, uint32_t dest_y, uint32_t w, uint32_t h);

void area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
void area_update_data(char * data, uint32_t pixel);
void area_update_end(void);

void vnc_options_override(dfb_vnc_options * opt);

private:
uint32_t area_x, area_y, area_w, area_h;
};

#endif
1 change: 1 addition & 0 deletions src/VNC_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/// Display
#define VNC_ILI9341
#define VNC_ST7789

// RA8875 not fully implemented
//#define VNC_RA8875
Expand Down

0 comments on commit 8a5cd70

Please sign in to comment.