mirror of
https://github.com/Xinyuan-LilyGO/T-Display-S3.git
synced 2024-09-21 09:57:26 +00:00
Updated the T-Display-S3-MIDI test program
This commit is contained in:
parent
7ab10ceaef
commit
d98c2393a7
@ -1,29 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* @Description: This program is used to test the T-Display-S3-MIDI program and consists
|
* @Description: This program is used to test the T-Display-S3-MIDI program and consists
|
||||||
of 3 parts, 1.PCF8575_Test, 2.MPR121_Test, 3.PCM5102A_Test
|
of 3 parts, 1.PCA9535_Test, 2.MPR121_Test, 3.PCM5102A_Test
|
||||||
|
|
||||||
When the program is freshly burned, you can see the "START" text in red. By touching
|
|
||||||
any of the TOUCH0 (0-11) or TOUCH1 (0-10) pins of the MPR121 touch sensor, the system is
|
|
||||||
activated. At this point, the "START" text changes to purple, indicating that the PCF8575
|
|
||||||
and MPR121 modes are being tested. Next, when you touch the touch IO pins, you can
|
|
||||||
observe that the GPIO level of PCF8575 on the screen flips (one flip per touch). The touch
|
|
||||||
range includes TOUCH0 (0-11) and TOUCH1 (0-3). If this occurs, it indicates a successful
|
|
||||||
test of PCF8575 and MPR121; otherwise, it fails.
|
|
||||||
When touching the 11th pin of TOUCH1, the system can be switched to test PCM5102A
|
|
||||||
mode.If an SD card is present, it will scan all files inside and display them on the T-Display-S3
|
|
||||||
screen. It will then proceed to play the ".mp3" file. Otherwise, the screen will display
|
|
||||||
"Failed to open directory" (requiring a mode switch to attempt playback again). Any other
|
|
||||||
situation will be considered a test failure.
|
|
||||||
|
|
||||||
* @version: V1.0.0
|
* @version: V1.0.0
|
||||||
* @Author: LILYGO_L
|
* @Author: LILYGO_L
|
||||||
* @Date: 2023-06-12 16:16:37
|
* @Date: 2023-06-12 16:16:37
|
||||||
* @LastEditors: LILYGO_L
|
* @LastEditors: LILYGO_L
|
||||||
* @LastEditTime: 2023-07-10 09:56:52
|
* @LastEditTime: 2023-07-24 15:46:32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "PCF8575.h"
|
|
||||||
#include "TFT_eSPI.h"
|
#include "TFT_eSPI.h"
|
||||||
#include "pin_config.h"
|
#include "pin_config.h"
|
||||||
#include "Adafruit_MPR121.h"
|
#include "Adafruit_MPR121.h"
|
||||||
@ -31,22 +17,21 @@ situation will be considered a test failure.
|
|||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
#include "SD.h"
|
#include "SD.h"
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
|
#include "PCA95x5.h"
|
||||||
|
|
||||||
|
#define MPR121_PCA95x5_Count 1
|
||||||
|
|
||||||
TFT_eSPI tft;
|
TFT_eSPI tft;
|
||||||
Audio audio;
|
Audio audio;
|
||||||
|
|
||||||
int32_t Windows = 0;
|
int32_t Windows = 0;
|
||||||
|
|
||||||
// Function interrupt
|
// Function interrupt
|
||||||
void PCF8575_MPR121_External_Interrupt();
|
void PCA9535_MPR121_External_Interrupt();
|
||||||
|
|
||||||
// Set IIC address
|
|
||||||
PCF8575 PCF8575_Class(T_DISPLAY_PCF8575_IIC_ADDRESS, PCF8575_SDA, PCF8575_SCL, T_DISPLAY_PCF8575_INTERRUPTPIN, PCF8575_MPR121_External_Interrupt);
|
|
||||||
bool PCF8575_External_Interrupt_Flag = false;
|
|
||||||
|
|
||||||
Adafruit_MPR121 Touch_Sensor1 = Adafruit_MPR121();
|
Adafruit_MPR121 Touch_Sensor1 = Adafruit_MPR121();
|
||||||
Adafruit_MPR121 Touch_Sensor2 = Adafruit_MPR121();
|
Adafruit_MPR121 Touch_Sensor2 = Adafruit_MPR121();
|
||||||
bool MPR121_External_Interrupt_Flag = false;
|
volatile bool MPR121_External_Interrupt_Flag = false;
|
||||||
|
volatile bool PCA95x5_External_Interrupt_Flag = false;
|
||||||
|
|
||||||
uint16_t touched1 = 0;
|
uint16_t touched1 = 0;
|
||||||
uint16_t touched2 = 0;
|
uint16_t touched2 = 0;
|
||||||
@ -56,14 +41,47 @@ File File_CurrentFile;
|
|||||||
File File_Root;
|
File File_Root;
|
||||||
bool File_Scan_Flag = true;
|
bool File_Scan_Flag = true;
|
||||||
|
|
||||||
void PCF8575_MPR121_External_Interrupt()
|
PCA9535 PCA9535_Class;
|
||||||
|
|
||||||
|
void PCA9535_MPR121_External_Interrupt()
|
||||||
{
|
{
|
||||||
// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)
|
// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)
|
||||||
PCF8575_External_Interrupt_Flag = true;
|
PCA95x5_External_Interrupt_Flag = true;
|
||||||
MPR121_External_Interrupt_Flag = true;
|
MPR121_External_Interrupt_Flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *PCF8575_TFT_Show(uint8_t Num)
|
void deviceScan(TwoWire *_port, Stream *stream)
|
||||||
|
{
|
||||||
|
uint8_t err, addr;
|
||||||
|
int nDevices = 0;
|
||||||
|
for (addr = 1; addr < 127; addr++)
|
||||||
|
{
|
||||||
|
_port->beginTransmission(addr);
|
||||||
|
err = _port->endTransmission();
|
||||||
|
if (err == 0)
|
||||||
|
{
|
||||||
|
stream->print("I2C device found at address 0x");
|
||||||
|
if (addr < 16)
|
||||||
|
stream->print("0");
|
||||||
|
stream->print(addr, HEX);
|
||||||
|
stream->println(" !");
|
||||||
|
nDevices++;
|
||||||
|
}
|
||||||
|
else if (err == 4)
|
||||||
|
{
|
||||||
|
stream->print("Unknow error at address 0x");
|
||||||
|
if (addr < 16)
|
||||||
|
stream->print("0");
|
||||||
|
stream->println(addr, HEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nDevices == 0)
|
||||||
|
stream->println("No I2C devices found\n");
|
||||||
|
else
|
||||||
|
stream->println("Done\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *PCA95x5_TFT_Show(uint8_t Num)
|
||||||
{
|
{
|
||||||
if (Num == 0)
|
if (Num == 0)
|
||||||
{
|
{
|
||||||
@ -76,29 +94,27 @@ const char *PCF8575_TFT_Show(uint8_t Num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PCF8575 test program, detect the mode of IO ports, and measure the voltage
|
* @brief PCA9535 test program, detect the mode of IO ports, and measure the voltage
|
||||||
level of the corresponding IO ports using a multimeter.
|
level of the corresponding IO ports using a multimeter.
|
||||||
|
|
||||||
* @return
|
* @return
|
||||||
* @Date 2023-07-13 10:06:19
|
* @Date 2023-07-13 10:06:19
|
||||||
*/
|
*/
|
||||||
void PCF8575_Test(void)
|
void PCA95x5_Test(void)
|
||||||
{
|
{
|
||||||
|
PCA95x5_External_Interrupt_Flag = false;
|
||||||
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
tft.setTextColor(TFT_VIOLET);
|
tft.setTextColor(TFT_VIOLET);
|
||||||
tft.drawString("START", 0, 5, 4);
|
tft.drawString("START", 0, 5, 4);
|
||||||
tft.setTextColor(TFT_BROWN);
|
tft.setTextColor(TFT_BROWN);
|
||||||
// tft.drawString("|---PCF8575_MPR121---|", 100, 10, 2);
|
// tft.drawString("|---PCA9535_MPR121---|", 100, 10, 2);
|
||||||
tft.drawString("|---TDS3_MIDI_Driver---|", 90, 10, 2);
|
tft.drawString("|---TDS3_MIDI_Driver---|", 90, 10, 2);
|
||||||
tft.drawString("LILYGO", 260, 5, 1);
|
tft.drawString("LILYGO", 260, 5, 1);
|
||||||
tft.drawString("V1.0.0", 260, 17, 1);
|
tft.drawString("V1.0.0", 260, 17, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
|
tft.drawString("READ VALUE FROM PCA95x5: ", 5, 30, 2);
|
||||||
PCF8575::DigitalInput readAllPin = PCF8575_Class.digitalReadAll();
|
|
||||||
delay(50); // Anti-jamming machine delay
|
|
||||||
|
|
||||||
tft.drawString("READ VALUE FROM PCF8575: ", 5, 30, 2);
|
|
||||||
|
|
||||||
tft.setTextColor(TFT_PINK);
|
tft.setTextColor(TFT_PINK);
|
||||||
tft.drawString("PORT 0", 50, 50, 1);
|
tft.drawString("PORT 0", 50, 50, 1);
|
||||||
@ -114,7 +130,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 60, 1);
|
tft.drawString("LOW", 100, 60, 1);
|
||||||
tft.drawString("HIGH", 100, 60, 1);
|
tft.drawString("HIGH", 100, 60, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p0), 100, 60, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P00)), 100, 60, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_01", 20, 74, 1);
|
tft.drawString("GPIO_01", 20, 74, 1);
|
||||||
tft.drawString("->", 75, 74, 1);
|
tft.drawString("->", 75, 74, 1);
|
||||||
@ -122,7 +138,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 74, 1);
|
tft.drawString("LOW", 100, 74, 1);
|
||||||
tft.drawString("HIGH", 100, 74, 1);
|
tft.drawString("HIGH", 100, 74, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p1), 100, 74, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P01)), 100, 74, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_02", 20, 88, 1);
|
tft.drawString("GPIO_02", 20, 88, 1);
|
||||||
tft.drawString("->", 75, 88, 1);
|
tft.drawString("->", 75, 88, 1);
|
||||||
@ -130,7 +146,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 88, 1);
|
tft.drawString("LOW", 100, 88, 1);
|
||||||
tft.drawString("HIGH", 100, 88, 1);
|
tft.drawString("HIGH", 100, 88, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p2), 100, 88, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P02)), 100, 88, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_03", 20, 102, 1);
|
tft.drawString("GPIO_03", 20, 102, 1);
|
||||||
tft.drawString("->", 75, 102, 1);
|
tft.drawString("->", 75, 102, 1);
|
||||||
@ -138,7 +154,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 102, 1);
|
tft.drawString("LOW", 100, 102, 1);
|
||||||
tft.drawString("HIGH", 100, 102, 1);
|
tft.drawString("HIGH", 100, 102, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p3), 100, 102, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P03)), 100, 102, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_04", 20, 116, 1);
|
tft.drawString("GPIO_04", 20, 116, 1);
|
||||||
tft.drawString("->", 75, 116, 1);
|
tft.drawString("->", 75, 116, 1);
|
||||||
@ -146,7 +162,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 116, 1);
|
tft.drawString("LOW", 100, 116, 1);
|
||||||
tft.drawString("HIGH", 100, 116, 1);
|
tft.drawString("HIGH", 100, 116, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p4), 100, 116, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P04)), 100, 116, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_05", 20, 130, 1);
|
tft.drawString("GPIO_05", 20, 130, 1);
|
||||||
tft.drawString("->", 75, 130, 1);
|
tft.drawString("->", 75, 130, 1);
|
||||||
@ -154,7 +170,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 130, 1);
|
tft.drawString("LOW", 100, 130, 1);
|
||||||
tft.drawString("HIGH", 100, 130, 1);
|
tft.drawString("HIGH", 100, 130, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p5), 100, 130, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P05)), 100, 130, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_06", 20, 144, 1);
|
tft.drawString("GPIO_06", 20, 144, 1);
|
||||||
tft.drawString("->", 75, 144, 1);
|
tft.drawString("->", 75, 144, 1);
|
||||||
@ -162,7 +178,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 144, 1);
|
tft.drawString("LOW", 100, 144, 1);
|
||||||
tft.drawString("HIGH", 100, 144, 1);
|
tft.drawString("HIGH", 100, 144, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p6), 100, 144, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P06)), 100, 144, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_07", 20, 158, 1);
|
tft.drawString("GPIO_07", 20, 158, 1);
|
||||||
tft.drawString("->", 75, 158, 1);
|
tft.drawString("->", 75, 158, 1);
|
||||||
@ -170,7 +186,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100, 158, 1);
|
tft.drawString("LOW", 100, 158, 1);
|
||||||
tft.drawString("HIGH", 100, 158, 1);
|
tft.drawString("HIGH", 100, 158, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p7), 100, 158, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P07)), 100, 158, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_08", 20 + 160, 60, 1);
|
tft.drawString("GPIO_08", 20 + 160, 60, 1);
|
||||||
tft.drawString("->", 75 + 160, 60, 1);
|
tft.drawString("->", 75 + 160, 60, 1);
|
||||||
@ -178,7 +194,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 60, 1);
|
tft.drawString("LOW", 100 + 160, 60, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 60, 1);
|
tft.drawString("HIGH", 100 + 160, 60, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p8), 100 + 160, 60, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P10)), 100 + 160, 60, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_09", 20 + 160, 74, 1);
|
tft.drawString("GPIO_09", 20 + 160, 74, 1);
|
||||||
tft.drawString("->", 75 + 160, 74, 1);
|
tft.drawString("->", 75 + 160, 74, 1);
|
||||||
@ -186,7 +202,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 74, 1);
|
tft.drawString("LOW", 100 + 160, 74, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 74, 1);
|
tft.drawString("HIGH", 100 + 160, 74, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p9), 100 + 160, 74, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P11)), 100 + 160, 74, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_10", 20 + 160, 88, 1);
|
tft.drawString("GPIO_10", 20 + 160, 88, 1);
|
||||||
tft.drawString("->", 75 + 160, 88, 1);
|
tft.drawString("->", 75 + 160, 88, 1);
|
||||||
@ -194,7 +210,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 88, 1);
|
tft.drawString("LOW", 100 + 160, 88, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 88, 1);
|
tft.drawString("HIGH", 100 + 160, 88, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p10), 100 + 160, 88, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P12)), 100 + 160, 88, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_11", 20 + 160, 102, 1);
|
tft.drawString("GPIO_11", 20 + 160, 102, 1);
|
||||||
tft.drawString("->", 75 + 160, 102, 1);
|
tft.drawString("->", 75 + 160, 102, 1);
|
||||||
@ -202,7 +218,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 102, 1);
|
tft.drawString("LOW", 100 + 160, 102, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 102, 1);
|
tft.drawString("HIGH", 100 + 160, 102, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p11), 100 + 160, 102, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P13)), 100 + 160, 102, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_12", 20 + 160, 116, 1);
|
tft.drawString("GPIO_12", 20 + 160, 116, 1);
|
||||||
tft.drawString("->", 75 + 160, 116, 1);
|
tft.drawString("->", 75 + 160, 116, 1);
|
||||||
@ -210,7 +226,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 116, 1);
|
tft.drawString("LOW", 100 + 160, 116, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 116, 1);
|
tft.drawString("HIGH", 100 + 160, 116, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p12), 100 + 160, 116, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P14)), 100 + 160, 116, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_13", 20 + 160, 130, 1);
|
tft.drawString("GPIO_13", 20 + 160, 130, 1);
|
||||||
tft.drawString("->", 75 + 160, 130, 1);
|
tft.drawString("->", 75 + 160, 130, 1);
|
||||||
@ -218,7 +234,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 130, 1);
|
tft.drawString("LOW", 100 + 160, 130, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 130, 1);
|
tft.drawString("HIGH", 100 + 160, 130, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p13), 100 + 160, 130, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P15)), 100 + 160, 130, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_14", 20 + 160, 144, 1);
|
tft.drawString("GPIO_14", 20 + 160, 144, 1);
|
||||||
tft.drawString("->", 75 + 160, 144, 1);
|
tft.drawString("->", 75 + 160, 144, 1);
|
||||||
@ -226,7 +242,7 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 144, 1);
|
tft.drawString("LOW", 100 + 160, 144, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 144, 1);
|
tft.drawString("HIGH", 100 + 160, 144, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p14), 100 + 160, 144, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P16)), 100 + 160, 144, 1);
|
||||||
|
|
||||||
tft.drawString("GPIO_15", 20 + 160, 158, 1);
|
tft.drawString("GPIO_15", 20 + 160, 158, 1);
|
||||||
tft.drawString("->", 75 + 160, 158, 1);
|
tft.drawString("->", 75 + 160, 158, 1);
|
||||||
@ -234,43 +250,39 @@ void PCF8575_Test(void)
|
|||||||
tft.drawString("LOW", 100 + 160, 158, 1);
|
tft.drawString("LOW", 100 + 160, 158, 1);
|
||||||
tft.drawString("HIGH", 100 + 160, 158, 1);
|
tft.drawString("HIGH", 100 + 160, 158, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawString(PCF8575_TFT_Show(readAllPin.p15), 100 + 160, 158, 1);
|
tft.drawString(PCA95x5_TFT_Show(PCA9535_Class.read(PCA95x5::Port::P17)), 100 + 160, 158, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MPR121 test program for detecting whether touch IO is triggered and recording
|
* @brief MPR121 test program for detecting whether touch IO is triggered and recording
|
||||||
the IO port number after the trigger for linkage debugging with PCF8575.
|
the IO port number after the trigger for linkage debugging with PCA9535.
|
||||||
|
|
||||||
* @return
|
* @return
|
||||||
* @Date 2023-07-13 11:32:22
|
* @Date 2023-07-13 11:32:22
|
||||||
*/
|
*/
|
||||||
void MPR121_Test(void)
|
void MPR121_Test(void)
|
||||||
{
|
{
|
||||||
|
// delay(100); // Anti-jamming machine delay
|
||||||
|
// touched1 = Touch_Sensor1.touched(); // Get touch data
|
||||||
|
// touched2 = Touch_Sensor2.touched();
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 12; i++)
|
for (uint8_t i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
if (touched1 & (1 << i))
|
if (touched1 & (1 << i))
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
PCA9535_Class.direction(PCA95x5::Direction::OUT_ALL);
|
||||||
{
|
|
||||||
PCF8575_Class.pinMode(i, OUTPUT); // Write to output
|
PCA9535_Class.write(PCA95x5::Level::H_ALL);
|
||||||
}
|
|
||||||
PCF8575_Class.digitalWrite(i, !PCF8575_Class.digitalRead(i));
|
PCA9535_Class.direction(PCA95x5::Direction::IN_ALL);
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
PCF8575_Class.pinMode(i, INPUT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (touched2 & (1 << i))
|
else if (touched2 & (1 << i))
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
PCA9535_Class.direction(PCA95x5::Direction::OUT_ALL);
|
||||||
{
|
|
||||||
PCF8575_Class.pinMode(i, OUTPUT);
|
PCA9535_Class.write(PCA95x5::Level::H_ALL);
|
||||||
}
|
|
||||||
PCF8575_Class.digitalWrite(i + 12, !PCF8575_Class.digitalRead(i + 12));
|
PCA9535_Class.direction(PCA95x5::Direction::IN_ALL);
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
PCF8575_Class.pinMode(i, INPUT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,6 +347,7 @@ void playNextAudio()
|
|||||||
{
|
{
|
||||||
sdfile = File_CurrentFile.name();
|
sdfile = File_CurrentFile.name();
|
||||||
audio.connecttoSD(sdfile.c_str());
|
audio.connecttoSD(sdfile.c_str());
|
||||||
|
delay(50);
|
||||||
tft.println("\nStart playing: " + sdfile);
|
tft.println("\nStart playing: " + sdfile);
|
||||||
tft.setCursor(0, 0);
|
tft.setCursor(0, 0);
|
||||||
}
|
}
|
||||||
@ -344,6 +357,8 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Hello T-Display-S3");
|
Serial.println("Hello T-Display-S3");
|
||||||
|
pinMode(PIN_POWER_ON, OUTPUT);
|
||||||
|
digitalWrite(PIN_POWER_ON, HIGH);
|
||||||
|
|
||||||
tft.begin();
|
tft.begin();
|
||||||
tft.setRotation(3);
|
tft.setRotation(3);
|
||||||
@ -351,24 +366,9 @@ void setup()
|
|||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
ledcAttachPin(TFT_BL, 1); // assign TFT_BL pin to channel 1
|
ledcAttachPin(TFT_BL, 1); // assign TFT_BL pin to channel 1
|
||||||
ledcSetup(1, 12000, 8); // 12 kHz PWM, 8-bit resolution
|
ledcSetup(1, 2000, 8); // 2 kHz PWM, 8-bit resolution
|
||||||
ledcWrite(1, 255); // brightness 0 - 255
|
ledcWrite(1, 255); // brightness 0 - 255
|
||||||
|
attachInterrupt(2, PCA9535_MPR121_External_Interrupt, FALLING);
|
||||||
// SD SPI
|
|
||||||
SPI.begin(PIN_SD_CLK, PIN_SD_MISO, PIN_SD_MOSI, PIN_SD_CS); // SPI boots
|
|
||||||
|
|
||||||
PCF8575_Class.begin();
|
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
PCF8575_Class.pinMode(i, INPUT); // Set the IO mode for all PCF8575s
|
|
||||||
}
|
|
||||||
|
|
||||||
Touch_Sensor1.begin(MPR121_ADDR1); // MPR121 address 1
|
|
||||||
Touch_Sensor2.begin(MPR121_ADDR2); // MPR121 address 2
|
|
||||||
|
|
||||||
// PCM5102A IIS
|
|
||||||
audio.setPinout(PCM5102A_BCK, PCM5102A_LRCK, PCM5102A_DIN);
|
|
||||||
audio.setVolume(10); // 0...21,Volume setting
|
|
||||||
|
|
||||||
tft.setTextColor(TFT_RED);
|
tft.setTextColor(TFT_RED);
|
||||||
tft.drawString("START", 0, 5, 4);
|
tft.drawString("START", 0, 5, 4);
|
||||||
@ -378,39 +378,66 @@ void setup()
|
|||||||
tft.drawString("LILYGO", 260, 5, 1);
|
tft.drawString("LILYGO", 260, 5, 1);
|
||||||
tft.drawString("V1.0.0", 260, 17, 1);
|
tft.drawString("V1.0.0", 260, 17, 1);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
|
|
||||||
|
// SD SPI
|
||||||
|
SPI.begin(PIN_SD_CLK, PIN_SD_MISO, PIN_SD_MOSI, PIN_SD_CS); // SPI boots
|
||||||
|
|
||||||
|
Touch_Sensor1.begin(MPR121_ADDR1); // MPR121 address 1
|
||||||
|
Touch_Sensor2.begin(MPR121_ADDR2); // MPR121 address 2
|
||||||
|
delay(50);
|
||||||
|
|
||||||
|
Wire.begin(MPR121_SDA, MPR121_SCL);
|
||||||
|
PCA9535_Class.attach(Wire);
|
||||||
|
PCA9535_Class.polarity(PCA95x5::Polarity::ORIGINAL_ALL);
|
||||||
|
PCA9535_Class.direction(PCA95x5::Direction::OUT_ALL);
|
||||||
|
// PCA9535_Class.write(PCA95x5::Level::H_ALL);
|
||||||
|
PCA9535_Class.direction(PCA95x5::Direction::IN_ALL);
|
||||||
|
delay(50);
|
||||||
|
|
||||||
|
deviceScan(&Wire, &Serial);
|
||||||
|
delay(50);
|
||||||
|
|
||||||
|
// PCM5102A IIS
|
||||||
|
audio.setPinout(PCM5102A_BCK, PCM5102A_LRCK, PCM5102A_DIN);
|
||||||
|
audio.setVolume(10); // 0...21,Volume setting
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (MPR121_External_Interrupt_Flag == true)
|
// deviceScan(&Wire, &Serial);
|
||||||
{
|
// delay(50);
|
||||||
MPR121_External_Interrupt_Flag = false;
|
|
||||||
|
|
||||||
delay(100); // Anti-jamming machine delay
|
if (Windows == 0)
|
||||||
|
{
|
||||||
touched1 = Touch_Sensor1.touched(); // Get touch data
|
touched1 = Touch_Sensor1.touched(); // Get touch data
|
||||||
touched2 = Touch_Sensor2.touched();
|
touched2 = Touch_Sensor2.touched();
|
||||||
|
if (MPR121_External_Interrupt_Flag == true)
|
||||||
if (touched2 & (1 << 11))
|
|
||||||
{
|
{
|
||||||
tft.fillScreen(TFT_BLACK);
|
MPR121_External_Interrupt_Flag = false;
|
||||||
SD.end();
|
delay(100); // Anti-jamming machine delay
|
||||||
SD.begin(PIN_SD_CS, SPI, 40000000);
|
|
||||||
|
|
||||||
playNextAudio();
|
if (touched2 & (1 << 11))
|
||||||
Windows = !Windows;
|
{
|
||||||
|
delay(200); // Anti-jamming machine delay
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
SD.end();
|
||||||
|
delay(100); // Anti-jamming machine delay
|
||||||
|
SD.begin(PIN_SD_CS, SPI, 40000000);
|
||||||
|
delay(100); // Anti-jamming machine delay
|
||||||
|
|
||||||
|
playNextAudio();
|
||||||
|
Windows = !Windows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (PCA95x5_External_Interrupt_Flag == true && Windows == 0)
|
||||||
{
|
{
|
||||||
|
PCA95x5_External_Interrupt_Flag = false;
|
||||||
MPR121_Test();
|
MPR121_Test();
|
||||||
|
PCA95x5_Test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PCF8575_External_Interrupt_Flag == true && Windows == 0)
|
|
||||||
{
|
|
||||||
PCF8575_External_Interrupt_Flag = false;
|
|
||||||
PCF8575_Test();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Windows == 1)
|
if (Windows == 1)
|
||||||
{
|
{
|
||||||
audio.loop();
|
audio.loop();
|
||||||
|
Loading…
Reference in New Issue
Block a user