Skip to content

Commit c9f861a

Browse files
committed
add ST7789 support
1 parent 9273144 commit c9f861a

File tree

11 files changed

+317
-14
lines changed

11 files changed

+317
-14
lines changed

.clang-format

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
BasedOnStyle: Google
3+
AccessModifierOffset: '-2'
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveAssignments: 'true'
6+
AlignConsecutiveDeclarations: 'false'
7+
AlignEscapedNewlines: Left
8+
AlignTrailingComments: 'true'
9+
AllowAllParametersOfDeclarationOnNextLine: 'false'
10+
AllowShortBlocksOnASingleLine: 'false'
11+
AllowShortCaseLabelsOnASingleLine: 'false'
12+
AllowShortFunctionsOnASingleLine: InlineOnly
13+
AllowShortIfStatementsOnASingleLine: 'true'
14+
AllowShortLoopsOnASingleLine: 'true'
15+
AlwaysBreakAfterDefinitionReturnType: None
16+
AlwaysBreakAfterReturnType: None
17+
AlwaysBreakBeforeMultilineStrings: 'true'
18+
AlwaysBreakTemplateDeclarations: 'false'
19+
BinPackParameters: 'true'
20+
BreakAfterJavaFieldAnnotations: 'false'
21+
BreakBeforeBinaryOperators: None
22+
BreakBeforeBraces: Attach
23+
BreakBeforeInheritanceComma: 'false'
24+
BreakBeforeTernaryOperators: 'false'
25+
BreakConstructorInitializers: BeforeColon
26+
BreakStringLiterals: 'false'
27+
ColumnLimit: '0'
28+
CompactNamespaces: 'true'
29+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
30+
ConstructorInitializerIndentWidth: '4'
31+
ContinuationIndentWidth: '4'
32+
Cpp11BracedListStyle: 'false'
33+
DerivePointerAlignment: 'false'
34+
FixNamespaceComments: 'true'
35+
IndentCaseLabels: 'true'
36+
IndentWidth: '4'
37+
IndentWrappedFunctionNames: 'false'
38+
JavaScriptQuotes: Single
39+
JavaScriptWrapImports: 'false'
40+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
41+
MaxEmptyLinesToKeep: '1'
42+
NamespaceIndentation: All
43+
ObjCBlockIndentWidth: '4'
44+
ObjCSpaceAfterProperty: 'false'
45+
ObjCSpaceBeforeProtocolList: 'false'
46+
PointerAlignment: Middle
47+
SortIncludes: 'false'
48+
SortUsingDeclarations: 'true'
49+
SpaceAfterCStyleCast: 'false'
50+
SpaceAfterTemplateKeyword: 'false'
51+
SpaceBeforeAssignmentOperators: 'true'
52+
SpaceBeforeParens: Never
53+
SpaceInEmptyParentheses: 'false'
54+
SpacesBeforeTrailingComments: '4'
55+
SpacesInAngles: 'false'
56+
SpacesInCStyleCastParentheses: 'false'
57+
SpacesInContainerLiterals: 'false'
58+
SpacesInParentheses: 'false'
59+
SpacesInSquareBrackets: 'false'
60+
TabWidth: '4'
61+
UseTab: Never
62+
63+
...

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ jobs:
108108
source $GITHUB_WORKSPACE/travis/common.sh
109109
clone_library https://github.com/Links2004/Adafruit_ILI9341
110110
111+
- name: download TFT_eSPI
112+
if: steps.cache_all.outputs.cache-hit != 'true'
113+
run: |
114+
source $GITHUB_WORKSPACE/travis/common.sh
115+
clone_library https://github.com/Bodmer/TFT_eSPI
116+
111117
- name: download esp8266
112118
if: steps.cache_all.outputs.cache-hit != 'true'
113119
run: |
@@ -171,6 +177,7 @@ jobs:
171177
172178
- name: copy code
173179
run: |
180+
mkdir -p $HOME/Arduino/libraries/
174181
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoVNC
175182
176183
- name: config IDE

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ Video:
2424
- ZLIB
2525

2626
##### Supported Hardware #####
27-
- ESP8266 [Arduino for ESP8266](https://github.com/Links2004/Arduino)
28-
27+
- ESP8266 [Arduino for ESP8266](https://github.com/esp8266/Arduino)
28+
- ESP32 [Arduino for ESP32](https://github.com/espressif/arduino-esp32)
2929
may run on Arduino DUE too.
3030

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

3435
more possible using ```VNCdisplay``` Interface
3536

examples/VNC_ST7789/VNC_ST7789.ino

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* VNC_ST7789.ino
3+
*
4+
* Created on: 17.01.2021
5+
*
6+
* required librarys:
7+
* - SPI (arduino core)
8+
* - WiFi (arduino core)
9+
* - arduinoVNC (https://github.com/Links2004/arduinoVNC)
10+
* - TFT_eSPI (https://github.com/Bodmer/TFT_eSPI)
11+
*/
12+
13+
#include <Arduino.h>
14+
#ifdef ESP8266
15+
#include <ESP8266WiFi.h>
16+
#else
17+
#include <WiFi.h>
18+
#endif
19+
#include <SPI.h>
20+
21+
#include <TFT_eSPI.h>
22+
#include <VNC_ST7789.h>
23+
#include <VNC.h>
24+
25+
const char * vnc_ip = "192.168.1.12";
26+
const uint16_t vnc_port = 5900;
27+
const char * vnc_pass = "12345678";
28+
29+
const char* ssid = "your-ssid";
30+
const char* password = "your-password";
31+
32+
ST7789VNC tft = ST7789VNC();
33+
arduinoVNC vnc = arduinoVNC(&tft);
34+
35+
void setup(void) {
36+
tft.begin();
37+
Serial.begin(115200);
38+
39+
tft.setRotation(0);
40+
tft.setTextSize(2);
41+
tft.setCursor(0, 0, 1);
42+
tft.println("Ready");
43+
44+
Serial.setDebugOutput(true);
45+
Serial.println();
46+
Serial.println();
47+
Serial.println();
48+
49+
Serial.print("Connecting to ");
50+
Serial.println(ssid);
51+
52+
WiFi.begin(ssid, password);
53+
while(WiFi.status() != WL_CONNECTED) {
54+
delay(500);
55+
Serial.print(".");
56+
}
57+
Serial.println("");
58+
Serial.println("WiFi connected");
59+
Serial.println("IP address: ");
60+
Serial.println(WiFi.localIP());
61+
62+
Serial.println(F("[SETUP] VNC..."));
63+
64+
vnc.begin(vnc_ip, vnc_port);
65+
//vnc.setPassword(vnc_pass); // check for vnc server settings
66+
}
67+
68+
void loop() {
69+
if(WiFi.status() != WL_CONNECTED) {
70+
vnc.reconnect();
71+
delay(100);
72+
} else {
73+
vnc.loop();
74+
if(!vnc.connected()) {
75+
delay(5000);
76+
}
77+
}
78+
}

library.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
"name": "arduinoVNC",
33
"keywords": "VNC, rfbproto, client, image, rfb",
44
"description": "VNC Client for Arduino",
5-
"repository":
6-
{
5+
"repository": {
76
"type": "git",
87
"url": "https://github.com/Links2004/arduinoVNC.git"
98
},
10-
"exclude": "tests",
119
"frameworks": "arduino",
12-
"platforms": "esp8266",
13-
"authors":
14-
{
15-
"name": "Markus Sattler",
16-
"url": "https://github.com/Links2004",
17-
"maintainer": true
18-
}
19-
}
10+
"platforms": "esp8266, espressif32",
11+
"authors": [
12+
{
13+
"maintainer": true,
14+
"name": "Markus Sattler",
15+
"url": "https://github.com/Links2004"
16+
}
17+
],
18+
"export": {
19+
"exclude": [
20+
"tests"
21+
]
22+
},
23+
"version": "1.4",
24+
"license": "GPL-2"
25+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=arduinoVNC
2-
version=1.3
2+
version=1.4
33
author=Markus Sattler
44
maintainer=Markus Sattler
55
sentence=VNC Client for Arduino

src/VNC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void arduinoVNC::begin(char *_host, uint16_t _port, bool _onlyFullUpdate) {
129129
opt.h_offset = 0;
130130
opt.v_offset = 0;
131131

132+
display->vnc_options_override(&opt);
133+
132134
setMaxFPS(100);
133135
}
134136

src/VNC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class VNCdisplay {
160160
virtual void area_update_data(char *data, uint32_t pixel) = 0;
161161
virtual void area_update_end(void) = 0;
162162

163+
virtual void vnc_options_override(dfb_vnc_options * opt) {};
163164
};
164165

165166
class arduinoVNC {

src/VNC_ST7789.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* @file VNC_ST7789.cpp
3+
* @date 17.01.2021
4+
* @author Markus Sattler
5+
*
6+
* based on the work of modi12jin
7+
*
8+
* Copyright (c) 2021 Markus Sattler. All rights reserved.
9+
* This file is part of the VNC client for Arduino.
10+
*
11+
* This program is free software; you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation; version 2 of the License
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with this program; if not, a copy can be downloaded from
22+
* http://www.gnu.org/licenses/gpl.html, or obtained by writing to the
23+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24+
* Boston, MA 02110-1301, USA.
25+
*
26+
*
27+
*/
28+
29+
#include "VNC_config.h"
30+
31+
#ifdef VNC_ST7789
32+
33+
#include "VNC.h"
34+
35+
#include <SPI.h>
36+
#include <TFT_eSPI.h>
37+
38+
#include "VNC_ST7789.h"
39+
40+
ST7789VNC::ST7789VNC() {
41+
TFT_eSPI();
42+
}
43+
44+
bool ST7789VNC::hasCopyRect(void) {
45+
return false;
46+
}
47+
48+
uint32_t ST7789VNC::getHeight(void) {
49+
return 240;
50+
}
51+
52+
uint32_t ST7789VNC::getWidth(void) {
53+
return 240;
54+
}
55+
56+
void ST7789VNC::draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * data) {
57+
TFT_eSPI::pushImage(x, y, w, h, (uint16_t *)data);
58+
}
59+
60+
void ST7789VNC::draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color) {
61+
TFT_eSPI::fillRect(x, y, w, h, ((((color)&0xff) << 8) | (((color) >> 8))));
62+
}
63+
64+
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) {
65+
}
66+
67+
void ST7789VNC::area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
68+
TFT_eSPI::setAddrWindow(x, y, w, h);
69+
}
70+
71+
void ST7789VNC::area_update_data(char * data, uint32_t pixel) {
72+
TFT_eSPI::pushPixels((uint8_t *)data, pixel);
73+
}
74+
75+
void ST7789VNC::area_update_end(void) {
76+
}
77+
78+
void vnc_options_override(dfb_vnc_options * opt) {
79+
// TODO: may need to be swaped for ESP8266
80+
opt->client.bigendian = 1;
81+
}
82+
#endif

src/VNC_ST7789.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* @file VNC_ST7789.h
3+
* @date 17.01.2021
4+
* @author Markus Sattler
5+
*
6+
* based on the work of modi12jin
7+
*
8+
* Copyright (c) 2021 Markus Sattler. All rights reserved.
9+
* This file is part of the VNC client for Arduino.
10+
*
11+
* This program is free software; you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation; version 2 of the License
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with this program; if not, a copy can be downloaded from
22+
* http://www.gnu.org/licenses/gpl.html, or obtained by writing to the
23+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24+
* Boston, MA 02110-1301, USA.
25+
*
26+
*
27+
*/
28+
29+
#ifndef VNC_ST7789_H_
30+
#define VNC_ST7789_H_
31+
32+
#include "VNC_config.h"
33+
#include <TFT_eSPI.h>
34+
#include "VNC_ST7789.h"
35+
#include "VNC.h"
36+
37+
class ST7789VNC : public VNCdisplay, public TFT_eSPI {
38+
public:
39+
ST7789VNC();
40+
41+
bool hasCopyRect(void);
42+
43+
uint32_t getHeight(void);
44+
uint32_t getWidth(void);
45+
46+
void draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t * data);
47+
48+
void draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color);
49+
50+
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);
51+
52+
void area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
53+
void area_update_data(char * data, uint32_t pixel);
54+
void area_update_end(void);
55+
56+
void vnc_options_override(dfb_vnc_options * opt);
57+
58+
private:
59+
uint32_t area_x, area_y, area_w, area_h;
60+
};
61+
62+
#endif

src/VNC_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
/// Display
3131
#define VNC_ILI9341
32+
#define VNC_ST7789
3233

3334
// RA8875 not fully implemented
3435
//#define VNC_RA8875

0 commit comments

Comments
 (0)