update with scani2cdevice
This commit is contained in:
parent
27dc8c2cd0
commit
e7c53e4d34
@ -45,7 +45,7 @@ void ttn_register(void (*callback)(uint8_t message));
|
||||
|
||||
// Select the payload format. Change on TTN as well. Only uncomment one.
|
||||
#define PAYLOAD_USE_FULL
|
||||
//#define PAYLOAD_USE_CAYENNE
|
||||
// #define PAYLOAD_USE_CAYENNE
|
||||
|
||||
#define DEBUG_PORT Serial // Serial debug port
|
||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||
@ -96,7 +96,7 @@ void ttn_register(void (*callback)(uint8_t message));
|
||||
// OLED
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define OLED_ADDRESS 0x3C
|
||||
#define SSD1306_ADDRESS 0x3C
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// GPS
|
||||
|
@ -29,6 +29,7 @@
|
||||
#ifdef T_BEAM_V10
|
||||
#include "axp20x.h"
|
||||
AXP20X_Class axp;
|
||||
bool ssd1306_found = false;
|
||||
bool axp192_found = false;
|
||||
bool pmu_irq = false;
|
||||
String baChStatus = "No charging";
|
||||
@ -134,14 +135,53 @@ uint32_t get_count() {
|
||||
return count;
|
||||
}
|
||||
|
||||
void scanI2Cdevice(void)
|
||||
{
|
||||
byte err, addr;
|
||||
int nDevices = 0;
|
||||
for (addr = 1; addr < 127; addr++) {
|
||||
Wire.beginTransmission(addr);
|
||||
err = Wire.endTransmission();
|
||||
if (err == 0) {
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.print(addr, HEX);
|
||||
Serial.println(" !");
|
||||
nDevices++;
|
||||
|
||||
if (addr == SSD1306_ADDRESS) {
|
||||
ssd1306_found = true;
|
||||
Serial.println("ssd1306 display found");
|
||||
}
|
||||
if (addr == AXP192_SLAVE_ADDRESS) {
|
||||
axp192_found = true;
|
||||
Serial.println("axp192 PMU found");
|
||||
}
|
||||
} else if (err == 4) {
|
||||
Serial.print("Unknow error at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.println(addr, HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// Debug
|
||||
#ifdef DEBUG_PORT
|
||||
DEBUG_PORT.begin(SERIAL_BAUD);
|
||||
#endif
|
||||
|
||||
delay(1000);
|
||||
|
||||
#ifdef T_BEAM_V10
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
scanI2Cdevice();
|
||||
axp192_found = true;
|
||||
if (axp192_found) {
|
||||
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
|
||||
|
@ -93,7 +93,7 @@ void screen_update() {
|
||||
|
||||
void screen_setup() {
|
||||
// Display instance
|
||||
display = new SSD1306Wire(OLED_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
display = new SSD1306Wire(SSD1306_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
display->init();
|
||||
display->flipScreenVertically();
|
||||
display->setFont(Custom_ArialMT_Plain_10);
|
||||
|
Loading…
Reference in New Issue
Block a user