Skip to content

Commit

Permalink
Merge pull request #148 from lovyan03/develop
Browse files Browse the repository at this point in the history
0.4.3
  • Loading branch information
lovyan03 authored Sep 24, 2021
2 parents 3d49184 + 1f937ff commit 6422cdc
Show file tree
Hide file tree
Showing 103 changed files with 3,440 additions and 789 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ file(GLOB SRCS
src/lgfx/v0/platforms/*.cpp
src/lgfx/v0/touch/*.cpp
src/lgfx/v1/*.cpp
src/lgfx/v1/misc/*.cpp
src/lgfx/v1/panel/*.cpp
src/lgfx/v1/platforms/arduino_default/*.cpp
src/lgfx/v1/platforms/esp32/*.cpp
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LovyanGFX

Display (LCD / OLED / EPD) graphics library (for ESP32 SPI, I2C, 8bitParallel / ESP8266 SPI / ATSAMD51 SPI).
Display (LCD / OLED / EPD) graphics library (for ESP32 SPI, I2C, 8bitParallel / ESP8266 SPI, I2C / ATSAMD51 SPI).
M5Stack / M5StickC / TTGO T-Watch / ODROID-GO / ESP-WROVER-KIT / WioTerminal / and more...
[![examples](http://img.youtube.com/vi/SMOHRPqUZcQ/0.jpg)](http://www.youtube.com/watch?v=SMOHRPqUZcQ "examples")
[![examples](http://img.youtube.com/vi/F5gsp41Elac/0.jpg)](http://www.youtube.com/watch?v=F5gsp41Elac "MultiPanel")
Expand All @@ -21,6 +21,7 @@ This library mimics [AdafruitGFX](https://github.com/adafruit/Adafruit-GFX-Libra
- オフスクリーンバッファ(スプライト)の高速な回転/拡縮描画
- 複数ディスプレイの同時利用
- モノクロディスプレイに対する減色描画の自動処理
- OpenCVを描画先として利用でき、PC上で動作可能

This library has the following advantages.
- ArduinoESP32 and ESP-IDF are supported.
Expand All @@ -29,6 +30,19 @@ This library has the following advantages.
- Fast rotation/expansion of the off-screen buffer (sprite).
- Simultaneous use of multiple displays.
- Automatic processing of color reduction drawing for monochrome displays.
- OpenCV can be used as a drawing destination and can run on a PC.


| | SPI | I2C | 8bit Para|16bit Para|
|:------:|:---:|:---:|:--------:|:--------:|
|ESP32 | HW | HW | HW (I2S) | --- |
|ESP32-S2| HW | HW | HW (I2S) | HW (I2S) |
|ESP32-C3| HW | HW | --- | --- |
|ESP8266 | HW | SW | --- | --- |
|SAMD51 | HW | HW | --- | --- |
|SAMD21 | HW | HW | --- | --- |

※ HW = HardWare Peripheral / SW = SoftWare implementation


対応環境 support environments
Expand Down Expand Up @@ -60,7 +74,7 @@ This library has the following advantages.
- ST7789 (M5StickCPlus, TTGO T-Watch, ESP-WROVER-KIT, Makerfabs MakePython, DSTIKE D-duino-32 XS)
- ST7796 (WT32-SC01)

- タッチスクリーン TouchScreens (only ESP32)
- タッチスクリーン TouchScreens
- I2C FT5x06 (FT5206, FT5306, FT5406, FT6206, FT6236, FT6336, FT6436)
- I2C GT911
- SPI XPT2046
Expand Down
23 changes: 23 additions & 0 deletions examples/Advanced/CMake_OpenCV/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required (VERSION 3.8)
project(LGFXOpenCV)

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")

file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
*.cpp
LovyanGFX/src/lgfx/Fonts/efont/*.c
LovyanGFX/src/lgfx/Fonts/IPA/*.c
LovyanGFX/src/lgfx/utility/*.c
LovyanGFX/src/lgfx/v1/*.cpp
LovyanGFX/src/lgfx/v1/misc/*.cpp
LovyanGFX/src/lgfx/v1/panel/*.cpp
LovyanGFX/src/lgfx/v1/platforms/opencv/*.cpp
)
add_executable (LGFXOpenCV ${Target_Files})

target_compile_features(LGFXOpenCV PUBLIC cxx_std_17)
target_include_directories(LGFXOpenCV PUBLIC "LovyanGFX/src/")
target_include_directories(LGFXOpenCV PUBLIC "C:/opencv/build/include")
target_link_libraries(LGFXOpenCV PUBLIC "C:/opencv/build/x64/vc15/lib/opencv_world452d.lib" )
43 changes: 43 additions & 0 deletions examples/Advanced/CMake_OpenCV/LGFXOpenCV.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <stdio.h> // for drawBmpFile / drawJpgFile / drawPngFile

#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>

LGFX lcd ( 320, 240 );
LGFX lcd2( 135, 240 );

int32_t target_x = 160 * 256;
int32_t target_y = 120 * 256;
int32_t current_x = 0;
int32_t current_y = 0;
int32_t add_x = 0;
int32_t add_y = 0;

void setup()
{
lcd.init();
lcd2.init();
}

void loop()
{
static int i;
++i;
lcd.fillCircle(current_x >> 8, current_y >> 8, 5, i);
current_x += add_x;
current_y += add_y;
add_x += (current_x < target_x) ? 1 : -1;
add_y += (current_y < target_y) ? 1 : -1;
lgfx::touch_point_t new_tp;
if (lcd.getTouch(&new_tp))
{
target_x = new_tp.x * 256;
target_y = new_tp.y * 256;
lcd.drawCircle(new_tp.x, new_tp.y, 5, TFT_WHITE);
}
lgfx::delay(1);

lcd2.fillRect(i & 127, i >> 7, 16, 16, i);
// lcd2.drawJpgFile("C:\\test.jpg", i & 127, i >> 7);
}
29 changes: 29 additions & 0 deletions examples/Advanced/CMake_OpenCV/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <opencv2/opencv.hpp>
#include <thread>

#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>

void setup(void);
void loop(void);

void loopThread(void)
{
setup();
for (;;)
{
loop();
std::this_thread::yield();
}
}

int main(int, char**)
{
std::thread sub_thread(loopThread);
for (;;)
{
std::this_thread::yield();
lgfx::Panel_OpenCV::imshowall();
}
}
4 changes: 4 additions & 0 deletions examples/Advanced/EPD/EPD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ LGFX_Sprite sp(&gfx);
int w = 200;
int h = 200;

#ifdef min
#undef min
#endif

void setup(void)
{
// M5.begin();
Expand Down
4 changes: 4 additions & 0 deletions examples/Sprite/ClockSample/ClockSample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ static int32_t halfwidth = width >> 1; // 時計盤の中心座標
static auto transpalette = 0; // 透過色パレット番号
static float zoom; // 表示倍率

#ifdef min
#undef min
#endif

void setup(void)
{
Serial.begin(115200);
Expand Down
4 changes: 4 additions & 0 deletions examples/Sprite/MeterSample/MeterSample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ static int32_t halfwidth = width >> 1; // 中心座標
static auto transpalette = 0; // 透過色パレット番号
static float zoom; // 表示倍率

#ifdef min
#undef min
#endif

void setup(void)
{
Serial.begin(115200);
Expand Down
4 changes: 4 additions & 0 deletions examples/Sprite/PartyParrot/PartyParrot.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,10 @@ static LGFX_Sprite sprite[10];
static std::uint32_t count = 0;
static float zoom = 0;

#ifdef min
#undef min
#endif

void setup()
{
lcd.init();
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/lovyan03/LovyanGFX.git"
},
"version": "0.4.2",
"version": "0.4.3",
"frameworks": ["arduino", "espidf"],
"platforms": ["espressif32", "espressif8266", "atmelsam"],
"build": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LovyanGFX
version=0.4.2
version=0.4.3
author=lovyan03
maintainer=lovyan03
sentence=TFT LCD Graphics driver with touch for ESP32, ESP8266, SAMD21, SAMD51
Expand Down
7 changes: 7 additions & 0 deletions src/lgfx/Fonts/IPA/lgfx_font_japan.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

extern const uint8_t lgfx_font_japan_mincho_8[];
extern const uint8_t lgfx_font_japan_mincho_12[];
extern const uint8_t lgfx_font_japan_mincho_16[];
Expand Down Expand Up @@ -40,5 +44,8 @@ extern const uint8_t lgfx_font_japan_gothic_p_32[];
extern const uint8_t lgfx_font_japan_gothic_p_36[];
extern const uint8_t lgfx_font_japan_gothic_p_40[];

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
8 changes: 8 additions & 0 deletions src/lgfx/Fonts/efont/lgfx_efont_cn.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <stdint.h>
#define U8G2_USE_LARGE_FONTS

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

extern const uint8_t lgfx_efont_cn_10[];
extern const uint8_t lgfx_efont_cn_10_b[];
extern const uint8_t lgfx_efont_cn_10_bi[];
Expand All @@ -21,3 +25,7 @@ extern const uint8_t lgfx_efont_cn_24[];
extern const uint8_t lgfx_efont_cn_24_b[];
extern const uint8_t lgfx_efont_cn_24_bi[];
extern const uint8_t lgfx_efont_cn_24_i[];

#ifdef __cplusplus
}
#endif /* __cplusplus */
8 changes: 8 additions & 0 deletions src/lgfx/Fonts/efont/lgfx_efont_ja.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <stdint.h>
#define U8G2_USE_LARGE_FONTS

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

extern const uint8_t lgfx_efont_ja_10[];
extern const uint8_t lgfx_efont_ja_10_b[];
extern const uint8_t lgfx_efont_ja_10_bi[];
Expand All @@ -21,3 +25,7 @@ extern const uint8_t lgfx_efont_ja_24[];
extern const uint8_t lgfx_efont_ja_24_b[];
extern const uint8_t lgfx_efont_ja_24_bi[];
extern const uint8_t lgfx_efont_ja_24_i[];

#ifdef __cplusplus
}
#endif /* __cplusplus */
8 changes: 8 additions & 0 deletions src/lgfx/Fonts/efont/lgfx_efont_kr.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <stdint.h>
#define U8G2_USE_LARGE_FONTS

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

extern const uint8_t lgfx_efont_kr_10[];
extern const uint8_t lgfx_efont_kr_10_b[];
extern const uint8_t lgfx_efont_kr_10_bi[];
Expand All @@ -21,3 +25,7 @@ extern const uint8_t lgfx_efont_kr_24[];
extern const uint8_t lgfx_efont_kr_24_b[];
extern const uint8_t lgfx_efont_kr_24_bi[];
extern const uint8_t lgfx_efont_kr_24_i[];

#ifdef __cplusplus
}
#endif /* __cplusplus */
8 changes: 8 additions & 0 deletions src/lgfx/Fonts/efont/lgfx_efont_tw.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <stdint.h>
#define U8G2_USE_LARGE_FONTS

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

extern const uint8_t lgfx_efont_tw_10[];
extern const uint8_t lgfx_efont_tw_10_b[];
extern const uint8_t lgfx_efont_tw_10_bi[];
Expand All @@ -21,3 +25,7 @@ extern const uint8_t lgfx_efont_tw_24[];
extern const uint8_t lgfx_efont_tw_24_b[];
extern const uint8_t lgfx_efont_tw_24_bi[];
extern const uint8_t lgfx_efont_tw_24_i[];

#ifdef __cplusplus
}
#endif /* __cplusplus */
33 changes: 22 additions & 11 deletions src/lgfx/utility/lgfx_qrcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
#include <stdlib.h>
#include <string.h>

#if __has_include(<alloca.h>)
#include <alloca.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif

#ifdef max
#undef max
#endif

//#pragma mark - Error Correction Lookup tables

#if LOCK_VERSION == 0
Expand Down Expand Up @@ -91,8 +102,7 @@ static const uint16_t NUM_RAW_DATA_MODULES = 567;


static int max(int a, int b) {
if (a > b) { return a; }
return b;
return (a > b) ? a : b;
}

/*
Expand Down Expand Up @@ -417,7 +427,7 @@ static void drawFunctionPatterns(BitBucket *modules, BitBucket *isFunction, uint
}

uint_fast8_t alignPositionIndex = alignCount - 1;
uint8_t alignPosition[alignCount];
uint8_t* alignPosition = (uint8_t*)alloca(alignCount);

alignPosition[0] = 6;

Expand Down Expand Up @@ -715,10 +725,10 @@ static bool performErrorCorrection(uint8_t version, uint8_t ecc, BitBucket *data

uint8_t shortDataBlockLen = shortBlockLen - blockEccLen;

uint8_t result[data->capacityBytes];
memset(result, 0, sizeof(result));
uint8_t coeff[blockEccLen];
uint8_t* result = (uint8_t*)alloca(data->capacityBytes);
memset(result, 0, data->capacityBytes);

uint8_t* coeff = (uint8_t*)alloca(blockEccLen);
rs_init(blockEccLen, coeff);

uint16_t offset = 0;
Expand Down Expand Up @@ -804,9 +814,10 @@ int8_t lgfx_qrcode_initBytes(QRCode *qrcode, uint8_t *modules, uint8_t version,
#endif

struct BitBucket codewords;
uint8_t codewordBytes[bb_getBufferSizeBytes(moduleCount)];
bb_initBuffer(&codewords, codewordBytes, (int32_t)sizeof(codewordBytes));

int32_t codewordLen = bb_getBufferSizeBytes(moduleCount);
uint8_t* codewordBytes = (uint8_t*)alloca(codewordLen);
bb_initBuffer(&codewords, codewordBytes, codewordLen);

// Place the data code words into the buffer
int8_t mode = encodeDataCodewords(&codewords, data, length, version);

Expand All @@ -829,7 +840,7 @@ int8_t lgfx_qrcode_initBytes(QRCode *qrcode, uint8_t *modules, uint8_t version,
bb_initGrid(&modulesGrid, modules, size);

BitBucket isFunctionGrid;
uint8_t isFunctionGridBytes[bb_getGridSizeBytes(size)];
uint8_t* isFunctionGridBytes = (uint8_t*)alloca(bb_getGridSizeBytes(size));
bb_initGrid(&isFunctionGrid, isFunctionGridBytes, size);

// Draw function patterns, draw all codewords, do masking
Expand Down
Loading

0 comments on commit 6422cdc

Please sign in to comment.