Fixed panel stuck bug, fixed power up/down bug

- There was a bug in power up sequence that was causing Inkplate to stuck in refresh, due to do/while loop.
Bad power up also caused partial updat to not work properly.
- Now temperature measurment is not dependent to screen refresh. Now you can read temperature from Inkplate built-in sensor anytime you want! Because of that, macros for powering up/down TPS65186 are moved from Inkplate.cpp to defines.h
- Removed unused functions and variables for gamma correction
- Improved cleaning (little bit slower, but better)
This commit is contained in:
BornaBiro 2020-10-08 01:52:32 +02:00
parent b6781dd127
commit fc268c7655
5 changed files with 104 additions and 82 deletions

View File

@ -79,33 +79,6 @@ Distributed as-is; no warranty is given.
{ \
digitalWriteMCP(SPV, LOW); \
}
#define WAKEUP 3
#define WAKEUP_SET \
{ \
digitalWriteMCP(WAKEUP, HIGH); \
}
#define WAKEUP_CLEAR \
{ \
digitalWriteMCP(WAKEUP, LOW); \
}
#define PWRUP 4
#define PWRUP_SET \
{ \
digitalWriteMCP(PWRUP, HIGH); \
}
#define PWRUP_CLEAR \
{ \
digitalWriteMCP(PWRUP, LOW); \
}
#define VCOM 5
#define VCOM_SET \
{ \
digitalWriteMCP(VCOM, HIGH); \
}
#define VCOM_CLEAR \
{ \
digitalWriteMCP(VCOM, LOW); \
}
#define GPIO0_ENABLE 8
@ -125,6 +98,17 @@ void Inkplate::begin(void)
return;
Wire.begin();
WAKEUP_SET;
delay(1);
Wire.beginTransmission(0x48);
Wire.write(0x09);
Wire.write(B00011011); // Power up seq.
Wire.write(B00000000); // Power up delay (3mS per rail)
Wire.write(B00011011); // Power down seq.
Wire.write(B00000000); // Power down delay (6mS per rail)
Wire.endTransmission();
delay(1);
WAKEUP_CLEAR;
mcpBegin(MCP23017_ADDR, mcpRegsInt);
pinModeMCP(VCOM, OUTPUT);
@ -177,19 +161,9 @@ void Inkplate::begin(void)
memset(_pBuffer, 0, 120000);
memset(D_memory4Bit, 255, 240000);
precalculateGamma(gammaLUT, 1);
_beginDone = 1;
}
void Inkplate::precalculateGamma(uint8_t *c, float gamma)
{
for (int i = 0; i < 256; ++i)
{
c[i] = int(round((pow(i / 255.0, gamma)) * 15));
}
}
void Inkplate::clearDisplay()
{
if (getDisplayMode() == 0)
@ -215,13 +189,13 @@ void Inkplate::display1b()
uint8_t dram;
einkOn();
cleanFast(0, 1);
cleanFast(1, 16);
cleanFast(1, 21);
cleanFast(2, 1);
cleanFast(0, 11);
cleanFast(0, 12);
cleanFast(2, 1);
cleanFast(1, 16);
cleanFast(1, 21);
cleanFast(2, 1);
cleanFast(0, 11);
cleanFast(0, 12);
for (int k = 0; k < 4; ++k)
{
uint8_t *DMemoryNewPtr = DMemoryNew + 59999;
@ -320,13 +294,13 @@ void Inkplate::display3b()
{
einkOn();
cleanFast(0, 1);
cleanFast(1, 16);
cleanFast(1, 21);
cleanFast(2, 1);
cleanFast(0, 11);
cleanFast(0, 12);
cleanFast(2, 1);
cleanFast(1, 16);
cleanFast(1, 21);
cleanFast(2, 1);
cleanFast(0, 11);
cleanFast(0, 12);
for (int k = 0; k < 8; ++k)
{
@ -521,7 +495,12 @@ void Inkplate::einkOff()
delay(6);
PWRUP_CLEAR;
WAKEUP_CLEAR;
delay(100);
unsigned long timer = millis();
do {
delay(1);
} while ((readPowerGood() != 0) && (millis() - timer) < 250);
pinsZstate();
setPanelState(0);
}
@ -533,14 +512,6 @@ void Inkplate::einkOn()
return;
WAKEUP_SET;
delay(1);
Wire.beginTransmission(0x48);
Wire.write(0x09);
Wire.write(B00011011); // Power up seq.
Wire.write(B00000000); // Power up delay (3mS per rail)
Wire.write(B00011011); // Power down seq.
Wire.write(B00000000); // Power down delay (6mS per rail)
Wire.endTransmission();
PWRUP_SET;
// Enable all rails
@ -558,29 +529,32 @@ void Inkplate::einkOn()
CKV_CLEAR;
OE_CLEAR;
VCOM_SET;
Wire.beginTransmission(0x48);
Wire.write(0x0D);
Wire.write(B10000000);
Wire.endTransmission();
delay(5);
Wire.beginTransmission(0x48);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(0x48, 1);
setTemperature(Wire.read());
// pinModeMCP(7, INPUT_PULLUP);
// while (!digitalReadMCP(7))
// ;
delay(100);
unsigned long timer = millis();
do {
delay(1);
} while ((readPowerGood() != PWR_GOOD_OK) && (millis() - timer) < 250);
if ((millis() - timer) >= 250)
{
WAKEUP_CLEAR;
VCOM_CLEAR;
PWRUP_CLEAR;
return;
}
OE_SET;
setPanelState(1);
}
uint8_t Inkplate::readPowerGood() {
Wire.beginTransmission(0x48);
Wire.write(0x0F);
Wire.endTransmission();
Wire.requestFrom(0x48, 1);
return Wire.read();
}
// LOW LEVEL FUNCTIONS
void Inkplate::vscan_start()

View File

@ -46,6 +46,7 @@ class Inkplate : public System, public Graphics
void einkOn();
void einkOff();
uint8_t readPowerGood();
void cleanFast(uint8_t c, uint8_t rep);
bool joinAP(const char *ssid, const char *pass)
@ -86,8 +87,6 @@ class Inkplate : public System, public Graphics
0x95959595, 0x95949495, 0x94949495, 0x94949495, 0xA4949494, 0x9494A4A4, 0x84A49494, 0x84948484, 0x84848484,
0x84848484, 0x84848484, 0xA5A48484, 0xA9A4A4A8, 0xA9A8A8A8, 0xA5A9A9A4, 0xA5A5A5A4, 0xA1A5A5A1, 0xA9A9A9A9,
0xA9A9A9A9, 0xA9A9A9A9, 0xA9A9A9A9, 0x15151515, 0x11111111};
uint8_t gammaLUT[256];
};
#endif

View File

@ -29,14 +29,34 @@ uint8_t System::getPanelState()
return _panelOn;
}
void System::setTemperature(int8_t t)
{
_temperature = t;
}
int8_t System::readTemperature()
{
return _temperature;
int8_t temp;
if(getPanelState() == 0)
{
WAKEUP_SET;
PWRUP_SET;
delay(5);
}
Wire.beginTransmission(0x48);
Wire.write(0x0D);
Wire.write(B10000000);
Wire.endTransmission();
delay(5);
Wire.beginTransmission(0x48);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(0x48, 1);
temp = Wire.read();
if(getPanelState() == 0)
{
PWRUP_CLEAR;
WAKEUP_CLEAR;
delay(5);
}
return temp;
}
uint8_t System::readTouchpad(uint8_t _pad)

View File

@ -21,6 +21,7 @@ Distributed as-is; no warranty is given.
#include "Arduino.h"
#include "SPI.h"
#include "defines.h"
#include "Esp.h"
#include "Mcp.h"
#include "NetworkClient.h"
@ -34,7 +35,6 @@ class System : public Esp, public Mcp, virtual public NetworkClient
void setSdCardOk(int16_t s);
int16_t getSdCardOk();
void setTemperature(int8_t t);
int8_t readTemperature();
uint8_t readTouchpad(uint8_t _pad);
@ -47,7 +47,6 @@ class System : public Esp, public Mcp, virtual public NetworkClient
private:
uint8_t _panelOn = 0;
int8_t _temperature;
int16_t _sdCardOk = 0;
};

View File

@ -30,6 +30,36 @@ Distributed as-is; no warranty is given.
#define PAD1 0
#define PAD2 1
#define PAD3 2
#define PWR_GOOD_OK 0b11111010
#define WAKEUP 3
#define WAKEUP_SET \
{ \
digitalWriteMCP(WAKEUP, HIGH); \
}
#define WAKEUP_CLEAR \
{ \
digitalWriteMCP(WAKEUP, LOW); \
}
#define PWRUP 4
#define PWRUP_SET \
{ \
digitalWriteMCP(PWRUP, HIGH); \
}
#define PWRUP_CLEAR \
{ \
digitalWriteMCP(PWRUP, LOW); \
}
#define VCOM 5
#define VCOM_SET \
{ \
digitalWriteMCP(VCOM, HIGH); \
}
#define VCOM_CLEAR \
{ \
digitalWriteMCP(VCOM, LOW); \
}
#define RGB3BIT(r, g, b) ((54UL * (r) + 183UL * (g) + 19UL * (b)) >> 13)
#define RGB8BIT(r, g, b) ((54UL * (r) + 183UL * (g) + 19UL * (b)) >> 8)