Skip to content

Commit 4b33a07

Browse files
authored
Merge pull request #18 from m5stack/develop
0.0.9
2 parents 9dad98f + 875765c commit 4b33a07

37 files changed

+16199
-1693
lines changed

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
set(COMPONENT_ADD_INCLUDEDIRS
2+
src
3+
)
4+
file(GLOB SRCS
5+
src/*.cpp
6+
src/lgfx/Fonts/efont/*.c
7+
src/lgfx/Fonts/IPA/*.c
8+
src/lgfx/utility/*.c
9+
src/lgfx/v1/*.cpp
10+
src/lgfx/v1/misc/*.cpp
11+
src/lgfx/v1/panel/*.cpp
12+
src/lgfx/v1/platforms/esp32/*.cpp
13+
src/lgfx/v1/platforms/esp32c3/*.cpp
14+
src/lgfx/v1/touch/*.cpp
15+
)
16+
set(COMPONENT_SRCS ${SRCS})
17+
set(COMPONENT_REQUIRES nvs_flash efuse)
18+
19+
register_component()
20+

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Graphics library for M5Stack series
44

5+
Support framework
6+
----------------
7+
- ESP-IDF
8+
- Arduino for ESP32
9+
10+
511
Support device
612
----------------
713
- M5Stack ( Basic / Gray / GO / Fire )
@@ -11,9 +17,10 @@ Support device
1117
- M5Stick C Plus
1218
- M5Paper
1319
- M5Tough
14-
15-
- M5UnitOLED
16-
- M5UnitLCD
20+
- M5Station
21+
- UnitOLED
22+
- UnitLCD
23+
- [AtomDisplay](docs/ATOMDisplay.md)
1724

1825

1926
License

component.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Main Makefile. This is basically the same as a component makefile.
3+
#
4+
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
5+
6+
COMPONENT_SRCDIRS := src
7+
COMPONENT_ADD_INCLUDEDIRS := src

docs/ATOMDisplay.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# ATOM Display library
2+
3+
4+
![M5Stack ATOM Display](https://static-cdn.m5stack.com/resource/docs/static/assets/img/product_pics/atom_base/atom_display/atom_display_01.webp "ATOM Display")
5+
6+
7+
### Notes.
8+
- The HDMI output resolution is fixed at 1280x720 60Hz.
9+
- If the image does not appear, reinsert the USB cable and wait a few seconds.
10+
- Audio output function is not included.
11+
- When inserting or removing the USB cable, please hold the ATOM itself. Repeatedly inserting and removing the USB cable while holding the docking base side may cause stress on the pin headers and result in poor contact.
12+
13+
### 注意事項
14+
- HDMIの出力解像度は 1280x720 60Hz 固定です。
15+
- 音声出力機能は含まれません。
16+
- 画像が表示されない場合はUSBケーブルを挿し直し、数秒待機してください。
17+
- USBケーブルを挿抜する際はATOM本体を保持してください。ドッキングベース側を保持した状態でUSB挿抜を行うと、ピンヘッダに応力が掛かり接触不良を引き起こす可能性があります。
18+
19+
20+
Sample Code:
21+
```
22+
#include <M5AtomDisplay.h>
23+
24+
// Create an instance of M5AtomDisplay
25+
// Set the resolution in the argument (width, height). default : 1280, 720.
26+
// M5AtomDisplay のインスタンスを用意
27+
// 引数で解像度(幅,高さ)を設定できます。 省略時は 1280, 720
28+
29+
M5AtomDisplay display ( 640, 360 );
30+
31+
// ※ By lowering the resolution, you can enlarge the image.
32+
// If the resolution after enlargement is less than 1280x720
33+
// , there will be a gap around the periphery.
34+
// ※ 解像度を下げることで、拡大表示することができます。
35+
// 拡大後の解像度が1280x720に満たない場合は外周に隙間が生じます。
36+
// width scale:
37+
// ~ 1280 = x1
38+
// ~ 640 = x2
39+
// ~ 320 = x4
40+
// ~ 256 = x5
41+
// ~ 160 = x8
42+
43+
// height scale:
44+
// ~ 720 = x1
45+
// ~ 360 = x2
46+
// ~ 240 = x3
47+
// ~ 180 = x4
48+
// ~ 144 = x5
49+
// ~ 120 = x6
50+
// ~ 102 = x7
51+
// ~ 90 = x8
52+
53+
54+
void setup(void)
55+
{
56+
// initialize
57+
// 初期化
58+
display.init();
59+
60+
// Set the display orientation
61+
// ディスプレイの向きを設定
62+
// 0 = normal / 1 = 90 deg / 2 = 180 deg / 3 = 270 deg / 4~7 = upside down
63+
display.setRotation(0);
64+
65+
// Set the color depth ( bpp )
66+
// 色深度を設定
67+
display.setColorDepth(24); // 24bit per pixel color setting
68+
//display.setColorDepth(16); // 16bit per pixel color setting ( default )
69+
//display.setColorDepth( 8); // 8bit per pixel color setting
70+
71+
display.startWrite();
72+
for (int y = 0; y < display.height(); ++y)
73+
{
74+
for (int x = 0; x < display.width(); ++x)
75+
{
76+
display.writePixel(x, y, display.color888(x, x+y, y));
77+
}
78+
}
79+
display.endWrite();
80+
81+
for (int i = 0; i < 16; ++i)
82+
{
83+
int x = rand() % display.width();
84+
int y = rand() % display.height();
85+
display.drawCircle(x, y, 16, rand());
86+
}
87+
}
88+
89+
void loop(void)
90+
{
91+
display.startWrite();
92+
93+
static constexpr const char hello_str[] = "Hello ATOM Display !";
94+
display.setFont(&fonts::Orbitron_Light_32);
95+
for (int i = -display.textWidth(hello_str); i < display.width(); ++i)
96+
{
97+
display.drawString(hello_str, i, (display.height() - display.fontHeight()) >> 1);
98+
}
99+
100+
display.endWrite();
101+
}
102+
```
103+
104+
105+
#### Is PSRAM required ? can I use it with ATOM Lite or ATOM Matrix?
106+
- PSRAM is NOT required. it will work with ATOM Lite and ATOM Matrix. The label on the product that says "FOR ATOM PSRAM ONLY" is incorrect.
107+
- In fact, in the early stages of development, we assumed that we would build a 1280x720 frame buffer in the ESP32's PSRAM and output the images. As the development progressed, the frame buffer was placed on the FPGA side, and in the final product, there was no need to have a frame buffer on the ESP32 side.
108+
109+
#### What is the difference between ATOM Lite and ATOM PSRAM?
110+
- ATOM Lite has ESP32 PICO-D4, ATOM PSRAM has ESP32 PICO-V3-02.
111+
- Some of the pins on the back are different. The ATOM PSRAM has a G5 pin where the ATOM Lite had a G23 pin, but the G23 pin is gone.
112+
113+
114+
115+
#### PSRAMは必須ですか?ATOM LiteやATOM Matrixで使えますか?
116+
- PSRAMは必須ではありません。ATOM LiteやATOM Matrixでも動作します。製品のラベルに記載されている "FOR ATOM PSRAM ONLY" という表記は誤りです。
117+
- 実は開発初期段階では、ESP32のPSRAMに1280x720のフレームバッファを構築して画像を出力する想定でした。開発が進むにつれ、フレームバッファはFPGA側に持つようになり、最終製品ではにESP32側でフレームバッファを持つ必要がなくなりました。
118+
119+
#### ATOM LiteとATOM PSRAMの違いは?
120+
- ATOM Liteには ESP32 PICO D4が搭載されています。ATOM PSRAMには ESP32 PICO V3-02 が搭載されています。
121+
- 背面のピンが一部違います。ATOM Liteの G23 が配置されていた箇所には、 ATOM PSRAM では G5 が配置されています。G23は無くなっているため、注意が必要です。
122+

examples/Basic/AnalogMeter/AnalogMeter.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ M5GFX display;
1212
//M5UnitLCD display; // default setting
1313
//M5UnitLCD display ( 21, 22, 400000 ); // SDA, SCL, FREQ
1414

15+
//#include <M5AtomDisplay.h>
16+
//M5AtomDisplay display;
17+
1518

1619
static constexpr float deg_to_rad = 0.017453292519943295769236907684886;
1720
static constexpr int TFT_GREY = 0x5AEB;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
#include <M5GFX.h>
3+
M5GFX display;
4+
5+
//#include <M5UnitOLED.h>
6+
//M5UnitOLED display; // default setting
7+
//M5UnitOLED display ( 21, 22, 400000 ); // SDA, SCL, FREQ
8+
9+
//#include <M5UnitLCD.h>
10+
//M5UnitLCD display; // default setting
11+
//M5UnitLCD display ( 21, 22, 400000 ); // SDA, SCL, FREQ
12+
13+
// #include <M5AtomDisplay.h>
14+
// M5AtomDisplay display;
15+
16+
static constexpr size_t BAR_COUNT = 64;
17+
static int max_y[BAR_COUNT];
18+
static int prev_y[BAR_COUNT];
19+
static uint32_t colors[BAR_COUNT];
20+
21+
void setup(void)
22+
{
23+
display.init();
24+
display.startWrite();
25+
display.fillScreen(TFT_BLACK);
26+
27+
if (display.isEPD())
28+
{
29+
display.setEpdMode(epd_mode_t::epd_fastest);
30+
}
31+
if (display.width() < display.height())
32+
{
33+
display.setRotation(display.getRotation() ^ 1);
34+
}
35+
36+
for (int x = 0; x < BAR_COUNT; ++x)
37+
{
38+
prev_y[x] = display.height();
39+
max_y[x] = display.height();
40+
int r=0,g=0,b=0;
41+
switch (x >> 4)
42+
{
43+
case 0:
44+
b = 255;
45+
g = x*0x11;
46+
break;
47+
case 1:
48+
b = 255 - (x&15)*0x11;
49+
g = 255;
50+
break;
51+
case 2:
52+
g = 255;
53+
r = (x&15)*0x11;
54+
break;
55+
case 3:
56+
r = 255;
57+
g = 255 - (x&15)*0x11;
58+
break;
59+
}
60+
colors[x] = display.color888(r,g,b);
61+
}
62+
}
63+
64+
void loop(void)
65+
{
66+
int h = display.height();
67+
68+
static int i;
69+
++i;
70+
display.waitDisplay();
71+
for (int x = 0; x < BAR_COUNT; ++x)
72+
{
73+
int y = (h>>1) - (sinf((float)((x-24)*i) / 3210.0f) + sinf((float)((x-40)*i) / 1234.0f)) * (h>>2);
74+
75+
int xpos = x * display.width() / BAR_COUNT;
76+
int w = ((x+1) * display.width() / BAR_COUNT) - xpos - 1;
77+
if (max_y[x]+1 >= y) { max_y[x] = y-1; }
78+
else
79+
{
80+
if ((i & 3) ==0 )
81+
{
82+
display.fillRect(xpos, max_y[x]-3, w, 1, TFT_BLACK);
83+
max_y[x]++;
84+
}
85+
}
86+
display.fillRect(xpos, max_y[x]-3, w, 3, TFT_WHITE);
87+
if (prev_y[x] < y)
88+
{
89+
display.fillRect(xpos, prev_y[x], w, y - prev_y[x], TFT_BLACK);
90+
}
91+
else
92+
{
93+
display.fillRect(xpos, y, w, prev_y[x] - y, colors[x]);
94+
}
95+
prev_y[x] = y;
96+
}
97+
display.display();
98+
}
99+

examples/Basic/GameOfLife/GameOfLife.ino

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ M5GFX display;
1515
//M5UnitLCD display; // default setting
1616
//M5UnitLCD display ( 21, 22, 400000 ); // SDA, SCL, FREQ
1717

18+
//#include <M5AtomDisplay.h>
19+
//M5AtomDisplay display;
20+
1821
M5Canvas canvas[2];
1922

2023
void setup(void)
2124
{
2225
display.begin();
26+
display.setColorDepth(8);
2327
display.setEpdMode(epd_mode_t::epd_fastest);
2428

2529
if (display.width() < display.height())
@@ -28,10 +32,24 @@ void setup(void)
2832
display.setPivot(display.width() /2 -0.5, display.height() /2 - 0.5);
2933
}
3034

35+
int z = 0;
36+
int width;
37+
do
38+
{
39+
width = display.width() / ++z;
40+
} while (width > 192);
41+
42+
z = 0;
43+
int height;
44+
do
45+
{
46+
height = display.height() / ++z;
47+
} while (height > 160);
48+
3149
for (int i = 0; i < 2; i++)
3250
{
3351
canvas[i].setColorDepth(8);
34-
canvas[i].createSprite(std::min(192, display.width()>>1), std::min(160, display.height()>>1));
52+
canvas[i].createSprite(width, height);
3553
canvas[i].createPalette();
3654
canvas[i].setPaletteColor(1, TFT_WHITE);
3755
canvas[i].setPivot(canvas[i].width() /2 -0.5, canvas[i].height() /2 - 0.5);
@@ -42,14 +60,17 @@ void setup(void)
4260
canvas[0].setTextDatum(textdatum_t::top_center);
4361
canvas[0].drawString("Game of Life", canvas[0].width() >> 1, canvas[0].height() >> 1);
4462
canvas[0].pushRotateZoom(&display, 0, (float)display.width() / canvas[0].width(), (float)display.height() / canvas[0].height());
45-
delay(1000);
63+
delay(2000);
64+
display.clear();
4665
}
4766

4867
void loop(void)
4968
{
5069
bool flip = false;
5170
int width = canvas[flip].width();
5271
int height = canvas[flip].height();
72+
int xz = display.width() / width;
73+
int yz = display.height() / height;
5374

5475
int y = 1;
5576
do
@@ -62,6 +83,7 @@ void loop(void)
6283
} while (++y < height - 1);
6384

6485
int diff;
86+
display.startWrite();
6587
do
6688
{
6789
flip = !flip;
@@ -101,12 +123,15 @@ void loop(void)
101123
bool flg = (neighbors == 3) || (neighbors == 2 && old_buf[idx]);
102124
if (flg != new_buf[idx])
103125
{
126+
display.fillRect(x * xz, y * yz, xz, yz, flg ? TFT_WHITE : TFT_BLACK);
104127
new_buf[idx] = flg;
105128
++diff;
106129
}
107130
} while (nx);
108131
} while (ny);
109132

110-
canvas[flip].pushRotateZoom(&display, 0, (float)display.width() / width, (float)display.height() / height);
133+
display.display();
134+
// canvas[flip].pushRotateZoom(&display, 0, (float)display.width() / width, (float)display.height() / height);
111135
} while (diff);
136+
display.endWrite();
112137
}

0 commit comments

Comments
 (0)