Skip to content

Commit

Permalink
Merge pull request #337 from lovyan03/develop
Browse files Browse the repository at this point in the history
1.1.2
  • Loading branch information
lovyan03 authored Jan 9, 2023
2 parents 79a4b91 + 80eb0e8 commit fa1e250
Show file tree
Hide file tree
Showing 17 changed files with 1,462 additions and 381 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ArduinoBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- 2.0.3
- 2.0.4
- 2.0.5
- 2.0.6

include:
# 3D matrix doesn't apply to these:
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ This library has the following advantages.
- Composite video signal (NTSC, PAL) output (only ESP32)


| | SPI | I2C | 8bit Para |16bit Para | CVBS |
|:------:|:---:|:---:|:---------:|:---------:|:-----:|
|ESP32 | HW | HW | HW (I2S) | --- |HW(I2S)|
|ESP32-S2| HW | HW | HW (I2S) | HW (I2S) | --- |
|ESP32-S3| HW | HW |HW(LCD/CAM)|HW(LCD/CAM)| --- |
|ESP32-C3| HW | HW | SW | --- | --- |
|ESP8266 | HW | SW | --- | --- | --- |
|SAMD51 | HW | HW | --- | --- | --- |
|SAMD21 | HW | HW | --- | --- | --- |
|RP2040 | HW | --- | --- | --- | --- |
| | SPI | I2C | 8bit Para |16bit Para | RGB | CVBS |
|:------:|:---:|:---:|:---------:|:---------:|:---------:|:--------:|
|ESP32 | HW | HW | HW (I2S) | --- | --- |HW(I2SDAC)|
|ESP32-S2| HW | HW | HW (I2S) | HW (I2S) | --- | --- |
|ESP32-S3| HW | HW |HW(LCD/CAM)|HW(LCD/CAM)|HW(LCD/CAM)| --- |
|ESP32-C3| HW | HW | SW | --- | --- | --- |
|ESP8266 | HW | SW | --- | --- | --- | --- |
|SAMD51 | HW | HW | --- | --- | --- | --- |
|SAMD21 | HW | HW | --- | --- | --- | --- |
|RP2040 | HW | --- | --- | --- | --- | --- |

※ HW = HardWare Peripheral / SW = SoftWare implementation

Expand All @@ -79,6 +79,7 @@ This library has the following advantages.
- ILI9486
- ILI9488 (Makerfabs Touch with Camera)
- IT8951 (M5Paper)
- NT35510/OTM8009A
- R61529
- RA8875
- RM68120
Expand Down Expand Up @@ -544,7 +545,7 @@ TomThumb font : [3-clause BSD](src/lgfx/Fonts/GFXFF/TomThumb.h) Brian J. Swetlan
実装予定 Unimplemented request
----------------
- ディスプレイ Displays
- OTM8009A / NT35510
- SEPS525
- LT7680A / LT7685
- RA8873 / RA8876
34 changes: 30 additions & 4 deletions doc/Panel_CVBS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ NTSCを使用した際に黒が僅かに白浮きしていると感じる場合
----------------

- 出力できる最大解像度は信号タイプによって差があります。
- 720 x 480 (NTSC,NTSC-J)
- 864 x 576 (PAL,PAL-M)
- 720 x 480 (PAL-M,NTSC,NTSC-J)
- 864 x 576 (PAL)
- 720 x 576 (PAL-N)
- 最大解像度以下であれば、任意の解像度を設定可能です。
- 最大解像度を整数で約分した解像度の指定を推奨します。
Expand All @@ -34,9 +34,9 @@ NTSCを使用した際に黒が僅かに白浮きしていると感じる場合
<TABLE>
<TR>
<TH></TH>
<TH> NTSC <BR> NTSC-J </TH>
<TH> PAL-M <BR> NTSC <BR> NTSC-J </TH>
<TH> PAL-N </TH>
<TH> PAL <BR> PAL-M </TH>
<TH> PAL </TH>
</TR>
<TR align="center">
<TH> max width </TH>
Expand Down Expand Up @@ -160,6 +160,12 @@ public:
cfg.chroma_level = 128; // 初期値128
// 数値を下げると彩度が下がり、0で白黒になります。数値を上げると彩度が上がります。;

// バックグラウンドでPSRAMの読出しを行うタスクの優先度を設定;
// cfg.task_priority = 25;

// バックグラウンドでPSRAMの読出しを行うタスクを実行するCPUを選択 (APP_CPU_NUM or PRO_CPU_NUM);
// cfg.task_pinned_core = PRO_CPU_NUM;

_panel_instance.config_detail(cfg);
}

Expand All @@ -172,7 +178,27 @@ LGFX gfx;

void setup(void)
{
// 色数の指定 (省略時は rgb332_1Byte)
//gfx.setColorDepth( 8); // RGB332 256色
//gfx.setColorDepth(16); // RGB565 65536色
//gfx.setColorDepth(lgfx::color_depth_t::rgb332_1Byte); // RGB332 256色
//gfx.setColorDepth(lgfx::color_depth_t::rgb565_2Byte); // RGB565 65536色
//gfx.setColorDepth(lgfx::color_depth_t::grayscale_8bit); // モノクロ 256階調

//※ 実行中に setColorDepth で色数を変更することも可能ですが、
// メモリの再割当を実行するため描画内容は無効になります。

gfx.init();

for (int x = 0; x < gfx.width(); ++x)
{
int v = x * 256 / gfx.width();
gfx.fillRect(x, 0 * gfx.height() >> 3, 7, gfx.height() >> 3, gfx.color888(v, v, v));
gfx.fillRect(x, 1 * gfx.height() >> 3, 7, gfx.height() >> 3, gfx.color888(v, 0 ,0));
gfx.fillRect(x, 2 * gfx.height() >> 3, 7, gfx.height() >> 3, gfx.color888(0, v, 0));
gfx.fillRect(x, 3 * gfx.height() >> 3, 7, gfx.height() >> 3, gfx.color888(0, 0, v));
}
delay(1000);
}

void loop(void)
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.5.0",
"version": "1.1.2",
"frameworks": ["arduino", "espidf"],
"platforms": ["espressif32", "espressif8266", "atmelsam"],
"headers": "LovyanGFX.hpp",
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.5.0
version=1.1.2
author=lovyan03
maintainer=lovyan03
sentence=TFT LCD Graphics driver with touch for ESP32, ESP8266, SAMD21, SAMD51, RP2040
Expand Down
50 changes: 22 additions & 28 deletions src/LovyanGFX.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
/*----------------------------------------------------------------------------/
Lovyan GFX library - LCD graphics library .
support platform:
ESP32 (SPI/I2S) with Arduino/ESP-IDF
ATSAMD51 (SPI) with Arduino
Original Source:
https://github.com/lovyan03/LovyanGFX/
Licence:
[BSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt)
Author:
[lovyan03](https://twitter.com/lovyan03)
Contributors:
[ciniml](https://github.com/ciniml)
[mongonta0716](https://github.com/mongonta0716)
[tobozo](https://github.com/tobozo)
Original Source:
https://github.com/lovyan03/LovyanGFX/
Licence:
[BSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt)
Author:
[lovyan03](https://twitter.com/lovyan03)
Contributors:
[ciniml](https://github.com/ciniml)
[mongonta0716](https://github.com/mongonta0716)
[tobozo](https://github.com/tobozo)
/----------------------------------------------------------------------------*/
#ifndef LOVYANGFX_HPP_
#define LOVYANGFX_HPP_
Expand All @@ -26,22 +22,20 @@ Original Source:
#undef setFont
#endif

#if __has_include("lgfx/v1_init.hpp") && ( defined ( LGFX_USE_V1 ) || !__has_include("lgfx/v0_init.hpp") )
#if defined ( LGFX_USE_V0 ) && __has_include("lgfx/v0_init.hpp")

#include "lgfx/v0_init.hpp"

#include "lgfx/v1_init.hpp"
#else

#if defined ( LGFX_AUTODETECT )
#include "lgfx/v1_init.hpp"

#include "LGFX_AUTODETECT.hpp"
#if defined ( LGFX_AUTODETECT )

#endif
#include "LGFX_AUTODETECT.hpp"

#else // if defined ( LGFX_USE_V0 )
#endif

#if __has_include("lgfx/v0_init.hpp")
#include "lgfx/v0_init.hpp"
#endif

#endif

#endif
14 changes: 9 additions & 5 deletions src/lgfx/v1/LGFXBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,9 @@ namespace lgfx
}
else
{
if (dst_depth == rgb565_2Byte) { pc.fp_copy = pixelcopy_t::copy_rgb_fast<swap565_t, T>; }
else { pc.fp_copy = pixelcopy_t::copy_rgb_fast<rgb332_t, T>; }
if ( dst_depth == rgb565_2Byte) { pc.fp_copy = pixelcopy_t::copy_rgb_fast<swap565_t, T>; }
else if (dst_depth == rgb332_1Byte) { pc.fp_copy = pixelcopy_t::copy_rgb_fast<rgb332_t, T>; }
else { pc.fp_copy = pixelcopy_t::copy_rgb_fast<grayscale_t, T>; }
}
return pc;
}
Expand Down Expand Up @@ -919,8 +920,9 @@ namespace lgfx
}
else
{
if (dst_depth == rgb565_2Byte) { pc.fp_copy = pixelcopy_t::copy_palette_fast<swap565_t, T>; }
else { pc.fp_copy = pixelcopy_t::copy_palette_fast<rgb332_t, T>; }
if ( dst_depth == rgb565_2Byte) { pc.fp_copy = pixelcopy_t::copy_palette_fast<swap565_t, T>; }
else if (dst_depth == rgb332_1Byte) { pc.fp_copy = pixelcopy_t::copy_palette_fast<rgb332_t, T>; }
else { pc.fp_copy = pixelcopy_t::copy_palette_fast<grayscale_t, T>; }
}
}
return pc;
Expand Down Expand Up @@ -1060,8 +1062,10 @@ namespace lgfx
{
if (depth == rgb565_2Byte) {
pc.fp_copy = pixelcopy_t::copy_rgb_antialias<swap565_t>;
} else {
} else if (depth == rgb332_1Byte) {
pc.fp_copy = pixelcopy_t::copy_rgb_antialias<rgb332_t>;
} else {
pc.fp_copy = pixelcopy_t::copy_rgb_antialias<grayscale_t>;
}
}
return pc;
Expand Down
2 changes: 1 addition & 1 deletion src/lgfx/v1/gitTagVersion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define LGFX_VERSION_MAJOR 1
#define LGFX_VERSION_MINOR 1
#define LGFX_VERSION_PATCH 0
#define LGFX_VERSION_PATCH 2
#define LOVYANGFX_VERSION F( LGFX_VERSION_MAJOR "." LGFX_VERSION_MINOR "." LGFX_VERSION_PATCH )
32 changes: 20 additions & 12 deletions src/lgfx/v1/misc/colortype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,15 @@ namespace lgfx
template<> LGFX_INLINE uint32_t color_convert<bgra8888_t , bgr666_t >(uint32_t c) { c<<=2; return (c << 8) + ((c & 0xC0C0C0) << 2) + 0xFF; }
template<> LGFX_INLINE uint32_t color_convert<bgra8888_t , bgr888_t >(uint32_t c) { return (c << 8) + 0xFF; }
template<> LGFX_INLINE uint32_t color_convert<bgra8888_t , grayscale_t>(uint32_t c) { return (((c << 8) + c) << 16) + (c << 8) + 0xFF; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb332_t >(uint32_t c) { uint_fast16_t t = ((c>>5)*0x49); t += ((c>>2)&7)*0x92; t += (c&3) * 0xAA; return t >> 3; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb565_t >(uint32_t c) { uint_fast16_t g = ( c & 0x07E0); g |= g >> 6; uint_fast16_t rb = ((c>>11)+(c&0x1F))*0x21; return (rb+g)>>4; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb888_t >(uint32_t c) { uint_fast16_t g = ( c >> 8) & 0xFF; g = (g << 1) + (g >> 7); return (g + ((c>>16)&0xFF)+(c&0xFF))>>2; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, argb8888_t >(uint32_t c) { uint_fast16_t g = ( c >> 8) & 0xFF; g = (g << 1) + (g >> 7); return (g + ((c>>16)&0xFF)+(c&0xFF))>>2; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, swap565_t >(uint32_t c) { uint_fast16_t rb = ((((c>>3)&0x1F) + ((c>>8)&0x1F)) * 0x21) >> 2; uint_fast16_t g = (c & 7); g = (((g << 3) + (c >> 13)) << 3) + g; return (rb+g) >> 2; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, bgr666_t >(uint32_t c) { uint_fast16_t g = ((c >> 8) & 0x3F)*0x82; uint_fast16_t rb = ((c>>16) + (c&0x3F))*0x41; return (rb+g)>>6; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, bgr888_t >(uint32_t c) { uint_fast16_t g = ( c >> 8) & 0xFF; g = (g << 1) + (g >> 7); return (g + ((c>>16)&0xFF)+(c&0xFF))>>2; }

// ITU-R BT.601 RGB to Y convert R 0.299 + G 0.587 + B 0.114
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb332_t >(uint32_t c) { return (((c >> 5) & 0x07) * 43 + ((c >> 2) & 0x07) * 86 + (c & 0x03) * 39) >> 2; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb565_t >(uint32_t c) { return (((c >> 11) & 0x1F) * 79 + ((c >> 5) & 0x3F) * 76 + (c & 0x1F) * 30) >> 5; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, rgb888_t >(uint32_t c) { return (((c >> 16) & 0xFF) * 77 + ((c >> 8) & 0xFF) * 151 + (c & 0xFF) * 29) >> 8; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, argb8888_t >(uint32_t c) { return (((c >> 24) & 0xFF) * 77 + ((c >> 16) & 0xFF) * 151 + ((c >> 8) & 0xFF) * 29) >> 8; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, swap565_t >(uint32_t c) { return (((c >> 3) & 0x1F) * 79+(((c<<3)+(c>>13))&0x3F)*76 + ((c >> 8) & 0x1F) * 30) >> 5; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, bgr666_t >(uint32_t c) { return (( c & 0x3F) * 39 + ((c >> 8) & 0x3F) * 76 + ((c >> 16) & 0x3F) * 15) >> 5; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, bgr888_t >(uint32_t c) { return (( c & 0xFF) * 77 + ((c >> 8) & 0xFF) * 151 + ((c >> 16) & 0xFF) * 29) >> 8; }
template<> LGFX_INLINE uint32_t color_convert<grayscale_t, bgra8888_t >(uint32_t c) { return color_convert<grayscale_t, bgr888_t>(c>>8); }

LGFX_INLINE rgb332_t& rgb332_t ::operator=(const rgb565_t& c) { set(color_convert<rgb332_t , rgb565_t >(c.get())); return *this; }
Expand Down Expand Up @@ -708,6 +710,7 @@ namespace lgfx
case rgb666_3Byte : return color_convert<bgr666_t , rgb332_t>;
case rgb565_2Byte : return color_convert<swap565_t , rgb332_t>;
case rgb332_1Byte : return no_convert;
case grayscale_8bit: return color_convert<grayscale_t, rgb332_t>;
default: break;
}
} else if (std::is_same<TSrc, rgb888_t>::value || std::is_same<TSrc, uint32_t>::value) {
Expand All @@ -717,6 +720,7 @@ namespace lgfx
case rgb666_3Byte : return color_convert<bgr666_t , rgb888_t>;
case rgb565_2Byte : return color_convert<swap565_t , rgb888_t>;
case rgb332_1Byte : return color_convert<rgb332_t , rgb888_t>;
case grayscale_8bit: return color_convert<grayscale_t,rgb888_t>;
default: break;
}
} else if (std::is_same<TSrc, argb8888_t>::value) {
Expand All @@ -726,6 +730,7 @@ namespace lgfx
case rgb666_3Byte : return color_convert<bgr666_t , rgb888_t>;
case rgb565_2Byte : return color_convert<swap565_t, rgb888_t>;
case rgb332_1Byte : return color_convert<rgb332_t , rgb888_t>;
case grayscale_8bit: return color_convert<grayscale_t,rgb888_t>;
default: break;
}
} else if (std::is_same<TSrc, bgr888_t>::value) {
Expand All @@ -735,6 +740,7 @@ namespace lgfx
case rgb666_3Byte : return color_convert<bgr666_t , bgr888_t>;
case rgb565_2Byte : return color_convert<swap565_t , bgr888_t>;
case rgb332_1Byte : return color_convert<rgb332_t , bgr888_t>;
case grayscale_8bit: return color_convert<grayscale_t,bgr888_t>;
default: break;
}
} else { // if (std::is_same<TSrc, rgb565_t>::value || std::is_same<TSrc, uint16_t>::value || std::is_same<TSrc, int>::value)
Expand All @@ -744,6 +750,7 @@ namespace lgfx
case rgb666_3Byte : return color_convert<bgr666_t , rgb565_t>;
case rgb565_2Byte : return getSwap16;
case rgb332_1Byte : return color_convert<rgb332_t , rgb565_t>;
case grayscale_8bit: return color_convert<grayscale_t,rgb565_t>;
default: break;
}
}
Expand Down Expand Up @@ -822,11 +829,12 @@ namespace lgfx
convert_bgr888 = get_fp_convert_src<bgr888_t >(depth_);

switch (depth_) {
case argb8888_4Byte: revert_rgb888 = color_convert<rgb888_t, bgra8888_t>; break;
case rgb888_3Byte: revert_rgb888 = color_convert<rgb888_t, bgr888_t >; break;
case rgb666_3Byte: revert_rgb888 = color_convert<rgb888_t, bgr666_t >; break;
case rgb565_2Byte: revert_rgb888 = color_convert<rgb888_t, swap565_t >; break;
case rgb332_1Byte: revert_rgb888 = color_convert<rgb888_t, rgb332_t >; break;
case argb8888_4Byte: revert_rgb888 = color_convert<rgb888_t, bgra8888_t >; break;
case rgb888_3Byte: revert_rgb888 = color_convert<rgb888_t, bgr888_t >; break;
case rgb666_3Byte: revert_rgb888 = color_convert<rgb888_t, bgr666_t >; break;
case rgb565_2Byte: revert_rgb888 = color_convert<rgb888_t, swap565_t >; break;
case rgb332_1Byte: revert_rgb888 = color_convert<rgb888_t, rgb332_t >; break;
case grayscale_8bit: revert_rgb888 = color_convert<rgb888_t, grayscale_t>; break;
default: revert_rgb888 = no_convert;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/lgfx/v1/misc/pixelcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ namespace lgfx
if (src_depth == rgb565_2Byte) {
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<swap565_t>(dst_depth);
fp_skip = pixelcopy_t::skip_rgb_affine<swap565_t>;
} else { // src_depth == rgb332_1Byte:
} else if (src_depth == rgb332_1Byte) {
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<rgb332_t >(dst_depth);
fp_skip = pixelcopy_t::skip_rgb_affine<rgb332_t>;
} else { // src_depth == grayscale_8bit:
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<grayscale_t >(dst_depth);
fp_skip = pixelcopy_t::skip_rgb_affine<grayscale_t>;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/lgfx/v1/misc/pixelcopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace lgfx
: (dst_depth == rgb666_3Byte) ? (std::is_same<bgr666_t, TSrc>::value
? copy_rgb_affine<bgr888_t, bgr888_t>
: copy_rgb_affine<bgr666_t, TSrc>)
: (dst_depth == grayscale_8bit) ? copy_rgb_affine<grayscale_t, TSrc>
: nullptr;
}

Expand All @@ -119,6 +120,7 @@ namespace lgfx
{
return (src_depth == rgb565_2Byte) ? copy_rgb_affine<TDst, swap565_t>
: (src_depth == rgb332_1Byte) ? copy_rgb_affine<TDst, rgb332_t >
: (src_depth == grayscale_8bit) ? copy_rgb_affine<TDst, grayscale_t>
: (src_depth == rgb888_3Byte) ? copy_rgb_affine<TDst, bgr888_t >
: (std::is_same<bgr666_t, TDst>::value)
? copy_rgb_affine<bgr888_t, bgr888_t>
Expand All @@ -132,6 +134,7 @@ namespace lgfx
: (dst_depth == rgb332_1Byte) ? copy_palette_affine<rgb332_t , TPalette>
: (dst_depth == rgb888_3Byte) ? copy_palette_affine<bgr888_t , TPalette>
: (dst_depth == rgb666_3Byte) ? copy_palette_affine<bgr666_t , TPalette>
: (dst_depth == grayscale_8bit) ? copy_palette_affine<grayscale_t, TPalette>
: nullptr;
}

Expand Down
Loading

0 comments on commit fa1e250

Please sign in to comment.