Skip to content

Commit 612a5a1

Browse files
committed
added OBS Support
1 parent e4e8f01 commit 612a5a1

File tree

1 file changed

+55
-48
lines changed

1 file changed

+55
-48
lines changed

streamdeck.ino

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#include <HX8347_kbv.h>
55
#include "Keyboard.h"
66

7-
#define LCD_CS A3
8-
#define LCD_CD A2
9-
#define LCD_WR A1
10-
#define LCD_RD A0
11-
#define LCD_RESET A4
7+
#define LCD_CS A3
8+
#define LCD_CD A2
9+
#define LCD_WR A1
10+
#define LCD_RD A0
11+
#define LCD_RESET A4
1212
#define TIRQ_PIN 3
1313
#define TFT_PIN 4
1414

@@ -22,18 +22,20 @@ uint8_t running;
2222
#define MAGENTA 0xF81F
2323
#define YELLOW 0xFFE0
2424
#define WHITE 0xFFFF
25+
#define ORANGE 0xFD00
2526

26-
#define KEY_F13 0xF0 // 0x68 & 0x88
27-
#define KEY_F14 0xF1 // 0x69 & 0x88
28-
#define KEY_F15 0xF2 // 0x6A & 0x88
29-
#define KEY_F16 0xF3 // 0x6B & 0x88
30-
#define KEY_F17 0xF4 // 0x6C & 0x88
31-
#define KEY_F18 0xF5 // 0x6D & 0x88
32-
#define KEY_F19 0xF6 // 0x68 & 0x88
33-
#define KEY_F20 0xF7 // 0x69 & 0x88
34-
#define KEY_F21 0xF8 // 0x6A & 0x88
35-
#define KEY_F22 0xF9 // 0x6B & 0x88
36-
27+
#define KEY_F13 0xF0
28+
#define KEY_F14 0xF1
29+
#define KEY_F15 0xF2
30+
#define KEY_F16 0xF3
31+
#define KEY_F17 0xF4
32+
#define KEY_F18 0xF5
33+
#define KEY_F19 0xF6
34+
#define KEY_F20 0xF7
35+
#define KEY_F21 0xF8
36+
#define KEY_F22 0xF9
37+
#define KEY_F23 0xFA
38+
#define KEY_F24 0xFB
3739

3840
boolean t1, t2, t3, t4, t5 , t6, t7, t8, t9, t10 , t11, t12;
3941
boolean t1h;
@@ -59,6 +61,8 @@ void loop() {
5961
TS_Point p = tss.getPoint();
6062
p.x = map(p.x, 320, 3850, 0, 480);
6163
p.y = map(p.y, 3800 , 305, 0, 320);
64+
65+
//################## Code for actions here ##################
6266
//################## LINE 1 ##################
6367
if (p.x > 20 && p.x < 90 && p.y > 80 && p.y < 150) {
6468
if (t1) {
@@ -89,10 +93,13 @@ void loop() {
8993
Keyboard.write(KEY_F15);
9094
}
9195
if (p.x > 200 && p.x < 275 && p.y > 80 && p.y < 150) {
96+
Keyboard.write(KEY_F17);
9297
}
9398
if (p.x > 290 && p.x < 365 && p.y > 80 && p.y < 150) {
99+
Keyboard.write(KEY_F18);
94100
}
95101
if (p.x > 385 && p.x < 455 && p.y > 80 && p.y < 150) {
102+
Keyboard.write(KEY_F19);
96103
}
97104

98105

@@ -131,8 +138,6 @@ void loop() {
131138
}
132139

133140
//################## LINE 3 ##################
134-
135-
136141
if (p.x > 20 && p.x < 90 && p.y > 245 && p.y < 315) {
137142
if (t11) {
138143
draw_re(10, 180, CYAN, "OBS", "Mic", "ON");
@@ -141,7 +146,7 @@ void loop() {
141146
draw_re(10, 180, RED, "OBS", "Mic", "OFF");
142147
t11 = true;
143148
}
144-
Keyboard.write(KEY_F22);
149+
Keyboard.write(KEY_F23);
145150
}
146151
if (p.x > 115 && p.x < 180 && p.y > 245 && p.y < 315) {
147152
if (t12) {
@@ -151,30 +156,34 @@ void loop() {
151156
draw_re(70, 180, RED, "OBS", "Speaker", "OFF");
152157
t12 = true;
153158
}
154-
Keyboard.write(KEY_F21);
159+
Keyboard.write(KEY_F24);
155160
}
156161
if (p.x > 200 && p.x < 275 && p.y > 245 && p.y < 315) {
162+
Keyboard.write(KEY_F20);
157163
}
158164
if (p.x > 290 && p.x < 365 && p.y > 245 && p.y < 315) {
165+
Keyboard.write(KEY_F21);
159166
}
160167
if (p.x > 385 && p.x < 455 && p.y > 245 && p.y < 315) {
168+
Keyboard.write(KEY_F22);
161169
}
162170
delay(500);
163171
}
164172
}
165173

166174
void initial() {
175+
//################## Initial ##################
167176
tft.setRotation(3);
168177
tft.fillScreen(RED);
169178
tft.fillScreen(WHITE);
170179
tft.fillScreen(BLACK);
171180
tft.setTextColor(WHITE);
172-
181+
173182
draw_re(10, 60, GREEN, "DISC", "Mic", "ON");
174183
draw_re(70, 60, GREEN, "TS", "Mic", "ON");
175-
draw_re(130, 60);
176-
draw_re(190, 60);
177-
draw_re(250, 60);
184+
draw_re(130, 60, ORANGE, "OBS", "Scene", "Idle");
185+
draw_re(190, 60, ORANGE, "OBS", "Timer", "ON/OFF");
186+
draw_re(250, 60, ORANGE, "OBS", "Scene", "Active");
178187

179188
draw_re(10, 120, GREEN, "DISC", "Speaker", "ON");
180189
draw_re(70, 120, GREEN, "TS", "Speaker", "ON");
@@ -184,9 +193,9 @@ void initial() {
184193

185194
draw_re(10, 180, CYAN, "OBS", "Mic", "ON");
186195
draw_re(70, 180, CYAN, "OBS", "Speaker", "ON");
187-
draw_re(130, 180);
188-
draw_re(190, 180);
189-
draw_re(250, 180);
196+
draw_re(130, 180, ORANGE, "OBS", "Scene", "OW");
197+
draw_re(190, 180, ORANGE, "OBS", "Scene", "PUBG");
198+
draw_re(250, 180, ORANGE, "OBS", "Scene", "SoW");
190199

191200
}
192201

@@ -201,8 +210,6 @@ void draw_re(int x, int y, uint16_t color, String txt1, String txt2, String txt3
201210
int dist = 10;
202211
int txtdst = 5;
203212
tft.drawRect(x, y, 32 + 2 * dist, 32 + 2 * dist, WHITE);
204-
//tft.setAddrWindow(x+dist, y+dist,x+31+dist, y+31+dist);
205-
//tft.pushColors(0, 1024,1);
206213
tft.fillRect(x + 1, y + 1, 50, 50, BLACK);
207214
tft.setTextColor(color);
208215
tft.setTextSize(1);
@@ -214,38 +221,38 @@ void draw_re(int x, int y, uint16_t color, String txt1, String txt2, String txt3
214221
tft.println(txt3);
215222
}
216223

217-
void write_Jinput(){
224+
void write_Jinput() {
218225
String JString = Serial.readString();
219226
tft.setTextSize(1);
220227
tft.setTextColor(WHITE);
221228
int x_desc = 5;
222229
int y_desc = 5;
223230
String count_items = getValue(JString, ';', 0);
224-
225-
for (int i = 1;i < count_items.toInt()*2;i = i + 2){
231+
232+
for (int i = 1; i < count_items.toInt() * 2; i = i + 2) {
226233
String string_desc = getValue(JString, ';', i);
227-
String string_item = getValue(JString, ';', i+1);
228-
tft.fillRect(x_desc+50, y_desc, 100, 7, BLACK); //x,y,l,h
234+
String string_item = getValue(JString, ';', i + 1);
235+
tft.fillRect(x_desc + 50, y_desc, 100, 7, BLACK); //x,y,l,h
229236
tft.setCursor(x_desc, y_desc);
230237
tft.println(string_desc);
231-
tft.setCursor(x_desc + 50, y_desc);
232-
tft.println(string_item);
233-
y_desc > 30 ? x_desc = x_desc + 150 : x_desc;
234-
y_desc > 30 ? y_desc = 5 : y_desc = y_desc + 10;
238+
tft.setCursor(50 + x_desc, y_desc);
239+
tft.println(string_item);
240+
y_desc > 24 ? x_desc = x_desc + 150 : x_desc;
241+
y_desc > 24 ? y_desc = 5 : y_desc = y_desc + 10;
235242
}
236243
JString = "";
237244
}
238245

239246
String getValue(String data, char separator, int index) {
240-
int found = 0;
241-
int strIndex[] = { 0, -1 };
242-
int maxIndex = data.length() - 1;
243-
for (int i = 0; i <= maxIndex && found <= index; i++) {
244-
if (data.charAt(i) == separator || i == maxIndex) {
245-
found++;
246-
strIndex[0] = strIndex[1] + 1;
247-
strIndex[1] = (i == maxIndex) ? i+1 : i;
248-
}
247+
int found = 0;
248+
int strIndex[] = { 0, -1 };
249+
int maxIndex = data.length() - 1;
250+
for (int i = 0; i <= maxIndex && found <= index; i++) {
251+
if (data.charAt(i) == separator || i == maxIndex) {
252+
found++;
253+
strIndex[0] = strIndex[1] + 1;
254+
strIndex[1] = (i == maxIndex) ? i + 1 : i;
249255
}
250-
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
256+
}
257+
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
251258
}

0 commit comments

Comments
 (0)