Skip to content

Commit 9f97e1e

Browse files
authored
Merge pull request #4 from lovyan03/unstable
Update: v0.2.0
2 parents 3770a01 + a202d8c commit 9f97e1e

File tree

5 files changed

+67
-9
lines changed

5 files changed

+67
-9
lines changed

LovyanLauncher/LovyanLauncher.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void drawFrame() {
6161
M5.Lcd.setTextFont(0);
6262
M5.Lcd.setTextColor(0x8410,0);
6363
M5.Lcd.drawString("- LovyanLauncher -", 207, 191, 1);
64-
M5.Lcd.drawString("@lovyan03 v0.1.9", 204, 201, 1);
64+
M5.Lcd.drawString("@lovyan03 v0.2.0", 204, 201, 1);
6565
M5.Lcd.drawString("http://git.io/fhdJV", 204, 211, 1);
6666
}
6767

1008 Bytes
Binary file not shown.

LovyanLauncher/src/I2CRegistry.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class I2CRegistry
1313
menuItem = mi;
1414
treeView = ((M5TreeView*)(mi->topItem()));
1515
M5.Lcd.fillScreen(0);
16-
btnDrawer.setText("Back","","");
16+
btnDrawer.setText("Back","Mode","Mode");
1717
btnDrawer.draw(true);
1818
if (setup()) {
1919
while (loop());
@@ -42,25 +42,38 @@ class I2CRegistry
4242
M5.Lcd.setCursor(20+i*19, 30);
4343
M5.Lcd.printf("x%01X", i);
4444
}
45+
step = 0;
46+
4547
return true;
4648
}
4749

4850
bool loop()
4951
{
5052
M5.update();
5153
if (M5.BtnA.wasReleased()) return false;
52-
54+
if (M5.BtnB.wasReleased() || M5.BtnC.wasReleased() || step == 0) {
55+
step = M5.BtnB.wasReleased() ? step << 1 : step >> 1;
56+
if (step == 0) step = 16;
57+
else if (step >= 32) step = 1;
58+
M5.Lcd.setTextFont(2);
59+
M5.Lcd.setTextSize(1);
60+
M5.Lcd.setCursor(32, 160);
61+
M5.Lcd.setTextColor(0xFFFF, 0);
62+
M5.Lcd.printf("%2d Byte read mode ", step);
63+
}
5364
Header.draw();
5465
btnDrawer.draw();
5566

5667
M5.Lcd.setTextFont(1);
5768
M5.Lcd.setTextSize(1);
69+
bool enabled;
5870
for (byte row = 0; row < regMax/16; ++row) {
59-
Wire.beginTransmission(addr);
60-
Wire.write(row * 16);
61-
bool enabled = (Wire.endTransmission(false) == 0 && Wire.requestFrom(addr, (uint8_t)16));
62-
6371
for (byte col = 0; col < 16; ++col) {
72+
if ((col % step) == 0) {
73+
Wire.beginTransmission(addr);
74+
Wire.write(row * 16 + col);
75+
enabled = (Wire.endTransmission(false) == 0 && Wire.requestFrom(addr, (uint8_t)(step ? step:16)));
76+
}
6477
int reg = col + row * 16;
6578
int x = 20 + col * 19;
6679
int y = 42 + row * 14;
@@ -89,6 +102,7 @@ class I2CRegistry
89102
M5ButtonDrawer btnDrawer;
90103
M5TreeView* treeView;
91104
MenuItem* menuItem;
105+
uint8_t step = 0;
92106

93107
virtual String getTitle() {
94108
return "I2C 0x" + String(addr,HEX) + " REGISTRY ";

LovyanLauncher/src/I2CScanner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class I2CScanner : public MenuCallBack
4242
if (exist) ex.push_back(adr);
4343
uint16_t color = exist ? 0xFFFF : 0x39E7;
4444
M5.Lcd.setTextColor(color, 0);
45-
if (_addr == adr) {
45+
if (exist && _addr == adr) {
4646
color = 0x421F;
4747
}
4848
M5.Lcd.drawRect(x,y,19,19, color);

LovyanLauncher/src/SystemInfo.h

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class SystemInfo : public MenuCallBack
1010
public:
1111
bool setup()
1212
{
13+
lcd_version = lcd_ver();
14+
M5.Lcd.begin();
1315
btnDrawer.setText(1, "Page");
1416
btnDrawer.setText(2, "Page");
1517
page = 0;
@@ -29,6 +31,7 @@ class SystemInfo : public MenuCallBack
2931
}
3032

3133
private:
34+
bool lcd_version;
3235
int page;
3336
const int pageCount = 2;
3437
void title(const char* title) {
@@ -71,11 +74,13 @@ class SystemInfo : public MenuCallBack
7174
print("Flash Frequency", "%3d MHz", ESP.getFlashChipSpeed() / 1000000);
7275
print("Flash Chip Size", "%d Byte", ESP.getFlashChipSize());
7376
print("ESP-IDF version", "%s", esp_get_idf_version());
77+
print("LCD Type", "%s", lcd_version ? "IPS" : "TN");
78+
print("IMU Type", "%s", get_imu_type().c_str());
7479

7580
title("Mac Address");
7681
uint8_t mac[6];
7782
esp_base_mac_addr_get(mac); print("Base Mac Address");printMac(mac);
78-
esp_efuse_mac_get_default(mac); print("Default");printMac(mac);
83+
//esp_efuse_mac_get_default(mac); print("Default");printMac(mac);
7984
esp_read_mac(mac, ESP_MAC_WIFI_STA); print("Wi-Fi Station");printMac(mac);
8085
esp_read_mac(mac, ESP_MAC_WIFI_SOFTAP);print("Wi-Fi Soft AP");printMac(mac);
8186
esp_read_mac(mac, ESP_MAC_BT); print("Bluetooth");printMac(mac);
@@ -107,6 +112,45 @@ class SystemInfo : public MenuCallBack
107112
void printMac(uint8_t* mac) {
108113
M5.Lcd.printf("%02X:%02X:%02X:%02X:%02X:%02X\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
109114
}
115+
116+
bool lcd_ver() const {
117+
bool res = 0;
118+
pinMode(TFT_RST, INPUT_PULLDOWN);
119+
delay(1);
120+
if (digitalRead(TFT_RST)) {
121+
res = 1;
122+
}
123+
pinMode(TFT_RST, OUTPUT);
124+
return res;
125+
}
126+
127+
String get_imu_type() const {
128+
String res;
129+
uint8_t tmp;
130+
if (M5.I2C.readByte(0x68, 0x75, &tmp)) {
131+
switch (tmp) {
132+
case 0x19: res = "MPU-6886"; break;
133+
case 0x68: res = "MPU-6050"; break;
134+
case 0x71: res = "MPU-9250"; break;
135+
default: res = "MPU-????"; break;
136+
}
137+
} else if (M5.I2C.readByte(0x6C, 0x30, &tmp)) {
138+
switch (tmp) {
139+
case 0x18: res = "SH200Q";
140+
default: res = "SH????";
141+
}
142+
} else {
143+
res = "not found";
144+
}
145+
146+
if (M5.I2C.readByte(0x0E, 0x07, &tmp)) {
147+
res += " + MAG3110";
148+
}
149+
if (M5.I2C.readByte(0x10, 0x40, &tmp)) {
150+
res += " + BMM150";
151+
}
152+
return res;
153+
}
110154
};
111155

112156
#endif

0 commit comments

Comments
 (0)