Skip to content

Commit

Permalink
Merge pull request #47 from lovyan03/develop
Browse files Browse the repository at this point in the history
v0.2.2
  • Loading branch information
lovyan03 authored Sep 25, 2020
2 parents 18a432d + 2936c28 commit 87c3288
Show file tree
Hide file tree
Showing 45 changed files with 41,666 additions and 3,098 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LovyanGFX

LCD graphics library (for ESP32 SPI or 8bit Parallel / ATSAMD51 SPI).
M5Stack / M5StickC / TTGO T-Watch / ODROID-GO / ESP-WROVER-KIT / WioTerminal / and more...
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 Down Expand Up @@ -35,20 +35,25 @@ This library has the following advantages.
- ESP-IDF
- Arduino ESP32
- Arduino ATSAMD51 (Seeed)
- Platformio
- PlatformIO

- ディスプレイ Displays
- HX8357
- ILI9163
- ILI9341 (ODROID-GO, ESP-WROVER-KIT, LoLin D32 Pro, WioTerminal)
- ILI9342 (M5Stack Basic,Gray,Fire,Go,Core2)
- ILI9342 (M5Stack, M5Stack Core2)
- ILI9486
- ILI9488
- SSD1351
- ST7735 (M5StickC, TTGO T-Wristband, TTGO TS, LoLin D32 Pro)
- ST7789 (M5StickCPlus, TTGO T-Watch, DSTIKE D-duino-32 XS, ESP-WROVER-KIT)
- ST7796

- タッチパネル TouchScreens (only ESP32)
- I2C FT5x06
- SPI XPT2046
- SPI STMPE610


対応機種については[src/lgfx/panel](src/lgfx/panel)をご参照ください。
接続するピンの初期設定は[src/LovyanGFX.hpp](src/LovyanGFX.hpp)にあります。
Expand All @@ -68,7 +73,8 @@ This library is also compatible with the above models and LCD panels with a simi
// 対応機種がボードマネージャに無い場合 ( TTGO T-Wristband や ESP-WROVER-KIT等 ) は、
// LovyanGFX.hppのincludeより前に、define LGFX_~ の定義を記述してください。

// #define LGFX_M5STACK // M5Stack / Core2
// #define LGFX_M5STACK // M5Stack (Basic / Gray / Go / Fire)
// #define LGFX_M5STACKCORE2 // M5StackCore2
// #define LGFX_M5STICKC // M5Stick C / CPlus
// #define LGFX_ODROID_GO // ODROID-GO
// #define LGFX_TTGO_TS // TTGO TS
Expand Down
3 changes: 2 additions & 1 deletion examples/Game/BallMaze/BallMaze.ino
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ void loop(void)
zoom *= 1 - zoom_speed;
if (zoom < zoom_min)
{
std::int32_t tx, ty;
zoom = zoom_min;
if ((BUTTON_A_PIN >=0 && lgfx::gpio_in(BUTTON_A_PIN) == 0)
|| (BUTTON_B_PIN >=0 && lgfx::gpio_in(BUTTON_B_PIN) == 0)
|| lcd.getTouch()
|| lcd.getTouch(&tx, &ty)
) break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion examples/HowToUse/1_simple_use/1_simple_use.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
// 対応機種がボードマネージャに無い場合 ( TTGO T-Wristband や ESP-WROVER-KIT等 ) は、
// LovyanGFX.hppのincludeより前に、define LGFX_~ の定義を記述してください。

// #define LGFX_M5STACK // M5Stack / Core2
// #define LGFX_M5STACK // M5Stack (Basic / Gray / Go / Fire)
// #define LGFX_M5STACKCORE2 // M5StackCore2
// #define LGFX_M5STICKC // M5Stick C / CPlus
// #define LGFX_ODROID_GO // ODROID-GO
// #define LGFX_TTGO_TS // TTGO TS
Expand Down
15 changes: 10 additions & 5 deletions examples/HowToUse/5_images/5_images.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static constexpr int image_height = 30;
#define W 0xFF,0xFF,0xFF,
#define _ 0x00,0x00,0x00,
static uint8_t rgb888[] = {
#include "image.h"
#include "image.txt"
};
#undef R
#undef G
Expand All @@ -35,7 +35,7 @@ static uint8_t rgb888[] = {
#define W 0xFF,0xFF,0xFF,
#define _ 0x00,0x00,0x00,
uint8_t bgr888[] = {
#include "image.h"
#include "image.txt"
};
#undef R
#undef G
Expand All @@ -55,7 +55,7 @@ uint8_t bgr888[] = {
#define W 0xFFFF,
#define _ 0x0000,
uint16_t swap565[] = {
#include "image.h"
#include "image.txt"
};
#undef R
#undef G
Expand All @@ -75,7 +75,7 @@ uint16_t swap565[] = {
#define W 0xFFFF,
#define _ 0x0000,
uint16_t rgb565[] = {
#include "image.h"
#include "image.txt"
};
#undef R
#undef G
Expand All @@ -95,7 +95,7 @@ uint16_t rgb565[] = {
#define W 0xFF,
#define _ 0x00,
uint8_t rgb332[] = {
#include "image.h"
#include "image.txt"
};
#undef R
#undef G
Expand Down Expand Up @@ -164,6 +164,11 @@ void loop(void)
lcd.pushImageDMA( 96, 120, image_width, image_height, (lgfx:: rgb565_t*) rgb565); // no DMA
lcd.pushImageDMA(128, 120, image_width, image_height, (lgfx:: rgb332_t*) rgb332); // no DMA

lcd.pushImageDMA( 0, 160, image_width, image_height, (void* )bgr888); // good
lcd.pushImageDMA( 32, 160, image_width, image_height, (uint16_t*)swap565); // good
lcd.pushImageDMA( 64, 160, image_width, image_height, (void* )rgb888); // endian no match
lcd.pushImageDMA( 96, 160, image_width, image_height, (uint16_t*)rgb565); // endian no match
lcd.pushImageDMA(128, 160, image_width, image_height, (uint8_t* )rgb332); // good
// DMA転送を使用した場合は、データ送信中にも処理が進みます。
// そのため、送信中のデータを意図せず書き換えてしまう可能性が生じます。
// 送信中のデータに変更を加えたい場合は、waitDMA関数を使用して送信完了を待機します。
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/Sprite/CollisionCircles/CollisionCircles.ino
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static void mainfunc(void)
_ball_count = ball_count;
}

#if defined (ESP32) || (CONFIG_IDF_TARGET_ESP32) || (ESP_PLATFORM)
#if defined (ESP32) || defined (CONFIG_IDF_TARGET_ESP32) || defined (ESP_PLATFORM)
static void taskDraw(void*)
{
while ( _is_running )
Expand Down Expand Up @@ -297,7 +297,7 @@ void setup(void)
_draw_count = 0;
_loop_count = 0;

#if defined (ESP32) || (CONFIG_IDF_TARGET_ESP32) || (ESP_PLATFORM)
#if defined (ESP32) || defined (CONFIG_IDF_TARGET_ESP32) || defined (ESP_PLATFORM)
disableCore0WDT();
xTaskCreate(taskDraw, "taskDraw", 2048, NULL, 0, NULL);
#endif
Expand All @@ -306,7 +306,7 @@ void setup(void)
void loop(void)
{
mainfunc();
#if defined (ESP32) || (CONFIG_IDF_TARGET_ESP32) || (ESP_PLATFORM)
#if defined (ESP32) || defined (CONFIG_IDF_TARGET_ESP32) || defined (ESP_PLATFORM)
while (_loop_count != _draw_count) taskYIELD();
#else
drawfunc();
Expand Down
43 changes: 43 additions & 0 deletions examples/Sprite/FlashMemSprite/FlashMemSprite.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//#define LGFX_AUTODETECT

#include <LovyanGFX.hpp>

#include "image320x240x16.h"
#include "image480x320x8.h"
#include "image640x480x4.h"
#include "image1280x960x1.h"

static LGFX lcd;
static LGFX_Sprite sprite;

void setup()
{
lcd.init();
if (lcd.width() < lcd.height()) { lcd.setRotation(lcd.getRotation() ^ 1); }

// setBufferを使用することで、予め用意されたデータを用いてスプライトを使用できるようにする。
sprite.setBuffer(const_cast<std::uint8_t*>(image320x240x16), 320, 240, 16);
// sprite.setBuffer(const_cast<std::uint8_t*>(image480x320x8), 480, 320, 8);
// sprite.setBuffer(const_cast<std::uint8_t*>(image640x480x4), 640, 480, 4);
// sprite.setBuffer(const_cast<std::uint8_t*>(image1280x960x1), 1280, 960, 1);
// sprite.createPalette();

// ※ 本来const(書換不可能)なデータをconst_castにより非constと偽って使用しています。
// このため、このスプライトに対して描画を行うとプログラムはクラッシュします。
// LCDや他のスプライトに描画する関数など、読出しを行う関数のみが使用できます。
// OK) sprite.pushSprite
// OK) sprite.pushRotated
// OK) sprite.pushRotateZoom
// OK) sprite.readRect
// NG) sprite.drawPixel
// NG) sprite.fillRect
// NG) sprite.scroll
}

void loop() {
static std::uint32_t count;
if (++count == 360) count = 0;
float zoom = (((float)count) / 200) + 0.1;
sprite.pushRotateZoom(&lcd, lcd.width() >> 1, lcd.height() >> 1, count, zoom, zoom);
}

Loading

0 comments on commit 87c3288

Please sign in to comment.