diff --git a/examples/Basic_Touch_Draw/Basic_Touch_Draw.ino b/examples/Basic_Touch_Draw/Basic_Touch_Draw.ino index 8f5c782..bf3314b 100755 --- a/examples/Basic_Touch_Draw/Basic_Touch_Draw.ino +++ b/examples/Basic_Touch_Draw/Basic_Touch_Draw.ino @@ -15,19 +15,22 @@ /// @n /// +// Screen +#include "PDLS_EXT3_Basic_Touch.h" + // SDK -#if defined(ENERGIA) // LaunchPad specific -#include "Energia.h" -#else // Arduino general -#include "Arduino.h" -#endif // SDK +// #include +#include "hV_HAL_Peripherals.h" + +// Configuration +#include "hV_Configuration.h" // Set parameters #define DISPLAY_TOUCH 1 // Include application, user and local libraries -#include "Wire.h" -#include "SPI.h" +// #include +// #include // Define structures and classes @@ -35,8 +38,6 @@ // === Pervasive Displays iTC // --- Touch -#include "PDLS_EXT3_Basic_Touch.h" - // Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_09_Touch, boardRaspberryPiPico_RP2040); Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_370_0C_Touch, boardRaspberryPiPico_RP2040); @@ -156,10 +157,6 @@ void setup() Serial.println("=== "); Serial.println(); - -#if defined(ARDUINO_ARCH_PIDUINO) - exit(0); -#endif } // Add loop code diff --git a/examples/Basic_Touch_GUI/Basic_Touch_GUI.ino b/examples/Basic_Touch_GUI/Basic_Touch_GUI.ino index 24f1049..829639f 100755 --- a/examples/Basic_Touch_GUI/Basic_Touch_GUI.ino +++ b/examples/Basic_Touch_GUI/Basic_Touch_GUI.ino @@ -15,20 +15,22 @@ /// @n /// +// Screen +#include "PDLS_EXT3_Basic_Touch.h" + // SDK -#if defined(ENERGIA) // LaunchPad specific -#include "Energia.h" -#else // Arduino general -#include "Arduino.h" -#endif // SDK +// #include +#include "hV_HAL_Peripherals.h" + +// Configuration +#include "hV_Configuration.h" // Set parameters #define DISPLAY_GUI 1 // Include application, user and local libraries -#include "Wire.h" -#include "SPI.h" -#include "PDLS_EXT3_Basic_Touch.h" +// #include +// #include #if (SCREEN_EPD_EXT3_RELEASE < 531) #error Required SCREEN_EPD_EXT3_RELEASE 531 @@ -167,10 +169,6 @@ void setup() Serial.println("=== "); Serial.println(); - -#if defined(ARDUINO_ARCH_PIDUINO) - exit(0); -#endif } // Add loop code diff --git a/examples/Basic_Touch_TicTacToe/Basic_Touch_TicTacToe.ino b/examples/Basic_Touch_TicTacToe/Basic_Touch_TicTacToe.ino index 458769b..ec3f1d1 100755 --- a/examples/Basic_Touch_TicTacToe/Basic_Touch_TicTacToe.ino +++ b/examples/Basic_Touch_TicTacToe/Basic_Touch_TicTacToe.ino @@ -15,12 +15,15 @@ /// @n /// +// Screen +#include "PDLS_EXT3_Basic_Touch.h" + // SDK -#if defined(ENERGIA) // LaunchPad specific -#include "Energia.h" -#else // Arduino general -#include "Arduino.h" -#endif // SDK +// #include +#include "hV_HAL_Peripherals.h" + +// Configuration +#include "hV_Configuration.h" // Set parameters #define PLAYER_NONE 0 @@ -30,8 +33,8 @@ #define NUMBER 4 // Include application, user and local libraries -#include "Wire.h" -#include "SPI.h" +// #include +// #include // Define structures and classes @@ -39,8 +42,6 @@ // === Pervasive Displays iTC // --- Touch -#include "PDLS_EXT3_Basic_Touch.h" - // Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_09_Touch, boardRaspberryPiPico_RP2040); Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_370_0C_Touch, boardRaspberryPiPico_RP2040); diff --git a/library.properties b/library.properties index e7ba71f..a761844 100755 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=PDLS_EXT3_Basic_Touch -version=7.0.0 +version=7.0.1 author=Rei Vilo for Pervasive Displays maintainer=Rei Vilo sentence=Library for Pervasive Displays monochrome e-paper screens with touch and EXT3-1 + EXT3-Touch diff --git a/src/Screen_EPD_EXT3.cpp b/src/Screen_EPD_EXT3.cpp index 567b80b..53c6d6e 100755 --- a/src/Screen_EPD_EXT3.cpp +++ b/src/Screen_EPD_EXT3.cpp @@ -26,6 +26,7 @@ // Release 609: Added temperature management // Release 610: Removed partial update // Release 700: Refactored screen and board functions +// Release 701: Improved functions names consistency // // Library header @@ -86,7 +87,8 @@ void Screen_EPD_EXT3_Fast::COG_initial(uint8_t updateMode) uint8_t index00_work[2]; // PSR indexE0_work[0] = indexE0_data[0]; - if ((_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL)) // Specific settings for fast update + indexE5_data[0] = u_temperature; + if ((u_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL)) // Specific settings for fast update { indexE5_work[0] = indexE5_data[0] | 0x40; // temperature | 0x40 index00_work[0] = index00_data[0] | 0x10; // PSR0 | 0x10 @@ -97,19 +99,19 @@ void Screen_EPD_EXT3_Fast::COG_initial(uint8_t updateMode) indexE5_work[0] = indexE5_data[0]; // Temperature index00_work[0] = index00_data[0]; // PSR0 index00_work[1] = index00_data[1]; // PSR1 - } // _codeExtra updateMode + } // u_codeExtra updateMode // New algorithm uint8_t index00_reset[] = {0x0e}; b_sendIndexData(0x00, index00_reset, 1); // Soft-reset b_waitBusy(); - b_sendIndexData(0xe5, indexE5_work, 1); // Input Temperature: 25C + b_sendIndexData(0xe5, indexE5_work, 1); // Input Temperature b_sendIndexData(0xe0, indexE0_work, 1); // Activate Temperature b_sendIndexData(0x00, index00_work, 2); // PSR // Specific settings for fast update, all screens - if ((_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL)) + if ((u_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL)) { uint8_t index50c_work[1]; // Vcom index50c_work[0] = index50c_data[0]; // 0x07 @@ -117,7 +119,7 @@ void Screen_EPD_EXT3_Fast::COG_initial(uint8_t updateMode) } // Additional settings for fast update, 154 213 266 and 370 screens (_flag50) - if ((_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL) and _flag50) + if ((u_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL) and _flag50) { uint8_t index50a_work[1]; // Vcom index50a_work[0] = index50a_data[0]; // 0x27 @@ -127,10 +129,10 @@ void Screen_EPD_EXT3_Fast::COG_initial(uint8_t updateMode) void Screen_EPD_EXT3_Fast::COG_getUserData() { - uint16_t _codeSizeType = _eScreen_EPD_EXT3 & 0xffff; + uint16_t u_codeSizeType = u_eScreen_EPD_EXT3 & 0xffff; // Size cSize cType Driver - switch (_codeSizeType) + switch (u_codeSizeType) { case 0x2709: // 2.71” = 0xcf, 0x8d @@ -154,18 +156,18 @@ void Screen_EPD_EXT3_Fast::COG_getUserData() void Screen_EPD_EXT3_Fast::COG_sendImageDataFast() { - uint8_t * nextBuffer = _newImage; - uint8_t * previousBuffer = _newImage + _pageColourSize; + uint8_t * nextBuffer = u_newImage; + uint8_t * previousBuffer = u_newImage + u_pageColourSize; - b_sendIndexData(0x10, previousBuffer, _frameSize); // Previous frame - b_sendIndexData(0x13, nextBuffer, _frameSize); // Next frame - memcpy(previousBuffer, nextBuffer, _frameSize); // Copy displayed next to previous + b_sendIndexData(0x10, previousBuffer, u_frameSize); // Previous frame + b_sendIndexData(0x13, nextBuffer, u_frameSize); // Next frame + memcpy(previousBuffer, nextBuffer, u_frameSize); // Copy displayed next to previous } void Screen_EPD_EXT3_Fast::COG_update(uint8_t updateMode) { // Specific settings for fast update, 154 213 266 and 370 screens (_flag50) - if ((_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL) and _flag50) + if ((u_codeExtra & FEATURE_FAST) and (updateMode != UPDATE_GLOBAL) and _flag50) { uint8_t index50b_work[1]; // Vcom index50b_work[0] = index50b_data[0]; // 0x07 @@ -173,18 +175,18 @@ void Screen_EPD_EXT3_Fast::COG_update(uint8_t updateMode) } b_sendCommand8(0x04); // Power on - digitalWrite(_pin.panelCS, HIGH); // CS# = 1 + digitalWrite(b_pin.panelCS, HIGH); // CS# = 1 b_waitBusy(); b_sendCommand8(0x12); // Display Refresh - digitalWrite(_pin.panelCS, HIGH); // CS# = 1 + digitalWrite(b_pin.panelCS, HIGH); // CS# = 1 b_waitBusy(); } void Screen_EPD_EXT3_Fast::COG_powerOff() { b_sendCommand8(0x02); // Turn off DC/DC - digitalWrite(_pin.panelCS, HIGH); // CS# = 1 + digitalWrite(b_pin.panelCS, HIGH); // CS# = 1 b_waitBusy(); } /// @endcond @@ -192,37 +194,39 @@ void Screen_EPD_EXT3_Fast::COG_powerOff() // === End of COG section // -// Class +// +// === Class section +// Screen_EPD_EXT3_Fast::Screen_EPD_EXT3_Fast(eScreen_EPD_EXT3_t eScreen_EPD_EXT3, pins_t board) { - _eScreen_EPD_EXT3 = eScreen_EPD_EXT3; - _pin = board; - _newImage = 0; // nullptr + u_eScreen_EPD_EXT3 = eScreen_EPD_EXT3; + b_pin = board; + u_newImage = 0; // nullptr } void Screen_EPD_EXT3_Fast::begin() { - _codeExtra = (_eScreen_EPD_EXT3 >> 16) & 0xff; - _codeSize = (_eScreen_EPD_EXT3 >> 8) & 0xff; - _codeType = _eScreen_EPD_EXT3 & 0xff; + u_codeExtra = (u_eScreen_EPD_EXT3 >> 16) & 0xff; + u_codeSize = (u_eScreen_EPD_EXT3 >> 8) & 0xff; + u_codeType = u_eScreen_EPD_EXT3 & 0xff; _screenColourBits = 2; // BWR and BWRY // Configure board - u_begin(_pin, FAMILY_SMALL, 0); + u_begin(b_pin, FAMILY_SMALL, 0); // // === Touch section // - if (!(_codeExtra & FEATURE_TOUCH)) + if (!(u_codeExtra & FEATURE_TOUCH)) { Serial.println(""); - Serial.println(formatString("! Error - Screen %06x non touch", _eScreen_EPD_EXT3)); + Serial.println(formatString("! Error - Screen %06x non touch", u_eScreen_EPD_EXT3)); } // // === End of touch section // - switch (_codeSize) + switch (u_codeSize) { case 0x27: // 2.71" and 2.71"-Touch @@ -241,77 +245,77 @@ void Screen_EPD_EXT3_Fast::begin() default: break; - } // _codeSize + } // u_codeSize - _bufferDepth = _screenColourBits; // 2 colours - _bufferSizeV = _screenSizeV; // vertical = wide size - _bufferSizeH = _screenSizeH / 8; // horizontal = small size 112 / 8; + u_bufferDepth = _screenColourBits; // 2 colours + u_bufferSizeV = _screenSizeV; // vertical = wide size + u_bufferSizeH = _screenSizeH / 8; // horizontal = small size 112 / 8, 1 bit per pixel // Force conversion for two unit16_t multiplication into uint32_t. // Actually for 1 colour; BWR requires 2 pages. - _pageColourSize = (uint32_t)_bufferSizeV * (uint32_t)_bufferSizeH; + u_pageColourSize = (uint32_t)u_bufferSizeV * (uint32_t)u_bufferSizeH; - // _frameSize = _pageColourSize, except for 9.69 and 11.98 - _frameSize = _pageColourSize; + // u_frameSize = u_pageColourSize, except for 9.69 and 11.98 + u_frameSize = u_pageColourSize; // 9.69 and 11.98 combine two half-screens, hence two frames with adjusted size #if defined(BOARD_HAS_PSRAM) // ESP32 PSRAM specific case - if (_newImage == 0) + if (u_newImage == 0) { static uint8_t * _newFrameBuffer; - _newFrameBuffer = (uint8_t *) ps_malloc(_pageColourSize * _bufferDepth); - _newImage = (uint8_t *) _newFrameBuffer; + _newFrameBuffer = (uint8_t *) ps_malloc(u_pageColourSize * u_bufferDepth); + u_newImage = (uint8_t *) _newFrameBuffer; } #else // default case - if (_newImage == 0) + if (u_newImage == 0) { static uint8_t * _newFrameBuffer; - _newFrameBuffer = new uint8_t[_pageColourSize * _bufferDepth]; - _newImage = (uint8_t *) _newFrameBuffer; + _newFrameBuffer = new uint8_t[u_pageColourSize * u_bufferDepth]; + u_newImage = (uint8_t *) _newFrameBuffer; } #endif // ESP32 BOARD_HAS_PSRAM - memset(_newImage, 0x00, _pageColourSize * _bufferDepth); + memset(u_newImage, 0x00, u_pageColourSize * u_bufferDepth); // Initialise the /CS pins - pinMode(_pin.panelCS, OUTPUT); - digitalWrite(_pin.panelCS, HIGH); // CS# = 1 + pinMode(b_pin.panelCS, OUTPUT); + digitalWrite(b_pin.panelCS, HIGH); // CS# = 1 // New generic solution - pinMode(_pin.panelDC, OUTPUT); - pinMode(_pin.panelReset, OUTPUT); - pinMode(_pin.panelBusy, INPUT); // All Pins 0 + pinMode(b_pin.panelDC, OUTPUT); + pinMode(b_pin.panelReset, OUTPUT); + pinMode(b_pin.panelBusy, INPUT); // All Pins 0 // Initialise Flash /CS as HIGH - if (_pin.flashCS != NOT_CONNECTED) + if (b_pin.flashCS != NOT_CONNECTED) { - pinMode(_pin.flashCS, OUTPUT); - digitalWrite(_pin.flashCS, HIGH); + pinMode(b_pin.flashCS, OUTPUT); + digitalWrite(b_pin.flashCS, HIGH); } // Initialise slave panel /CS as HIGH - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - pinMode(_pin.panelCSS, OUTPUT); - digitalWrite(_pin.panelCSS, HIGH); + pinMode(b_pin.panelCSS, OUTPUT); + digitalWrite(b_pin.panelCSS, HIGH); } // Initialise slave Flash /CS as HIGH - if (_pin.flashCSS != NOT_CONNECTED) + if (b_pin.flashCSS != NOT_CONNECTED) { - pinMode(_pin.flashCSS, OUTPUT); - digitalWrite(_pin.flashCSS, HIGH); + pinMode(b_pin.flashCSS, OUTPUT); + digitalWrite(b_pin.flashCSS, HIGH); } // Initialise SD-card /CS as HIGH - if (_pin.cardCS != NOT_CONNECTED) + if (b_pin.cardCS != NOT_CONNECTED) { - pinMode(_pin.cardCS, OUTPUT); - digitalWrite(_pin.cardCS, HIGH); + pinMode(b_pin.cardCS, OUTPUT); + digitalWrite(b_pin.cardCS, HIGH); } // Initialise SPI @@ -368,7 +372,7 @@ void Screen_EPD_EXT3_Fast::begin() f_fontSolid = false; _penSolid = false; - _invert = false; + u_invert = false; // Report Serial.println(formatString("= Screen %s %ix%i", WhoAmI().c_str(), screenSizeX(), screenSizeY())); @@ -409,7 +413,6 @@ uint8_t Screen_EPD_EXT3_Fast::flushMode(uint8_t updateMode) switch (updateMode) { case UPDATE_FAST: - case UPDATE_PARTIAL: case UPDATE_GLOBAL: _flushFast(); @@ -439,6 +442,7 @@ void Screen_EPD_EXT3_Fast::_flushFast() // Update COG_update(UPDATE_FAST); + COG_powerOff(); } @@ -446,24 +450,24 @@ void Screen_EPD_EXT3_Fast::clear(uint16_t colour) { if (colour == myColours.grey) { - for (uint16_t i = 0; i < _bufferSizeV; i++) + for (uint16_t i = 0; i < u_bufferSizeV; i++) { uint16_t pattern = (i % 2) ? 0b10101010 : 0b01010101; - for (uint16_t j = 0; j < _bufferSizeH; j++) + for (uint16_t j = 0; j < u_bufferSizeH; j++) { - _newImage[i * _bufferSizeH + j] = pattern; + u_newImage[i * u_bufferSizeH + j] = pattern; } } } - else if ((colour == myColours.white) xor _invert) + else if ((colour == myColours.white) xor u_invert) { // physical black 00 - memset(_newImage, 0x00, _pageColourSize); + memset(u_newImage, 0x00, u_pageColourSize); } else { // physical white 10 - memset(_newImage, 0xff, _pageColourSize); + memset(u_newImage, 0xff, u_pageColourSize); } } @@ -507,15 +511,15 @@ void Screen_EPD_EXT3_Fast::_setPoint(uint16_t x1, uint16_t y1, uint16_t colour) uint16_t b1 = _getB(x1, y1); // Basic colours - if ((colour == myColours.white) xor _invert) + if ((colour == myColours.white) xor u_invert) { // physical black 00 - bitClear(_newImage[z1], b1); + bitClear(u_newImage[z1], b1); } - else if ((colour == myColours.black) xor _invert) + else if ((colour == myColours.black) xor u_invert) { // physical white 10 - bitSet(_newImage[z1], b1); + bitSet(u_newImage[z1], b1); } } @@ -577,7 +581,7 @@ uint32_t Screen_EPD_EXT3_Fast::_getZ(uint16_t x1, uint16_t y1) // According to 11.98 inch Spectra Application Note // at http:// www.pervasivedisplays.com/LiteratureRetrieve.aspx?ID=245146 - z1 = (uint32_t)x1 * _bufferSizeH + (y1 >> 3); + z1 = (uint32_t)x1 * u_bufferSizeH + (y1 >> 3); return z1; } @@ -607,7 +611,7 @@ uint16_t Screen_EPD_EXT3_Fast::_getPoint(uint16_t x1, uint16_t y1) uint32_t z1 = _getZ(x1, y1); uint16_t b1 = _getB(x1, y1); - _value = bitRead(_newImage[z1], b1); + _value = bitRead(u_newImage[z1], b1); _value <<= 4; _value &= 0b11110000; @@ -627,6 +631,9 @@ uint16_t Screen_EPD_EXT3_Fast::_getPoint(uint16_t x1, uint16_t y1) return _result; } +// +// === End of Class section +// // // === Touch section @@ -668,23 +675,23 @@ void Screen_EPD_EXT3_Fast::_beginTouch() Wire.begin(); - if (_pin.touchInt != NOT_CONNECTED) + if (b_pin.touchInt != NOT_CONNECTED) { - pinMode(_pin.touchInt, INPUT_PULLUP); + pinMode(b_pin.touchInt, INPUT_PULLUP); } - if (_pin.touchReset != NOT_CONNECTED) + if (b_pin.touchReset != NOT_CONNECTED) { - pinMode(_pin.touchReset, OUTPUT); + pinMode(b_pin.touchReset, OUTPUT); } - if (_codeSize == 0x27) + if (u_codeSize == 0x27) { - digitalWrite(_pin.touchReset, HIGH); + digitalWrite(b_pin.touchReset, HIGH); delay(100); - digitalWrite(_pin.touchReset, LOW); + digitalWrite(b_pin.touchReset, LOW); delay(100); - digitalWrite(_pin.touchReset, HIGH); + digitalWrite(b_pin.touchReset, HIGH); delay(100); _touchAddress = TOUCH_271_ADDRESS; // 0x41 @@ -699,13 +706,13 @@ void Screen_EPD_EXT3_Fast::_beginTouch() _touchYmin = 0; _touchYmax = bufferRead[2] + (bufferRead[3] << 8); // Ymax } - else if (_codeSize == 0x37) + else if (u_codeSize == 0x37) { - digitalWrite(_pin.touchReset, HIGH); + digitalWrite(b_pin.touchReset, HIGH); delay(10); - digitalWrite(_pin.touchReset, LOW); + digitalWrite(b_pin.touchReset, LOW); delay(10); - digitalWrite(_pin.touchReset, HIGH); + digitalWrite(b_pin.touchReset, HIGH); delay(1000); _touchAddress = TOUCH_370_ADDRESS; // 0x38 @@ -714,7 +721,7 @@ void Screen_EPD_EXT3_Fast::_beginTouch() _touchXmax = 239; // Xmax, hardware hard-coded _touchYmin = 0; _touchYmax = 415; // Ymax, hardware hard-coded - } // _codeSize + } // u_codeSize _touchPrevious = TOUCH_EVENT_NONE; } @@ -723,7 +730,7 @@ void Screen_EPD_EXT3_Fast::_getRawTouch(uint16_t & x0, uint16_t & y0, uint16_t & { delay(10); - if (_codeSize == 0x27) + if (u_codeSize == 0x27) { uint8_t bufferWrite[1] = {0}; uint8_t bufferRead[5] = {0}; @@ -736,7 +743,7 @@ void Screen_EPD_EXT3_Fast::_getRawTouch(uint16_t & x0, uint16_t & y0, uint16_t & t0 = TOUCH_EVENT_NONE; // Only one finger read, interrupt not used - // uint8_t flagInterrupt = 1 - digitalRead(_pin.touchInt); + // uint8_t flagInterrupt = 1 - digitalRead(b_pin.touchInt); // if ((number > 0) and (number < 3) and (flagInterrupt > 0)) if ((number > 0) and (number < 3)) { @@ -780,9 +787,9 @@ void Screen_EPD_EXT3_Fast::_getRawTouch(uint16_t & x0, uint16_t & y0, uint16_t & } } } - else if (_codeSize == 0x37) + else if (u_codeSize == 0x37) { - uint8_t flagInterrupt = 1 - digitalRead(_pin.touchInt); + uint8_t flagInterrupt = 1 - digitalRead(b_pin.touchInt); bool flagValid; z0 = 0; @@ -837,16 +844,16 @@ void Screen_EPD_EXT3_Fast::_getRawTouch(uint16_t & x0, uint16_t & y0, uint16_t & z0 = 0x16; } } - } // _codeSize + } // u_codeSize } bool Screen_EPD_EXT3_Fast::_getInterruptTouch() { - if (_pin.touchInt != NOT_CONNECTED) + if (b_pin.touchInt != NOT_CONNECTED) { // Translate for true = interrupt // 271 and 370: LOW = false for interrupt - return (digitalRead(_pin.touchInt) == LOW); + return (digitalRead(b_pin.touchInt) == LOW); } else { diff --git a/src/Screen_EPD_EXT3.h b/src/Screen_EPD_EXT3.h index c4e5b71..7857339 100755 --- a/src/Screen_EPD_EXT3.h +++ b/src/Screen_EPD_EXT3.h @@ -17,8 +17,8 @@ /// * 3.70"-Touch reference xTP370PGH0x /// /// @author Rei Vilo -/// @date 21 Sep 2023 -/// @version 700 +/// @date 21 Oct 2023 +/// @version 701 /// /// @copyright (c) Rei Vilo, 2010-2023 /// @copyright Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) @@ -45,8 +45,13 @@ // Board #include "hV_Board.h" -// EPD utilities -#include "hV_Utilities_EPD.h" +// PDLS utilities +#include "hV_Utilities_PDLS.h" + +// Checks +#if (hV_HAL_PERIPHERALS_RELEASE < 700) +#error Required hV_HAL_PERIPHERALS_RELEASE 700 +#endif // hV_HAL_PERIPHERALS_RELEASE #if (hV_CONFIGURATION_RELEASE < 700) #error Required hV_CONFIGURATION_RELEASE 700 @@ -64,7 +69,7 @@ /// /// @brief Library release number /// -#define SCREEN_EPD_EXT3_RELEASE 700 +#define SCREEN_EPD_EXT3_RELEASE 701 /// /// @brief Library variant @@ -85,7 +90,7 @@ // Objects // /// -/// @brief Class for Pervasive Displays iTC monochome touch screens with embedded fast update +/// @brief Class for Pervasive Displays iTC monochrome touch screens with embedded fast update /// @details Screen controllers /// * LCD: proprietary, SPI /// * touch: proprietary, I2C @@ -94,13 +99,14 @@ /// @note All commands work on the frame-buffer, /// to be displayed on screen with flush() /// -class Screen_EPD_EXT3_Fast final : public hV_Screen_Buffer, public hV_Utilities_EPD +class Screen_EPD_EXT3_Fast final : public hV_Screen_Buffer, public hV_Utilities_PDLS { public: /// /// @brief Constructor with default pins /// @param eScreen_EPD_EXT3 size and model of the e-screen /// @param board board configuration + /// @note Frame-buffer generated by the class /// @note To be used with begin() with no parameter /// Screen_EPD_EXT3_Fast(eScreen_EPD_EXT3_t eScreen_EPD_EXT3, pins_t board); @@ -186,7 +192,7 @@ class Screen_EPD_EXT3_Fast final : public hV_Screen_Buffer, public hV_Utilities_ /// @brief Convert /// @param x1 x-axis coordinate /// @param y1 y-axis coordinate - /// @return index for _newImage[] + /// @return index for u_newImage[] /// uint32_t _getZ(uint16_t x1, uint16_t y1); @@ -194,7 +200,7 @@ class Screen_EPD_EXT3_Fast final : public hV_Screen_Buffer, public hV_Utilities_ /// @brief Convert /// @param x1 x-axis coordinate /// @param y1 y-axis coordinate - /// @return bit for _newImage[] + /// @return bit for u_newImage[] /// uint16_t _getB(uint16_t x1, uint16_t y1); diff --git a/src/hV_Board.cpp b/src/hV_Board.cpp index 0d56291..a2d2056 100755 --- a/src/hV_Board.cpp +++ b/src/hV_Board.cpp @@ -22,28 +22,28 @@ hV_Board::hV_Board() void hV_Board::b_begin(pins_t board, uint8_t family, uint16_t delayCS) { - _pin = board; - _family = family; - _delayCS = delayCS; + b_pin = board; + b_family = family; + b_delayCS = delayCS; } void hV_Board::b_reset(uint32_t ms1, uint32_t ms2, uint32_t ms3, uint32_t ms4, uint32_t ms5) { delay(ms1); // delay 5ms - digitalWrite(_pin.panelReset, HIGH); // RES# = 1 + digitalWrite(b_pin.panelReset, HIGH); // RES# = 1 delay(ms2); // delay 5ms - digitalWrite(_pin.panelReset, LOW); + digitalWrite(b_pin.panelReset, LOW); delay(ms3); - digitalWrite(_pin.panelReset, HIGH); + digitalWrite(b_pin.panelReset, HIGH); delay(ms4); - digitalWrite(_pin.panelCS, HIGH); // CS# = 1 + digitalWrite(b_pin.panelCS, HIGH); // CS# = 1 delay(ms5); } -void hV_Board::b_waitBusy() +void hV_Board::b_waitBusy(bool state) { // LOW = busy, HIGH = ready - while (digitalRead(_pin.panelBusy) != HIGH) + while (digitalRead(b_pin.panelBusy) != state) { delay(32); // non-blocking } @@ -66,70 +66,101 @@ void hV_Board::b_sendIndexFixed(uint8_t index, uint8_t data, uint32_t size) void hV_Board::b_sendIndexData(uint8_t index, const uint8_t * data, uint32_t size) { - digitalWrite(_pin.panelDC, LOW); // DC Low - digitalWrite(_pin.panelCS, LOW); // CS Low - if (_family == FAMILY_LARGE) + digitalWrite(b_pin.panelDC, LOW); // DC Low + digitalWrite(b_pin.panelCS, LOW); // CS Low + if (b_family == FAMILY_LARGE) { - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, LOW); + digitalWrite(b_pin.panelCSS, LOW); } delayMicroseconds(450); // 450 + 50 = 500 } - delayMicroseconds(50); + delayMicroseconds(b_delayCS); SPI.transfer(index); - delayMicroseconds(50); - if (_family == FAMILY_LARGE) + delayMicroseconds(b_delayCS); + if (b_family == FAMILY_LARGE) { - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - delayMicroseconds(450); // 450 + 50 = 500 - digitalWrite(_pin.panelCSS, HIGH); + delayMicroseconds(450); // 450 + 50 = 500 + digitalWrite(b_pin.panelCSS, HIGH); } } - digitalWrite(_pin.panelCS, HIGH); // CS High - digitalWrite(_pin.panelDC, HIGH); // DC High - digitalWrite(_pin.panelCS, LOW); // CS Low - if (_family == FAMILY_LARGE) + digitalWrite(b_pin.panelCS, HIGH); // CS High + digitalWrite(b_pin.panelDC, HIGH); // DC High + digitalWrite(b_pin.panelCS, LOW); // CS Low + if (b_family == FAMILY_LARGE) { - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, LOW); // CSS Low + digitalWrite(b_pin.panelCSS, LOW); // CSS Low delayMicroseconds(450); // 450 + 50 = 500 } } - delayMicroseconds(50); + delayMicroseconds(b_delayCS); for (uint32_t i = 0; i < size; i++) { SPI.transfer(data[i]); } - delayMicroseconds(50); - if (_family == FAMILY_LARGE) + delayMicroseconds(b_delayCS); + if (b_family == FAMILY_LARGE) { - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { delayMicroseconds(450); // 450 + 50 = 500 - digitalWrite(_pin.panelCSS, HIGH); + digitalWrite(b_pin.panelCSS, HIGH); } } - digitalWrite(_pin.panelCS, HIGH); // CS High + digitalWrite(b_pin.panelCS, HIGH); // CS High } // Software SPI Master protocol setup +void hV_Board::b_sendIndexDataBoth(uint8_t index, const uint8_t * data, uint32_t size) +{ + digitalWrite(b_pin.panelDC, LOW); // DC Low = Command + digitalWrite(b_pin.panelCS, LOW); // CS Low = Select + if (b_pin.panelCSS != NOT_CONNECTED) + { + digitalWrite(b_pin.panelCSS, LOW); // CS Low = Select + } + + delayMicroseconds(b_delayCS); // Longer delay for large screens + SPI.transfer(index); + delayMicroseconds(b_delayCS); // Longer delay for large screens + + // digitalWrite(b_pin.panelCS, HIGH); // CS High = Unselect + digitalWrite(b_pin.panelDC, HIGH); // DC High = Data + // digitalWrite(b_pin.panelCS, LOW); // CS Low = Select + + delayMicroseconds(b_delayCS); // Longer delay for large screens + for (uint32_t i = 0; i < size; i++) + { + SPI.transfer(data[i]); + } + delayMicroseconds(b_delayCS); // Longer delay for large screens + + digitalWrite(b_pin.panelCS, HIGH); // CS High = Unselect + if (b_pin.panelCSS != NOT_CONNECTED) + { + digitalWrite(b_pin.panelCSS, HIGH); // CS High = Unselect + } +} + void hV_Board::b_sendIndexDataMaster(uint8_t index, const uint8_t * data, uint32_t size) { - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, HIGH); // CS slave HIGH + digitalWrite(b_pin.panelCSS, HIGH); // CS slave HIGH } - digitalWrite(_pin.panelDC, LOW); // DC Low = Command - digitalWrite(_pin.panelCS, LOW); // CS Low = Select + digitalWrite(b_pin.panelDC, LOW); // DC Low = Command + digitalWrite(b_pin.panelCS, LOW); // CS Low = Select delayMicroseconds(500); SPI.transfer(index); delayMicroseconds(500); - digitalWrite(_pin.panelCS, HIGH); // CS High = Unselect - digitalWrite(_pin.panelDC, HIGH); // DC High = Data - digitalWrite(_pin.panelCS, LOW); // CS Low = Select + digitalWrite(b_pin.panelCS, HIGH); // CS High = Unselect + digitalWrite(b_pin.panelDC, HIGH); // DC High = Data + digitalWrite(b_pin.panelCS, LOW); // CS Low = Select delayMicroseconds(500); for (uint32_t i = 0; i < size; i++) @@ -137,33 +168,33 @@ void hV_Board::b_sendIndexDataMaster(uint8_t index, const uint8_t * data, uint32 SPI.transfer(data[i]); } delayMicroseconds(500); - digitalWrite(_pin.panelCS, HIGH); // CS High= Unselect + digitalWrite(b_pin.panelCS, HIGH); // CS High= Unselect } // Software SPI Slave protocol setup void hV_Board::b_sendIndexDataSlave(uint8_t index, const uint8_t * data, uint32_t size) { - digitalWrite(_pin.panelCS, HIGH); // CS Master High - digitalWrite(_pin.panelDC, LOW); // DC Low= Command - if (_pin.panelCSS != NOT_CONNECTED) + digitalWrite(b_pin.panelCS, HIGH); // CS Master High + digitalWrite(b_pin.panelDC, LOW); // DC Low= Command + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, LOW); // CS slave LOW + digitalWrite(b_pin.panelCSS, LOW); // CS slave LOW } delayMicroseconds(500); SPI.transfer(index); delayMicroseconds(500); - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, HIGH); // CS slave HIGH + digitalWrite(b_pin.panelCSS, HIGH); // CS slave HIGH } - digitalWrite(_pin.panelDC, HIGH); // DC High = Data + digitalWrite(b_pin.panelDC, HIGH); // DC High = Data - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, LOW); // CS slave LOW + digitalWrite(b_pin.panelCSS, LOW); // CS slave LOW } delayMicroseconds(500); @@ -173,33 +204,33 @@ void hV_Board::b_sendIndexDataSlave(uint8_t index, const uint8_t * data, uint32_ SPI.transfer(data[i]); } delayMicroseconds(500); - if (_pin.panelCSS != NOT_CONNECTED) + if (b_pin.panelCSS != NOT_CONNECTED) { - digitalWrite(_pin.panelCSS, HIGH); // CS slave HIGH + digitalWrite(b_pin.panelCSS, HIGH); // CS slave HIGH } } void hV_Board::b_sendCommand8(uint8_t command) { - digitalWrite(_pin.panelDC, LOW); - digitalWrite(_pin.panelCS, LOW); + digitalWrite(b_pin.panelDC, LOW); + digitalWrite(b_pin.panelCS, LOW); SPI.transfer(command); - digitalWrite(_pin.panelCS, HIGH); + digitalWrite(b_pin.panelCS, HIGH); } void hV_Board::b_sendCommandData8(uint8_t command, uint8_t data) { - digitalWrite(_pin.panelDC, LOW); // LOW = command - digitalWrite(_pin.panelCS, LOW); + digitalWrite(b_pin.panelDC, LOW); // LOW = command + digitalWrite(b_pin.panelCS, LOW); SPI.transfer(command); - digitalWrite(_pin.panelDC, HIGH); // HIGH = data + digitalWrite(b_pin.panelDC, HIGH); // HIGH = data SPI.transfer(data); - digitalWrite(_pin.panelCS, HIGH); + digitalWrite(b_pin.panelCS, HIGH); } // @@ -207,7 +238,7 @@ void hV_Board::b_sendCommandData8(uint8_t command, uint8_t data) // pins_t hV_Board::getBoardPins() { - return _pin; + return b_pin; } // // === End of Miscellaneous section diff --git a/src/hV_Board.h b/src/hV_Board.h index 263ace4..5f4e763 100755 --- a/src/hV_Board.h +++ b/src/hV_Board.h @@ -34,7 +34,7 @@ // /// /// @brief Class for Pervasive Displays EXT3, EXT3-1 and EXT3-Touch boards -/// @details Functions for EXT3 board +/// @details Functions for EXT3-1 board /// * GPIO /// * SPI for LCD and external Flash and SRAM memory /// * I2C for touch and haptic feedback @@ -96,6 +96,15 @@ class hV_Board /// void b_sendIndexData(uint8_t index, const uint8_t * data, uint32_t size); + /// + /// @brief Send data through SPI to the two halves of large screens + /// @param index register + /// @param data data + /// @param size number of bytes + /// @note Valid only for 9.7 and 12.20" screens + /// + void b_sendIndexDataBoth(uint8_t index, const uint8_t * data, uint32_t size); + /// /// @brief Send data through SPI to first half of large screens /// @param index register @@ -115,9 +124,11 @@ class hV_Board /// /// @brief Wait for ready - /// @details Wait for panelBusy low + /// @details Wait for panelBusy to reach state + /// @note Signal is busy until reaching state + /// @param state to reach HIGH = default, LOW /// - void b_waitBusy(); + void b_waitBusy(bool state = HIGH); /// /// @brief Send a command @@ -144,9 +155,9 @@ class hV_Board /// void b_resume(); - pins_t _pin; - uint16_t _delayCS = 50; // ms - uint8_t _family; + pins_t b_pin; + uint16_t b_delayCS = 50; // ms + uint8_t b_family; /// @endcond }; diff --git a/src/hV_Colours565.cpp b/src/hV_Colours565.cpp index b754162..cc404ce 100755 --- a/src/hV_Colours565.cpp +++ b/src/hV_Colours565.cpp @@ -13,6 +13,9 @@ // // See hV_Colours565.h for references // +// Release 611: Added support for red and yellow colour screens +// Release 700: Refactored screen and board functions +// // Library header #include "hV_Colours565.h" diff --git a/src/hV_Colours565.h b/src/hV_Colours565.h index bff1240..1757125 100755 --- a/src/hV_Colours565.h +++ b/src/hV_Colours565.h @@ -6,8 +6,8 @@ /// @n Based on highView technology /// /// @author Rei Vilo -/// @date 21 Jun 2023 -/// @version 611 +/// @date 21 Sep 2023 +/// @version 700 /// /// @copyright (c) Rei Vilo, 2010-2023 /// @copyright Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) @@ -16,11 +16,14 @@ // SDK #include "hV_HAL_Peripherals.h" +// Configuration +#include "hV_Configuration.h" + #ifndef hV_COLOURS_RELEASE /// /// @brief Library release number /// -#define hV_COLOURS_RELEASE 611 +#define hV_COLOURS_RELEASE 700 /// /// @class hV_Colours565 diff --git a/src/hV_Common.h b/src/hV_Common.h new file mode 100755 index 0000000..48b4cd4 --- /dev/null +++ b/src/hV_Common.h @@ -0,0 +1,50 @@ +/// +/// @file hV_Common.h +/// @brief Shared low-level libraries for the Pervasive Displays Library Suite +/// +/// @details Project Pervasive Displays Library Suite +/// @n Based on highView technology +/// +/// @author Rei Vilo +/// @date 21 Oct 2023 +/// @version 701 +/// +/// @copyright (c) Rei Vilo, 2010-2023 +/// @copyright All rights reserved +/// +/// * Basic edition: for hobbyists and for basic usage +/// @n Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) +/// +/// * Evaluation edition: for professionals or organisations, no commercial usage +/// @n All rights reserved +/// +/// * Commercial edition: for professionals or organisations, commercial usage +/// @n All rights reserved +/// + +#ifndef hV_COMMON_RELEASE +/// +/// @brief Library release number +/// +#define hV_COMMON_RELEASE 701 + +// SDK +#include "hV_HAL_Peripherals.h" + +// Configuration +#include "hV_Configuration.h" +#include "hV_List_Constants.h" +#include "hV_List_Options.h" +#include "hV_List_Boards.h" +#include "hV_List_Screens.h" + +#include "hV_Documentation.h" + +#include "hV_Utilities_Common.h" +#include "hV_Colours565.h" + +// Screen +// #include "hV_Screen_Virtual.h" +// #include "hV_Screen_Buffer.h" + +#endif // hV_COMMON_RELEASE diff --git a/src/hV_Configuration.h b/src/hV_Configuration.h index 0d563e3..30008a3 100755 --- a/src/hV_Configuration.h +++ b/src/hV_Configuration.h @@ -19,8 +19,8 @@ /// * 11. Set storage mode, not implemented /// /// @author Rei Vilo -/// @date 21 Sep 2023 -/// @version 700 +/// @date 21 Oct 2023 +/// @version 701 /// /// @copyright (c) Rei Vilo, 2010-2023 /// @copyright All rights reserved @@ -67,7 +67,7 @@ /// /// @brief Release /// -#define hV_CONFIGURATION_RELEASE 700 +#define hV_CONFIGURATION_RELEASE 701 /// /// @name 1- List of supported Pervasive Displays screens diff --git a/src/hV_Documentation.h b/src/hV_Documentation.h index 554374c..e0d0007 100755 --- a/src/hV_Documentation.h +++ b/src/hV_Documentation.h @@ -41,8 +41,8 @@ /// Additionally, the **[Wiki](https://docs.pervasivedisplays.com/)** provides a gradual introduction to the e-paper technology and how to use it. /// /// @author Rei Vilo -/// @date 21 Sep 2023 -/// @version 700 +/// @date 21 Oct 2023 +/// @version 701 /// /// @copyright © Rei Vilo, 2010-2023 /// @copyright All rights reserved diff --git a/src/hV_Font_Terminal.cpp b/src/hV_Font_Terminal.cpp index e2e4a9d..4b1957d 100755 --- a/src/hV_Font_Terminal.cpp +++ b/src/hV_Font_Terminal.cpp @@ -21,7 +21,7 @@ // #include "hV_Font_Terminal.h" -//#include "hV_Utilities.h" +//#include "hV_Utilities_Common.h" // The Arduino IDE doesn't allow to select the libraries, hence this condition. #if (FONT_MODE == USE_FONT_TERMINAL) diff --git a/src/hV_Font_Terminal.h b/src/hV_Font_Terminal.h index 7b2b4df..5fc2d88 100755 --- a/src/hV_Font_Terminal.h +++ b/src/hV_Font_Terminal.h @@ -40,7 +40,7 @@ /// #define hV_FONT_TERMINAL_RELEASE 507 -#include "hV_Utilities.h" +#include "hV_Utilities_Common.h" #include "hV_Font.h" /// diff --git a/src/hV_HAL_Peripherals.h b/src/hV_HAL_Peripherals.h index 4de7157..3deae1a 100755 --- a/src/hV_HAL_Peripherals.h +++ b/src/hV_HAL_Peripherals.h @@ -34,11 +34,13 @@ /// * Arduino SDK https://www.arduino.cc/reference/en/ /// * Energia SDK https://energia.nu/reference/ /// -#if defined(ENERGIA) // LaunchPad specific -#include "Energia.h" -#else // Arduino general -#include "Arduino.h" -#endif // SDK +#include + +/// +/// @brief SDK other libraries +/// +#include +#include /// /// @brief Other libraries @@ -47,7 +49,4 @@ #include #include -#include "SPI.h" -#include "Wire.h" - -#endif // hV_HAL_PERIPHERALS_RELEASE \ No newline at end of file +#endif // hV_HAL_PERIPHERALS_RELEASE diff --git a/src/hV_List_Boards.h b/src/hV_List_Boards.h index adea26d..9476ead 100755 --- a/src/hV_List_Boards.h +++ b/src/hV_List_Boards.h @@ -5,6 +5,9 @@ /// @details Project Pervasive Displays Library Suite /// @n Based on highView technology /// +/// @n Content +/// * 2- List of pre-configured boards +/// /// @author Rei Vilo /// @date 21 Sep 2023 /// @version 700 @@ -149,7 +152,7 @@ const pins_t boardESP32DevKitC = /// /// @name Other boards /// @{ - + /// /// @brief Texas Instruments LaunchPad MSP430 and MSP432 LaunchPad configuration, tested /// @@ -210,6 +213,7 @@ const pins_t boardCC1352 = /// /// @brief Raspberry Pi Zero, 2B, 3B, 4B configuration with RasPiArduino, tested /// @warning Not recommended +/// @deprecated Use boardRaspberryPiZeroB_MRAA instead (7.0.0) /// @see https://github.com/me-no-dev/RasPiArduino /// const pins_t boardRaspberryPiZeroB_RasPiArduino = @@ -231,6 +235,7 @@ const pins_t boardRaspberryPiZeroB_RasPiArduino = /// /// @brief Raspberry Pi Pico Arduino mbed configuration, tested /// @warning Not recommended +/// @deprecated Use boardRaspberryPiPico_RP2040 instead (7.0.0) /// @see https://github.com/arduino/ArduinoCore-mbed /// const pins_t boardRaspberryPiPico_Arduino = diff --git a/src/hV_List_Constants.h b/src/hV_List_Constants.h index 16cc155..3f8421a 100755 --- a/src/hV_List_Constants.h +++ b/src/hV_List_Constants.h @@ -52,12 +52,12 @@ /// /// @brief Update mode /// @note Numbers are sequential and exclusive -/// @deprecated Partial update is removed. Use fast update instead (7.0.0). +/// @deprecated Partial update is removed. Use fast update instead (7.0.0). /// @{ #define UPDATE_NONE 0x00 ///< No update #define UPDATE_GLOBAL 0x01 ///< Global update, default #define UPDATE_FAST 0x02 ///< Fast update -#define UPDATE_PARTIAL 0x03 ///< Partial update +#define UPDATE_PARTIAL 0x03 ///< Partial update, deprecated /// @} /// @@ -131,6 +131,7 @@ /// /// @brief Orientation constants +/// @note Numbers are sequential and exclusive /// @{ /// #define ORIENTATION_PORTRAIT 6 ///< Portrait or vertical, higher than large diff --git a/src/hV_List_Options.h b/src/hV_List_Options.h new file mode 100755 index 0000000..aa71bcb --- /dev/null +++ b/src/hV_List_Options.h @@ -0,0 +1,185 @@ +/// +/// @file hV_List_Options.h +/// @brief List of options for Pervasive Displays Library Suite +/// +/// @details Project Pervasive Displays Library Suite +/// @n Based on highView technology +/// +/// @n Content +/// * 3- Font mode, internal MCU or external SPI Flash +/// * 4- Maximum number of fonts +/// * 5- SRAM memory, internal MCU or external SPI +/// * 6- Use self or virtual object +/// * 7- Touch mode, activated or not +/// * 8- Haptic feedback mode, activated or not +/// * 9. Set GPIO expander mode, not implemented +/// * 10. String object of char array options for string. +/// * 11. Set storage mode, serial console by default +/// +/// @author Rei Vilo +/// @date 21 Oct 2023 +/// @version 701 +/// +/// @copyright (c) Rei Vilo, 2010-2023 +/// @copyright All rights reserved +/// +/// * Basic edition: for hobbyists and for basic usage +/// @n Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) +/// +/// * Evaluation edition: for professionals or organisations, evaluation only, no commercial usage +/// @n All rights reserved +/// +/// * Commercial edition: for professionals or organisations, commercial usage +/// @n All rights reserved +/// + +#ifndef hV_LIST_OPTIONS_RELEASE +/// +/// @brief Release +/// +#define hV_LIST_OPTIONS_RELEASE 701 + +/// +/// @name 3- Set font mode +/// @details From header files or from external flash +/// * Basic edition: Terminal font +/// * Evaluation edition: DejaVu font as header +/// * Commercial edition: DejaVu font as either header or external SPI Flash +/// @note USE_FONT_HEADER requires addFont() +/// @note Font Manager requires USE_FONT_HEADER +/// @warning 8- and 16-bit MCUs may limit the size of the fonts. Use 32-bit MCUs for optimal performance. +/// +/// @{ +#define USE_FONT_TERMINAL 1 ///< Use default Terminal fonts +#define USE_FONT_HEADER 2 ///< Use fonts from header files +#define USE_FONT_FLASH 3 ///< Use fonts from external SPI Flash memory +#define USE_FONT_INTERNAL 4 ///< Use fonts from internal CGU + +#define FONT_MODE USE_FONT_HEADER ///< Selected option +/// @} + +/// +/// @brief 4- Maximum number of fonts +/// @details With MCU Flash, based on available memory, check performed at compilation +/// * USE_FONT_TERMINAL: 1..4 +/// * USE_FONT_HEADER: 1..64 +/// +/// With SPI Flash, based on the fonts previously uploaded +/// * USE_FONT_FLASH: eg. 64 +/// +#if (FONT_MODE == USE_FONT_TERMINAL) +#define MAX_FONT_SIZE 4 +#else +#define MAX_FONT_SIZE 64 +#endif + +/// +/// @name 5- Set SRAM memory +/// @details From internal MCU or external SPI +/// * Basic edition: MCU internal SRAM +/// * Commercial edition: MCU internal SRAM +/// * Evaluation edition: MCU internal or SPI external SRAM +/// +/// @{ +#define USE_INTERNAL_MCU 1 ///< Use MCU internal +#define USE_EXTERNAL_SPI 2 ///< Use SPI External + +#define SRAM_MODE USE_INTERNAL_MCU ///< Selected option +/// @} + +/// +/// @name 6- Use virtual object +/// @details From hV_Screen_Virtual.h for extended compability +/// @note Declare additional variables if USE_hV_SCREEN_SELF +/// @n Virtual object requires ~1 kB bytes. +/// * Basic edition: self option +/// * Evaluation edition: virtual option +/// * Commercial edition: self and virtual options +/// @note Recommended: USE_hV_SCREEN_VIRTUAL +/// @warning Issues with virtual function on arm-none-eabi-g++ 4.9.3: use USE_hV_SCREEN_SELF instead. +/// @{ +#define USE_hV_SCREEN_VIRTUAL 1 ///< Use virtual object +#define USE_hV_SCREEN_SELF 2 ///< Do not use virtual object + +#define USE_hV_SCREEN USE_hV_SCREEN_VIRTUAL ///< Selected option +/// @} + +/// +/// @name 7- Set touch mode +/// @details Only two screens are ready for touch +/// * Basic edition: iTC 2.71 BW and iTC 3.70 BW +/// * Evaluation edition: iTC 2.71 BW and iTC 3.70 BW +/// * Commercial edition: iTC 2.71 BW and iTC 3.70 BW +/// @note Touch uses I2C and polling over interrupt +/// @{ +#define USE_TOUCH_NONE 0 ///< Do not use touch +#define USE_TOUCH_YES 1 ///< Use touch + +#define TOUCH_MODE USE_TOUCH_YES ///< Selected option +/// @} + +/// +/// @brief 8- Set haptic feedback mode +/// * Basic edition: no haptic feedback +/// * Evaluation edition: ERM or LRA +/// * Commercial edition: ERM or LRA +/// +/// @{ +#define USE_HAPTICS_NONE 0 ///< No motor +#define USE_DRV2605L_ERM 1 ///< DRV2605L with ERM = eccentric rotating mass +#define USE_DRV2605L_LRA 2 ///< DRV2605L with LRA = linear resonant actuator + +#define HAPTICS_MODE USE_HAPTICS_NONE ///< Selected option +/// @} + +/// +/// @brief 9- Set GPIO expander mode +/// * Basic edition: no expander +/// * Evaluation edition: PCF8574 or PCA9536 +/// * Commercial edition: PCF8574 or PCA9536 +/// +/// @{ +#define USE_EXPANDER_NONE 0 ///< No I2C expander +#define USE_I2C_PCF8574 1 ///< PCF8574 8 ports GPIO I2C 100 kHz expander +#define USE_I2C_PCA9536 2 ///< PCA9536 4 ports GPIO I2C 400 kHz expander +#define USE_I2C_TCA6408 3 ///< TCA6408 8 ports GPIO I2C 400 kHz expander + +#define EXPANDER_MODE USE_EXPANDER_NONE ///< Selected option +/// @} + +/// +/// @brief 10- Set string mode +/// * Basic edition: String object +/// * Evaluation edition: char array +/// * Commercial edition: String object or char array +/// +/// @{ +#define USE_STRING_OBJECT 1 +#define USE_CHAR_ARRAY 2 + +#define STRING_MODE USE_CHAR_ARRAY +/// @} + +/// +/// @brief 11- Storage mode +/// * Basic edition: none +/// * Evaluation edition: none +/// * Commercial edition: option +/// +/// @note Options can be combined +/// @code {.cpp} +/// #define STORAGE_MODE (USE_SD_CARD | USE_SPI_FLASH) +/// #define STORAGE_MODE (USE_LINUX_FILES | USE_SERIAL_CONSOLE) +/// @endcode +/// +/// @{ +#define USE_NONE 0 ///< No storage +#define USE_SD_CARD 1 ///< SD card +#define USE_SPI_FLASH 2 ///< External SPI Flash +#define USE_SERIAL_CONSOLE 4 ///< Serial console for writing only +#define USE_LINUX_FILES 8 ///< For Linux native applications + +#define STORAGE_MODE USE_SERIAL_CONSOLE ///< Selected options +/// @} + +#endif // hV_LIST_OPTIONS_RELEASE diff --git a/src/hV_List_Screens.h b/src/hV_List_Screens.h old mode 100644 new mode 100755 index 98deeed..acc31de --- a/src/hV_List_Screens.h +++ b/src/hV_List_Screens.h @@ -6,6 +6,9 @@ /// @details Project Pervasive Displays Library Suite /// @n Based on highView technology /// +/// @n Content +/// * 1- List of supported Pervasive Displays screens +/// /// @author Rei Vilo /// @date 21 Sep 2023 /// @version 700 @@ -60,7 +63,7 @@ /// @} /// -/// @name Colour black-white-red screens +/// @name Colour black-white-red Spectra screens /// @note Global update mode /// @see https://www.pervasivedisplays.com/products/?_sft_etc_itc=itc&_sft_product_colour=black-white-red /// @{ @@ -82,7 +85,7 @@ /// @} /// -/// @name Colour black-white-red-yellow screens +/// @name Colour black-white-red-yellow Spectra 4 screens /// @note Global update mode /// @see https://www.pervasivedisplays.com/products/?_sft_etc_itc=itc&_sft_product_colour=black-white-red-yellow /// @{ @@ -95,7 +98,7 @@ /// /// @name Monochrome touch screens with embedded fast update /// @note Global and fast update modes -/// @deprecated Partial update is removed. Use fast update instead (7.0.0). +/// @deprecated Partial update is removed. Use fast update instead (7.0.0). /// @see https://www.pervasivedisplays.com/products /// @{ /// @@ -142,6 +145,7 @@ #define eScreen_EPD_EXT3_271_09_Wide (uint32_t)0x092709 ///< reference xE2271KS09x /// @todo eScreen_EPD_EXT3_287_09_Wide not tested #define eScreen_EPD_EXT3_287_09_Wide (uint32_t)0x092809 ///< reference xE2287PS09x, not tested +#define eScreen_EPD_EXT3_290_0F_Wide (uint32_t)0x09290F ///< reference xE2290KS0Fx #define eScreen_EPD_EXT3_370_0C_Wide (uint32_t)0x09370C ///< reference xE2370KS0Cx #define eScreen_EPD_EXT3_417_0D_Wide (uint32_t)0x09410D ///< reference xE2417KS0Dx /// @todo eScreen_EPD_EXT3_437_0C_Wide not tested @@ -157,10 +161,10 @@ /// /// @name Frame-buffer sizes -/// @details +/// @details /// * Black-white-red screens and monochrome screens /// @n Frame-buffer size = width * height / 8 * depth, uint32_t -/// @n Depth = 2 +/// @n Depth = 2 /// * Black-white-red_yellow screens /// @n Frame-buffer size = width * height / 4 * depth, uint32_t /// @n Depth = 1 diff --git a/src/hV_Screen_Buffer.cpp b/src/hV_Screen_Buffer.cpp index f996b28..0344777 100755 --- a/src/hV_Screen_Buffer.cpp +++ b/src/hV_Screen_Buffer.cpp @@ -16,6 +16,7 @@ // Release 520: Added use of hV_HAL_Peripherals // Release 523: Fixed rounded rectangles // Release 526: Improved touch management +// Release 700: Refactored screen and board functions // // Library header diff --git a/src/hV_Screen_Buffer.h b/src/hV_Screen_Buffer.h index 3715388..530aff4 100755 --- a/src/hV_Screen_Buffer.h +++ b/src/hV_Screen_Buffer.h @@ -36,7 +36,9 @@ // Other libraries #include "hV_Colours565.h" -#include "hV_Utilities.h" + +// Common utilities +#include "hV_Utilities_Common.h" #if (FONT_MODE == USE_FONT_TERMINAL) #include "hV_Font_Terminal.h" @@ -93,6 +95,7 @@ class hV_Screen_Buffer : protected hV_Font_Terminal /// * 3 = left rotated /// * ORIENTATION_PORTRAIT = 6 = check portrait /// * ORIENTATION_LANDSCAPE = 7 = check landscape + /// @note Run the Common_Orientation.ino example to identify the options /// virtual void setOrientation(uint8_t orientation); diff --git a/src/hV_Utilities.cpp b/src/hV_Utilities_Common.cpp similarity index 98% rename from src/hV_Utilities.cpp rename to src/hV_Utilities_Common.cpp index 5c643b6..e58b649 100755 --- a/src/hV_Utilities.cpp +++ b/src/hV_Utilities_Common.cpp @@ -1,5 +1,5 @@ // -// hV_Utilities.cpp +// hV_Utilities_Common.cpp // Library C++ code // ---------------------------------- // @@ -10,13 +10,13 @@ // Copyright (c) Rei Vilo, 2010-2023 // Licence Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) // -// See hV_Utilities.h for references +// See hV_Utilities_Common.h for references // // Release 700: Refactored screen and board functions // // Library header -#include "hV_Utilities.h" +#include "hV_Utilities_Common.h" #include "stdarg.h" #include "stdio.h" diff --git a/src/hV_Utilities.h b/src/hV_Utilities_Common.h similarity index 98% rename from src/hV_Utilities.h rename to src/hV_Utilities_Common.h index de3b4ab..5dca950 100755 --- a/src/hV_Utilities.h +++ b/src/hV_Utilities_Common.h @@ -1,13 +1,13 @@ /// -/// @file hV_Utilities.h +/// @file hV_Utilities_Common.h /// @brief Utilities for highView Library Suite /// /// @details Project Pervasive Displays Library Suite /// @n Based on highView technology /// /// @author Rei Vilo -/// @date 21 Sep 2023 -/// @version 700 +/// @date 21 Oct 2023 +/// @version 701 /// /// @copyright (c) Rei Vilo, 2010-2023 /// @copyright Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) @@ -29,7 +29,7 @@ /// /// @brief Library release number /// -#define hV_UTILITIES_RELEASE 700 +#define hV_UTILITIES_RELEASE 701 #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) diff --git a/src/hV_Utilities_EPD.cpp b/src/hV_Utilities_PDLS.cpp similarity index 72% rename from src/hV_Utilities_EPD.cpp rename to src/hV_Utilities_PDLS.cpp index ba100fc..32b5fd9 100755 --- a/src/hV_Utilities_EPD.cpp +++ b/src/hV_Utilities_PDLS.cpp @@ -1,5 +1,5 @@ // -// hV_Utilities_EPD.cpp +// hV_Utilities_PDLS.cpp // Library C++ code // ---------------------------------- // @@ -13,46 +13,46 @@ // // Library header -#include "hV_Utilities_EPD.h" +#include "hV_Utilities_PDLS.h" -hV_Utilities_EPD::hV_Utilities_EPD() +hV_Utilities_PDLS::hV_Utilities_PDLS() { ; } -void hV_Utilities_EPD::u_begin(pins_t board, uint8_t family, uint16_t delayCS) +void hV_Utilities_PDLS::u_begin(pins_t board, uint8_t family, uint16_t delayCS) { b_begin(board, family, delayCS); } -void hV_Utilities_EPD::u_WhoAmI(char * answer) +void hV_Utilities_PDLS::u_WhoAmI(char * answer) { memcpy(answer, 0x00, strlen(answer)); - if (_codeExtra > 0) + if (u_codeExtra > 0) { strcat(answer, "-"); - if (_codeExtra & FEATURE_FAST) + if (u_codeExtra & FEATURE_FAST) { strcat(answer, "F"); } - if (_codeExtra & FEATURE_TOUCH) + if (u_codeExtra & FEATURE_TOUCH) { strcat(answer, "T"); } - if (_codeExtra & FEATURE_OTHER) + if (u_codeExtra & FEATURE_OTHER) { strcat(answer, "b"); } - if (_codeExtra & FEATURE_WIDE_TEMPERATURE) + if (u_codeExtra & FEATURE_WIDE_TEMPERATURE) { strcat(answer, "W"); } - if (_codeExtra & FEATURE_RED) + if (u_codeExtra & FEATURE_RED) { strcat(answer, "BWR"); } - if (_codeExtra & FEATURE_RED_YELLOW) + if (u_codeExtra & FEATURE_RED_YELLOW) { strcat(answer, "BWRY"); } @@ -80,38 +80,38 @@ void hV_Utilities_EPD::u_WhoAmI(char * answer) #endif // FONT_MODE } -void hV_Utilities_EPD::invert(bool flag) +void hV_Utilities_PDLS::invert(bool flag) { - _invert = flag; + u_invert = flag; } // // === Temperature section // -void hV_Utilities_EPD::setTemperatureC(int8_t temperatureC) +void hV_Utilities_PDLS::setTemperatureC(int8_t temperatureC) { - _temperature = temperatureC; + u_temperature = temperatureC; - // uint8_t _temperature2; - // if (_temperature < 0) + // uint8_t u_temperature2; + // if (u_temperature < 0) // { - // _temperature2 = -_temperature; - // _temperature2 = (uint8_t)(~_temperature2) + 1; // 2's complement + // u_temperature2 = -u_temperature; + // u_temperature2 = (uint8_t)(~_temperature2) + 1; // 2's complement // } // else // { - // _temperature2 = _temperature; + // u_temperature2 = u_temperature; // } - // indexE5_data[0] = _temperature2; + // indexE5_data[0] = u_temperature2; } -void hV_Utilities_EPD::setTemperatureF(int16_t temperatureF) +void hV_Utilities_PDLS::setTemperatureF(int16_t temperatureF) { int8_t temperatureC = ((temperatureF - 32) * 5) / 9; // C = (F - 32) * 5 / 9 setTemperatureC(temperatureC); } -uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) +uint8_t hV_Utilities_PDLS::checkTemperatureMode(uint8_t updateMode) { // #define FEATURE_FAST 0x01 ///< With embedded fast update // #define FEATURE_TOUCH 0x02 ///< With capacitive touch panel @@ -124,21 +124,21 @@ uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) // #define FEATURE_BWRY 0x20 ///< With red and yellow colours // #define FEATURE_HIGH_DEFINITION 0x40 ///< With high definition - switch (_codeExtra & 0x19) + switch (u_codeExtra & 0x19) { case FEATURE_FAST: // PS series // Fast PS Embedded fast update FU: +15 to +30 °C GU: 0 to +50 °C if (updateMode == UPDATE_FAST) // Fast update { - if ((_temperature < 15) or (_temperature > 30)) + if ((u_temperature < 15) or (u_temperature > 30)) { updateMode = UPDATE_GLOBAL; } } if (updateMode == UPDATE_GLOBAL) // Global update { - if ((_temperature < 0) or (_temperature > 50)) + if ((u_temperature < 0) or (u_temperature > 50)) { updateMode = UPDATE_NONE; } @@ -150,14 +150,14 @@ uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) // Wide KS Wide temperature and embedded fast update FU: 0 to +50 °C GU: -15 to +60 °C if (updateMode == UPDATE_FAST) // Fast update { - if ((_temperature < 0) or (_temperature > 50)) + if ((u_temperature < 0) or (u_temperature > 50)) { updateMode = UPDATE_GLOBAL; } } if (updateMode == UPDATE_GLOBAL) // Global update { - if ((_temperature < -15) or (_temperature > 60)) + if ((u_temperature < -15) or (u_temperature > 60)) { updateMode = UPDATE_NONE; } @@ -168,7 +168,7 @@ uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) // Freezer HS Global update below 0 °C FU: - GU: -25 to +30 °C updateMode = UPDATE_GLOBAL; - if ((_temperature < -25) or (_temperature > 30)) + if ((u_temperature < -25) or (u_temperature > 30)) { updateMode = UPDATE_NONE; } @@ -181,7 +181,7 @@ uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) // BWR JS Red colour FU: - GU: 0 to +40 °C // BWRY QS Red and yellow colours FU: - GU: 0 to +40 °C - if ((_temperature < 0) or (_temperature > 40)) + if ((u_temperature < 0) or (u_temperature > 40)) { updateMode = UPDATE_NONE; } @@ -191,7 +191,7 @@ uint8_t hV_Utilities_EPD::checkTemperatureMode(uint8_t updateMode) // Normal CS Global update above 0 °C FU: - GU: 0 to +50 °C updateMode = UPDATE_GLOBAL; - if ((_temperature < 0) or (_temperature > 50)) + if ((u_temperature < 0) or (u_temperature > 50)) { updateMode = UPDATE_NONE; } diff --git a/src/hV_Utilities_EPD.h b/src/hV_Utilities_PDLS.h similarity index 79% rename from src/hV_Utilities_EPD.h rename to src/hV_Utilities_PDLS.h index ec456fa..c796d3f 100755 --- a/src/hV_Utilities_EPD.h +++ b/src/hV_Utilities_PDLS.h @@ -1,5 +1,5 @@ /// -/// @file hV_Utilities_EPD.h +/// @file hV_Utilities_PDLS.h /// @brief Driver for Pervasive Displays EXT3, EXT3-1 and EXT3-Touch boards /// /// @details Project Pervasive Displays Library Suite @@ -28,9 +28,13 @@ #include "hV_Board.h" // Utilities -#include "hV_Utilities.h" +#include "hV_Utilities_Common.h" // Checks +#if (hV_HAL_PERIPHERALS_RELEASE < 700) +#error Required hV_HAL_PERIPHERALS_RELEASE 700 +#endif // hV_HAL_PERIPHERALS_RELEASE + #if (hV_CONFIGURATION_RELEASE < 700) #error Required hV_CONFIGURATION_RELEASE 700 #endif // hV_CONFIGURATION_RELEASE @@ -39,11 +43,11 @@ #error Required hV_BOARD_RELEASE 700 #endif // hV_BOARD_RELEASE -#ifndef hV_UTILITIES_EPD_RELEASE +#ifndef hV_UTILITIES_PDLS_RELEASE /// /// @brief Library release number /// -#define hV_UTILITIES_EPD_RELEASE 700 +#define hV_UTILITIES_PDLS_RELEASE 700 // Objects // @@ -51,10 +55,10 @@ /// @brief Class for Pervasive Displays e-paper displays /// @details Shared common functions and variables /// -class hV_Utilities_EPD : public hV_Board +class hV_Utilities_PDLS : public hV_Board { public: - hV_Utilities_EPD(); + hV_Utilities_PDLS(); /// /// @brief Set temperature in Celsius @@ -106,24 +110,24 @@ class hV_Utilities_EPD : public hV_Board // Screen dependent variables #if (SRAM_MODE == USE_INTERNAL_MCU) - uint8_t * _newImage; + uint8_t * u_newImage; #elif (SRAM_MODE == USE_EXTERNAL_SPI) - uint32_t _newImage; + uint32_t u_newImage; #endif // SRAM_MODE - eScreen_EPD_EXT3_t _eScreen_EPD_EXT3; - int8_t _temperature = 25; - uint8_t _codeExtra; - uint8_t _codeSize; - uint8_t _codeType; - uint16_t _bufferSizeV, _bufferSizeH, _bufferDepth; - uint32_t _pageColourSize, _frameSize; - bool _invert = false; + eScreen_EPD_EXT3_t u_eScreen_EPD_EXT3; + int8_t u_temperature = 25; + uint8_t u_codeExtra; + uint8_t u_codeSize; + uint8_t u_codeType; + uint16_t u_bufferSizeV, u_bufferSizeH, u_bufferDepth; + uint32_t u_pageColourSize, u_frameSize; + bool u_invert = false; /// @endcond }; -#endif // hV_UTILITIES_EPD_RELEASE +#endif // hV_UTILITIES_PDLS_RELEASE