Skip to content

Commit 8529924

Browse files
committed
Looking into SSD1306 not writing properly
1 parent ff4a416 commit 8529924

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/Wippersnapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,7 +2834,7 @@ void Wippersnapper::connect() {
28342834
#endif
28352835

28362836
// Configure hardware
2837-
WS.pinCfgCompleted = false;
2837+
WS.pinCfgCompleted = true;
28382838
while (!WS.pinCfgCompleted) {
28392839
WS_DEBUG_PRINTLN(
28402840
"Polling for message containing hardware configuration...");
@@ -2901,26 +2901,26 @@ ws_status_t Wippersnapper::run() {
29012901
WS._mqtt->processPackets(10);
29022902
WS.feedWDT();
29032903

2904-
// Process digital inputs, digitalGPIO module
2904+
/* // Process digital inputs, digitalGPIO module
29052905
WS._digitalGPIO->processDigitalInputs();
29062906
WS.feedWDT();
29072907
29082908
// Process analog inputs
29092909
WS._analogIO->update();
2910-
WS.feedWDT();
2910+
WS.feedWDT(); */
29112911

29122912
// Process I2C sensor events
29132913
if (WS._isI2CPort0Init)
29142914
WS._i2cPort0->update();
29152915
WS.feedWDT();
29162916

2917-
// Process DS18x20 sensor events
2917+
/* // Process DS18x20 sensor events
29182918
WS._ds18x20Component->update();
29192919
WS.feedWDT();
29202920
29212921
// Process UART sensor events
29222922
WS._uartComponent->update();
2923-
WS.feedWDT();
2923+
WS.feedWDT(); */
29242924

29252925
return WS_NET_CONNECTED; // TODO: Make this funcn void!
29262926
}

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,9 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
879879
_drivers_out.push_back(_sevenSeg);
880880
WS_DEBUG_PRINTLN("7-Segement LED Matrix Initialized Successfully!");
881881
} else if (strcmp("ssd1306", msgDeviceInitReq->i2c_device_name) == 0) {
882+
WS_DEBUG_PRINTLN("SSD1306 display detected!");
882883
_ssd1306 = new WipperSnapper_I2C_Driver_Out_Ssd1306(this->_i2c, i2cAddress);
884+
WS_DEBUG_PRINTLN("Configuring SSD1306 display...");
883885
_ssd1306->ConfigureSSD1306(
884886
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.width,
885887
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.height,
@@ -891,6 +893,7 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
891893
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
892894
return false;
893895
}
896+
WS_DEBUG_PRINTLN("SSD1306 display configured successfully!");
894897
_drivers_out.push_back(_ssd1306);
895898
WS_DEBUG_PRINTLN("SSD1306 display initialized Successfully!");
896899
} else {
@@ -1190,6 +1193,7 @@ bool WipperSnapper_Component_I2C::Handle_I2cDeviceOutputWrite(
11901193
driver_out->WriteMessageCharLCD(&msgDeviceWrite->output_msg.write_char_lcd);
11911194
} else if (msgDeviceWrite->which_output_msg ==
11921195
wippersnapper_i2c_v1_I2CDeviceOutputWrite_write_ssd1306_tag) {
1196+
WS_DEBUG_PRINTLN("Calling WriteMessageSSD1306..");
11931197
driver_out->WriteMessageSSD1306(
11941198
msgDeviceWrite->output_msg.write_ssd1306.message);
11951199
} else {

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,24 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
6464
*/
6565
bool begin() {
6666
_display = new Adafruit_SSD1306(_width, _height, _i2c);
67-
bool did_begin = _display->begin(SSD1306_SWITCHCAPVCC, _sensorAddress);
67+
bool did_begin = _display->begin(
68+
SSD1306_SWITCHCAPVCC,
69+
0x3C); // TODO: Note that this is hardcoded, not sure why not init'd yet
6870
if (!did_begin)
6971
return false;
7072

7173
// Show initial display buffer contents on the screen --
7274
// the library initializes this with an Adafruit splash screen.
7375
_display->display();
74-
delay(2000);
76+
delay(1000);
7577
// Clear the buffer
7678
_display->clearDisplay();
7779
// Configure the text size and color
7880
_display->setTextSize(_text_sz);
7981
_display->setTextColor(SSD1306_WHITE);
8082
// Reset the cursor position
8183
_display->setCursor(0, 0);
84+
_display->display();
8285
return true;
8386
}
8487

@@ -107,18 +110,25 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
107110
if (_display == nullptr)
108111
return;
109112
_display->clearDisplay();
110-
_display->setCursor(0, 0);
111113

112114
// Calculate the line height based on the text size (NOTE: base height is
113115
// 8px)
114116
int16_t line_height = 8 * _text_sz;
117+
WS_DEBUG_PRINT("Line height: ");
118+
WS_DEBUG_PRINTLN(line_height);
115119

116120
int16_t y_idx = 0;
121+
_display->setCursor(0, y_idx);
117122
for (int i = 0; message[i] != '\0'; i++) {
118123
if (message[i] == '\n') {
124+
WS_DEBUG_PRINTLN("New line detected!");
119125
y_idx += line_height;
120126
_display->setCursor(0, y_idx);
121127
} else {
128+
WS_DEBUG_PRINT("Printing char: ");
129+
WS_DEBUG_PRINT(message[i]);
130+
WS_DEBUG_PRINT(" at y: ");
131+
WS_DEBUG_PRINTLN(y_idx);
122132
_display->print(message[i]);
123133
}
124134
}

src/components/register/Wippersnapper_Register.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ bool Wippersnapper::encodePubRegistrationReq() {
7777
/****************************************************************************/
7878
void Wippersnapper::pollRegistrationResp() {
7979
// Blocking loop, WDT reset upon failure.
80+
WS._boardStatus = WS_BOARD_DEF_OK;
8081
while (WS._boardStatus != WS_BOARD_DEF_OK) {
8182
WS_DEBUG_PRINT("Polling for registration message response...");
8283
WS_DEBUG_PRINTLN(WS._boardStatus);

0 commit comments

Comments
 (0)