Skip to content

Commit a4639e1

Browse files
committed
Fixing cppcheck comments
1 parent 8ca3ce4 commit a4639e1

35 files changed

+747
-948
lines changed

src/canvas/canvas.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ void NanoCanvasOps<4>::drawBitmap1(lcdint_t xpos, lcdint_t ypos, lcduint_t w, lc
666666
}
667667
else if ( !(m_textMode & CANVAS_MODE_TRANSPARENT) )
668668
{
669-
data = 0x00;
670669
m_buf[addr] &= ~(0x0F << BITS_SHIFT4(x));
671670
}
672671
}

src/canvas/internal/canvas_types_int.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#ifndef DOXYGEN_SHOULD_SKIP_THIS
3636
static inline uint8_t pgm_read_byte(const void *ptr)
3737
{
38-
return *((const uint8_t *)ptr);
38+
return *reinterpret_cast<const uint8_t*>(ptr);
3939
}
4040
#endif
4141
#endif

src/lcd_hal/arduino/arduino_spi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ArduinoSpi2
113113
* @param mosiPin MOSI pin to use, -1 by default
114114
* @param freq frequency in HZ to run spi bus at
115115
*/
116-
ArduinoSpi2(int8_t csPin = -1, int8_t dcPin = -1, int8_t clkPin = -1, int8_t mosiPin = -1, uint32_t freq = 8000000);
116+
explicit ArduinoSpi2(int8_t csPin = -1, int8_t dcPin = -1, int8_t clkPin = -1, int8_t mosiPin = -1, uint32_t freq = 8000000);
117117
~ArduinoSpi2();
118118

119119
/**

src/lcd_hal/avr/i2c_embedded.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void SoftwareI2c::start()
159159
ssd1306_delay(I2C_START_STOP_DELAY);
160160
DIGITAL_WRITE_LOW(DDR_REG, PORT_REG, m_scl); // Set to LOW
161161
ssd1306_delay(I2C_HALF_CLOCK);
162-
send((m_sa << 1) | 0x00);
162+
send(m_sa << 1);
163163
}
164164

165165
void SoftwareI2c::start(uint8_t sa, bool read_op)

src/lcd_hal/esp/platform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void lcd_attachInterrupt(int pin, void (*interrupt)(), int level)
111111

112112
uint8_t lcd_pgmReadByte(const void *ptr)
113113
{
114-
return *((const uint8_t *)ptr);
114+
return *reinterpret_cast<const uint8_t *>(ptr);
115115
}
116116

117117
uint16_t lcd_eepromReadWord(const void *ptr)

src/lcd_hal/linux/linux_i2c.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LinuxI2c
4343
* @param busId i2c bus number, if -1 defaults to 1
4444
* @param sa i2c address of the display (7 bits)
4545
*/
46-
LinuxI2c(int8_t busId = -1, uint8_t sa = 0x00);
46+
explicit LinuxI2c(int8_t busId = -1, uint8_t sa = 0x00);
4747
~LinuxI2c();
4848

4949
/**

src/lcd_hal/linux/platform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void lcd_attachInterrupt(int pin, void (*interrupt)(void), int level)
426426

427427
uint8_t lcd_pgmReadByte(const void *ptr)
428428
{
429-
return *((const uint8_t *)ptr);
429+
return *reinterpret_cast<const uint8_t *>(ptr);
430430
}
431431

432432
uint16_t lcd_eepromReadWord(const void *ptr)

src/lcd_hal/linux/sdl_i2c.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SdlI2c
4141
* @param sda pin number to use as data line
4242
* @param sa i2c address of the display (7 bits)
4343
*/
44-
SdlI2c(int8_t scl = -1, int8_t sda = -1, uint8_t sa = 0x00);
44+
explicit SdlI2c(int8_t scl = -1, int8_t sda = -1, uint8_t sa = 0x00);
4545
~SdlI2c();
4646

4747
/**

src/lcd_hal/mingw/platform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void lcd_randomSeed(int seed){};
6666
void lcd_attachInterrupt(int pin, void (*interrupt)(void), int level){};
6767
uint8_t lcd_pgmReadByte(const void *ptr)
6868
{
69-
return *((const uint8_t *)ptr);
69+
return *reinterpret_cast<const uint8_t *>(ptr);
7070
};
7171
uint16_t lcd_eepromReadWord(const void *ptr)
7272
{

src/lcd_hal/pico/pico_i2c.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PicoI2c
4545
* @param sda data pin to use for i2c
4646
* @param sa i2c address of the device to control over i2c
4747
*/
48-
PicoI2c(int8_t scl = -1, int8_t sda = -1, uint8_t sa = 0x00);
48+
explicit PicoI2c(int8_t scl = -1, int8_t sda = -1, uint8_t sa = 0x00);
4949
~PicoI2c();
5050

5151
/**

src/lcd_hal/pico/pico_spi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PicoSpi
5454
* @param mosiPin mosi pin to use, -1 to use default. Doesn't work on all controllers
5555
* @param freq frequency in HZ to run spi bus at
5656
*/
57-
PicoSpi(int8_t csPin = -1, int8_t dcPin = -1, int8_t clkPin = -1, int8_t mosiPin = -1, uint32_t freq = 0);
57+
explicit PicoSpi(int8_t csPin = -1, int8_t dcPin = -1, int8_t clkPin = -1, int8_t mosiPin = -1, uint32_t freq = 0);
5858
~PicoSpi();
5959

6060
/**

src/lcd_hal/stm32/platform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void lcd_attachInterrupt(int pin, void (*interrupt)(), int level)
173173

174174
uint8_t lcd_pgmReadByte(const void *ptr)
175175
{
176-
return *((const uint8_t *)ptr);
176+
return *reinterpret_cast<const uint8_t *>(ptr);
177177
}
178178

179179
uint16_t lcd_eepromReadWord(const void *ptr)

src/v2/lcd/base/ssd1306_common.inl

+2-2
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ template <class O, class I> void NanoDisplayOps<O, I>::print(char c)
673673
#define lcd_gfx_max(x, y) ((x) > (y) ? (x) : (y))
674674
#endif
675675

676-
template <class O, class I> static uint8_t getMaxScreenItems(NanoDisplayOps<O, I> &display, SAppMenu *menu)
676+
template <class O, class I> static uint8_t getMaxScreenItems(NanoDisplayOps<O, I> &display, const SAppMenu *menu)
677677
{
678678
return (menu->height - 16) / display.getFont().getHeader().height;
679679
}
@@ -799,7 +799,7 @@ template <class O, class I> void NanoDisplayOps<O, I>::updateMenuSmooth(SAppMenu
799799
}
800800
}
801801

802-
template <class O, class I> uint8_t NanoDisplayOps<O, I>::menuSelection(SAppMenu *menu)
802+
template <class O, class I> uint8_t NanoDisplayOps<O, I>::menuSelection(const SAppMenu *menu)
803803
{
804804
return menu->selection;
805805
}

src/v2/lcd/il9163/lcd_il9163.inl

+48-58
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ template <class I> void InterfaceIL9163<I>::startBlock(lcduint_t x, lcduint_t y,
5959

6060
template <class I> void InterfaceIL9163<I>::nextBlock()
6161
{
62+
6263
}
6364

6465
template <class I> void InterfaceIL9163<I>::endBlock()
@@ -117,6 +118,7 @@ template <class I> void InterfaceIL9163<I>::setRotation(uint8_t rotation)
117118
this->stop();
118119
}
119120

121+
120122
////////////////////////////////////////////////////////////////////////////////
121123
// IL9163 basic 16-bit implementation
122124
////////////////////////////////////////////////////////////////////////////////
@@ -131,54 +133,34 @@ template <class I> void DisplayIL9163x16<I>::end()
131133

132134
static const PROGMEM uint8_t s_IL9163_lcd128x128x16_initData[] = {
133135
#ifdef SDL_EMULATION
134-
SDL_LCD_IL9163,
135-
0x00,
136-
0x00,
137-
0x00,
136+
SDL_LCD_IL9163, 0x00,
137+
0x00, 0x00,
138138
#endif
139-
// 0x01, 0x00, // sw reset. not needed, we do hardware reset
140-
0x11,
141-
0x00, // exit sleep mode
142-
0x3A,
143-
0x01,
144-
0x05, // set 16-bit pixel format
145-
0x26,
146-
0x01,
147-
0x04, // set gamma curve: valid values 1, 2, 4, 8
148-
// 0xF2, 0x01, 0x01, // enable gamma adjustment, 0 - to disable
149-
// 0xE0, 15, 0x3F, 0x25, 0x1C,
150-
// 0x1E, 0x20, 0x12,
151-
// 0x2A, 0x90, 0x24,
152-
// 0x11, 0x00, 0x00,
153-
// 0x00, 0x00, 0x00, // positive gamma correction
154-
// 0xE1, 15, 0x20, 0x20, 0x20,
155-
// 0x20, 0x05, 0x00,
156-
// 0x15, 0xA7, 0x3D,
157-
// 0x18, 0x25, 0x2A,
158-
// 0x2B, 0x2B, 0x3A, // negative gamma correction
159-
// 0xB1, 0x02, 0x08, 0x08, // frame rate control 1, use by default
160-
// 0xB4, 0x01, 0x07, // display inversion, use by default
161-
0xC0,
162-
0x02,
163-
0x0A,
164-
0x02, // power control 1
165-
0xC1,
166-
0x01,
167-
0x02, // power control 2
168-
0xC5,
169-
0x02,
170-
0x50,
171-
0x5B, // vcom control 1
172-
0xC7,
173-
0x01,
174-
0x40, // vcom offset
175-
// 0x2A, 0x04, 0x00, 0x00, 0x00, 0x7F, // set column address, not needed.
176-
// 0x2B, 0x04, 0x00, 0x00, 0x00, 0x9F, // set page address, not needed.
177-
0x36,
178-
0x01,
179-
0b00000000, // Horizontal addressing mode
180-
0x29,
181-
0x00,
139+
// 0x01, 0x00, // sw reset. not needed, we do hardware reset
140+
0x11, 0x00, // exit sleep mode
141+
0x3A, 0x01, 0x05, // set 16-bit pixel format
142+
0x26, 0x01, 0x04, // set gamma curve: valid values 1, 2, 4, 8
143+
// 0xF2, 0x01, 0x01, // enable gamma adjustment, 0 - to disable
144+
// 0xE0, 15, 0x3F, 0x25, 0x1C,
145+
// 0x1E, 0x20, 0x12,
146+
// 0x2A, 0x90, 0x24,
147+
// 0x11, 0x00, 0x00,
148+
// 0x00, 0x00, 0x00, // positive gamma correction
149+
// 0xE1, 15, 0x20, 0x20, 0x20,
150+
// 0x20, 0x05, 0x00,
151+
// 0x15, 0xA7, 0x3D,
152+
// 0x18, 0x25, 0x2A,
153+
// 0x2B, 0x2B, 0x3A, // negative gamma correction
154+
// 0xB1, 0x02, 0x08, 0x08, // frame rate control 1, use by default
155+
// 0xB4, 0x01, 0x07, // display inversion, use by default
156+
0xC0, 0x02, 0x0A, 0x02, // power control 1
157+
0xC1, 0x01, 0x02, // power control 2
158+
0xC5, 0x02, 0x50, 0x5B, // vcom control 1
159+
0xC7, 0x01, 0x40, // vcom offset
160+
// 0x2A, 0x04, 0x00, 0x00, 0x00, 0x7F, // set column address, not needed.
161+
// 0x2B, 0x04, 0x00, 0x00, 0x00, 0x9F, // set page address, not needed.
162+
0x36, 0x01, 0b00000000, // Horizontal addressing mode
163+
0x29, 0x00,
182164
};
183165

184166
////////////////////////////////////////////////////////////////////////////////
@@ -192,7 +174,10 @@ template <class I> void DisplayIL9163_128x128x16<I>::begin()
192174
this->m_h = 128;
193175
// Give LCD some time to initialize. Refer to IL9163 datasheet
194176
lcd_delay(120);
195-
_configureSpiDisplay<I>(this->m_intf, s_IL9163_lcd128x128x16_initData, sizeof(s_IL9163_lcd128x128x16_initData));
177+
_configureSpiDisplay<I>(this->m_intf,
178+
s_IL9163_lcd128x128x16_initData,
179+
sizeof(s_IL9163_lcd128x128x16_initData));
180+
196181
}
197182

198183
template <class I> void DisplayIL9163_128x128x16<I>::end()
@@ -201,18 +186,20 @@ template <class I> void DisplayIL9163_128x128x16<I>::end()
201186

202187
static const PROGMEM uint8_t s_IL9163_lcd128x160x16_initData[] = {
203188
#ifdef SDL_EMULATION
204-
SDL_LCD_IL9163, 0x00, 0b00000011, 0x00,
189+
SDL_LCD_IL9163, 0x00,
190+
0b00000011, 0x00,
205191
#endif
206-
// 0x01, 0x00, // sw reset. not needed, we do hardware reset
207-
0x11, 0x00, // exit sleep mode
208-
0x3A, 0x01, 0x05, // set 16-bit pixel format
209-
0x26, 0x01, 0x04, // set gamma curve: valid values 1, 2, 4, 8
192+
// 0x01, 0x00, // sw reset. not needed, we do hardware reset
193+
0x11, 0x00, // exit sleep mode
194+
0x3A, 0x01, 0x05, // set 16-bit pixel format
195+
0x26, 0x01, 0x04, // set gamma curve: valid values 1, 2, 4, 8
210196
0xC0, 0x02, 0x0A, 0x02, // power control 1
211-
0xC1, 0x01, 0x02, // power control 2
197+
0xC1, 0x01, 0x02, // power control 2
212198
0xC5, 0x02, 0x50, 0x5B, // vcom control 1
213-
0xC7, 0x01, 0x40, // vcom offset
214-
0x36, 0x01, 0b00000000, // Horizontal addressing mode
215-
0x29, 0x00};
199+
0xC7, 0x01, 0x40, // vcom offset
200+
0x36, 0x01, 0b00000000, // Horizontal addressing mode
201+
0x29, 0x00
202+
};
216203

217204
////////////////////////////////////////////////////////////////////////////////
218205
// IL9163 basic 16-bit implementation
@@ -225,7 +212,10 @@ template <class I> void DisplayIL9163_128x160x16<I>::begin()
225212
this->m_h = 160;
226213
// Give LCD some time to initialize. Refer to IL9163 datasheet
227214
lcd_delay(120);
228-
_configureSpiDisplay<I>(this->m_intf, s_IL9163_lcd128x160x16_initData, sizeof(s_IL9163_lcd128x160x16_initData));
215+
_configureSpiDisplay<I>(this->m_intf,
216+
s_IL9163_lcd128x160x16_initData,
217+
sizeof(s_IL9163_lcd128x160x16_initData));
218+
229219
}
230220

231221
template <class I> void DisplayIL9163_128x160x16<I>::end()

src/v2/lcd/ili9341/lcd_ili9341.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ template <class I> class InterfaceILI9341: public I
120120
void rotateOutput(uint8_t rotate);
121121

122122
private:
123-
const int8_t m_dc = -1; ///< data/command pin for SPI, -1 for i2c
123+
const int8_t m_dc = -1; ///< data/command pin for SPI, -1 for i2c
124124
NanoDisplayBase<InterfaceILI9341<I>> &m_base; ///< basic lcd display support interface
125125
uint8_t m_rotation = 0x00;
126126
uint8_t m_rotate_output = 0x00;

0 commit comments

Comments
 (0)