-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4baa54
commit 8c5dd9d
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <M5CoreS3.h> | ||
|
||
void setup() | ||
{ | ||
CoreS3.begin(); | ||
CoreS3.Display.setTextColor(YELLOW); // Set the font color to yellow. | ||
CoreS3.Display.setTextSize(2); // Set the font size to 2. | ||
CoreS3.Display.println("M5CoreS3 I2C Tester"); // Print a string on the screen. | ||
CoreS3.Ex_I2C.begin(); | ||
CoreS3.In_I2C.begin(); | ||
} | ||
|
||
int textColor = YELLOW; | ||
|
||
void runScan(m5::I2C_Class &i2c) | ||
{ | ||
int address; | ||
for (address = 8; address < 0x78; address++) { | ||
if (i2c.start(address, false, 400000) && i2c.stop()) { | ||
CoreS3.Display.print(address, HEX); | ||
CoreS3.Display.print(" "); | ||
Serial.print(address, HEX); | ||
Serial.print(" "); | ||
} else { | ||
CoreS3.Display.print("."); | ||
Serial.print("."); | ||
} | ||
|
||
delay(10); | ||
} | ||
if (textColor == YELLOW) { | ||
textColor = CYAN; | ||
} else { | ||
textColor = YELLOW; | ||
} | ||
CoreS3.Display.setTextColor(textColor, BLACK); | ||
} | ||
|
||
void loop() | ||
{ | ||
int count = 5; | ||
CoreS3.Display.clear(); | ||
while (count--) { | ||
CoreS3.Display.setCursor(0, 0); | ||
CoreS3.Display.println("Ex I2C Address [HEX]"); | ||
runScan(CoreS3.Ex_I2C); | ||
} | ||
count = 5; | ||
CoreS3.Display.clear(); | ||
|
||
while (count--) { | ||
CoreS3.Display.setCursor(0, 0); | ||
CoreS3.Display.println("In I2C Address [HEX]"); | ||
runScan(CoreS3.In_I2C); | ||
} | ||
} |