sforkowany z mirror/meshtastic-firmware
tryfix #1363
Ask for the register several times and only go on if the answer is the same in 2 consecutive tries.raytac-diy
rodzic
cf45e4fce5
commit
ed62b6916c
|
@ -6,21 +6,28 @@
|
||||||
uint8_t oled_probe(byte addr)
|
uint8_t oled_probe(byte addr)
|
||||||
{
|
{
|
||||||
uint8_t r = 0;
|
uint8_t r = 0;
|
||||||
|
uint8_t r_prev = 0;
|
||||||
|
uint8_t c = 0;
|
||||||
uint8_t o_probe = 0;
|
uint8_t o_probe = 0;
|
||||||
Wire.beginTransmission(addr);
|
do {
|
||||||
Wire.write(0x00);
|
r_prev = r;
|
||||||
Wire.endTransmission();
|
Wire.beginTransmission(addr);
|
||||||
Wire.requestFrom((int)addr, 1);
|
Wire.write(0x00);
|
||||||
if (Wire.available()) {
|
Wire.endTransmission();
|
||||||
r = Wire.read();
|
Wire.requestFrom((int)addr, 1);
|
||||||
}
|
if (Wire.available()) {
|
||||||
r &= 0x0f;
|
r = Wire.read();
|
||||||
if (r == 0x08 || r == 0x00) {
|
}
|
||||||
o_probe = 2; // SH1106
|
r &= 0x0f;
|
||||||
} else if ( r == 0x03 || r == 0x06 || r == 0x07) {
|
|
||||||
o_probe = 1; // SSD1306
|
if (r == 0x08 || r == 0x00) {
|
||||||
}
|
o_probe = 2; // SH1106
|
||||||
DEBUG_MSG("0x%x subtype probed\n", r);
|
} else if ( r == 0x03 || r == 0x06 || r == 0x07) {
|
||||||
|
o_probe = 1; // SSD1306
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
} while ((r != r_prev) && (c < 4));
|
||||||
|
DEBUG_MSG("0x%x subtype probed in %i tries \n", r, c);
|
||||||
return o_probe;
|
return o_probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue