Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set(COMPONENT_ADD_INCLUDEDIRS
)
file(GLOB SRCS
src/*.cpp
src/lgfx/Fonts/lvgl/lv_font_*.c
src/lgfx/Fonts/efont/*.c
src/lgfx/Fonts/IPA/*.c
src/lgfx/Fonts/lvgl/*.c
src/lgfx/utility/*.c
src/lgfx/v1/*.cpp
src/lgfx/v1/lv_font/*.c
Expand Down
2 changes: 1 addition & 1 deletion src/lgfx/utility/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4242,7 +4242,7 @@ auto RESULT_NS_IMPL::detail::throw_bad_result_access(E&& error) -> void
std::abort();
#else
std::abort();
/* // ESP32-S3向けビルドがコンパイルエラーとなるためコメントアウト by lovyan03;
/* // ESP32-S3向けビルドがコンパイルエラーとなるためコメントアウト by lovyan03;
using exception_type = bad_result_access<
typename std::remove_const<
typename std::remove_reference<E>::type
Expand Down
81 changes: 41 additions & 40 deletions src/lgfx/v1/LGFXBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,9 @@ namespace lgfx
auto scanline = (rgb888_t*)alloca(w * sizeof(rgb888_t));

startWrite();
for( int _y=0;_y<h;_y++ ) {
for( int _y=0;_y<(int)h;_y++ ) {
// only half of the scan line needs to be calculated, the other half is mirrored
for( int _x=0;_x<=w/2;_x++ ) {
for( int _x=0;_x<=(int)w/2;_x++ ) {
auto distance = pixelDistance( fmidx, fmidy, _x*vratio, _y*hratio );
scanline[_x] = map_gradient( distance, 0, hyp0, gradient );
scanline[(w-1)-_x] = scanline[_x];
Expand All @@ -1118,11 +1118,11 @@ namespace lgfx
bool is_vertical = style==VLINEAR;
const uint32_t gradient_len = is_vertical ? h : w;
auto scanline = (rgb888_t*)alloca(gradient_len * sizeof(rgb888_t));
for(int i=0;i<gradient_len;i++) { // memoize one gradient scanline
for(int i=0;i<(int)gradient_len;i++) { // memoize one gradient scanline
scanline[i] = map_gradient( i, 0, gradient_len, gradient );
}
startWrite();
for( int ys=0;ys<h;ys++ ) {
for( int ys=0;ys<(int)h;ys++ ) {
if( is_vertical ) { // scanline is used as an colors index
setColor(color888(scanline[ys].r, scanline[ys].g, scanline[ys].b));
drawFastHLine( x, y+ys, w );
Expand Down Expand Up @@ -2059,47 +2059,48 @@ namespace lgfx
uint16_t LGFXBase::decodeUTF8(uint8_t c)
{
// 7 bit Unicode Code Point
if (!(c & 0x80)) {
_decoderState = utf8_decode_state_t::utf8_state0;
return c;
}

if (_decoderState == utf8_decode_state_t::utf8_state0)
{
// 11 bit Unicode Code Point
if ((c & 0xE0) == 0xC0)
if ((c & 0x80)) {
// multibyte start or continue byte
switch (_decoderState)
{
_unicode_buffer = ((c & 0x1F)<<6);
_decoderState = utf8_decode_state_t::utf8_state1;
return 0;
}
case utf8_decode_state_t::utf8_state3:
case utf8_decode_state_t::utf8_state2:
case utf8_decode_state_t::utf8_state1:
_decoderState=(utf8_decode_state_t)((uint8_t)_decoderState-1);
_unicode_buffer |= ((c & 0x3F) << (6 * (uint8_t)_decoderState));
return _decoderState ? 0 : _unicode_buffer;

case utf8_decode_state_t::utf8_state0:
default:
// 11 bit Unicode Code Point
if ((c & 0xE0) == 0xC0)
{
_unicode_buffer = ((c & 0x1F) << (6 * 1));
_decoderState = utf8_decode_state_t::utf8_state1;
return 0;
}

// 16 bit Unicode Code Point
if ((c & 0xF0) == 0xE0)
{
_unicode_buffer = ((c & 0x0F)<<12);
_decoderState = utf8_decode_state_t::utf8_state2;
return 0;
}
// 21 bit Unicode Code Point not supported so fall-back to extended ASCII
//if ((c & 0xF8) == 0xF0) return (uint16_t)c;
}
else
{
if (_decoderState == utf8_decode_state_t::utf8_state2)
{
_unicode_buffer |= ((c & 0x3F)<<6);
_decoderState = utf8_decode_state_t::utf8_state1;
return 0;
// 16 bit Unicode Code Point
if ((c & 0xF0) == 0xE0)
{
_unicode_buffer = ((c & 0x0F) << (6 * 2));
_decoderState = utf8_decode_state_t::utf8_state2;
return 0;
}
// 21 bit Unicode Code Point not supported so fall-back to extended ASCII
if ((c & 0xF8) == 0xF0)
{
_unicode_buffer = (c & 0x07)<<(6 * 3); // 6 bits for each of the 3 bytes
_decoderState = utf8_decode_state_t::utf8_state3;
return 0;
}
// fallback to extended ASCII
break;
}
_unicode_buffer |= (c & 0x3F);
_decoderState = utf8_decode_state_t::utf8_state0;
return _unicode_buffer;
}

// single byte ASCII
_decoderState = utf8_decode_state_t::utf8_state0;

return c; // fall-back to extended ASCII
return c;
}

int32_t LGFXBase::fontHeight(const IFont* font) const
Expand Down
1 change: 1 addition & 0 deletions src/lgfx/v1/LGFXBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ namespace lgfx
{ utf8_state0 = 0
, utf8_state1 = 1
, utf8_state2 = 2
, utf8_state3 = 3
};
utf8_decode_state_t _decoderState = utf8_state0; // UTF8 decoder state
uint16_t _unicode_buffer = 0; // Unicode code-point buffer
Expand Down
17 changes: 5 additions & 12 deletions src/lgfx/v1/lgfx_fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#ifdef max
#undef max
#endif
#ifdef abs
#undef abs
#endif

namespace lgfx
{
Expand Down Expand Up @@ -960,30 +963,20 @@ namespace lgfx
}

uint8_t glyph_bpp = 8;
// NOTE: LV_FONT_GLYPH_FORMAT_* are enum values (see lv_font/font.h),
// not preprocessor macros, so they cannot be #ifdef'd.
switch (gd.format)
{
#ifdef LV_FONT_GLYPH_FORMAT_A1
case LV_FONT_GLYPH_FORMAT_A1:
#endif
#ifdef LV_FONT_GLYPH_FORMAT_A1_ALIGNED
case LV_FONT_GLYPH_FORMAT_A1_ALIGNED:
#endif
glyph_bpp = 1;
break;
#ifdef LV_FONT_GLYPH_FORMAT_A2
case LV_FONT_GLYPH_FORMAT_A2:
#endif
#ifdef LV_FONT_GLYPH_FORMAT_A2_ALIGNED
case LV_FONT_GLYPH_FORMAT_A2_ALIGNED:
#endif
glyph_bpp = 2;
break;
#ifdef LV_FONT_GLYPH_FORMAT_A4
case LV_FONT_GLYPH_FORMAT_A4:
#endif
#ifdef LV_FONT_GLYPH_FORMAT_A4_ALIGNED
case LV_FONT_GLYPH_FORMAT_A4_ALIGNED:
#endif
glyph_bpp = 4;
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/lgfx/v1/platforms/esp32/Bus_EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool Bus_EPD::init(void)
bus_config.wr_gpio_num = (gpio_num_t)_config.pin_cl;
bus_config.bus_width = _config.bus_width;
for (int i = 0; i < _config.bus_width; ++i) {
bus_config.data_gpio_nums[i] = _config.pin_data[i];
bus_config.data_gpio_nums[i] = (gpio_num_t)_config.pin_data[i];
// starting from ESP-IDF v5.4, esp_lcd_new_i80_bus removed `gpio_set_direction` call on all pins include these data pins,
// for somehow unknown reason, some of data pin like GPIO11, GPIO12 are Open-Drain mode when bootup and remains OD after
// `esp_lcd_new_i80_bus`, which will cause screen not works as expected.
Expand Down
22 changes: 15 additions & 7 deletions src/lgfx/v1/platforms/esp32/Bus_Parallel8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ Original Source:
#include <soc/i2s_struct.h>
#include <rom/gpio.h>

#if defined (ESP_IDF_VERSION_VAL) && (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0))
#define LGFX_GPIO_PAD_SELECT(pin) rom_gpio_pad_select_gpio((gpio_num_t)(pin))
#define LGFX_GPIO_MATRIX_OUT(pin, sig, inv, oen_inv) rom_gpio_matrix_out((gpio_num_t)(pin), (sig), (inv), (oen_inv))
#else
#define LGFX_GPIO_PAD_SELECT(pin) gpio_pad_select_gpio((gpio_num_t)(pin))
#define LGFX_GPIO_MATRIX_OUT(pin, sig, inv, oen_inv) gpio_matrix_out((gpio_num_t)(pin), (sig), (inv), (oen_inv))
#endif

namespace lgfx
{
inline namespace v1
Expand Down Expand Up @@ -122,21 +130,21 @@ namespace lgfx
{
int32_t pin = _cfg.pin_data[i];
if (pin < 0) { continue; }
gpio_pad_select_gpio(pin);
LGFX_GPIO_PAD_SELECT(pin);
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT_OUTPUT);
gpio_matrix_out(pin, idx_base + i, 0, 0);
LGFX_GPIO_MATRIX_OUT(pin, idx_base + i, 0, 0);
}

for (size_t i = 0; i < 3; ++i)
{
int32_t pin = _cfg.pin_ctrl[i];
if (pin < 0) { continue; }
gpio_pad_select_gpio(pin);
LGFX_GPIO_PAD_SELECT(pin);
gpio_hi(pin);
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_OUTPUT);
}

gpio_matrix_out(_cfg.pin_rs, idx_base + 8, 0, 0);
LGFX_GPIO_MATRIX_OUT(_cfg.pin_rs, idx_base + 8, 0, 0);

uint32_t dport_clk_en;
uint32_t dport_rst;
Expand All @@ -154,7 +162,7 @@ namespace lgfx
dport_rst = DPORT_I2S1_RST;
}
#endif
gpio_matrix_out(_cfg.pin_wr, idx_base, 1, 0); // WR (Write-strobe in 8080 mode, Active-low)
LGFX_GPIO_MATRIX_OUT(_cfg.pin_wr, idx_base, 1, 0); // WR (Write-strobe in 8080 mode, Active-low)

DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, dport_clk_en);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, dport_rst);
Expand Down Expand Up @@ -534,7 +542,7 @@ namespace lgfx
if (_cache_index) { _cache_index = _flush(_cache_index, true); }
_wait();

gpio_matrix_out(_cfg.pin_rs, 0x100, 0, 0);
LGFX_GPIO_MATRIX_OUT(_cfg.pin_rs, 0x100, 0, 0);
gpio_lo(_cfg.pin_rd);
}

Expand All @@ -543,7 +551,7 @@ namespace lgfx
gpio_hi(_cfg.pin_rd);

auto idx_base = (_cfg.i2s_port == I2S_NUM_0) ? I2S0O_DATA_OUT16_IDX : I2S1O_DATA_OUT16_IDX;
gpio_matrix_out(_cfg.pin_rs, idx_base, 0, 0);
LGFX_GPIO_MATRIX_OUT(_cfg.pin_rs, idx_base, 0, 0);
}

void Bus_Parallel8::_read_bytes(uint8_t* __restrict dst, uint32_t length)
Expand Down
4 changes: 3 additions & 1 deletion src/lgfx/v1/platforms/esp32/Bus_Parallel8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Original Source:
#include <freertos/FreeRTOS.h>
#endif

#if __has_include(<driver/i2s_std.h>)
#if __has_include(<driver/i2s_types.h>)
#include <driver/i2s_types.h>
#elif __has_include(<driver/i2s_std.h>)
#include <driver/i2s_std.h>
#else
#include <driver/i2s.h>
Expand Down
Loading
Loading