51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
// Question
|
|
String Question(String Message) {
|
|
|
|
Serial.print(Message + " : ");
|
|
while(!Serial.available());
|
|
|
|
Message = Serial.readStringUntil('\n');
|
|
while(Serial.available()) Serial.read();
|
|
Message.trim();
|
|
Serial.println(Message);
|
|
return Message;
|
|
|
|
}
|
|
|
|
// OLED Display
|
|
void oled_write(String message) {
|
|
display.clearDisplay();
|
|
display.setTextSize(1);
|
|
display.setTextColor(SSD1306_WHITE);
|
|
display.setCursor(0, 0);
|
|
display.println(message);
|
|
display.display();
|
|
}
|
|
|
|
// I2C Scanner
|
|
void scanI2C() {
|
|
|
|
byte error, address;
|
|
int nDevices = 0;
|
|
|
|
for(address = 1; address < 127; address++ ) {
|
|
Wire.beginTransmission(address);
|
|
error = Wire.endTransmission();
|
|
if (error == 0) {
|
|
Serial.print("I2C device found at address 0x");
|
|
if (address<16) Serial.print("0");
|
|
Serial.println(address, HEX);
|
|
nDevices++;
|
|
} else if (error==4) {
|
|
Serial.print("Unknown error at address 0x");
|
|
if (address<16) Serial.print("0");
|
|
Serial.println(address, HEX);
|
|
}
|
|
}
|
|
|
|
if (nDevices == 0)
|
|
Serial.println("No I2C devices found");
|
|
else
|
|
Serial.println("Scan complete");
|
|
|
|
} |