Skip to content

Commit

Permalink
fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Aug 16, 2023
1 parent a496877 commit 7beba02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ bool Wippersnapper::configureDigitalPinReq(
/*****************************************************************************/
bool cbDecodePinConfigMsg(pb_istream_t *stream, const pb_field_t *field,
void **arg) {
(void) field, arg; // marking unused parameters to avoid compiler warning
bool is_success = true;
WS_DEBUG_PRINTLN("cbDecodePinConfigMsg");

Expand Down Expand Up @@ -386,6 +387,7 @@ bool cbDecodePinConfigMsg(pb_istream_t *stream, const pb_field_t *field,
bool cbDecodeDigitalPinWriteMsg(pb_istream_t *stream, const pb_field_t *field,
void **arg) {
bool is_success = true;
(void) field, arg; // marking unused parameters to avoid compiler warning
WS_DEBUG_PRINTLN("cbDecodeDigitalPinWriteMsg");

// Decode stream into a PinEvent
Expand Down Expand Up @@ -417,6 +419,7 @@ bool cbDecodeDigitalPinWriteMsg(pb_istream_t *stream, const pb_field_t *field,
*/
/**************************************************************************/
bool cbSignalMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
(void) arg; // marking unused parameters to avoid compiler warning
bool is_success = true;
WS_DEBUG_PRINTLN("cbSignalMsg");

Expand Down Expand Up @@ -567,15 +570,11 @@ bool encodeI2CResponse(wippersnapper_signal_v1_I2CResponse *msgi2cResponse) {
@brief Initializes an I2C bus component
@param msgInitRequest
A pointer to an i2c bus initialization message.
@param i2cPort
Desired I2C port to initialize.
@return True if initialized successfully, False otherwise.
*/
/******************************************************************************************/
bool initializeI2CBus(wippersnapper_i2c_v1_I2CBusInitRequest msgInitRequest,
int i2cPort) {
// TODO: i2cPort is not handled right now, we should add support for multiple
// i2c ports!
bool initializeI2CBus(wippersnapper_i2c_v1_I2CBusInitRequest msgInitRequest) {
// FUTURE TODO:we should add support for multiple i2c ports!
if (WS._isI2CPort0Init)
return true;
// Initialize bus
Expand All @@ -599,6 +598,7 @@ bool initializeI2CBus(wippersnapper_i2c_v1_I2CBusInitRequest msgInitRequest,
/******************************************************************************************/
bool cbDecodeI2CDeviceInitRequestList(pb_istream_t *stream,
const pb_field_t *field, void **arg) {
(void) field, arg; // marking unused parameters to avoid compiler warning
WS_DEBUG_PRINTLN("EXEC: cbDecodeI2CDeviceInitRequestList");
// Decode stream into individual msgI2CDeviceInitRequest messages
wippersnapper_i2c_v1_I2CDeviceInitRequest msgI2CDeviceInitRequest =
Expand All @@ -616,7 +616,7 @@ bool cbDecodeI2CDeviceInitRequestList(pb_istream_t *stream,
wippersnapper_signal_v1_I2CResponse_resp_i2c_device_init_tag;

// Check I2C bus
if (!initializeI2CBus(msgI2CDeviceInitRequest.i2c_bus_init_req, 0)) {
if (!initializeI2CBus(msgI2CDeviceInitRequest.i2c_bus_init_req)) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize I2C Bus");
msgi2cResponse.payload.resp_i2c_device_init.bus_response =
WS._i2cPort0->getBusStatus();
Expand Down Expand Up @@ -687,7 +687,7 @@ bool cbDecodeSignalRequestI2C(pb_istream_t *stream, const pb_field_t *field,
wippersnapper_i2c_v1_I2CBusScanResponse_init_zero;

// Check I2C bus
if (!initializeI2CBus(msgScanReq.bus_init_request, 0)) {
if (!initializeI2CBus(msgScanReq.bus_init_request)) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize I2C Bus");
msgi2cResponse.payload.resp_i2c_scan.bus_response =
WS._i2cPort0->getBusStatus();
Expand Down Expand Up @@ -756,7 +756,7 @@ bool cbDecodeSignalRequestI2C(pb_istream_t *stream, const pb_field_t *field,
wippersnapper_signal_v1_I2CResponse_resp_i2c_device_init_tag;

// Check I2C bus
if (!initializeI2CBus(msgI2CDeviceInitRequest.i2c_bus_init_req, 0)) {
if (!initializeI2CBus(msgI2CDeviceInitRequest.i2c_bus_init_req)) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize I2C Bus");
msgi2cResponse.payload.resp_i2c_device_init.bus_response =
WS._i2cPort0->getBusStatus();
Expand Down
4 changes: 2 additions & 2 deletions src/components/pixels/ws_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ strand_s strands[MAX_PIXEL_STRANDS]{
/**************************************************************************/
ws_pixels::~ws_pixels() {
// de-allocate all strands
for (int i = 0; i < sizeof(strands) / sizeof(strands[0]); i++)
for (size_t i = 0; i < sizeof(strands) / sizeof(strands[0]); i++)
deallocateStrand(i);
}

Expand Down Expand Up @@ -338,7 +338,7 @@ bool ws_pixels::addStrand(
/**************************************************************************/
int ws_pixels::getStrandIdx(int16_t dataPin,
wippersnapper_pixels_v1_PixelsType type) {
for (int16_t strandIdx = 0; strandIdx < sizeof(strands) / sizeof(strands[0]);
for (size_t strandIdx = 0; strandIdx < sizeof(strands) / sizeof(strands[0]);
strandIdx++) {
if (type == wippersnapper_pixels_v1_PixelsType_PIXELS_TYPE_NEOPIXEL &&
strands[strandIdx].pinNeoPixel == dataPin)
Expand Down
2 changes: 2 additions & 0 deletions src/components/pwm/ws_pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ bool ws_pwm::attach(uint8_t pin, double freq, uint8_t resolution) {
uint8_t rc = _ledcMgr->attachPin(pin, freq, resolution);
if (rc == LEDC_CH_ERR)
is_attached = false;
#else
(void) pin; // marking as unused parameter to avoid compiler warning
#endif
return is_attached; // always true on non-esp32
}
Expand Down

0 comments on commit 7beba02

Please sign in to comment.