mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
more cppcheck fixes
This commit is contained in:
parent
b5acc47728
commit
2cea42bad1
|
|
@ -3,18 +3,21 @@
|
||||||
#include "FontConfig.h"
|
#include "FontConfig.h"
|
||||||
//#include "OLEDDisplayFonts.h"
|
//#include "OLEDDisplayFonts.h"
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
Bitmap::Bitmap(uint width, uint height)
|
Bitmap::Bitmap(uint width, uint height)
|
||||||
: _width(width), _height(height), _buffer(0)
|
: _width(width), _height(height), _buffer(0)
|
||||||
{
|
{
|
||||||
allocateBuffer();
|
allocateBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
Bitmap::Bitmap(OLEDDisplay * display)
|
Bitmap::Bitmap(OLEDDisplay * display)
|
||||||
: _width(display->getWidth()), _height(display->getHeight()), _buffer(0)
|
: _width(display->getWidth()), _height(display->getHeight()), _buffer(0)
|
||||||
{
|
{
|
||||||
allocateBuffer();
|
allocateBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
Bitmap::~Bitmap()
|
Bitmap::~Bitmap()
|
||||||
{
|
{
|
||||||
if(_buffer != 0)
|
if(_buffer != 0)
|
||||||
|
|
@ -23,16 +26,19 @@ Bitmap::~Bitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
uint Bitmap::getWidth() const
|
uint Bitmap::getWidth() const
|
||||||
{
|
{
|
||||||
return _width;
|
return _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
uint Bitmap::getHeight() const
|
uint Bitmap::getHeight() const
|
||||||
{
|
{
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::setPixel(int x, int y)
|
void Bitmap::setPixel(int x, int y)
|
||||||
{
|
{
|
||||||
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
||||||
|
|
@ -41,6 +47,7 @@ void Bitmap::setPixel(int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::clearPixel(int x, int y)
|
void Bitmap::clearPixel(int x, int y)
|
||||||
{
|
{
|
||||||
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
||||||
|
|
@ -49,6 +56,7 @@ void Bitmap::clearPixel(int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
bool Bitmap::getPixel(int x, int y) const
|
bool Bitmap::getPixel(int x, int y) const
|
||||||
{
|
{
|
||||||
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
if(x >= 0 && x < _width && y >= 0 && y < _height)
|
||||||
|
|
@ -58,11 +66,13 @@ bool Bitmap::getPixel(int x, int y) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::clear()
|
void Bitmap::clear()
|
||||||
{
|
{
|
||||||
memset(_buffer, 0, _width * _height / 8);
|
memset(_buffer, 0, _width * _height / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawLine(int x0, int y0, int x1, int y1)
|
void Bitmap::drawLine(int x0, int y0, int x1, int y1)
|
||||||
{
|
{
|
||||||
int dx = abs(x1 - x0);
|
int dx = abs(x1 - x0);
|
||||||
|
|
@ -70,7 +80,6 @@ void Bitmap::drawLine(int x0, int y0, int x1, int y1)
|
||||||
int sx = x0 < x1 ? 1 : -1;
|
int sx = x0 < x1 ? 1 : -1;
|
||||||
int sy = y0 < y1 ? 1 : -1;
|
int sy = y0 < y1 ? 1 : -1;
|
||||||
int err = (dx > dy ? dx : -dy) / 2;
|
int err = (dx > dy ? dx : -dy) / 2;
|
||||||
int e2;
|
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +87,7 @@ void Bitmap::drawLine(int x0, int y0, int x1, int y1)
|
||||||
if(x0 == x1 && y0 == y1)
|
if(x0 == x1 && y0 == y1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
e2 = err;
|
int e2 = err;
|
||||||
if(e2 > -dx)
|
if(e2 > -dx)
|
||||||
{
|
{
|
||||||
err -= dy;
|
err -= dy;
|
||||||
|
|
@ -92,6 +101,7 @@ void Bitmap::drawLine(int x0, int y0, int x1, int y1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawHorizontalLine(int x, int y, int length)
|
void Bitmap::drawHorizontalLine(int x, int y, int length)
|
||||||
{
|
{
|
||||||
if(y < 0 || y >= _height)
|
if(y < 0 || y >= _height)
|
||||||
|
|
@ -105,6 +115,7 @@ void Bitmap::drawHorizontalLine(int x, int y, int length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawVerticalLine(int x, int y, int length)
|
void Bitmap::drawVerticalLine(int x, int y, int length)
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= _width)
|
if (x < 0 || x >= _width)
|
||||||
|
|
@ -118,6 +129,7 @@ void Bitmap::drawVerticalLine(int x, int y, int length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawRect(int x, int y, int width, int height)
|
void Bitmap::drawRect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
drawHorizontalLine(x, y, width);
|
drawHorizontalLine(x, y, width);
|
||||||
|
|
@ -126,6 +138,7 @@ void Bitmap::drawRect(int x, int y, int width, int height)
|
||||||
drawHorizontalLine(x, y + height - 1, width);
|
drawHorizontalLine(x, y + height - 1, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::fillRect(int x, int y, int width, int height)
|
void Bitmap::fillRect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
|
|
@ -134,6 +147,7 @@ void Bitmap::fillRect(int x, int y, int width, int height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawCircle(int x0, int y0, int radius)
|
void Bitmap::drawCircle(int x0, int y0, int radius)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
@ -168,6 +182,7 @@ void Bitmap::drawCircle(int x0, int y0, int radius)
|
||||||
setPixel(x0, y0 - radius);
|
setPixel(x0, y0 - radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::fillCircle(int x0, int y0, int radius)
|
void Bitmap::fillCircle(int x0, int y0, int radius)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
@ -195,6 +210,7 @@ void Bitmap::fillCircle(int x0, int y0, int radius)
|
||||||
drawHorizontalLine(x0 - radius, y0, 2 * radius);
|
drawHorizontalLine(x0 - radius, y0, 2 * radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawCircleQuads(int x0, int y0, int radius, int quads)
|
void Bitmap::drawCircleQuads(int x0, int y0, int radius, int quads)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
@ -251,6 +267,7 @@ void Bitmap::drawCircleQuads(int x0, int y0, int radius, int quads)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawProgressBar(int x, int y, int width, int height, int progress)
|
void Bitmap::drawProgressBar(int x, int y, int width, int height, int progress)
|
||||||
{
|
{
|
||||||
int radius = height / 2;
|
int radius = height / 2;
|
||||||
|
|
@ -271,6 +288,7 @@ void Bitmap::drawProgressBar(int x, int y, int width, int height, int progress)
|
||||||
fillCircle(xRadius + maxProgressWidth, yRadius, innerRadius);
|
fillCircle(xRadius + maxProgressWidth, yRadius, innerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
int Bitmap::drawChar(int x, int y, char c)
|
int Bitmap::drawChar(int x, int y, char c)
|
||||||
{
|
{
|
||||||
fontDesc_t const * font = getSystemFont();
|
fontDesc_t const * font = getSystemFont();
|
||||||
|
|
@ -322,6 +340,7 @@ int Bitmap::drawChar(int x, int y, char c)
|
||||||
return x + FONT_CHAR_SPACING;
|
return x + FONT_CHAR_SPACING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
int Bitmap::drawString(int x, int y, String text)
|
int Bitmap::drawString(int x, int y, String text)
|
||||||
{
|
{
|
||||||
int next_x = x;
|
int next_x = x;
|
||||||
|
|
@ -332,6 +351,7 @@ int Bitmap::drawString(int x, int y, String text)
|
||||||
return next_x;
|
return next_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawStringf(int x, int y, char * buffer, String format, ... )
|
void Bitmap::drawStringf(int x, int y, char * buffer, String format, ... )
|
||||||
{
|
{
|
||||||
va_list myargs;
|
va_list myargs;
|
||||||
|
|
@ -341,6 +361,7 @@ void Bitmap::drawStringf(int x, int y, char * buffer, String format, ... )
|
||||||
drawString(x, y, buffer);
|
drawString(x, y, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
int Bitmap::drawStringLF(int x, int y, String text)
|
int Bitmap::drawStringLF(int x, int y, String text)
|
||||||
{
|
{
|
||||||
fontDesc_t const * font = getSystemFont();
|
fontDesc_t const * font = getSystemFont();
|
||||||
|
|
@ -357,6 +378,7 @@ int Bitmap::drawStringLF(int x, int y, String text)
|
||||||
return next_x;
|
return next_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::drawStringLFf(int x, int y, char * buffer, String format, ... )
|
void Bitmap::drawStringLFf(int x, int y, char * buffer, String format, ... )
|
||||||
{
|
{
|
||||||
va_list myargs;
|
va_list myargs;
|
||||||
|
|
@ -394,6 +416,7 @@ void Bitmap::drawStringLFf(int x, int y, char * buffer, String format, ... )
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void Bitmap::allocateBuffer()
|
void Bitmap::allocateBuffer()
|
||||||
{
|
{
|
||||||
_buffer = new uint8_t[_width * _height / 8];
|
_buffer = new uint8_t[_width * _height / 8];
|
||||||
|
|
|
||||||
|
|
@ -40,26 +40,31 @@ OLEDDisplay::~OLEDDisplay()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::displayOn()
|
void OLEDDisplay::displayOn()
|
||||||
{
|
{
|
||||||
sendCommand(DISPLAYON);
|
sendCommand(DISPLAYON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::displayOff()
|
void OLEDDisplay::displayOff()
|
||||||
{
|
{
|
||||||
sendCommand(DISPLAYOFF);
|
sendCommand(DISPLAYOFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::invertDisplay()
|
void OLEDDisplay::invertDisplay()
|
||||||
{
|
{
|
||||||
sendCommand(INVERTDISPLAY);
|
sendCommand(INVERTDISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::normalDisplay()
|
void OLEDDisplay::normalDisplay()
|
||||||
{
|
{
|
||||||
sendCommand(NORMALDISPLAY);
|
sendCommand(NORMALDISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::setContrast(uint8_t contrast, uint8_t precharge, uint8_t comdetect)
|
void OLEDDisplay::setContrast(uint8_t contrast, uint8_t precharge, uint8_t comdetect)
|
||||||
{
|
{
|
||||||
sendCommand(SETPRECHARGE); //0xD9
|
sendCommand(SETPRECHARGE); //0xD9
|
||||||
|
|
@ -73,18 +78,15 @@ void OLEDDisplay::setContrast(uint8_t contrast, uint8_t precharge, uint8_t comde
|
||||||
sendCommand(DISPLAYON);
|
sendCommand(DISPLAYON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::setBrightness(uint8_t brightness)
|
void OLEDDisplay::setBrightness(uint8_t brightness)
|
||||||
{
|
{
|
||||||
uint8_t contrast = brightness;
|
uint8_t contrast = brightness * 1.171 - 43;
|
||||||
if (brightness < 128)
|
if (brightness < 128)
|
||||||
{
|
{
|
||||||
// Magic values to get a smooth/ step-free transition
|
// Magic values to get a smooth/ step-free transition
|
||||||
contrast = brightness * 1.171;
|
contrast = brightness * 1.171;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
contrast = brightness * 1.171 - 43;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t precharge = 241;
|
uint8_t precharge = 241;
|
||||||
if (brightness == 0)
|
if (brightness == 0)
|
||||||
|
|
@ -95,28 +97,33 @@ void OLEDDisplay::setBrightness(uint8_t brightness)
|
||||||
setContrast(contrast, precharge, comdetect);
|
setContrast(contrast, precharge, comdetect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::resetOrientation()
|
void OLEDDisplay::resetOrientation()
|
||||||
{
|
{
|
||||||
sendCommand(SEGREMAP);
|
sendCommand(SEGREMAP);
|
||||||
sendCommand(COMSCANINC);
|
sendCommand(COMSCANINC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::flipScreenVertically()
|
void OLEDDisplay::flipScreenVertically()
|
||||||
{
|
{
|
||||||
sendCommand(SEGREMAP | 0x01);
|
sendCommand(SEGREMAP | 0x01);
|
||||||
sendCommand(COMSCANDEC);
|
sendCommand(COMSCANDEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::mirrorScreen()
|
void OLEDDisplay::mirrorScreen()
|
||||||
{
|
{
|
||||||
sendCommand(SEGREMAP);
|
sendCommand(SEGREMAP);
|
||||||
sendCommand(COMSCANDEC);
|
sendCommand(COMSCANDEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::clear()
|
void OLEDDisplay::clear()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
uint OLEDDisplay::getWidth()
|
uint OLEDDisplay::getWidth()
|
||||||
{
|
{
|
||||||
switch(_geometry)
|
switch(_geometry)
|
||||||
|
|
@ -131,6 +138,7 @@ uint OLEDDisplay::getWidth()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
uint OLEDDisplay::getHeight()
|
uint OLEDDisplay::getHeight()
|
||||||
{
|
{
|
||||||
switch(_geometry)
|
switch(_geometry)
|
||||||
|
|
@ -146,6 +154,7 @@ uint OLEDDisplay::getHeight()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
void OLEDDisplay::sendInitCommands()
|
void OLEDDisplay::sendInitCommands()
|
||||||
{
|
{
|
||||||
sendCommand(DISPLAYOFF);
|
sendCommand(DISPLAYOFF);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ private:
|
||||||
TwoWire * _wire = NULL;
|
TwoWire * _wire = NULL;
|
||||||
uint8_t _address;
|
uint8_t _address;
|
||||||
bool _doI2cAutoInit = false;
|
bool _doI2cAutoInit = false;
|
||||||
int _frequency;
|
|
||||||
|
|
||||||
virtual void sendCommand(uint8_t command) override;
|
virtual void sendCommand(uint8_t command) override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ lib_deps =
|
||||||
peterus/ESP-FTP-Server-Lib @ 0.9.5
|
peterus/ESP-FTP-Server-Lib @ 0.9.5
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_flags =
|
check_flags =
|
||||||
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient -ilib/Display
|
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient
|
||||||
check_skip_packages = yes
|
check_skip_packages = yes
|
||||||
#monitor_flags = --raw
|
#monitor_flags = --raw
|
||||||
# activate for OTA Update, use the CALLSIGN from is-cfg.json as upload_port:
|
# activate for OTA Update, use the CALLSIGN from is-cfg.json as upload_port:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue