42
42
// (THE ESP32 TOUCHDOWN USES THIS!)
43
43
// #define USECAPTOUCH
44
44
45
- // ------- Uncomment and populate the following if your cap touch uses custom i2c pins ------ -
46
- // #define CUSTOM_TOUCH_SDA 26
47
- // #define CUSTOM_TOUCH_SCL 27
45
+ // ------- If your board is capapble of USB HID you can undefine this -
46
+
47
+ // #define USEUSBHID
48
48
49
- // PAY ATTENTION! Even if resistive touch is not used, the TOUCH pin has to be defined!
50
- // It can be a random unused pin.
51
- // TODO: Find a way around this!
49
+ // ------- Uncomment and populate the following if your cap touch uses custom i2c pins -------
50
+ // #define CUSTOM_TOUCH_SDA 17
51
+ // #define CUSTOM_TOUCH_SCL 18
52
52
53
53
// ------- Uncomment the define below if you want to use SLEEP and wake up on touch -------
54
54
// The pin where the IRQ from the touch screen is connected uses ESP-style GPIO_NUM_* instead of just pinnumber
61
61
// and if you are using the original ESP32-BLE-Keyboard library by T-VK -------
62
62
// #define USE_NIMBLE
63
63
64
- const char *versionnumber = " 0.9.17 " ;
64
+ const char *versionnumber = " 0.9.18a " ;
65
65
66
- /* Version 0.9.16 .
66
+ /* Version 0.9.18a .
67
67
*
68
- * Added UserActions. In the UserAction.h file there are a few functions you can define and
69
- * select through the configurator. The functions have to written before compiling. These functions
70
- * are then hardcoded. Look at UserActions.h for some examples.
71
- *
72
- * Added some missing characters.
68
+ * Adding ESP32-S3 support
73
69
*/
74
70
75
- /* TODO NEXT VERSION
76
- *
77
- * - get image height/width and use it in bmp drawing.
78
- */
79
-
80
71
#include < pgmspace.h> // PROGMEM support header
81
72
#include < FS.h> // Filesystem support header
82
73
#include < SPIFFS.h> // Filesystem support header
83
74
#include < Preferences.h> // Used to store states before sleep/reboot
84
75
85
76
#include < TFT_eSPI.h> // The TFT_eSPI library
86
77
87
- #include < BleKeyboard.h> // BleKeyboard is used to communicate over BLE
78
+ #if defined(USEUSBHID)
79
+
80
+ #include " USB.h"
81
+ #include " USBHIDKeyboard.h"
82
+ #include " Keydefines.h"
83
+ USBHIDKeyboard bleKeyboard;
84
+
85
+ #else
86
+
87
+ #include < BleKeyboard.h> // BleKeyboard is used to communicate over BLE
88
+ BleKeyboard bleKeyboard (" FreeTouchDeck" , " Made by me" );
89
+
90
+ // Checking for BLE Keyboard version
91
+ #ifndef BLE_KEYBOARD_VERSION
92
+ #warning Old BLE Keyboard version detected. Please update.
93
+ #define BLE_KEYBOARD_VERSION " Outdated"
94
+ #endif // !defined(BLE_KEYBOARD_VERSION)
95
+
96
+ #endif // if
88
97
89
98
#if defined(USE_NIMBLE)
90
99
91
- #include " NimBLEDevice.h" // Additional BLE functionaity using NimBLE
92
- #include " NimBLEUtils.h" // Additional BLE functionaity using NimBLE
93
- #include " NimBLEBeacon.h" // Additional BLE functionaity using NimBLE
100
+ #include " NimBLEDevice.h" // Additional BLE functionaity using NimBLE
101
+ #include " NimBLEUtils.h" // Additional BLE functionaity using NimBLE
102
+ #include " NimBLEBeacon.h" // Additional BLE functionaity using NimBLE
94
103
95
104
#else
96
105
97
- #include " BLEDevice.h" // Additional BLE functionaity
98
- #include " BLEUtils.h" // Additional BLE functionaity
99
- #include " BLEBeacon.h" // Additional BLE functionaity
106
+ #include " BLEDevice.h" // Additional BLE functionaity
107
+ #include " BLEUtils.h" // Additional BLE functionaity
108
+ #include " BLEBeacon.h" // Additional BLE functionaity
100
109
101
- #endif // USE_NIMBLE
110
+ #endif // defined( USE_NIMBLE)
102
111
103
112
#include " esp_sleep.h" // Additional BLE functionaity
104
113
#include " esp_bt_main.h" // Additional BLE functionaity
@@ -114,12 +123,10 @@ const char *versionnumber = "0.9.17";
114
123
#include < ESPmDNS.h> // DNS functionality
115
124
116
125
#ifdef USECAPTOUCH
117
- #include < Wire.h>
118
- #include < FT6236.h>
119
- FT6236 ts = FT6236();
120
- #endif
121
-
122
- BleKeyboard bleKeyboard (" FreeTouchDeck" , " Made by me" );
126
+ #include < Wire.h>
127
+ #include < FT6236.h>
128
+ FT6236 ts = FT6236();
129
+ #endif // defined(USECAPTOUCH)
123
130
124
131
AsyncWebServer webserver (80 );
125
132
@@ -289,12 +296,6 @@ char* jsonfilefail = "";
289
296
// Invoke the TFT_eSPI button class and create all the button objects
290
297
TFT_eSPI_Button key[6 ];
291
298
292
- // Checking for BLE Keyboard version
293
- #ifndef BLE_KEYBOARD_VERSION
294
- #warning Old BLE Keyboard version detected. Please update.
295
- #define BLE_KEYBOARD_VERSION " Outdated"
296
- #endif
297
-
298
299
// --------- Internal references ------------
299
300
// (this needs to be below all structs etc..)
300
301
#include " ScreenHelper.h"
@@ -332,27 +333,27 @@ void setup()
332
333
Serial.println (" " );
333
334
334
335
#ifdef USECAPTOUCH
335
- #ifdef CUSTOM_TOUCH_SDA
336
- if (!ts.begin (40 , CUSTOM_TOUCH_SDA, CUSTOM_TOUCH_SCL))
337
- #else
338
- if (!ts.begin (40 ))
339
- #endif
336
+ #ifdef CUSTOM_TOUCH_SDA
337
+ if (!ts.begin (40 , CUSTOM_TOUCH_SDA, CUSTOM_TOUCH_SCL))
338
+ #else
339
+ if (!ts.begin (40 ))
340
+ #endif // defined(CUSTOM_TOUCH_SDA)
340
341
{
341
342
Serial.println (" [WARNING]: Unable to start the capacitive touchscreen." );
342
343
}
343
344
else
344
345
{
345
346
Serial.println (" [INFO]: Capacitive touch started!" );
346
347
}
347
- #endif
348
+ #endif // defined(USECAPTOUCH)
348
349
349
- // Setup PWM channel and attach pin 32
350
+ // Setup PWM channel and attach pin bl_pin
350
351
ledcSetup (0 , 5000 , 8 );
351
352
#ifdef TFT_BL
352
353
ledcAttachPin (TFT_BL, 0 );
353
354
#else
354
- ledcAttachPin (32 , 0 );
355
- #endif
355
+ ledcAttachPin (backlightPin , 0 );
356
+ #endif // defined(TFT_BL)
356
357
ledcWrite (0 , ledBrightness); // Start @ initial Brightness
357
358
358
359
// --------------- Init Display -------------------------
@@ -429,7 +430,7 @@ void setup()
429
430
Serial.println (" [INFO]: Waiting for touch calibration..." );
430
431
touch_calibrate ();
431
432
Serial.println (" [INFO]: Touch calibration completed!" );
432
- #endif
433
+ #endif // !defined(USECAPTOUCH)
433
434
434
435
// Let's first check if all the files we need exist
435
436
if (!checkfile (" /config/general.json" ))
@@ -514,7 +515,7 @@ if(generalconfig.beep){
514
515
ledcWrite (2 , 0 );
515
516
}
516
517
517
- #endif
518
+ #endif // defined(speakerPin)
518
519
519
520
if (!loadConfig (" homescreen" )){
520
521
Serial.println (" [WARNING]: homescreen.json seems to be corrupted!" );
@@ -565,12 +566,28 @@ if(generalconfig.beep){
565
566
566
567
// ------------------BLE Initialization ------------------------------------------------------------------------
567
568
569
+ #if defined(USEUSBHID)
570
+
571
+ // initialize control over the keyboard:
572
+ bleKeyboard.begin ();
573
+ USB.begin ();
574
+
575
+ #else
576
+
568
577
Serial.println (" [INFO]: Starting BLE" );
569
578
bleKeyboard.begin ();
570
579
580
+ #endif // if defined(USEUSBHID)
581
+
571
582
// ---------------- Printing version numbers -----------------------------------------------
583
+
584
+ #if defined(USEUSBHID)
585
+ Serial.println (" [INFO]: Using USB Keyboard" );
586
+ #else
572
587
Serial.print (" [INFO]: BLE Keyboard version: " );
573
588
Serial.println (BLE_KEYBOARD_VERSION);
589
+ #endif // if defined(USEUSBHID)
590
+
574
591
Serial.print (" [INFO]: ArduinoJson version: " );
575
592
Serial.println (ARDUINOJSON_VERSION);
576
593
Serial.print (" [INFO]: TFT_eSPI version: " );
@@ -596,7 +613,7 @@ if(generalconfig.beep){
596
613
Serial.println (" minutes" );
597
614
islatched[28 ] = 1 ;
598
615
}
599
- #endif
616
+ #endif // defined(touchInterruptPin)
600
617
601
618
Serial.println (" [INFO]: Boot completed and successful!" );
602
619
@@ -741,7 +758,7 @@ void loop(void)
741
758
742
759
pressed = tft.getTouch (&t_x, &t_y);
743
760
744
- #endif
761
+ #endif // defined(USECAPTOUCH)
745
762
746
763
if (pressed)
747
764
{
@@ -779,7 +796,7 @@ void loop(void)
779
796
780
797
pressed = tft.getTouch (&t_x, &t_y);
781
798
782
- #endif
799
+ #endif // defined(USECAPTOUCH)
783
800
784
801
if (pressed)
785
802
{
@@ -818,7 +835,7 @@ void loop(void)
818
835
819
836
pressed = tft.getTouch (&t_x, &t_y);
820
837
821
- #endif
838
+ #endif // defined(USECAPTOUCH)
822
839
823
840
if (pressed)
824
841
{
@@ -863,7 +880,7 @@ void loop(void)
863
880
ledcDetachPin (speakerPin);
864
881
ledcWrite (2 , 0 );
865
882
}
866
- #endif
883
+ #endif // defined(speakerPin)
867
884
Serial.println (" [INFO]: Saving latched states" );
868
885
869
886
// You could uncomment this to see the latch stated before going to sleep
@@ -879,7 +896,7 @@ void loop(void)
879
896
esp_deep_sleep_start ();
880
897
}
881
898
}
882
- #endif
899
+ #endif // defined(touchInterruptPin)
883
900
884
901
// Touch coordinates are stored here
885
902
uint16_t t_x = 0 , t_y = 0 ;
@@ -906,7 +923,7 @@ void loop(void)
906
923
907
924
pressed = tft.getTouch (&t_x, &t_y);
908
925
909
- #endif
926
+ #endif // defined(USECAPTOUCH)
910
927
911
928
// Check if the X and Y coordinates of the touch are within one of our buttons
912
929
for (uint8_t b = 0 ; b < 6 ; b++)
0 commit comments