Modify I2C and IRQ PINs

This commit is contained in:
Leon
2024-07-15 11:16:25 +08:00
parent d22a64a70d
commit 6e6fb70248
2 changed files with 35 additions and 38 deletions

View File

@@ -37,15 +37,8 @@
#define DYNAMIC_SPI_SPEED // uncomment to enable dynamic SPI Speed https://github.com/ohmytime/TFT_eSPI_DynamicSpeed #define DYNAMIC_SPI_SPEED // uncomment to enable dynamic SPI Speed https://github.com/ohmytime/TFT_eSPI_DynamicSpeed
#ifdef DEEPELEC_DP_666 #ifdef DEEPELEC_DP_66X
#include "ExtensionIOXL9555.hpp" #define EXT_IRQ 14
#endif
#ifdef DEEPELEC_DP_666
#define RTP_IRQ 33
#define EXT_IO_SDA 32
#define EXT_IO_SCL 14
ExtensionIOXL9555 extIO;
#endif #endif
#ifdef ARS #ifdef ARS
@@ -156,7 +149,7 @@ byte BWset;
byte BWsetAM; byte BWsetAM;
byte BWsetFM; byte BWsetFM;
byte charwidth = 8; byte charwidth = 8;
#if defined(CHINA_PORTABLE) || defined(DEEPELEC_DP_666) #if defined(CHINA_PORTABLE) || defined(DEEPELEC_DP_66X)
byte hardwaremodel = PORTABLE_ILI9341; byte hardwaremodel = PORTABLE_ILI9341;
#else #else
byte hardwaremodel = BASE_ILI9341; byte hardwaremodel = BASE_ILI9341;
@@ -627,17 +620,8 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_A), read_encoder, CHANGE); attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_A), read_encoder, CHANGE);
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE); attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE);
#ifdef DEEPELEC_DP_666 #ifdef DEEPELEC_DP_66X
bool extIO_dect = false; pinMode(EXT_IRQ, INPUT_PULLUP);
// Device address 0x20~0x27
if (extIO.begin(Wire1, XL9555_SLAVE_ADDRESS0, EXT_IO_SDA, EXT_IO_SCL)) {
extIO_dect = true;
pinMode(RTP_IRQ, INPUT_PULLUP);
// Set PORT0 as input,mask = 0xFF = all pin input
extIO.configPort(ExtensionIOXL9555::PORT0, 0xFF);
// Set PORT1 as input,mask = 0xFF = all pin input
extIO.configPort(ExtensionIOXL9555::PORT1, 0xFF);
}
#endif #endif
tft.setSwapBytes(true); tft.setSwapBytes(true);
@@ -733,13 +717,6 @@ void setup() {
tftPrint(0, myLanguage[language][8], 160, 3, PrimaryColor, PrimaryColorSmooth, 28); tftPrint(0, myLanguage[language][8], 160, 3, PrimaryColor, PrimaryColorSmooth, 28);
tftPrint(0, "Software " + String(VERSION), 160, 152, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(0, "Software " + String(VERSION), 160, 152, PrimaryColor, PrimaryColorSmooth, 16);
#ifdef DEEPELEC_DP_666
if (extIO_dect)
tftPrint(-1, "EXT_IO OK!", 240, 152, PrimaryColor, PrimaryColorSmooth, 16);
else
tftPrint(-1, "EXT_IO ERR!", 240, 152, PrimaryColor, PrimaryColorSmooth, 16);
#endif
tft.fillRect(120, 230, 16, 6, GreyoutColor); tft.fillRect(120, 230, 16, 6, GreyoutColor);
tft.fillRect(152, 230, 16, 6, GreyoutColor); tft.fillRect(152, 230, 16, 6, GreyoutColor);
tft.fillRect(184, 230, 16, 6, GreyoutColor); tft.fillRect(184, 230, 16, 6, GreyoutColor);
@@ -791,6 +768,20 @@ void setup() {
} }
tftPrint(0, "Patch: v" + String(TEF), 160, 202, ActiveColor, ActiveColorSmooth, 28); tftPrint(0, "Patch: v" + String(TEF), 160, 202, ActiveColor, ActiveColorSmooth, 28);
#ifdef DEEPELEC_DP_66X
bool extIO_dect = false;
// Device address 0x20
// Set PORT0/PORT1 as input
Wire.beginTransmission(0x20);
Wire.write(0x06);
Wire.write(0xFF);
Wire.write(0xFF);
if (Wire.endTransmission() == 0) {
extIO_dect = true;
tftPrint(-1, "HW:DP-666", 240, 152, PrimaryColor, PrimaryColorSmooth, 16);
}
#endif
if (analogRead(BATTERY_PIN) < 200) batterydetect = false; if (analogRead(BATTERY_PIN) < 200) batterydetect = false;
if (wifi) { if (wifi) {
@@ -1224,13 +1215,19 @@ void loop() {
} }
} }
#ifdef DEEPELEC_DP_666 #ifdef DEEPELEC_DP_66X
if (digitalRead(RTP_IRQ) == LOW) { if (digitalRead(EXT_IRQ) == LOW) {
int16_t temp; int16_t temp = 1;
temp = extIO.readPort(ExtensionIOXL9555::PORT1) & 0xFF; Wire.beginTransmission(0x20);
temp = (temp << 8) | (extIO.readPort(ExtensionIOXL9555::PORT0) & 0xFF); Wire.write(0x00);
if (!screenmute && !menu && !advancedRDS && !afscreen) Wire.endTransmission();
ShowNumInput(temp); Wire.requestFrom(0x20, 2);
if (Wire.available() == 2) {
temp = Wire.read() & 0xFF;
temp |= (Wire.read() & 0xFF) * 256;
if (!screenmute && !menu && !advancedRDS && !afscreen)
ShowNumInput(temp);
}
} }
#endif #endif
@@ -4287,7 +4284,7 @@ void DefaultSettings(byte userhardwaremodel) {
EEPROM.writeByte(EE_BYTE_SHOWRDSERRORS, 1); EEPROM.writeByte(EE_BYTE_SHOWRDSERRORS, 1);
EEPROM.writeByte(EE_BYTE_TEF, 0); EEPROM.writeByte(EE_BYTE_TEF, 0);
if (userhardwaremodel == BASE_ILI9341) EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, 0); else EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, 1); if (userhardwaremodel == BASE_ILI9341) EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, 0); else EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, 1);
#ifdef DEEPELEC_DP_666 #ifdef DEEPELEC_DP_66X
EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1); EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1);
#else #else
EEPROM.writeByte(EE_BYTE_ROTARYMODE, 0); EEPROM.writeByte(EE_BYTE_ROTARYMODE, 0);
@@ -4691,7 +4688,7 @@ void setAutoSpeedSPI() {
} }
} }
#ifdef DEEPELEC_DP_666 #ifdef DEEPELEC_DP_66X
byte keyval[16] = { byte keyval[16] = {
2, 3, 127, 5, 6, 0, 9, 13, 8, 7, 4, 1, 0, 0, 0, 0 2, 3, 127, 5, 6, 0, 9, 13, 8, 7, 4, 1, 0, 0, 0, 0
}; };

View File

@@ -5,6 +5,6 @@
// #define HAS_AIR_BAND // uncomment to enable Air Band(Make sure you have Air Band extend board) // #define HAS_AIR_BAND // uncomment to enable Air Band(Make sure you have Air Band extend board)
// #define CHINA_PORTABLE // uncomment for China Portable build (Simplified Chinese) // #define CHINA_PORTABLE // uncomment for China Portable build (Simplified Chinese)
#define DEEPELEC_DP_666 // uncomment for DEEPELEC Portable DP-666 build (Simplified Chinese) #define DEEPELEC_DP_66X // uncomment for DEEPELEC Portable DP-66X build (Simplified Chinese)
#endif #endif