Skip to content

Commit 6c1666e

Browse files
committed
Expose more funcs in drvBase
1 parent 5c42673 commit 6c1666e

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/Wippersnapper_demo.ino.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmpdpm_2l97"
2+
#include <Arduino.h>
3+
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
4+
# 16 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
5+
#include "Wippersnapper_Networking.h"
6+
Wippersnapper_WiFi wipper;
7+
8+
9+
#define WS_DEBUG
10+
void setup();
11+
void loop();
12+
#line 22 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
13+
void setup() {
14+
15+
wipper.provision();
16+
17+
Serial.begin(115200);
18+
19+
20+
wipper.connect();
21+
22+
}
23+
24+
void loop() {
25+
wipper.run();
26+
}

src/components/display/drivers/dispDrvBase.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ class dispDrvBase {
8080
*/
8181
virtual bool begin(thinkinkmode_t mode, bool reset = true);
8282

83+
/*!
84+
@brief Attempts to initialize a SPI TFT driver.
85+
@return True if the display was initialized successfully, false otherwise.
86+
*/
87+
virtual bool begin();
88+
8389
/*!
8490
@brief Writes a message to the display.
8591
@param message
@@ -88,6 +94,10 @@ class dispDrvBase {
8894
*/
8995
virtual void writeMessage(const char *message) = 0;
9096

97+
void setWidth(int16_t w) { _width = w; }
98+
void setHeight(int16_t h) { _height = h; }
99+
void setRotation(uint8_t r) { _rotation = r; }
100+
91101
protected:
92102
int16_t _pin_dc; ///< Data/Command pin
93103
int16_t _pin_rst; ///< Reset pin
@@ -100,6 +110,7 @@ class dispDrvBase {
100110
uint8_t _text_sz = 1; ///< Text size for displaying a message
101111
int16_t _height; ///< Height of the display
102112
int16_t _width; ///< Width of the display
113+
uint8_t _rotation; ///< Rotation of the display
103114
};
104115

105116
#endif // WS_DISP_DRV_BASE_H

src/components/display/hardware.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,20 @@ bool DisplayHardware::beginTft(
278278
miso = parsePin(spi_config->pin_miso);
279279
}
280280

281-
return false;
281+
// Create display driver object using the factory function
282+
_drvDisp = CreateDrvDispTft(_name, cs, dc, mosi, sck, rst, miso);
283+
if (!_drvDisp) {
284+
WS_DEBUG_PRINTLN("[display] Failed to create display driver!");
285+
return false;
286+
}
287+
288+
_drvDisp->setWidth(config->width);
289+
_drvDisp->setHeight(config->height);
290+
_drvDisp->setRotation(config->rotation);
291+
_drvDisp->begin();
292+
293+
WS_DEBUG_PRINTLN("[display] TFT display initialized successfully!");
294+
return true;
282295
}
283296

284297
/*!

0 commit comments

Comments
 (0)