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); \ 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 #define GPIO0_ENABLE 8
@ -125,6 +98,17 @@ void Inkplate::begin(void)
return; return;
Wire.begin(); 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); mcpBegin(MCP23017_ADDR, mcpRegsInt);
pinModeMCP(VCOM, OUTPUT); pinModeMCP(VCOM, OUTPUT);
@ -177,19 +161,9 @@ void Inkplate::begin(void)
memset(_pBuffer, 0, 120000); memset(_pBuffer, 0, 120000);
memset(D_memory4Bit, 255, 240000); memset(D_memory4Bit, 255, 240000);
precalculateGamma(gammaLUT, 1);
_beginDone = 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() void Inkplate::clearDisplay()
{ {
if (getDisplayMode() == 0) if (getDisplayMode() == 0)
@ -215,13 +189,13 @@ void Inkplate::display1b()
uint8_t dram; uint8_t dram;
einkOn(); einkOn();
cleanFast(0, 1); cleanFast(0, 1);
cleanFast(1, 16); cleanFast(1, 21);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(0, 11); cleanFast(0, 12);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(1, 16); cleanFast(1, 21);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(0, 11); cleanFast(0, 12);
for (int k = 0; k < 4; ++k) for (int k = 0; k < 4; ++k)
{ {
uint8_t *DMemoryNewPtr = DMemoryNew + 59999; uint8_t *DMemoryNewPtr = DMemoryNew + 59999;
@ -320,13 +294,13 @@ void Inkplate::display3b()
{ {
einkOn(); einkOn();
cleanFast(0, 1); cleanFast(0, 1);
cleanFast(1, 16); cleanFast(1, 21);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(0, 11); cleanFast(0, 12);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(1, 16); cleanFast(1, 21);
cleanFast(2, 1); cleanFast(2, 1);
cleanFast(0, 11); cleanFast(0, 12);
for (int k = 0; k < 8; ++k) for (int k = 0; k < 8; ++k)
{ {
@ -521,7 +495,12 @@ void Inkplate::einkOff()
delay(6); delay(6);
PWRUP_CLEAR; PWRUP_CLEAR;
WAKEUP_CLEAR; WAKEUP_CLEAR;
delay(100);
unsigned long timer = millis();
do {
delay(1);
} while ((readPowerGood() != 0) && (millis() - timer) < 250);
pinsZstate(); pinsZstate();
setPanelState(0); setPanelState(0);
} }
@ -533,14 +512,6 @@ void Inkplate::einkOn()
return; return;
WAKEUP_SET; WAKEUP_SET;
delay(1); 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; PWRUP_SET;
// Enable all rails // Enable all rails
@ -558,29 +529,32 @@ void Inkplate::einkOn()
CKV_CLEAR; CKV_CLEAR;
OE_CLEAR; OE_CLEAR;
VCOM_SET; VCOM_SET;
Wire.beginTransmission(0x48);
Wire.write(0x0D);
Wire.write(B10000000);
Wire.endTransmission();
delay(5);
Wire.beginTransmission(0x48); unsigned long timer = millis();
Wire.write(0x00); do {
Wire.endTransmission(); delay(1);
} while ((readPowerGood() != PWR_GOOD_OK) && (millis() - timer) < 250);
Wire.requestFrom(0x48, 1); if ((millis() - timer) >= 250)
setTemperature(Wire.read()); {
WAKEUP_CLEAR;
// pinModeMCP(7, INPUT_PULLUP); VCOM_CLEAR;
// while (!digitalReadMCP(7)) PWRUP_CLEAR;
// ; return;
}
delay(100);
OE_SET; OE_SET;
setPanelState(1); setPanelState(1);
} }
uint8_t Inkplate::readPowerGood() {
Wire.beginTransmission(0x48);
Wire.write(0x0F);
Wire.endTransmission();
Wire.requestFrom(0x48, 1);
return Wire.read();
}
// LOW LEVEL FUNCTIONS // LOW LEVEL FUNCTIONS
void Inkplate::vscan_start() void Inkplate::vscan_start()

View File

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

View File

@ -29,14 +29,34 @@ uint8_t System::getPanelState()
return _panelOn; return _panelOn;
} }
void System::setTemperature(int8_t t)
{
_temperature = t;
}
int8_t System::readTemperature() 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) uint8_t System::readTouchpad(uint8_t _pad)

View File

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

View File

@ -30,6 +30,36 @@ Distributed as-is; no warranty is given.
#define PAD1 0 #define PAD1 0
#define PAD2 1 #define PAD2 1
#define PAD3 2 #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 RGB3BIT(r, g, b) ((54UL * (r) + 183UL * (g) + 19UL * (b)) >> 13)
#define RGB8BIT(r, g, b) ((54UL * (r) + 183UL * (g) + 19UL * (b)) >> 8) #define RGB8BIT(r, g, b) ((54UL * (r) + 183UL * (g) + 19UL * (b)) >> 8)