-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Links2004/ST7789
add ST7789 support
- Loading branch information
Showing
11 changed files
with
317 additions
and
14 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
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 | ||
|
||
... |
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,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); | ||
} | ||
} | ||
} |
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
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,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 |
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 @@ | ||
/* | ||
* @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 |
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