ArduinoDumbDisplay v0.9.9-r34
DumbDisplay Arduino Library -- https://github.com/trevorwslee/Arduino-DumbDisplay
 
Loading...
Searching...
No Matches
esp32dumbdisplay.h
1//************************************************//
2//*** must define DD_4_ESP32 before including ***/
3//************************************************//
4
5#ifndef esp32dumbdisplay_h
6#define esp32dumbdisplay_h
7
8// after inclusion, can check DD_USING_WIFI to be sure WIFI is used
9#define DD_USING_BT
10
11// #ifndef DD_4_ESP32
12// #error DD_4_ESP32 need be defined in order to use DumbDisplay for ESP32
13// #else
14
15#ifndef ESP32
16 #error DDBluetoothSerialIO is for ESP32
17#endif
18
19//#else
20
21
22#include "BluetoothSerial.h"
23#include "dumbdisplay.h"
24
25
28 public:
29 /* ESP32 BluetoothSerial IO mechanism */
30 /* - btLocalName -- BT name */
31 /* - enableSerial: enable Serial as well or not (if enabled, connecting via USB will also work) */
32 /* - serialBaud: Serial baud rate (if enableSerial) */
33 DDBluetoothSerialIO(const String& btLocalName, bool enableSerial = false,
34 unsigned long serialBaud = DD_SERIAL_BAUD):
35 DDInputOutput(serialBaud, enableSerial, enableSerial) {
36 this->btLocalName = btLocalName;
37 // if (!enableSerial) { // disabled since 2023-08-13
38 // Serial.begin(serialBaud);
39 // }
40 }
41 const char* getWhat() {
42 return "ESP32BT";
43 }
44 bool available() {
45 return serialBT.available();
46 }
47 char read() {
48 return serialBT.read();
49 }
50 void print(const String &s) {
51 serialBT.print(s);
52 }
53 void print(const char *p) {
54 serialBT.print(p);
55 }
56 void write(uint8_t b) {
57 serialBT.write(b);
58 }
59 void write(const uint8_t *buf, size_t size) {
60 serialBT.write(buf, size);
61 }
62 bool preConnect(bool firstCall) {
63 DDInputOutput::preConnect(firstCall);
64 serialBT.begin(btLocalName);
65 if (!willUseSerial()) { // since 2024-08-13
66 if (firstCall) {
67 if (!Serial) Serial.begin(DD_SERIAL_BAUD);
68 }
69 String address = serialBT.getBtAddressString();
70 address.toUpperCase();
71 Serial.println("bluetooth address: " + address);
72 }
73 return true;
74 }
75 void flush() {
76 if (false) {
77 serialBT.flush(); // not the expected "flush"
78 }
79 }
80 bool canConnectPassive() {
81 return true;
82 }
83 bool canUseBuffer() {
84 return true;
85 }
86 private:
87 String btLocalName;
88 BluetoothSerial serialBT;
89};
90
91
92//#endif
93#endif
Subclass of DDInputOutput.
Definition: esp32dumbdisplay.h:27
Class for DD input/output; you explicitly constructed it, pass in when instantiate DumbDisplay,...
Definition: _dd_io.h:9