You've already forked TEF6686_ESP32
Added basic touch events
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#define CONTRASTPIN 2
|
#define CONTRASTPIN 2
|
||||||
#define STANDBYLED 19
|
#define STANDBYLED 19
|
||||||
#define SMETERPIN 27
|
#define SMETERPIN 27
|
||||||
|
#define TOUCHIRQ 33
|
||||||
|
|
||||||
#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
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ bool StereoToggle;
|
|||||||
bool store;
|
bool store;
|
||||||
bool TAold;
|
bool TAold;
|
||||||
bool TPold;
|
bool TPold;
|
||||||
|
bool touch_detect;
|
||||||
bool tuned;
|
bool tuned;
|
||||||
bool USBmode = 1;
|
bool USBmode = 1;
|
||||||
bool XDRGTKMuteScreen;
|
bool XDRGTKMuteScreen;
|
||||||
@@ -630,12 +632,16 @@ void setup() {
|
|||||||
if (displayflip == 0) {
|
if (displayflip == 0) {
|
||||||
#ifdef ARS
|
#ifdef ARS
|
||||||
tft.setRotation(0);
|
tft.setRotation(0);
|
||||||
|
#elif defined(DEEPELEC_DP_66X)
|
||||||
|
tft.setRotation(1);
|
||||||
#else
|
#else
|
||||||
tft.setRotation(3);
|
tft.setRotation(3);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#ifdef ARS
|
#ifdef ARS
|
||||||
tft.setRotation(2);
|
tft.setRotation(2);
|
||||||
|
#elif defined(DEEPELEC_DP_66X)
|
||||||
|
tft.setRotation(3);
|
||||||
#else
|
#else
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
#endif
|
#endif
|
||||||
@@ -649,7 +655,9 @@ void setup() {
|
|||||||
pinMode(ROTARY_PIN_B, INPUT);
|
pinMode(ROTARY_PIN_B, INPUT);
|
||||||
pinMode (STANDBYLED, OUTPUT);
|
pinMode (STANDBYLED, OUTPUT);
|
||||||
digitalWrite(STANDBYLED, HIGH);
|
digitalWrite(STANDBYLED, HIGH);
|
||||||
|
pinMode(TOUCHIRQ, INPUT);
|
||||||
|
|
||||||
|
attachInterrupt(digitalPinToInterrupt(TOUCHIRQ), Touch_IRQ_Handler, CHANGE);
|
||||||
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);
|
||||||
|
|
||||||
@@ -701,10 +709,22 @@ void setup() {
|
|||||||
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
|
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
|
||||||
if (displayflip == 0) {
|
if (displayflip == 0) {
|
||||||
displayflip = 1;
|
displayflip = 1;
|
||||||
|
#ifdef ARS
|
||||||
|
tft.setRotation(2);
|
||||||
|
#elif defined(DEEPELEC_DP_66X)
|
||||||
|
tft.setRotation(3);
|
||||||
|
#else
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
displayflip = 0;
|
displayflip = 0;
|
||||||
|
#ifdef ARS
|
||||||
|
tft.setRotation(0);
|
||||||
|
#elif defined(DEEPELEC_DP_66X)
|
||||||
|
tft.setRotation(1);
|
||||||
|
#else
|
||||||
tft.setRotation(3);
|
tft.setRotation(3);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, displayflip);
|
EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, displayflip);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
@@ -893,6 +913,18 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (hardwaremodel == PORTABLE_TOUCH_ILI9341 && touch_detect) {
|
||||||
|
if (tft.getTouchRawZ() > 100) {
|
||||||
|
uint16_t x, y;
|
||||||
|
tft.getTouch(&x, &y);
|
||||||
|
if (x > 0 || y > 0) {
|
||||||
|
doTouchEvent(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
touch_detect = false;
|
||||||
|
}
|
||||||
|
|
||||||
Communication();
|
Communication();
|
||||||
|
|
||||||
if (tot != 0) {
|
if (tot != 0) {
|
||||||
@@ -1832,22 +1864,7 @@ void BANDBUTTONPress() {
|
|||||||
SelectBand();
|
SelectBand();
|
||||||
ScreensaverTimerReopen();
|
ScreensaverTimerReopen();
|
||||||
} else {
|
} else {
|
||||||
if (tunemode != TUNE_MEM) {
|
doBandToggle();
|
||||||
ToggleBand(band);
|
|
||||||
radio.clearRDS(fullsearchrds);
|
|
||||||
StoreFrequency();
|
|
||||||
SelectBand();
|
|
||||||
if (XDRGTKUSB || XDRGTKTCP) {
|
|
||||||
if (band == BAND_FM) DataPrint("M0\nT" + String(frequency * 10) + "\n");
|
|
||||||
else if (band == BAND_OIRT) DataPrint("M0\nT" + String(frequency_OIRT * 10) + "\n");
|
|
||||||
else DataPrint("M1\nT" + String(frequency_AM) + "\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
scanmodeold = tunemode;
|
|
||||||
startFMDXScan();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ScreensaverTimerRestart();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (band < BAND_GAP) {
|
if (band < BAND_GAP) {
|
||||||
@@ -4937,6 +4954,25 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doBandToggle() {
|
||||||
|
if (tunemode != TUNE_MEM) {
|
||||||
|
ToggleBand(band);
|
||||||
|
radio.clearRDS(fullsearchrds);
|
||||||
|
StoreFrequency();
|
||||||
|
SelectBand();
|
||||||
|
if (XDRGTKUSB || XDRGTKTCP) {
|
||||||
|
if (band == BAND_FM) DataPrint("M0\nT" + String(frequency * 10) + "\n");
|
||||||
|
else if (band == BAND_OIRT) DataPrint("M0\nT" + String(frequency_OIRT * 10) + "\n");
|
||||||
|
else DataPrint("M1\nT" + String(frequency_AM) + "\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scanmodeold = tunemode;
|
||||||
|
startFMDXScan();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ScreensaverTimerRestart();
|
||||||
|
}
|
||||||
|
|
||||||
void StoreMemoryPos(uint8_t _pos) {
|
void StoreMemoryPos(uint8_t _pos) {
|
||||||
EEPROM.writeByte(_pos + EE_PRESETS_BAND_START, band);
|
EEPROM.writeByte(_pos + EE_PRESETS_BAND_START, band);
|
||||||
EEPROM.writeByte(_pos + EE_PRESET_BW_START, BWset);
|
EEPROM.writeByte(_pos + EE_PRESET_BW_START, BWset);
|
||||||
@@ -5011,6 +5047,10 @@ void ClearMemoryRange(uint8_t start, uint8_t stop) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Touch_IRQ_Handler() {
|
||||||
|
touch_detect = true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEEPELEC_DP_66X
|
#ifdef DEEPELEC_DP_66X
|
||||||
byte numval[16] = {
|
byte numval[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
|
||||||
|
|||||||
@@ -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_66X // uncomment for DEEPELEC Portable DP-66X build (Simplified Chinese)
|
#define DEEPELEC_DP_66X // uncomment for DEEPELEC Portable DP-66X build (Simplified Chinese)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,3 +2,29 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
void doTouchEvent(uint16_t x, uint16_t y) {
|
||||||
|
if (!menu && !advancedRDS && !seek && !afscreen) { // Normal radio mode
|
||||||
|
if (x > 0 && x < 320 && y > 180 && y < 240 && band < BAND_GAP) { // -----------------
|
||||||
|
leave = true;
|
||||||
|
BuildAdvancedRDS(); // Switch to Advanced RDS View
|
||||||
|
return;
|
||||||
|
} else if (x > 60 && x < 240 && y > 40 && y < 100) {
|
||||||
|
doBandToggle(); // Toggle bands
|
||||||
|
return;
|
||||||
|
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
|
||||||
|
doTuneMode(); // Toggle tune mode
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!menu && advancedRDS && !seek && !afscreen) { // Advanced RDS mode
|
||||||
|
if (x > 0 && x < 320 && y > 180 && y < 240) { // -----------------
|
||||||
|
leave = true;
|
||||||
|
BuildDisplay();
|
||||||
|
SelectBand();
|
||||||
|
ScreensaverTimerReopen(); // Switch to normal radio view
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/touch.h
15
src/touch.h
@@ -6,4 +6,19 @@
|
|||||||
|
|
||||||
extern TFT_eSPI tft;
|
extern TFT_eSPI tft;
|
||||||
|
|
||||||
|
extern bool advancedRDS;
|
||||||
|
extern bool afscreen;
|
||||||
|
extern bool leave;
|
||||||
|
extern bool menu;
|
||||||
|
extern bool seek;
|
||||||
|
extern byte band;
|
||||||
|
|
||||||
|
void doTouchEvent(uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
extern void ScreensaverTimerReopen();
|
||||||
|
extern void BuildDisplay();
|
||||||
|
extern void SelectBand();
|
||||||
|
extern void BuildAdvancedRDS();
|
||||||
|
extern void doBandToggle();
|
||||||
|
extern void doTuneMode();
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user