Skip to content

Commit ff11e09

Browse files
authored
Merge pull request #102 from m5stack/develop
0.1.17
2 parents fa3fc1c + f882faf commit ff11e09

File tree

17 files changed

+253
-75
lines changed

17 files changed

+253
-75
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Supported device
1212
----------------
1313
- M5Stack ( Basic / Gray / GO / Fire )
1414
- M5Stack Core2
15+
- M5Stack CoreS3 / CoreS3SE
1516
- M5Stack CoreInk
1617
- M5Stick C
1718
- M5Stick C Plus
@@ -23,6 +24,7 @@ Supported device
2324
- M5Dial
2425
- M5DinMeter
2526
- M5Cardputer
27+
- M5VAMeter
2628
- UnitOLED
2729
- UnitMiniOLED
2830
- UnitLCD

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.1.16",
13+
"version": "0.1.17",
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.1.16
2+
version=0.1.17
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack All Display

src/M5GFX.cpp

Lines changed: 75 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ namespace m5gfx
325325
static constexpr int32_t i2c_freq = 400000;
326326
static constexpr int_fast16_t aw9523_i2c_addr = 0x58; // AW9523B
327327
static constexpr int_fast16_t axp_i2c_addr = 0x34; // AXP2101
328+
static constexpr int_fast16_t gc0308_i2c_addr = 0x21; // GC0308
328329
static constexpr int_fast16_t i2c_port = I2C_NUM_1;
329330
static constexpr int_fast16_t i2c_sda = GPIO_NUM_12;
330331
static constexpr int_fast16_t i2c_scl = GPIO_NUM_11;
@@ -424,6 +425,26 @@ namespace m5gfx
424425
}
425426
};
426427

428+
struct Light_M5StackAtomS3R : public lgfx::ILight
429+
{
430+
bool init(uint8_t brightness) override
431+
{
432+
lgfx::i2c::init(i2c_port, GPIO_NUM_45, GPIO_NUM_0);
433+
lgfx::i2c::writeRegister8(i2c_port, 48, 0x00, 0b01000000, 0, i2c_freq);
434+
lgfx::delay(1);
435+
lgfx::i2c::writeRegister8(i2c_port, 48, 0x08, 0b00000001, 0, i2c_freq);
436+
lgfx::i2c::writeRegister8(i2c_port, 48, 0x70, 0b00000000, 0, i2c_freq);
437+
438+
setBrightness(brightness);
439+
return true;
440+
}
441+
442+
void setBrightness(uint8_t brightness) override
443+
{
444+
lgfx::i2c::writeRegister8(i2c_port, 48, 0x0e, brightness, 0, i2c_freq);
445+
}
446+
};
447+
427448
#endif
428449

429450
__attribute__ ((unused))
@@ -1183,7 +1204,8 @@ namespace m5gfx
11831204
m5gfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x12, 0b11111111); // LEDMODE_P0
11841205
m5gfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x13, 0b11111111); // LEDMODE_P1
11851206
m5gfx::i2c::writeRegister8(i2c_port, axp_i2c_addr, 0x90, 0xBF); // LDOS ON/OFF control 0
1186-
m5gfx::i2c::writeRegister8(i2c_port, axp_i2c_addr, 0x95, 0x28); // ALDO3 set to 3.3v // for TF card slot
1207+
m5gfx::i2c::writeRegister8(i2c_port, axp_i2c_addr, 0x94, 33 - 5); // ALDO3 set to 3.3v // for GC0308 Camera
1208+
m5gfx::i2c::writeRegister8(i2c_port, axp_i2c_addr, 0x95, 33 - 5); // ALDO4 set to 3.3v // for TF card slot
11871209

11881210
bus_cfg.pin_mosi = GPIO_NUM_37;
11891211
bus_cfg.pin_miso = GPIO_NUM_35;
@@ -1199,31 +1221,14 @@ namespace m5gfx
11991221
id = _read_panel_id(bus_spi, GPIO_NUM_3);
12001222
if ((id & 0xFF) == 0xE3)
12011223
{ // check panel (ILI9342)
1202-
gpio::pin_backup_t backup_pins[] = { GPIO_NUM_38, GPIO_NUM_45, GPIO_NUM_46 };
1203-
auto result = lgfx::gpio::command(
1204-
(const uint8_t[]) {
1205-
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_38, // CoreS3 = CAM_HREF
1206-
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_45, // CoreS3 = CAM_PCLK
1207-
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_46, // CoreS3 = CAM_VSYNC
1208-
lgfx::gpio::command_mode_input_pullup , GPIO_NUM_38,
1209-
lgfx::gpio::command_read , GPIO_NUM_38,
1210-
lgfx::gpio::command_mode_input_pullup , GPIO_NUM_45,
1211-
lgfx::gpio::command_read , GPIO_NUM_45,
1212-
lgfx::gpio::command_mode_input_pullup , GPIO_NUM_46,
1213-
lgfx::gpio::command_read , GPIO_NUM_46,
1214-
lgfx::gpio::command_end
1215-
}
1216-
);
1217-
for (auto &bup : backup_pins) { bup.restore(); }
1218-
1219-
// In "CoreS3", even if GPIO38,45,46 are set to Input_pullup, LOW is output.
1220-
// This characteristic can be used to distinguish between the two models.
12211224
board = board_t::board_M5StackCoreS3;
1222-
if (result == 0b111) {
1225+
// Camera GC0308 check (not found == M5StackCoreS3SE)
1226+
auto chk_gc = lgfx::i2c::readRegister8(i2c_port, gc0308_i2c_addr, 0x00, i2c_freq);
1227+
if (chk_gc .has_value() && chk_gc .value() == 0x9b) {
1228+
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5StackCoreS3");
1229+
} else {
12231230
board = board_M5StackCoreS3SE;
12241231
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5StackCoreS3SE");
1225-
} else {
1226-
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5StackCoreS3");
12271232
}
12281233
bus_cfg.freq_write = 40000000;
12291234
bus_cfg.freq_read = 16000000;
@@ -1250,11 +1255,55 @@ namespace m5gfx
12501255
lgfx::i2c::release(i2c_port);
12511256
}
12521257

1258+
if (board == 0 || board == board_t::board_M5AtomS3R)
1259+
{
1260+
_pin_reset(GPIO_NUM_48, use_reset); // LCD RST
1261+
bus_cfg.pin_mosi = GPIO_NUM_21;
1262+
bus_cfg.pin_miso = (gpio_num_t)-1; //GPIO_NUM_NC;
1263+
bus_cfg.pin_sclk = GPIO_NUM_15;
1264+
bus_cfg.pin_dc = GPIO_NUM_42;
1265+
bus_cfg.spi_mode = 0;
1266+
bus_cfg.spi_3wire = true;
1267+
bus_spi->config(bus_cfg);
1268+
bus_spi->init();
1269+
id = _read_panel_id(bus_spi, GPIO_NUM_14);
1270+
if ((id & 0xFFFFFF) == 0x079100)
1271+
{ // check panel (GC9107)
1272+
board = board_t::board_M5AtomS3R;
1273+
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5AtomS3R");
1274+
bus_spi->release();
1275+
bus_cfg.spi_host = SPI3_HOST;
1276+
bus_cfg.freq_write = 40000000;
1277+
bus_cfg.freq_read = 16000000;
1278+
bus_spi->config(bus_cfg);
1279+
bus_spi->init();
1280+
auto p = new Panel_GC9107();
1281+
p->bus(bus_spi);
1282+
{
1283+
auto cfg = p->config();
1284+
cfg.pin_cs = GPIO_NUM_14;
1285+
cfg.pin_rst = GPIO_NUM_48;
1286+
cfg.panel_width = 128;
1287+
cfg.panel_height = 128;
1288+
cfg.offset_y = 32;
1289+
cfg.readable = false;
1290+
cfg.bus_shared = false;
1291+
p->config(cfg);
1292+
}
1293+
_panel_last.reset(p);
1294+
_set_backlight(new Light_M5StackAtomS3R());
1295+
1296+
goto init_clear;
1297+
}
1298+
lgfx::pinMode(GPIO_NUM_48, lgfx::pin_mode_t::input); // LCD RST
1299+
bus_spi->release();
1300+
}
1301+
12531302
if (board == 0 || board == board_t::board_M5AtomS3)
12541303
{
12551304
_pin_reset(GPIO_NUM_34, use_reset); // LCD RST
12561305
bus_cfg.pin_mosi = GPIO_NUM_21;
1257-
bus_cfg.pin_miso = GPIO_NUM_13;
1306+
bus_cfg.pin_miso = (gpio_num_t)-1; //GPIO_NUM_NC;
12581307
bus_cfg.pin_sclk = GPIO_NUM_17;
12591308
bus_cfg.pin_dc = GPIO_NUM_33;
12601309
bus_cfg.spi_mode = 0;
@@ -1586,6 +1635,7 @@ namespace m5gfx
15861635
case board_M5Tough: title = "M5Tough"; break;
15871636
case board_M5Station: title = "M5Station"; break;
15881637
case board_M5AtomS3: title = "M5AtomS3"; break;
1638+
case board_M5AtomS3R: title = "M5AtomS3R"; break;
15891639
case board_M5Dial: title = "M5Dial"; break;
15901640
case board_M5Cardputer: title = "M5Cardputer"; break;
15911641
case board_M5DinMeter: title = "M5DinMeter"; break;
@@ -1597,6 +1647,7 @@ namespace m5gfx
15971647

15981648
switch (board) {
15991649
case board_M5AtomS3:
1650+
case board_M5AtomS3R:
16001651
w = 128;
16011652
h = 128;
16021653
break;

src/lgfx/boards.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace lgfx // This should not be changed to "m5gfx"
2424
, board_M5AirQ
2525
, board_M5VAMeter
2626
, board_M5StackCoreS3SE
27+
, board_M5AtomS3R
2728

2829
/// non display boards
2930
, board_M5Atom = 128
@@ -52,6 +53,8 @@ namespace lgfx // This should not be changed to "m5gfx"
5253
, board_M5UnitRCA
5354
, board_M5ModuleDisplay
5455
, board_M5ModuleRCA
56+
57+
, board_FrameBuffer = 512
5558
};
5659
}
5760
using namespace boards;

src/lgfx/v1/LGFXBase.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ namespace lgfx
11251125
for( int ys=0;ys<h;ys++ ) {
11261126
if( is_vertical ) { // scanline is used as an colors index
11271127
setColor(color888(scanline[ys].r, scanline[ys].g, scanline[ys].b));
1128-
drawFastHLine( x, ys, w );
1128+
drawFastHLine( x, y+ys, w );
11291129
} else { // scanline is used as a line buffer
11301130
pushImage( x, y+ys, w, 1, scanline );
11311131
}
@@ -1441,6 +1441,27 @@ namespace lgfx
14411441
endWrite();
14421442
}
14431443

1444+
void LGFXBase::pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, pixelcopy_t *param)
1445+
{
1446+
uint32_t x_mask = 7 >> (param->src_bits >> 1);
1447+
param->src_bitwidth = (w + x_mask) & (~x_mask);
1448+
1449+
int32_t dx=0, dw=w;
1450+
if (0 < _clip_l - x) { dx = _clip_l - x; dw -= dx; x = _clip_l; }
1451+
1452+
if (_adjust_width(x, dx, dw, _clip_l, _clip_r - _clip_l + 1)) return;
1453+
param->src_x32 = param->src_x32_add * dx;
1454+
1455+
int32_t dy=0, dh=h;
1456+
if (0 < _clip_t - y) { dy = _clip_t - y; dh -= dy; y = _clip_t; }
1457+
if (_adjust_width(y, dy, dh, _clip_t, _clip_b - _clip_t + 1)) return;
1458+
param->src_y = dy;
1459+
1460+
startWrite();
1461+
_panel->writeImageARGB(x, y, dw, dh, param);
1462+
endWrite();
1463+
}
1464+
14441465
void LGFXBase::make_rotation_matrix(float* result, float dst_x, float dst_y, float src_x, float src_y, float angle, float zoom_x, float zoom_y)
14451466
{
14461467
float rad = fmodf(angle, 360) * deg_to_rad;
@@ -1510,15 +1531,15 @@ namespace lgfx
15101531
else
15111532
if (pc_post.dst_bits > 16) {
15121533
if (dst_depth == rgb888_3Byte) {
1513-
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t>;
1534+
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t, argb8888_t>;
15141535
} else {
1515-
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t>;
1536+
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t, argb8888_t>;
15161537
}
15171538
} else {
15181539
if (dst_depth == rgb565_2Byte) {
1519-
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t>;
1540+
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t, argb8888_t>;
15201541
} else { // src_depth == rgb332_1Byte:
1521-
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t>;
1542+
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t, argb8888_t>;
15221543
}
15231544
}
15241545
push_image_affine_aa(matrix, pc, &pc_post);

src/lgfx/v1/LGFXBase.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,35 @@ namespace lgfx
564564
LGFX_INLINE_T void pushGrayscaleImageRotateZoom(float dst_x, float dst_y, float src_x, float src_y, float angle, float zoom_x, float zoom_y, int32_t w, int32_t h, const uint8_t* image, color_depth_t depth, const T& forecolor, const T& backcolor) { push_grayimage_rotate_zoom(dst_x, dst_y, src_x, src_y, angle, zoom_x, zoom_y, w, h, image, depth, convert_to_rgb888(forecolor), convert_to_rgb888(backcolor)); }
565565
LGFX_INLINE_T void pushGrayscaleImageAffine(const float matrix[6], int32_t w, int32_t h, const uint8_t* image, color_depth_t depth, const T& forecolor, const T& backcolor) { push_grayimage_affine(matrix, w, h, image, depth, convert_to_rgb888(forecolor), convert_to_rgb888(backcolor)); }
566566

567+
//----------------------------------------------------------------------------
568+
569+
// T == bgra8888_t or argb8888_t
570+
template<typename T>
571+
void pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, const T* data)
572+
{
573+
auto pc = create_pc(data);
574+
575+
// not support 1, 2, 4, and palette mode.
576+
if (pc.dst_bits < 8 || this->hasPalette()) { return; }
577+
578+
if (pc.dst_bits > 16) {
579+
if (pc.dst_depth == rgb888_3Byte) {
580+
pc.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t, T>;
581+
} else {
582+
pc.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t, T>;
583+
}
584+
} else {
585+
if (pc.dst_depth == rgb565_2Byte) {
586+
pc.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t, T>;
587+
} else { // src_depth == rgb332_1Byte:
588+
pc.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t, T>;
589+
}
590+
}
591+
pushAlphaImage(x, y, w, h, &pc);
592+
}
593+
594+
void pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, pixelcopy_t *param);
595+
567596
//----------------------------------------------------------------------------
568597

569598
/// read RGB565 16bit color

src/lgfx/v1/LGFX_Sprite.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ namespace lgfx
201201
return createFromBmp(&data);
202202
}
203203

204+
bool createFromBmpFile(const char *path)
205+
{
206+
auto data = _create_data_wrapper();
207+
return create_from_bmp_file(data, path);
208+
}
209+
204210
template <typename T>
205211
bool createFromBmpFile(T &fs, const char *path)
206212
{

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 1
3-
#define LGFX_VERSION_PATCH 16
3+
#define LGFX_VERSION_PATCH 17
44
#define LOVYANGFX_VERSION F( LGFX_VERSION_MAJOR "." LGFX_VERSION_MINOR "." LGFX_VERSION_PATCH )

src/lgfx/v1/misc/common_function.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ namespace lgfx
1111

1212
void memset_multi(uint8_t* buf, uint32_t c, size_t size, size_t length)
1313
{
14-
if (size == 1 || ((c & 0xFF) == ((c >> 8) & 0xFF) && (size == 2 || ((c & 0xFF) == ((c >> 16) & 0xFF)))))
14+
if (size == 1
15+
|| ( (c & 0xFF) == ((c >> 8) & 0xFF)
16+
&& ( size == 2
17+
|| ( (c & 0xFF) == ((c >> 16) & 0xFF)
18+
&& ( size == 3
19+
|| ( (c & 0xFF) == ((c >> 24) & 0xFF)
20+
))))))
1521
{
1622
memset(buf, c, size * length);
1723
return;

0 commit comments

Comments
 (0)