Skip to content

Commit 41af34c

Browse files
authored
Merge pull request #23 from m5stack/develop
0.0.14
2 parents 283f638 + a823efa commit 41af34c

File tree

9 files changed

+81
-22
lines changed

9 files changed

+81
-22
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.0.13",
13+
"version": "0.0.14",
1414
"framework": "arduino",
1515
"platforms": "espressif32",
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.0.13
2+
version=0.0.14
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack All Display

src/M5AtomDisplay.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class M5AtomDisplay : public lgfx::LGFX_Device
6060
static constexpr int spi_mosi = 19;
6161
static constexpr int spi_miso = 22;
6262

63-
int spi_sclk = (esp_efuse_get_pkg_ver() == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)
63+
int spi_sclk = (m5gfx::get_pkg_ver() == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)
6464
? 23 // for ATOM Lite / Matrix
6565
: 5 // for ATOM PSRAM
6666
;
@@ -98,10 +98,12 @@ class M5AtomDisplay : public lgfx::LGFX_Device
9898

9999
{
100100
auto cfg = _panel_instance.config();
101+
cfg.offset_rotation = 3;
101102
cfg.pin_cs = spi_cs;
102103
cfg.readable = false;
103104
cfg.bus_shared = false;
104105
_panel_instance.config(cfg);
106+
_panel_instance.setRotation(1);
105107
}
106108
#endif
107109
lgfx::Panel_M5HDMI::config_resolution_t cfg_reso;
@@ -127,7 +129,7 @@ class M5AtomDisplay : public lgfx::LGFX_Device
127129
, uint_fast8_t scale_h = M5ATOMDISPLAY_SCALE_H
128130
)
129131
{
130-
return _panel_instance.setResolution
132+
bool res = _panel_instance.setResolution
131133
( logical_width
132134
, logical_height
133135
, refresh_rate
@@ -136,6 +138,8 @@ class M5AtomDisplay : public lgfx::LGFX_Device
136138
, scale_w
137139
, scale_h
138140
);
141+
setRotation(getRotation());
142+
return res;
139143
}
140144
};
141145

src/M5GFX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ namespace m5gfx
447447

448448
std::uint32_t id;
449449

450-
std::uint32_t pkg_ver = esp_efuse_get_pkg_ver();
450+
std::uint32_t pkg_ver = m5gfx::get_pkg_ver();
451451

452452
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) /// check PICO-D4 (M5StickC,CPlus,T,T2 / CoreInk / ATOM )
453453
{

src/M5GFX.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727

2828
#include <vector>
2929

30-
namespace m5
31-
{
32-
class M5Unified;
33-
}
34-
3530
namespace m5gfx
3631
{
3732
using namespace lgfx;
@@ -134,8 +129,6 @@ namespace m5gfx
134129

135130
class M5GFX : public lgfx::LGFX_Device
136131
{
137-
friend m5::M5Unified;
138-
139132
static M5GFX* _instance;
140133

141134
struct DisplayState
@@ -156,12 +149,6 @@ namespace m5gfx
156149
board_t autodetect(bool use_reset = false, board_t board = board_t::board_unknown);
157150
void _set_backlight(lgfx::ILight* bl);
158151
void _set_pwm_backlight(std::int16_t pin, std::uint8_t ch, std::uint32_t freq = 12000, bool invert = false);
159-
void _set_board(board_t board) { _board = board; }
160-
bool _init_with_panel(lgfx::Panel_Device* panel)
161-
{
162-
setPanel(panel);
163-
return LGFX_Device::init_impl(true, true);
164-
}
165152

166153
public:
167154
M5GFX(void);
@@ -197,7 +184,7 @@ namespace m5gfx
197184
#ifdef __M5GFX_M5ATOMDISPLAY__
198185
if (getBoard() == board_t::board_M5AtomDisplay)
199186
{
200-
return ((Panel_M5HDMI*)panel())->setResolution
187+
bool res = ((Panel_M5HDMI*)panel())->setResolution
201188
( logical_width
202189
, logical_height
203190
, refresh_rate
@@ -206,6 +193,8 @@ namespace m5gfx
206193
, scale_w
207194
, scale_h
208195
);
196+
setRotation(getRotation());
197+
return res;
209198
}
210199
#endif
211200
return false;

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 0
3-
#define LGFX_VERSION_PATCH 9
3+
#define LGFX_VERSION_PATCH 10
44
#define LOVYANGFX_VERSION F( LGFX_VERSION_MAJOR "." LGFX_VERSION_MINOR "." LGFX_VERSION_PATCH )

src/lgfx/v1/panel/Panel_M5HDMI.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ namespace lgfx
418418
while (_bus->readData(8) == 0xFF) {}
419419
_bus->readData(8); // skip 0xFF
420420
uint32_t data = _bus->readData(32);
421+
(void)data; // suppress compiler warning.
421422
ESP_LOGI(TAG, "FPGA ID:%02x %02x %02x %02x", data & 0xFF, (data >> 8) & 0xFF, (data >> 16) & 0xFF, data >> 24);
422423
cs_control(true);
423424
_bus->endRead();
@@ -527,7 +528,31 @@ namespace lgfx
527528
bool Panel_M5HDMI::setResolution( const config_resolution_t& cfg_reso )
528529
{
529530
config_resolution(cfg_reso);
530-
return _init_resolution();
531+
bool res = _init_resolution();
532+
533+
union cmd_t
534+
{
535+
uint8_t raw[10];
536+
struct __attribute__((packed))
537+
{
538+
uint8_t cmd;
539+
uint32_t xy1;
540+
uint32_t xy2;
541+
uint8_t color;
542+
};
543+
};
544+
cmd_t cmd;
545+
cmd.cmd = CMD_FILLRECT_8;
546+
cmd.xy1 = 0;
547+
cmd.color = 0;
548+
static constexpr uint32_t mask = 0xFF00FF;
549+
uint32_t xy = (_cfg.memory_width - 1) + ((_cfg.memory_height - 1) << 16);
550+
cmd.xy2 = ((xy >> 8) & mask) + ((xy & mask) << 8);
551+
startWrite();
552+
_bus->writeBytes(cmd.raw, sizeof(cmd_t), false, false);
553+
endWrite();
554+
555+
return res;
531556
}
532557

533558
void Panel_M5HDMI::config_resolution( const config_resolution_t& cfg_reso )

src/lgfx/v1/platforms/esp32/common.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,33 @@ Original Source:
2929
#include <driver/spi_master.h>
3030
#include <driver/rtc_io.h>
3131
#include <driver/periph_ctrl.h>
32-
#include <soc/soc.h>
3332
#include <soc/rtc.h>
33+
#include <soc/soc.h>
3434
#include <soc/i2c_reg.h>
3535
#include <soc/i2c_struct.h>
3636
#include <esp_log.h>
3737

38+
#include <soc/apb_ctrl_reg.h>
39+
#include <soc/efuse_reg.h>
40+
41+
#if defined (ESP_IDF_VERSION_VAL)
42+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(3, 4, 0)
43+
44+
// include <esp_efuse.h> でエラーが出るバージョンが存在するため、エラー回避用の記述を行ってからincludeする。;
45+
#define _ROM_SECURE_BOOT_H_
46+
#define MAX_KEY_DIGESTS 3
47+
struct ets_secure_boot_key_digests
48+
{
49+
const void *key_digests[MAX_KEY_DIGESTS];
50+
bool allow_key_revoke;
51+
};
52+
typedef struct ets_secure_boot_key_digests ets_secure_boot_key_digests_t;
53+
54+
#include <esp_efuse.h>
55+
#define USE_ESP_EFUSE_GET_PKG_VER
56+
#endif
57+
#endif
58+
3859
#if __has_include(<soc/i2c_periph.h>)
3960
#include <soc/i2c_periph.h>
4061
#endif
@@ -69,6 +90,23 @@ namespace lgfx
6990
return div_num << 12 | ((div_num-1)>>1) << 6 | div_num | pre << 18;
7091
}
7192

93+
uint32_t get_pkg_ver(void)
94+
{
95+
#if defined ( USE_ESP_EFUSE_GET_PKG_VER )
96+
return esp_efuse_get_pkg_ver();
97+
#else
98+
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
99+
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)
100+
{
101+
if (REG_READ(APB_CTRL_DATE_REG) & 0x80000000)
102+
{ // ESP32PICOV302
103+
return 6;
104+
}
105+
}
106+
return pkg_ver;
107+
#endif
108+
}
109+
72110
//----------------------------------------------------------------------------
73111

74112
void pinMode(int_fast16_t pin, pin_mode_t mode)

src/lgfx/v1/platforms/esp32/common.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ namespace lgfx
9494
uint32_t getApbFrequency(void);
9595
uint32_t FreqToClockDiv(uint32_t fapb, uint32_t hz);
9696

97+
// esp_efuse_get_pkg_ver
98+
uint32_t get_pkg_ver(void);
99+
97100
//----------------------------------------------------------------------------
98101

99102
#if defined (ARDUINO)

0 commit comments

Comments
 (0)