Skip to content

Commit bf16c3d

Browse files
authored
Merge pull request #154 from m5stack/develop
0.2.14
2 parents 232e0d8 + fbe11fc commit bf16c3d

File tree

9 files changed

+221
-158
lines changed

9 files changed

+221
-158
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "git",
1111
"url": "https://github.com/m5stack/M5GFX.git"
1212
},
13-
"version": "0.2.13",
13+
"version": "0.2.14",
1414
"frameworks": ["arduino", "espidf", "*"],
1515
"platforms": ["espressif32", "native"],
1616
"headers": "M5GFX.h"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5GFX
2-
version=0.2.13
2+
version=0.2.14
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack All Display

src/M5GFX.cpp

Lines changed: 185 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <soc/gpio_reg.h>
1515

1616
#include "lgfx/v1/panel/Panel_ILI9342.hpp"
17+
#include "lgfx/v1/panel/Panel_SSD1306.hpp"
1718
#include "lgfx/v1/panel/Panel_ST7735.hpp"
1819
#include "lgfx/v1/panel/Panel_ST7789.hpp"
1920
#include "lgfx/v1/panel/Panel_GC9A01.hpp"
@@ -2058,142 +2059,205 @@ The usage of each pin is as follows.
20582059
std::uint32_t pkg_ver = m5gfx::get_pkg_ver();
20592060
ESP_LOGD(LIBRARY_NAME, "pkg_ver : %02x", (int)pkg_ver);
20602061

2061-
if (board == 0 || board == board_t::board_M5NanoC6)
2062-
{
2063-
}
2064-
2065-
if (board == 0 || board == board_t::board_ArduinoNessoN1)
2066-
{
2067-
gpio::pin_backup_t backup_pins[] =
2068-
{ GPIO_NUM_8
2069-
, GPIO_NUM_10
2070-
, GPIO_NUM_16
2071-
, GPIO_NUM_17
2072-
, GPIO_NUM_20
2073-
, GPIO_NUM_21
2074-
, GPIO_NUM_22
2075-
};
2076-
auto result = lgfx::gpio::command(
2077-
(const uint8_t[]) {
2078-
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_8,
2079-
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_10,
2080-
lgfx::gpio::command_read , GPIO_NUM_8,
2081-
lgfx::gpio::command_read , GPIO_NUM_10,
2082-
lgfx::gpio::command_end
2083-
}
2084-
);
2085-
2086-
if (result == 0x03) {
2087-
// PI4IO E0
2088-
// P0 BTN1
2089-
// P1 BTN2
2090-
// P2-P5 NC
2091-
// P5 LNA Enable
2092-
// P6 RF Switch
2093-
// P7 LoRa Reset
2094-
static constexpr const uint8_t reg_data_io1[] = {
2095-
0x03, 0b11100000, 0, // PI4IO_REG_IO_DIR
2096-
0x05, 0b10000000, 0, // PI4IO_REG_OUT_SET
2097-
0x07, 0b00011100, 0, // PI4IO_REG_OUT_H_IM
2098-
0x0D, 0b11000011, 0, // PI4IO_REG_PULL_SEL
2099-
0x0B, 0b11000011, 0, // PI4IO_REG_PULL_EN
2100-
0x09, 0b00000011, 0, // PI4IO_REG_IN_DEF_STA
2101-
0x11, 0b11111100, 0, // PI4IO_REG_INT_MASK
2102-
0xFF,0xFF,0xFF,
2103-
};
2104-
// PI4IO E1
2105-
// P0 Power OFF system
2106-
// P1 LCD_RST
2107-
// P2 EXT_PWR_EN
2108-
// P3 NC
2109-
// P4 NC
2110-
// P5 VIN_DET
2111-
// P6 LCD_BL
2112-
// P7 SYS_LEDG Low-level light
2113-
static constexpr const uint8_t reg_data_io2[] = {
2114-
0x03, 0b11000111, 0, // PI4IO_REG_IO_DIR
2115-
0x07, 0b00011000, 0, // PI4IO_REG_OUT_H_IM
2116-
0x05, 0b00000000, 0, // PI4IO_REG_OUT_SET
2117-
0x0D, 0b10000000, 0, // PI4IO_REG_PULL_SEL
2118-
0x0B, 0b11111111, 0, // PI4IO_REG_PULL_EN
2119-
0x05, 0b10000010, 0, // PI4IO_REG_OUT_SET
2120-
0xFF,0xFF,0xFF,
2062+
if (pkg_ver == 1)
2063+
{ // ESP32C6FH4(QFN32) : NanoC6
2064+
if (board == 0 || board == board_t::board_M5NanoC6)
2065+
{
2066+
}
2067+
} else
2068+
if (pkg_ver == 0)
2069+
{ // ESP32C6(QFN40) : NessoN1, UnitC6L
2070+
if (board == 0 || board == board_t::board_ArduinoNessoN1 || board == board_t::board_M5UnitC6L)
2071+
{
2072+
gpio::pin_backup_t backup_pins[] =
2073+
{ GPIO_NUM_8
2074+
, GPIO_NUM_10
2075+
, GPIO_NUM_16
2076+
, GPIO_NUM_17
2077+
, GPIO_NUM_18
2078+
, GPIO_NUM_20
2079+
, GPIO_NUM_21
2080+
, GPIO_NUM_22
21212081
};
2122-
lgfx::i2c::init(i2c_port, GPIO_NUM_10, GPIO_NUM_8);
2123-
i2c_write_register8_array(i2c_port, pi4io2_i2c_addr, reg_data_io2, 100000);
2124-
i2c_write_register8_array(i2c_port, pi4io1_i2c_addr, reg_data_io1, 100000);
2125-
2126-
bus_cfg.pin_mosi = GPIO_NUM_21;
2127-
bus_cfg.pin_miso = GPIO_NUM_22;
2128-
bus_cfg.pin_sclk = GPIO_NUM_20;
2129-
bus_cfg.pin_dc = GPIO_NUM_16;
2130-
bus_cfg.spi_mode = 0;
2131-
bus_cfg.spi_3wire = true;
2132-
bus_spi->config(bus_cfg);
2133-
bus_spi->init();
2082+
/*
2083+
| | NessoN1 | UnitC6L |
2084+
|:--:+:-------:+:-------:|
2085+
| G8 | SYS_SCL | SYS_SCL |
2086+
| G10| SYS_SDA | SYS_SDA |
2087+
| G18| GND | NC |
2088+
*/
2089+
auto result = lgfx::gpio::command(
2090+
(const uint8_t[]) {
2091+
lgfx::gpio::command_mode_input_pullup , GPIO_NUM_18,
2092+
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_8,
2093+
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_10,
2094+
lgfx::gpio::command_read , GPIO_NUM_18,
2095+
lgfx::gpio::command_read , GPIO_NUM_8,
2096+
lgfx::gpio::command_read , GPIO_NUM_10,
2097+
lgfx::gpio::command_end
2098+
}
2099+
);
2100+
// 3 == NessoN1 / 7 == UnitC6L
2101+
// ESP_LOGE("debug", "\n\nN1/C6L detect %02x\n\n\n", (int)result);
2102+
if (result == 0x07)
2103+
{ // UnitC6L ?
2104+
lgfx::i2c::init(i2c_port, GPIO_NUM_10, GPIO_NUM_8);
2105+
2106+
_pin_reset(GPIO_NUM_6, use_reset); // LCD RST
2107+
bus_cfg.pin_mosi = GPIO_NUM_21;
2108+
bus_cfg.pin_miso = GPIO_NUM_22; // NC
2109+
bus_cfg.pin_sclk = GPIO_NUM_20;
2110+
bus_cfg.pin_dc = GPIO_NUM_18;
2111+
bus_cfg.spi_mode = 0;
2112+
bus_cfg.spi_3wire = true;
2113+
bus_spi->config(bus_cfg);
2114+
bus_spi->init();
21342115

2135-
id = _read_panel_id(bus_spi, GPIO_NUM_17);
2136-
// check panel (ST7789)
2137-
if ((id & 0xFB) == 0x81) // 0x81 or 0x85
2138-
{
2139-
board = board_t::board_ArduinoNessoN1;
2140-
ESP_LOGI(LIBRARY_NAME, "[Autodetect] board_ArduinoNessoN1");
2116+
// id = _read_panel_id(bus_spi, GPIO_NUM_6);
2117+
// if (id == 0x??) // check panel (SSD1306)
2118+
{
2119+
board = board_t::board_M5UnitC6L;
2120+
ESP_LOGI(LIBRARY_NAME, "[Autodetect] board_M5UnitC6L");
21412121

2122+
bus_spi->release();
2123+
bus_cfg.freq_write = 40000000;
2124+
bus_cfg.freq_read = 10000000;
2125+
bus_spi->config(bus_cfg);
2126+
bus_spi->init();
2127+
auto p = new Panel_SSD1306();
2128+
p->bus(bus_spi);
2129+
{
2130+
_panel_last.reset(p);
2131+
auto cfg = p->config();
2132+
cfg.pin_cs = GPIO_NUM_6; // OLED CS
2133+
cfg.pin_rst = GPIO_NUM_15; // OLED RST
2134+
cfg.panel_width = 64;
2135+
cfg.panel_height = 48;
2136+
cfg.offset_x = 32;
2137+
cfg.offset_y = 0;
2138+
cfg.offset_rotation = 0;
2139+
cfg.readable = true;
2140+
cfg.bus_shared = false;
2141+
p->config(cfg);
2142+
p->setRotation(0);
2143+
}
2144+
goto init_clear;
2145+
}
21422146
bus_spi->release();
2143-
bus_cfg.freq_write = 40000000;
2144-
bus_cfg.freq_read = 16000000;
2147+
} else
2148+
if (result == 0x03)
2149+
{ // NessoN1 ?
2150+
lgfx::i2c::init(i2c_port, GPIO_NUM_10, GPIO_NUM_8);
2151+
// PI4IO E0
2152+
// P0 BTN1
2153+
// P1 BTN2
2154+
// P2-P5 NC
2155+
// P5 LNA Enable
2156+
// P6 RF Switch
2157+
// P7 LoRa Reset
2158+
static constexpr const uint8_t reg_data_io1[] = {
2159+
0x03, 0b11100000, 0, // PI4IO_REG_IO_DIR
2160+
0x05, 0b10000000, 0, // PI4IO_REG_OUT_SET
2161+
0x07, 0b00011100, 0, // PI4IO_REG_OUT_H_IM
2162+
0x0D, 0b11000011, 0, // PI4IO_REG_PULL_SEL
2163+
0x0B, 0b11000011, 0, // PI4IO_REG_PULL_EN
2164+
0x09, 0b00000011, 0, // PI4IO_REG_IN_DEF_STA
2165+
0x11, 0b11111100, 0, // PI4IO_REG_INT_MASK
2166+
0xFF,0xFF,0xFF,
2167+
};
2168+
// PI4IO E1
2169+
// P0 Power OFF system
2170+
// P1 LCD_RST
2171+
// P2 EXT_PWR_EN
2172+
// P3 NC
2173+
// P4 NC
2174+
// P5 VIN_DET
2175+
// P6 LCD_BL
2176+
// P7 SYS_LEDG Low-level light
2177+
static constexpr const uint8_t reg_data_io2[] = {
2178+
0x03, 0b11000111, 0, // PI4IO_REG_IO_DIR
2179+
0x07, 0b00011000, 0, // PI4IO_REG_OUT_H_IM
2180+
0x05, 0b00000000, 0, // PI4IO_REG_OUT_SET
2181+
0x0D, 0b10000000, 0, // PI4IO_REG_PULL_SEL
2182+
0x0B, 0b11111111, 0, // PI4IO_REG_PULL_EN
2183+
0x05, 0b10000010, 0, // PI4IO_REG_OUT_SET
2184+
0xFF,0xFF,0xFF,
2185+
};
2186+
i2c_write_register8_array(i2c_port, pi4io2_i2c_addr, reg_data_io2, 100000);
2187+
i2c_write_register8_array(i2c_port, pi4io1_i2c_addr, reg_data_io1, 100000);
2188+
2189+
bus_cfg.pin_mosi = GPIO_NUM_21;
2190+
bus_cfg.pin_miso = GPIO_NUM_22;
2191+
bus_cfg.pin_sclk = GPIO_NUM_20;
2192+
bus_cfg.pin_dc = GPIO_NUM_16;
2193+
bus_cfg.spi_mode = 0;
2194+
bus_cfg.spi_3wire = true;
21452195
bus_spi->config(bus_cfg);
21462196
bus_spi->init();
2147-
auto p = new Panel_ST7789();
2148-
p->bus(bus_spi);
2149-
{
2150-
_panel_last.reset(p);
2151-
auto cfg = p->config();
2152-
cfg.pin_cs = GPIO_NUM_17; // LCD CS
2153-
cfg.pin_rst = -1;
2154-
cfg.panel_width = 135;
2155-
cfg.panel_height = 240;
2156-
cfg.offset_x = 52;
2157-
cfg.offset_y = 40;
2158-
cfg.offset_rotation = 0;
2159-
cfg.readable = true;
2160-
cfg.invert = true;
2161-
cfg.bus_shared = true;
2162-
p->config(cfg);
2163-
p->setRotation(0);
2164-
}
21652197

2198+
id = _read_panel_id(bus_spi, GPIO_NUM_17);
2199+
// check panel (ST7789)
2200+
if ((id & 0xFB) == 0x81) // 0x81 or 0x85
21662201
{
2167-
auto t = new m5gfx::Touch_FT5x06();
2168-
if (t) {
2169-
_touch_last.reset(t);
2170-
auto cfg = t->config();
2202+
board = board_t::board_ArduinoNessoN1;
2203+
ESP_LOGI(LIBRARY_NAME, "[Autodetect] board_ArduinoNessoN1");
21712204

2172-
cfg.x_min = 0;
2173-
cfg.x_max = 134;
2174-
cfg.y_min = 0;
2175-
cfg.y_max = 239;
2176-
cfg.bus_shared = true;
2177-
cfg.offset_rotation = 0;
2178-
2179-
cfg.i2c_port = I2C_NUM_0;
2180-
cfg.i2c_addr = 0x38;
2205+
bus_spi->release();
2206+
bus_cfg.freq_write = 40000000;
2207+
bus_cfg.freq_read = 16000000;
2208+
bus_spi->config(bus_cfg);
2209+
bus_spi->init();
2210+
auto p = new Panel_ST7789();
2211+
p->bus(bus_spi);
2212+
{
2213+
_panel_last.reset(p);
2214+
auto cfg = p->config();
2215+
cfg.pin_cs = GPIO_NUM_17; // LCD CS
21812216
cfg.pin_rst = -1;
2182-
cfg.pin_int = GPIO_NUM_3;
2183-
cfg.pin_sda = GPIO_NUM_10;
2184-
cfg.pin_scl = GPIO_NUM_8;
2185-
cfg.freq = 400000;
2217+
cfg.panel_width = 135;
2218+
cfg.panel_height = 240;
2219+
cfg.offset_x = 52;
2220+
cfg.offset_y = 40;
2221+
cfg.offset_rotation = 0;
2222+
cfg.readable = true;
2223+
cfg.invert = true;
2224+
cfg.bus_shared = true;
2225+
p->config(cfg);
2226+
p->setRotation(0);
2227+
}
21862228

2187-
t->config(cfg);
2188-
p->touch(t);
2229+
{
2230+
auto t = new m5gfx::Touch_FT5x06();
2231+
if (t) {
2232+
_touch_last.reset(t);
2233+
auto cfg = t->config();
2234+
2235+
cfg.x_min = 0;
2236+
cfg.x_max = 134;
2237+
cfg.y_min = 0;
2238+
cfg.y_max = 239;
2239+
cfg.bus_shared = true;
2240+
cfg.offset_rotation = 0;
2241+
2242+
cfg.i2c_port = I2C_NUM_0;
2243+
cfg.i2c_addr = 0x38;
2244+
cfg.pin_rst = -1;
2245+
cfg.pin_int = GPIO_NUM_3;
2246+
cfg.pin_sda = GPIO_NUM_10;
2247+
cfg.pin_scl = GPIO_NUM_8;
2248+
cfg.freq = 400000;
2249+
2250+
t->config(cfg);
2251+
p->touch(t);
2252+
}
21892253
}
2254+
_set_backlight(new Light_ArduinoNessoN1());
2255+
goto init_clear;
21902256
}
2191-
_set_backlight(new Light_ArduinoNessoN1());
2192-
goto init_clear;
2257+
bus_spi->release();
21932258
}
2194-
bus_spi->release();
2259+
for (auto &bup : backup_pins) { bup.restore(); }
21952260
}
2196-
for (auto &bup : backup_pins) { bup.restore(); }
21972261
}
21982262

21992263
#endif

src/lgfx/v1/gitTagVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#define LGFX_VERSION_MAJOR 1
22
#define LGFX_VERSION_MINOR 2
3-
#define LGFX_VERSION_PATCH 13
3+
#define LGFX_VERSION_PATCH 14
44
#define LOVYANGFX_VERSION F( LGFX_VERSION_MAJOR "." LGFX_VERSION_MINOR "." LGFX_VERSION_PATCH )

src/lgfx/v1/misc/pixelcopy.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ namespace lgfx
6969
if (src_depth == rgb565_2Byte) {
7070
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<swap565_t>(dst_depth);
7171
fp_skip = pixelcopy_t::skip_rgb_affine<swap565_t>;
72+
} else if (src_depth == rgb565_nonswapped) {
73+
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<rgb565_t>(dst_depth);
74+
fp_skip = pixelcopy_t::skip_rgb_affine<rgb565_t>;
7275
} else if (src_depth == rgb332_1Byte) {
7376
fp_copy = pixelcopy_t::get_fp_copy_rgb_affine<rgb332_t >(dst_depth);
7477
fp_skip = pixelcopy_t::skip_rgb_affine<rgb332_t>;
@@ -111,7 +114,7 @@ namespace lgfx
111114
param->src_y32 += param->src_y32_add;
112115
uint32_t raw = (pgm_read_byte(&s[i >> 3]) >> (-((int32_t)i + param->src_bits) & 7)) & param->src_mask;
113116
if (raw != param->transp) {
114-
auto dstidx = index * param->dst_bits;
117+
uint32_t dstidx = index * param->dst_bits;
115118
auto shift = (-(int32_t)(dstidx + param->dst_bits)) & 7;
116119
auto tmp = &d[dstidx >> 3];
117120
*tmp = (*tmp & ~(param->dst_mask << shift)) | ((param->dst_mask & raw) << shift);

src/lgfx/v1/misc/pixelcopy.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ namespace lgfx
209209
const auto src_x32_add = param->src_x32_add;
210210
const auto src_y32_add = param->src_y32_add;
211211

212-
uint32_t prev_i = (param->src_x + param->src_y * param->src_bitwidth);
213-
uint32_t ibits = prev_i * param->src_bits;
212+
int prev_i = (param->src_x + param->src_y * param->src_bitwidth);
213+
int ibits = prev_i * param->src_bits;
214214
uint32_t prev_raw = (pgm_read_byte(&s[ibits >> 3]) >> (-(int32_t)(ibits + param->src_bits) & 7)) & param->src_mask;
215215
do {
216216
if (prev_raw == transp) { break; }
@@ -220,7 +220,7 @@ namespace lgfx
220220
++color_len;
221221
param->src_x32 += src_x32_add;
222222
param->src_y32 += src_y32_add;
223-
uint32_t i = (param->src_x + param->src_y * param->src_bitwidth);
223+
int i = (param->src_x + param->src_y * param->src_bitwidth);
224224
if (prev_i == i) { continue; }
225225
prev_i = i;
226226
ibits = i * param->src_bits;

0 commit comments

Comments
 (0)