Skip to content

Commit 50ba776

Browse files
committed
WaveSentry
1 parent d3490bb commit 50ba776

File tree

6 files changed

+80
-8
lines changed

6 files changed

+80
-8
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
- { env: "Marauder-Mini" }
7373
- { env: "Awok-Mini" }
7474
- { env: "Awok-Touch" }
75+
- { env: "WaveSentry-R1" }
7576
- { env: "Phantom_S024R" }
7677
- { env: "elecrow-24B" }
7778
- { env: "elecrow-28B" }

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Things that needs to be done in next updates
8686
## Latest Changelog
8787
* 2.6.5:
8888
* [x] Added possibility to order by "Latest update"
89+
* [x] Port to OpenSourceSRDLabs [WaveSentry and WaveSentry Pro ](https://opensourcesdrlab.com/products/aifw-wavesentry-esp32?VariantsId=10331)
8990
* 2.6.4:
9091
* [x] Fixed CYD 3243S035R touchscreen rotation
9192
* [x] Fixed Marauder V7 screen issues

boards/marauder-v4og/interface.cpp

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@
55

66
CYD28_TouchR touch(320, 240);
77

8+
#ifdef WAVESENTRY
9+
#include <RotaryEncoder.h>
10+
RotaryEncoder *encoder = nullptr;
11+
IRAM_ATTR void checkPosition() { encoder->tick(); }
12+
#endif
13+
814
/***************************************************************************************
915
** Function name: _setup_gpio()
1016
** Location: main.cpp
1117
** Description: initial setup for the device
1218
***************************************************************************************/
13-
void _setup_gpio() { pinMode(TFT_BL, OUTPUT); }
19+
void _setup_gpio() {
20+
pinMode(TFT_BL, OUTPUT);
21+
#ifdef WAVESENTRY
22+
pinMode(ENCODER_KEY, INPUT);
23+
encoder = new RotaryEncoder(ENCODER_INA, ENCODER_INB, RotaryEncoder::LatchMode::TWO03);
24+
attachInterrupt(digitalPinToInterrupt(ENCODER_INA), checkPosition, CHANGE);
25+
attachInterrupt(digitalPinToInterrupt(ENCODER_INB), checkPosition, CHANGE);
26+
#endif
27+
}
1428

1529
/***************************************************************************************
1630
** Function name: _post_setup_gpio()
@@ -59,8 +73,8 @@ void _setBrightness(uint8_t brightval) {
5973
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
6074
**********************************************************************/
6175
void InputHandler(void) {
62-
static long tm = millis();
63-
if (millis() - tm > 300 || LongPress) { // don´t allow multiple readings in less than 200ms
76+
static unsigned long tm = millis();
77+
if (millis() - tm > 200 || LongPress) { // don´t allow multiple readings in less than 200ms
6478
if (touch.touched()) {
6579
auto t = touch.getPointScaled();
6680
t = touch.getPointScaled();
@@ -91,6 +105,41 @@ void InputHandler(void) {
91105
touchHeatMap(touchPoint);
92106
} else touchPoint.pressed = false;
93107
}
108+
109+
#ifdef WAVESENTRY
110+
static int posDifference = 0;
111+
static int lastPos = 0;
112+
bool sel = !BTN_ACT;
113+
114+
int newPos = encoder->getPosition();
115+
if (newPos != lastPos) {
116+
posDifference += (newPos - lastPos);
117+
lastPos = newPos;
118+
}
119+
120+
if (millis() - tm < 200 && !LongPress) return;
121+
122+
sel = digitalRead(ENCODER_KEY);
123+
124+
if (posDifference != 0 || sel == BTN_ACT) {
125+
if (!wakeUpScreen()) AnyKeyPress = true;
126+
else return;
127+
}
128+
if (posDifference > 0) {
129+
PrevPress = true;
130+
posDifference--;
131+
}
132+
if (posDifference < 0) {
133+
NextPress = true;
134+
posDifference++;
135+
}
136+
137+
if (sel == BTN_ACT) {
138+
posDifference = 0;
139+
SelPress = true;
140+
tm = millis();
141+
}
142+
#endif
94143
}
95144

96145
/*********************************************************************

boards/marauder-v4og/platformio.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,16 @@ build_flags =
9292
-DPART_16MB=1
9393
build_unflags =
9494
-DPART_04MB=1
95+
96+
[env:WaveSentry-R1]
97+
extends = env:Marauder-v4-OG
98+
build_flags =
99+
${env:Marauder-v4-OG.build_flags}
100+
-D WAVESENTRY=1
101+
-D ENCODER_INA=2
102+
-D ENCODER_INB=14
103+
-D ENCODER_KEY=0
104+
-D HAS_ENCODER=1
105+
lib_deps =
106+
${env.lib_deps}
107+
mathertel/RotaryEncoder @1.5.3

platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ default_envs =
6565
;Awok-Touch
6666
;Phantom_S024R
6767
;smoochiee-board
68+
;WaveSentry-R1
69+
6870
build_cache_dir = .pio/buildcache
6971
cache_dir = .pio/cache
7072
boards_dir = boards/_jsonfiles

src/mykeyboard.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include "settings.h"
55
#include <globals.h>
66

7-
const int max_FM_size = tftWidth / (LW * FM) - 1;
8-
const int max_FP_size = tftWidth / (LW)-2;
7+
int max_FM_size = tftWidth / (LW * FM) - 1;
8+
int max_FP_size = tftWidth / (LW)-2;
99

1010
// QWERTY KEYSET
1111
const int qwerty_keyboard_width = 12;
@@ -736,14 +736,18 @@ String generalKeyboard(
736736
#endif
737737

738738
#if defined(HAS_ENCODER) // T-Embed and T-LoRa-Pager
739+
#ifndef HAS_TOUCH
739740
LongPress = true;
740-
if (check(SelPress) || selection_made) {
741+
#endif
742+
// WaveSentry has Encoder and Touchscreen
743+
// if touchscreen is pressed, ignore encoder input
744+
if ((check(SelPress) || selection_made) && touchPoint.pressed == false) {
741745
LongPress = false;
742746
selection_made = true;
743747
} else {
744748
/* NEXT "Btn" to move forward on th X axis (to the right) */
745749
// if ESC is pressed while NEXT or PREV is received, then we navigate on the Y axis instead
746-
if (check(NextPress)) {
750+
if (check(NextPress) && touchPoint.pressed == false) {
747751
if (EscPress) {
748752
y++;
749753
} else if ((x >= buttons_number - 1 && y <= -1) || (x >= KeyboardWidth - 1 && y >= 0)) {
@@ -764,7 +768,7 @@ String generalKeyboard(
764768
redraw = true;
765769
}
766770
/* PREV "Btn" to move backwards on th X axis (to the left) */
767-
if (check(PrevPress)) {
771+
if (check(PrevPress) && touchPoint.pressed == false) {
768772
if (EscPress) {
769773
y--;
770774
} else if (x <= 0) {
@@ -822,6 +826,8 @@ String generalKeyboard(
822826
/// This calls the QUERTY keyboard. Returns the user typed strings, return the ASCII ESC character
823827
/// if the operation was cancelled
824828
String keyboard(String current_text, int max_size, String textbox_title) {
829+
max_FM_size = tftWidth / (LW * FM) - 1;
830+
max_FP_size = tftWidth / (LW)-2;
825831
return generalKeyboard<qwerty_keyboard_height, qwerty_keyboard_width>(
826832
current_text, max_size, textbox_title, qwerty_keyset
827833
);

0 commit comments

Comments
 (0)