From 72f5fe623fcfe6fef8c787a3521fa8e751330825 Mon Sep 17 00:00:00 2001 From: moononournation Date: Wed, 10 Jan 2024 21:52:45 +0800 Subject: [PATCH] #45 --- .../ImgViewer/ImgViewerPng/ImgViewerPng.ino | 2 +- .../MultiplePDQgraphicstest.ino | 2 +- examples/PDQgraphicstest/PDQgraphicstest.ino | 2 +- src/Arduino_GFX.h | 4 +- src/databus/Arduino_Wire.cpp | 8 ++-- src/databus/Arduino_XCA9554SWSPI.cpp | 47 ++++++++++++------- src/databus/Arduino_XL9535SWSPI.cpp | 2 +- src/display/Arduino_SSD1306.cpp | 21 +++++---- 8 files changed, 52 insertions(+), 36 deletions(-) diff --git a/examples/ImgViewer/ImgViewerPng/ImgViewerPng.ino b/examples/ImgViewer/ImgViewerPng/ImgViewerPng.ino index a92126a4..6fa814f8 100644 --- a/examples/ImgViewer/ImgViewerPng/ImgViewerPng.ino +++ b/examples/ImgViewer/ImgViewerPng/ImgViewerPng.ino @@ -184,7 +184,7 @@ void setup() gfx->fillScreen(BLACK); for (int16_t x = 0; x < w; x += 5) { - gfx->drawFastVLine(x, 0, h, PINK); + gfx->drawFastVLine(x, 0, h, PALERED); } #ifdef GFX_BL diff --git a/examples/MultipleDisplay/MultiplePDQgraphicstest/MultiplePDQgraphicstest.ino b/examples/MultipleDisplay/MultiplePDQgraphicstest/MultiplePDQgraphicstest.ino index 64895676..710b65a4 100644 --- a/examples/MultipleDisplay/MultiplePDQgraphicstest/MultiplePDQgraphicstest.ino +++ b/examples/MultipleDisplay/MultiplePDQgraphicstest/MultiplePDQgraphicstest.ino @@ -375,7 +375,7 @@ int32_t testText() gfx->println(F("Size 8")); gfx->setTextSize(9); - gfx->setTextColor(PINK); + gfx->setTextColor(PALERED); gfx->println(F("Size 9")); return micros() - start; diff --git a/examples/PDQgraphicstest/PDQgraphicstest.ino b/examples/PDQgraphicstest/PDQgraphicstest.ino index cc03eeba..0aef2328 100644 --- a/examples/PDQgraphicstest/PDQgraphicstest.ino +++ b/examples/PDQgraphicstest/PDQgraphicstest.ino @@ -362,7 +362,7 @@ int32_t testText() gfx->println(F("Size 8")); gfx->setTextSize(9); - gfx->setTextColor(PINK); + gfx->setTextColor(PALERED); gfx->println(F("Size 9")); return micros() - start; diff --git a/src/Arduino_GFX.h b/src/Arduino_GFX.h index 3f8d8bba..7352fbb0 100644 --- a/src/Arduino_GFX.h +++ b/src/Arduino_GFX.h @@ -50,7 +50,7 @@ #define RGB565_WHITE RGB565(255, 255, 255) #define RGB565_ORANGE RGB565(255, 165, 0) #define RGB565_GREENYELLOW RGB565(173, 255, 41) -#define RGB565_PINK RGB565(255, 130, 198) +#define RGB565_PALERED RGB565(255, 130, 198) // Color definitions #ifndef DISABLE_COLOR_DEFINES @@ -72,7 +72,7 @@ #define WHITE RGB565_WHITE #define ORANGE RGB565_ORANGE #define GREENYELLOW RGB565_GREENYELLOW -#define PINK RGB565_PINK +#define PALERED RGB565_PALERED #endif // Many (but maybe not all) non-AVR board installs define macros diff --git a/src/databus/Arduino_Wire.cpp b/src/databus/Arduino_Wire.cpp index 4b21a233..9525794c 100644 --- a/src/databus/Arduino_Wire.cpp +++ b/src/databus/Arduino_Wire.cpp @@ -54,7 +54,7 @@ void Arduino_Wire::write(uint8_t d) _wire->write(d); } -void Arduino_Wire::writeCommand(uint8_t c) +void Arduino_Wire::writeCommand(uint8_t) { // println("Wire::writeCommand()"); // not implemented. @@ -85,19 +85,19 @@ void Arduino_Wire::writePixels(uint16_t *, uint32_t) } #if !defined(LITTLE_FOOT_PRINT) -void Arduino_Wire::writeBytes(uint8_t *data, uint32_t len) +void Arduino_Wire::writeBytes(uint8_t *, uint32_t) { // println("Wire::writeBytes()"); // not implemented } #endif // !defined(LITTLE_FOOT_PRINT) -void Arduino_Wire::writeRegister(uint8_t reg, uint8_t *data, size_t len) +void Arduino_Wire::writeRegister(uint8_t, uint8_t *, size_t) { // println("Wire::writeRegister()"); } -uint8_t Arduino_Wire::readRegister(uint8_t reg, uint8_t *data, size_t len) +uint8_t Arduino_Wire::readRegister(uint8_t, uint8_t *, size_t) { // println("Wire::readRegister()"); return 0; diff --git a/src/databus/Arduino_XCA9554SWSPI.cpp b/src/databus/Arduino_XCA9554SWSPI.cpp index dac22118..83acdbc9 100644 --- a/src/databus/Arduino_XCA9554SWSPI.cpp +++ b/src/databus/Arduino_XCA9554SWSPI.cpp @@ -1,9 +1,9 @@ #include "Arduino_XCA9554SWSPI.h" -//#define XCA9554_DEBUG +// #define XCA9554_DEBUG Arduino_XCA9554SWSPI::Arduino_XCA9554SWSPI(int8_t rst, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire, uint8_t i2c_addr) - : _rst(rst), _cs(cs), _sck(sck), _mosi(mosi), _wire(wire), _i2c_addr(i2c_addr) + : _rst(rst), _cs(cs), _sck(sck), _mosi(mosi), _wire(wire), _i2c_addr(i2c_addr) { } @@ -71,14 +71,16 @@ void Arduino_XCA9554SWSPI::writeCommand(uint8_t c) { if (c & bit) { - if (last_databit != 1) { + if (last_databit != 1) + { last_databit = 1; this->digitalWrite(_mosi, last_databit); } } else { - if (last_databit != 0) { + if (last_databit != 0) + { last_databit = 0; this->digitalWrite(_mosi, last_databit); } @@ -102,14 +104,20 @@ void Arduino_XCA9554SWSPI::write(uint8_t d) this->digitalWrite(_sck, 1); uint8_t bit = 0x80; - while (bit) { - if (d & bit) { - if (last_databit != 1) { + while (bit) + { + if (d & bit) + { + if (last_databit != 1) + { last_databit = 1; this->digitalWrite(_mosi, last_databit); } - } else { - if (last_databit != 0) { + } + else + { + if (last_databit != 0) + { last_databit = 0; this->digitalWrite(_mosi, last_databit); } @@ -130,7 +138,7 @@ void Arduino_XCA9554SWSPI::writeRepeat(uint16_t, uint32_t) // not implemented } -void Arduino_XCA9554SWSPI::writeBytes(uint8_t *data, uint32_t len) +void Arduino_XCA9554SWSPI::writeBytes(uint8_t *, uint32_t) { // not implemented } @@ -171,7 +179,8 @@ uint8_t Arduino_XCA9554SWSPI::readRegister(uint8_t reg, uint8_t *data, size_t le _wire->endTransmission(); _wire->requestFrom(_i2c_addr, len); size_t index = 0; - while (index < len) { + while (index < len) + { data[index++] = _wire->read(); #ifdef XCA9554_DEBUG // printf("0x%02X, ", data[index-1]); @@ -189,13 +198,18 @@ void Arduino_XCA9554SWSPI::pinMode(uint8_t pin, uint8_t mode) { uint8_t port = 0; this->readRegister(XCA9554_CONFIG_PORT_REG, &port, 1); - if (mode == OUTPUT) { + if (mode == OUTPUT) + { port &= ~(1UL << pin); - } else { + } + else + { port |= (1UL << pin); } this->writeRegister(XCA9554_CONFIG_PORT_REG, &port, 1); - } else { + } + else + { // println("xCA9554 not found"); } } @@ -207,7 +221,8 @@ void Arduino_XCA9554SWSPI::digitalWrite(uint8_t pin, uint8_t val) uint8_t reg_data = output_buf; reg_data &= ~(1UL << pin); - if (val == HIGH) { + if (val == HIGH) + { reg_data |= (1UL << pin); } this->writeRegister(XCA9554_OUTPUT_PORT_REG, ®_data, 1); @@ -226,7 +241,7 @@ int Arduino_XCA9554SWSPI::digitalRead(uint8_t pin) uint8_t port = 0; this->readRegister(XCA9554_INPUT_PORT_REG, &port, 1); // printf("Read 0x%02X\n", port); - return(port & (1UL << pin)) ? HIGH : LOW; + return (port & (1UL << pin)) ? HIGH : LOW; } else { diff --git a/src/databus/Arduino_XL9535SWSPI.cpp b/src/databus/Arduino_XL9535SWSPI.cpp index 73fe8cf7..8c56ee60 100644 --- a/src/databus/Arduino_XL9535SWSPI.cpp +++ b/src/databus/Arduino_XL9535SWSPI.cpp @@ -107,7 +107,7 @@ void Arduino_XL9535SWSPI::writeRepeat(uint16_t, uint32_t) // not implemented } -void Arduino_XL9535SWSPI::writeBytes(uint8_t *data, uint32_t len) +void Arduino_XL9535SWSPI::writeBytes(uint8_t *, uint32_t) { // not implemented } diff --git a/src/display/Arduino_SSD1306.cpp b/src/display/Arduino_SSD1306.cpp index 37041b82..9e96d0c8 100644 --- a/src/display/Arduino_SSD1306.cpp +++ b/src/display/Arduino_SSD1306.cpp @@ -102,13 +102,14 @@ bool Arduino_SSD1306::begin(int32_t speed) return true; } -void Arduino_SSD1306::setBrightness(uint8_t brightness){ - // _sendCommand(SSD1306_SETCONTRAST); - // ??? _sendCommand((brightness < 50) ? 0 : _contrast); ??? - // _sendCommand((brightness < 50) ? 0 : 0x8f); -}; // setBrightness +void Arduino_SSD1306::setBrightness(uint8_t /* brightness */) +{ + // _sendCommand(SSD1306_SETCONTRAST); + // ??? _sendCommand((brightness < 50) ? 0 : _contrast); ??? + // _sendCommand((brightness < 50) ? 0 : 0x8f); +} -void Arduino_SSD1306::drawBitmap(int16_t xStart, int16_t yStart, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) +void Arduino_SSD1306::drawBitmap(int16_t xStart, int16_t yStart, uint8_t *bitmap, int16_t w, int16_t h, uint16_t /* color */, uint16_t /* bg */) { printf("SSD1306::drawBitmap %d/%d w:%d h:%d\n", xStart, yStart, w, h); uint16_t bufferLength = TWI_BUFFER_LENGTH; @@ -152,7 +153,7 @@ void Arduino_SSD1306::drawBitmap(int16_t xStart, int16_t yStart, uint8_t *bitmap _bus->write(SSD1306_COLUMNADDR); _bus->write(_colStart); _bus->write(_colEnd); - // set column + // set column _bus->endWrite(); // send out page data @@ -187,7 +188,7 @@ void Arduino_SSD1306::drawIndexedBitmap(int16_t, int16_t, uint8_t *, uint16_t *, // println("SSD1306::Not Implemented drawIndexedBitmap()"); } -void Arduino_SSD1306::draw3bitRGBBitmap(int16_t, int16_t, uint8_t *bitmap, int16_t w, int16_t h) +void Arduino_SSD1306::draw3bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t) { // println("SSD1306::Not Implemented draw3bitRGBBitmap()"); } @@ -202,9 +203,9 @@ void Arduino_SSD1306::draw24bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, i // println("SSD1306::Not Implemented draw24bitRGBBitmap()"); } -void Arduino_SSD1306::invertDisplay(bool i) +void Arduino_SSD1306::invertDisplay(bool) { - // _bus->sendCommand(i ? ILI9488_INVON : ILI9488_INVOFF); + // println("SSD1306::Not Implemented invertDisplay()"); } void Arduino_SSD1306::displayOn(void)