Skip to content

Commit 59c8a73

Browse files
committed
Update firmware to match previous PB commit's updated PBs
1 parent dd6599a commit 59c8a73

File tree

3 files changed

+28
-49
lines changed

3 files changed

+28
-49
lines changed

src/components/i2c/controller.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,8 @@ bool I2cController::Handle_I2cDeviceOutputWrite(pb_istream_t *stream) {
834834
if (_i2c_model->GetI2cDeviceOutputWriteMsg()->which_output_msg ==
835835
wippersnapper_i2c_I2cDeviceOutputWrite_write_led_backpack_tag) {
836836
WS_DEBUG_PRINTLN("[i2c] Writing to LED backpack...");
837-
if (!driver->LedBackpackWrite(&_i2c_model->GetI2cDeviceOutputWriteMsg()
838-
->output_msg.write_led_backpack)) {
839-
WS_DEBUG_PRINTLN("[i2c] ERROR: Unable to write to LED backpack!");
840-
return false;
841-
}
837+
driver->WriteMessage(_i2c_model->GetI2cDeviceOutputWriteMsg()
838+
->output_msg.write_led_backpack.message);
842839
} else if (_i2c_model->GetI2cDeviceOutputWriteMsg()->which_output_msg ==
843840
wippersnapper_i2c_I2cDeviceOutputWrite_write_char_lcd_tag) {
844841
WS_DEBUG_PRINTLN("[i2c] Writing to char LCD...");

src/components/i2c/drivers/drvOutCharLcd.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ class drvOutCharLcd : public drvOutputBase {
8282
_enable_backlight = enable_backlight;
8383
}
8484

85+
/*!
86+
@brief Enables or disables the backlight on a character LCD.
87+
@param enable_backlight
88+
True to enable the backlight, False to disable it.
89+
*/
90+
void EnableBackLightCharLCD(bool enable_backlight) {
91+
if (_lcd == nullptr)
92+
return;
93+
if (_enable_backlight) {
94+
_lcd->setBacklight(HIGH);
95+
} else {
96+
_lcd->setBacklight(LOW);
97+
}
98+
_enable_backlight = enable_backlight;
99+
}
100+
85101
/*!
86102
@brief Writes a message to the LCD.
87103
@param message
@@ -94,11 +110,6 @@ class drvOutCharLcd : public drvOutputBase {
94110
// Before writing, let's clear the display
95111
_lcd->clear();
96112

97-
// TODO: Remove all the prints!
98-
// Print the message to the serial
99-
Serial.print("Writing message to Char. LCD: ");
100-
Serial.println(message);
101-
102113
size_t message_length = strlen(message);
103114
size_t cur_idx = 0; // Current index in the message
104115

src/components/i2c/drivers/drvOutputBase.h

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ class drvOutputBase : public drvBase {
102102
// noop
103103
}
104104

105+
/*!
106+
@brief Enables or disables the backlight on a character LCD.
107+
@param enable_backlight
108+
True to enable the backlight, False to disable it.
109+
*/
110+
void EnableBackLightCharLCD(bool enable_backlight) {
111+
// noop
112+
}
113+
105114
/*!
106115
@brief Writes a message to the LCD.
107116
@param write_char_lcd
@@ -110,10 +119,8 @@ class drvOutputBase : public drvBase {
110119
*/
111120
bool
112121
WriteMessageCharLCD(wippersnapper_i2c_output_CharLCDWrite *write_char_lcd) {
122+
EnableBackLightCharLCD(write_char_lcd->enable_backlight);
113123
WriteMessage(write_char_lcd->message);
114-
// NOTE: While this isn't calling any other funcs in here and ret'ing true,
115-
// I want to keep this function high-level for when we implement backlight
116-
// color and scrolling.
117124
return true;
118125
}
119126

@@ -126,42 +133,6 @@ class drvOutputBase : public drvBase {
126133
// noop
127134
}
128135

129-
/*!
130-
@brief High-level fn, executes a call to the appropriate driver
131-
function(s) based on the message data type to write.
132-
@param msg_backpack_write
133-
Pointer to a wippersnapper_i2c_output_LedBackpackWrite message.
134-
@returns True if the message was written successfully, False otherwise.
135-
*/
136-
bool LedBackpackWrite(
137-
wippersnapper_i2c_output_LedBackpackWrite *msg_backpack_write) {
138-
// Check if we should adjust brightness
139-
if (msg_backpack_write->adjust_brightness)
140-
SetLedBackpackBrightness((uint8_t)msg_backpack_write->brightness);
141-
142-
// Write the message to a LED backpack
143-
switch (msg_backpack_write->which_message) {
144-
case wippersnapper_i2c_output_LedBackpackWrite_text_tag:
145-
WS_DEBUG_PRINTLN("[i2c] Writing text to LED backpack...");
146-
WriteMessage(msg_backpack_write->message.text);
147-
break;
148-
case wippersnapper_i2c_output_LedBackpackWrite_number_int_tag:
149-
WS_DEBUG_PRINTLN("[i2c] Writing int to LED backpack...");
150-
WriteValue(msg_backpack_write->message.number_int);
151-
break;
152-
case wippersnapper_i2c_output_LedBackpackWrite_number_float_tag:
153-
WS_DEBUG_PRINTLN("[i2c] Writing float to LED backpack...");
154-
WriteValue(msg_backpack_write->message.number_float);
155-
break;
156-
default:
157-
WS_DEBUG_PRINTLN("[i2c] ERROR: Unable to determine LED backpack "
158-
"message type!");
159-
return false;
160-
break;
161-
}
162-
return true;
163-
}
164-
165136
protected:
166137
};
167138
#endif // DRV_OUTPUT_BASE_H

0 commit comments

Comments
 (0)