Skip to content

Commit

Permalink
Release 8.0.4
Browse files Browse the repository at this point in the history
Added power management
  • Loading branch information
rei-vilo committed Jul 18, 2024
1 parent e342505 commit fd9d5a5
Show file tree
Hide file tree
Showing 14 changed files with 340 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
// Define structures and classes

// Define variables and constants
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_PS_09_Fast, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_PS_09_Wide, boardRaspberryPiPico_RP2040);
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_PS_09, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_KS_09, boardRaspberryPiPico_RP2040);

// Prototypes

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PDLS_EXT3_Basic_Fast
version=8.0.3
version=8.0.4
author=Rei Vilo for Pervasive Displays
maintainer=Rei Vilo
sentence=Library for Pervasive Displays iTC monochrome screens with embedded fast update and EXT3-1 board
Expand Down
193 changes: 110 additions & 83 deletions src/Screen_EPD_EXT3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// Release 802: Added references to application notes
// Release 802: Refactored CoG functions
// Release 803: Added types for string and frame-buffer
// Release 804: Improved power management
//

// Library header
Expand Down Expand Up @@ -464,7 +465,26 @@ void Screen_EPD_EXT3_Fast::COG_MediumKP_powerOff()
void Screen_EPD_EXT3_Fast::COG_SmallKP_reset()
{
// Application note § 2. Power on COG driver
b_reset(5, 5, 10, 5, 5); // small
b_reset(5, 5, 10, 5, 5); // Small

// Check after reset
switch (u_eScreen_EPD)
{
case eScreen_EPD_150_KS_0J:
case eScreen_EPD_152_KS_0J:

if (digitalRead(b_pin.panelBusy) == HIGH)
{
mySerial.println();
mySerial.println("hV * Incorrect type for 1.52-Wide");
while (0x01);
}
break;

default:

break;
}
}

void Screen_EPD_EXT3_Fast::COG_SmallKP_getDataOTP()
Expand Down Expand Up @@ -873,13 +893,27 @@ void Screen_EPD_EXT3_Fast::begin()
break;
}

//
// === Touch section
//

//
// === End of touch section
//

//
// === Large screen section
//
// Check panelCSS for large screens
if (((u_codeSize == SIZE_969) or (u_codeSize == SIZE_1198)) and (b_pin.panelCSS == NOT_CONNECTED))
{
mySerial.println();
mySerial.println("hV * Required pin panelCSS is NOT_CONNECTED");
while (0x01);
}
//
// === End of Large screen section
//

// Configure board
switch (u_codeSize)
Expand All @@ -903,6 +937,14 @@ void Screen_EPD_EXT3_Fast::begin()
break;
}

//
// === Touch section
//

//
// === End of touch section
//

// Sizes
switch (u_codeSize)
{
Expand Down Expand Up @@ -1061,6 +1103,10 @@ void Screen_EPD_EXT3_Fast::begin()

memset(s_newImage, 0x00, u_pageColourSize * u_bufferDepth);

setTemperatureC(25); // 25 Celsius = 77 Fahrenheit
b_fsmPowerScreen = FSM_OFF;
setPowerProfile(MODE_MANUAL, SCOPE_GPIO_ONLY);

// Turn SPI on, initialise GPIOs and set GPIO levels
// Reset panel and get tables
resume();
Expand All @@ -1080,10 +1126,13 @@ void Screen_EPD_EXT3_Fast::begin()
v_penSolid = false;
u_invert = false;

setTemperatureC(25); // 25 Celsius = 77 Fahrenheit
//
// === Touch section
//

// Turn SPI off and pull GPIOs low
suspend();
//
// === End of Touch section
//
}

STRING_TYPE Screen_EPD_EXT3_Fast::WhoAmI()
Expand All @@ -1094,62 +1143,61 @@ STRING_TYPE Screen_EPD_EXT3_Fast::WhoAmI()
return formatString("iTC %i.%02i\"%s", v_screenDiagonal / 100, v_screenDiagonal % 100, work);
}

void Screen_EPD_EXT3_Fast::suspend()
void Screen_EPD_EXT3_Fast::suspend(uint8_t suspendScope)
{
// Suspend GPIO
b_suspend();

// Suspend SPI
hV_HAL_SPI_end();
if (((suspendScope & FSM_GPIO_MASK) == FSM_GPIO_MASK) and (b_pin.panelPower != NOT_CONNECTED))
{
if ((b_fsmPowerScreen & FSM_GPIO_MASK) == FSM_GPIO_MASK)
{
b_suspend();
}
}
}

void Screen_EPD_EXT3_Fast::resume()
{
// Resume GPIO
b_resume();

// Check type and get tables
if (u_flagOTP == false)
// Target FSM_ON
// Source FSM_OFF
// FSM_SLEEP
if (b_fsmPowerScreen != FSM_ON)
{
hV_HAL_SPI3_begin(); // Define 3-wire SPI pins
s_getDataOTP(); // 3-wire SPI read OTP memory
}
if ((b_fsmPowerScreen & FSM_GPIO_MASK) != FSM_GPIO_MASK)
{
b_resume(); // GPIO

// Reset
s_reset();
s_reset(); // Reset

// Check after reset
switch (u_eScreen_EPD)
{
case eScreen_EPD_150_KS_0J:
case eScreen_EPD_152_KS_0J:
b_fsmPowerScreen |= FSM_GPIO_MASK;
}

if (digitalRead(b_pin.panelBusy) == HIGH)
{
mySerial.println();
mySerial.println("hV * Incorrect type for 1.52-Wide");
while (0x01);
}
break;
// Check type and get tables
if (u_flagOTP == false)
{
s_getDataOTP(); // 3-wire SPI read OTP memory

default:
s_reset(); // Reset
}

break;
}
// Start SPI
switch (u_eScreen_EPD)
{
case eScreen_EPD_150_KS_0J:
case eScreen_EPD_152_KS_0J:

// Start SPI
switch (u_eScreen_EPD)
{
case eScreen_EPD_150_KS_0J:
case eScreen_EPD_152_KS_0J:
hV_HAL_SPI_begin(16000000); // 1.52" tested with 4, 8, 16 and 32 MHz, with unicity check
break;

hV_HAL_SPI_begin(16000000); // 1.52" tested with 4, 8, 16 and 32 MHz
break;
case eScreen_EPD_206_KS_0E:
case eScreen_EPD_290_KS_0F:

default:
hV_HAL_SPI_begin(16000000); // 2.06" tested with 4, 8 and 16 MHz, with unicity check
break;

hV_HAL_SPI_begin(); // Standard 8 MHz
break;
default:

hV_HAL_SPI_begin(); // Standard 8 MHz, with unicity check
break;
}
}
}

Expand All @@ -1175,7 +1223,11 @@ void Screen_EPD_EXT3_Fast::s_reset()

void Screen_EPD_EXT3_Fast::s_getDataOTP()
{
uint16_t _readBytes = 0;
hV_HAL_SPI_end(); // With unicity check

hV_HAL_SPI3_begin(); // Define 3-wire SPI pins

// Get data OTP
switch (b_family)
{
case FAMILY_MEDIUM:
Expand All @@ -1196,8 +1248,11 @@ void Screen_EPD_EXT3_Fast::s_getDataOTP()

void Screen_EPD_EXT3_Fast::s_flush(uint8_t updateMode)
{
// Turn SPI on, initialise GPIOs and set GPIO levels
resume();
// Resume
if (b_fsmPowerScreen != FSM_ON)
{
resume();
}

switch (b_family)
{
Expand All @@ -1222,8 +1277,11 @@ void Screen_EPD_EXT3_Fast::s_flush(uint8_t updateMode)
break;
}

// Turn SPI off and pull GPIOs low
suspend();
// Suspend
if (u_suspendMode == MODE_AUTO)
{
suspend(u_suspendScope);
}
}

uint8_t Screen_EPD_EXT3_Fast::flushMode(uint8_t updateMode)
Expand Down Expand Up @@ -1337,7 +1395,7 @@ void Screen_EPD_EXT3_Fast::s_setOrientation(uint8_t orientation)

bool Screen_EPD_EXT3_Fast::s_orientCoordinates(uint16_t & x, uint16_t & y)
{
bool _flagResult = RESULT_ERROR; // false = success, true = error
bool _flagResult = RESULT_ERROR;
switch (v_orientation)
{
case 3: // checked, previously 1
Expand Down Expand Up @@ -1419,38 +1477,7 @@ uint16_t Screen_EPD_EXT3_Fast::s_getB(uint16_t x1, uint16_t y1)

uint16_t Screen_EPD_EXT3_Fast::s_getPoint(uint16_t x1, uint16_t y1)
{
// Orient and check coordinates are within screen
if (s_orientCoordinates(x1, y1) == RESULT_ERROR)
{
return 0x0000;
}

uint16_t _result = 0;
uint8_t _value = 0;

// Coordinates
uint32_t z1 = s_getZ(x1, y1);
uint16_t b1 = s_getB(x1, y1);

_value = bitRead(s_newImage[z1], b1);
_value <<= 4;
_value &= 0b11110000;

// red = 0-1, black = 1-0, white 0-0
switch (_value)
{
case 0x10:

_result = myColours.black;
break;

default:

_result = myColours.white;
break;
}

return _result;
return 0x0000;
}
//
// === End of Class section
Expand Down
12 changes: 7 additions & 5 deletions src/Screen_EPD_EXT3.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/// * 4.37 reference xE2437PS0Cx
///
/// @author Rei Vilo
/// @date 21 May 2024
/// @version 803
/// @date 21 Jul 2024
/// @version 804
///
/// @copyright (c) Rei Vilo, 2010-2024
/// @copyright All rights reserved
Expand Down Expand Up @@ -89,7 +89,7 @@
///
/// @brief Library release number
///
#define SCREEN_EPD_EXT3_RELEASE 803
#define SCREEN_EPD_EXT3_RELEASE 804

///
/// @brief Library variant
Expand Down Expand Up @@ -136,9 +136,11 @@ class Screen_EPD_EXT3_Fast final : public hV_Screen_Buffer, public hV_Utilities_

///
/// @brief Suspend
/// @details Turn SPI off and set all GPIOs low
/// @param suspendScope default = SCOPE_GPIO_ONLY, otherwise SCOPE_NONE
/// @details Power off and set all GPIOs low
/// @note If panelPower is NOT_CONNECTED, SCOPE_GPIO_ONLY defaults to SCOPE_NONE
///
void suspend();
void suspend(uint8_t suspendScope = SCOPE_GPIO_ONLY);

///
/// @brief Resume after suspend()
Expand Down
Loading

0 comments on commit fd9d5a5

Please sign in to comment.