Skip to content

Commit

Permalink
Release 120 with support for BWR screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Rei Vilo committed Oct 7, 2016
1 parent f57bb14 commit 31995c4
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 28 deletions.
11 changes: 8 additions & 3 deletions example/PervasiveDisplays_Demo/PervasiveDisplays_Demo.ino
Expand Up @@ -9,7 +9,7 @@
/// @author Rei VILO
/// @author http://embeddedcomputing.weebly.com
/// @date Jun 28, 2016
/// @version 107
/// @version 120
///
/// @copyright (c) Rei VILO, 2010-2016 - SPECIAL EDITION FOR ENERGIA
/// @copyright All rights reserved
Expand All @@ -20,7 +20,7 @@


///
/// @file PervasiveDisplays.ino
/// @file PervasiveDisplays_Demo.ino
/// @brief Main sketch
///
/// @details <#details#>
Expand All @@ -29,7 +29,7 @@
/// @author Rei VILO
/// @author http://embeddedcomputing.weebly.com
/// @date Jun 28, 2016
/// @version 107
/// @version 120
///
/// @copyright (c) Rei VILO, 2010-2016 - SPECIAL EDITION FOR ENERGIA
/// @copyright All rights reserved
Expand All @@ -55,6 +55,9 @@
#include "Pervasive_EPD_BoosterPack2.h"
#include "Screen_EPD.h"

//#if Screen_EPD_RELEASE < 120
//#error Required Screen_EPD_RELEASE 120
//#endif

// Define structures and classes

Expand All @@ -75,6 +78,8 @@ Screen_EPD myScreen(eScreen_EPD_eTC_271_Mb); // ok
// . switches = 0101 010x
//Screen_EPD myScreen(eScreen_EPD_iTC_287); // ok
//Screen_EPD myScreen(eScreen_EPD_iTC_420); // ok
//Screen_EPD myScreen(eScreen_EPD_iTC_287_BWR); // ok
//Screen_EPD myScreen(eScreen_EPD_iTC_420_BWR); // ok


// Prototypes
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion src/LCD_screen.h
Expand Up @@ -26,7 +26,7 @@
#if defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific
#include "Energia.h"
#else
#error Paltform not supported
#error Platform not supported
#endif // end IDE

#ifndef LCD_SCREEN_RELEASE
Expand Down
15 changes: 0 additions & 15 deletions src/LCD_screen_buffer.h
Expand Up @@ -92,15 +92,6 @@ class LCD_screen_buffer : public LCD_screen
/// @name Graphics
/// @{

// ///
// /// @brief Draw circle
// /// @param x0 center, point coordinate, x-axis
// /// @param y0 center, point coordinate, y-axis
// /// @param radius radius
// /// @param colour 16-bit colour
// ///
// virtual void circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t colour);

///
/// @brief Draw line, rectangle coordinates
/// @param x1 top left coordinate, x-axis
Expand All @@ -111,12 +102,6 @@ class LCD_screen_buffer : public LCD_screen
///
virtual void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t colour);

// ///
// /// @brief Set pen opaque
// /// @param flag default = true = opaque = solid, false = wire frame
// ///
// virtual void setPenSolid(bool flag = true);

///
/// @brief Draw rectangle, rectangle coordinates
/// @param x1 top left coordinate, x-axis
Expand Down
109 changes: 106 additions & 3 deletions src/Screen_EPD.cpp
Expand Up @@ -28,6 +28,7 @@ Screen_EPD::Screen_EPD(eScreen_EPD_t eScreen)
_flagBeginDone = false;
_eScreen = eScreen;

// Screen width and height
switch (_eScreen)
{
case eScreen_EPD_eTC_144_Mb:
Expand Down Expand Up @@ -67,12 +68,14 @@ Screen_EPD::Screen_EPD(eScreen_EPD_t eScreen)
break;

case eScreen_EPD_iTC_287:
case eScreen_EPD_iTC_287_BWR:

_widthScreen = 296 ; // x = wide size
_heightScreen = 128; // y = small size
break;

case eScreen_EPD_iTC_420:
case eScreen_EPD_iTC_420_BWR:

_widthScreen = 300 ; // x = wide size
_heightScreen = 400; // y = small size
Expand All @@ -83,9 +86,24 @@ Screen_EPD::Screen_EPD(eScreen_EPD_t eScreen)
break;
}

// Buffer depth. BWR requires 2 buffers.
switch (_eScreen)
{
case eScreen_EPD_iTC_287_BWR:
case eScreen_EPD_iTC_420_BWR:

_depthBuffer = 2;
break;

default:

_depthBuffer = 1;
break;
}

_widthBuffer = _widthScreen; // x = wide size
_heightBuffer = _heightScreen / 8; // 112 / 8;
_sizeBuffer = _widthBuffer * _heightBuffer;
_sizeBuffer = _widthBuffer * _heightBuffer; // actually, size for one buffer. BWR requires 2 buffers.
}

void Screen_EPD::begin()
Expand All @@ -95,8 +113,8 @@ void Screen_EPD::begin()
// Framebuffer initialisation
if (!_flagBeginDone)
{
uint8_t * _newFrameBuffer = new uint8_t[_sizeBuffer];
uint8_t * _oldFrameBuffer = new uint8_t[_sizeBuffer];
uint8_t * _newFrameBuffer = new uint8_t[_sizeBuffer * _depthBuffer];
uint8_t * _oldFrameBuffer = new uint8_t[_sizeBuffer * _depthBuffer];
_flagBeginDone = true;

_oldImage = (uint8_t *) _oldFrameBuffer;
Expand Down Expand Up @@ -149,6 +167,16 @@ void Screen_EPD::begin()
_result = _pdi_epd.begin(dr_iTC_Drivers, EPD_420_BW, USE_Temperature_Sensor);
break;

case eScreen_EPD_iTC_287_BWR:

_result = _pdi_epd.begin(dr_iTC_Drivers, EPD_287_BWR, USE_Temperature_Sensor);
break;

case eScreen_EPD_iTC_420_BWR:

_result = _pdi_epd.begin(dr_iTC_Drivers, EPD_420_BWR, USE_Temperature_Sensor);
break;

default:
Serial.println(". begin");
break;
Expand Down Expand Up @@ -176,6 +204,16 @@ void Screen_EPD::flush()
memcpy(_oldImage, _newImage, _sizeBuffer);
}

//void Screen_EPD::setActivePage(uint8_t page)
//{
// _page = (page % 2);
//}
//
//void Screen_EPD::copyPageFromTo(uint8_t fromPage, uint8_t toPage)
//{
//
//}

void Screen_EPD::clear(uint16_t colour)
{
switch (_eScreen)
Expand Down Expand Up @@ -232,7 +270,40 @@ void Screen_EPD::clear(uint16_t colour)
}
break;

case eScreen_EPD_iTC_287_BWR:
case eScreen_EPD_iTC_420_BWR:

if (colour == redColour)
{
memset(_newImage, 0x00, _sizeBuffer);
memset(_newImage + _sizeBuffer, 0xff, _sizeBuffer);
}
else if (colour == greyColour)
{
for (uint8_t i = 0; i < _widthBuffer; i++)
{
uint16_t pattern = (i % 2) ? 0b10101010 : 0b01010101;
for (uint8_t j = 0; j < _heightBuffer; j++)
{
_newImage[i * _heightBuffer + j] = pattern;
}
}
memset(_newImage + _sizeBuffer, 0x00, _sizeBuffer);
}
else if ((colour != whiteColour) xor _invert)
{
memset(_newImage, 0xff, _sizeBuffer);
memset(_newImage + _sizeBuffer, 0x00, _sizeBuffer);
}
else
{
memset(_newImage, 0x00, _sizeBuffer);
memset(_newImage + _sizeBuffer, 0x00, _sizeBuffer);
}
break;

default:

Serial.println(". clear");
break;
}
Expand Down Expand Up @@ -282,6 +353,16 @@ String Screen_EPD::WhoAmI()
return "iTC 4.20\"";
break;

case eScreen_EPD_iTC_287_BWR:

return "iTC 2.87\" BWR";
break;

case eScreen_EPD_iTC_420_BWR:

return "iTC 4.20\" BWR";
break;

default:
break;
}
Expand Down Expand Up @@ -379,7 +460,29 @@ void Screen_EPD::_setPoint(uint16_t x1, uint16_t y1, uint16_t colour)
}
break;

case eScreen_EPD_iTC_287_BWR:
case eScreen_EPD_iTC_420_BWR:

if ((colour == redColour))
{
bitClear(_newImage[x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
bitSet(_newImage[_sizeBuffer + x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
}
else if ((colour != whiteColour) xor _invert)
{
bitSet(_newImage[x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
bitClear(_newImage[_sizeBuffer + x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
}
else
{
bitClear(_newImage[x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
bitClear(_newImage[_sizeBuffer + x1 * _heightBuffer + (y1 >> 3)], 7 - (y1 % 8));
}
break;


default:

Serial.println(". _setPoint");
break;
}
Expand Down
27 changes: 21 additions & 6 deletions src/Screen_EPD.h
Expand Up @@ -7,8 +7,8 @@
///
/// @author Rei VILO
/// @author http://embeddedcomputing.weebly.com
/// @date Sep 07, 2016
/// @version 109
/// @date Oct 06, 2016
/// @version 120
///
/// @copyright (c) Rei VILO, 2010-2016 - SPECIAL EDITION FOR ENERGIA
/// @copyright All rights reserved
Expand All @@ -25,7 +25,6 @@
///


// Core library - IDE-based
// Core library - IDE-based
#if defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific
#include "Energia.h"
Expand All @@ -37,7 +36,7 @@
///
/// @brief Library release number
///
#define Screen_EPD_RELEASE 107
#define Screen_EPD_RELEASE 120

// Other libraries
#include "LCD_screen_buffer.h"
Expand All @@ -62,6 +61,9 @@ enum eScreen_EPD_t
eScreen_EPD_iTC_215, ///< eScreen_EPD_iTC_215
eScreen_EPD_iTC_287, ///< eScreen_EPD_iTC_287
eScreen_EPD_iTC_420, ///< eScreen_EPD_iTC_420

eScreen_EPD_iTC_287_BWR, ///< eScreen_EPD_iTC_287_BWR
eScreen_EPD_iTC_420_BWR, ///< eScreen_EPD_iTC_420_BWR
};


Expand All @@ -85,6 +87,17 @@ enum eScreen_EPD_t
/// * iTC 287 switches = 0101 010x http://www.pervasivedisplays.com/products/287
/// * iTC 420 switches = 0101 010x http://www.pervasivedisplays.com/products/420
///
/// * iTC 287 BWR switches = 0101 010x http://www.pervasivedisplays.com/products/287
/// * iTC 420 BWR switches = 0101 010x http://www.pervasivedisplays.com/products/420
///


///
/// @brief Class for Pervasive Displays screens
/// @details Screen controllers
/// * LCD: propietary, SPI
/// * touch: no touch
///
class Screen_EPD : public LCD_screen_buffer
{
public:
Expand Down Expand Up @@ -126,6 +139,7 @@ class Screen_EPD : public LCD_screen_buffer
///
uint8_t getResult();

/// @cond
private:
// * Virtual =0 compulsory functions
// Orientation
Expand All @@ -151,10 +165,11 @@ class Screen_EPD : public LCD_screen_buffer
uint8_t _result;
bool _flagBeginDone;

uint16_t _widthBuffer, _heightBuffer;
uint16_t _widthBuffer, _heightBuffer, _depthBuffer;
uint32_t _sizeBuffer;
uint16_t _widthScreen, _heightScreen;
uint16_t _widthScreen, _heightScreen, _depthScreen;
eScreen_EPD_t _eScreen;
};
/// @endcond

#endif

0 comments on commit 31995c4

Please sign in to comment.