Skip to content

Commit

Permalink
refactor: store LUTs in PROGMEM
Browse files Browse the repository at this point in the history
  • Loading branch information
todd-herbert committed Jul 29, 2023
1 parent 6242765 commit c6d2fa7
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 35 deletions.
3 changes: 1 addition & 2 deletions src/Displays/DEPG0150BNS810/DEPG0150BNS810.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DEPG0150BNS810 : public GFX {

// Look Up Table for the "partial refresh" operation
// Modified from original Heltec source
const unsigned char lut_partial[159] = {
PROGMEM static constexpr uint8_t lut_partial[153] = {
0x40,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
Expand All @@ -38,7 +38,6 @@ class DEPG0150BNS810 : public GFX {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,

0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x02,0x17,0x41,0xB0,0x32,0x28,
};


Expand Down
22 changes: 13 additions & 9 deletions src/Displays/DEPG0150BNS810/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "DEPG0150BNS810.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t DEPG0150BNS810::lut_partial[];

// Constructor
DEPG0150BNS810::DEPG0150BNS810( uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {

Expand Down Expand Up @@ -154,23 +158,23 @@ void DEPG0150BNS810::setFastmode(FastmodeList::Fastmode mode) {
// -----------------------------------------------
unsigned char count;
sendCommand(0x32); // "LUT"
for(count=0;count<153;count++)
sendData(lut_partial[count]);
for(count=0; count < sizeof(lut_partial); count++)
sendData(pgm_read_byte_near(lut_partial + count));
wait();

sendCommand(0x3F); // "Option for LUT end"
sendData(lut_partial[153]);
sendData(0x02);

sendCommand(0x03); // "Gate voltage"
sendData(lut_partial[154]);
sendData(0x17);

sendCommand(0x04); // "Source voltage"
sendData(lut_partial[155]);
sendData(lut_partial[156]);
sendData(lut_partial[157]);
sendData(0x41);
sendData(0xB0);
sendData(0x32);

sendCommand(0x2C); // allegedly: vcom
sendData(lut_partial[158]);
sendCommand(0x2C); // vcom
sendData(0x28);

sendCommand(0x37); // "Write Register for Display Option"
sendData(0x00); // Heltec comment: "Local flash function is enabled, pingpong mode is enabled"
Expand Down
5 changes: 2 additions & 3 deletions src/Displays/DEPG0154BNS800/DEPG0154BNS800.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DEPG0154BNS800 : public GFX {

// Look Up Table for the "partial refresh" operation
// Unmodified from Heltec source
const unsigned char lut_partial[159] = {
PROGMEM static constexpr uint8_t lut_partial[153] = {
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
Expand All @@ -36,8 +36,7 @@ class DEPG0154BNS800 : public GFX {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x02,0x17,0x41,0xB0,0x32,0x28
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0
};


Expand Down
20 changes: 12 additions & 8 deletions src/Displays/DEPG0154BNS800/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "DEPG0154BNS800.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t DEPG0154BNS800::lut_partial[];

// Constructor
DEPG0154BNS800::DEPG0154BNS800(uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {

Expand Down Expand Up @@ -154,23 +158,23 @@ void DEPG0154BNS800::setFastmode(FastmodeList::Fastmode mode) {
// -----------------------------------------------
unsigned char count;
sendCommand(0x32); // "LUT"
for(count=0;count<153;count++)
sendData(lut_partial[count]);
for(count=0; count < sizeof(lut_partial); count++)
sendData(pgm_read_byte_near(lut_partial + count));
wait();

sendCommand(0x3F); // "Option for LUT end"
sendData(lut_partial[153]);
sendData(0x02);

sendCommand(0x03); // "Gate voltage"
sendData(lut_partial[154]);
sendData(0x17);

sendCommand(0x04); // "Source voltage"
sendData(lut_partial[155]);
sendData(lut_partial[156]);
sendData(lut_partial[157]);
sendData(0x41);
sendData(0xB0);
sendData(0x32);

sendCommand(0x2C); // allegedly: vcom
sendData(lut_partial[158]);
sendData(0x28);

sendCommand(0x37); // "Write Register for Display Option"
sendData(0x00); // Heltec comment: "Local flash function is enabled, pingpong mode is enabled"
Expand Down
2 changes: 1 addition & 1 deletion src/Displays/DEPG0290BNS75A/DEPG0290BNS75A.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DEPG0290BNS75A : public GFX {

// Look Up Table for the "partial refresh" operation
// Composite of data from ZinggJM/GxEPD2
const unsigned char lut_partial[70] = {
PROGMEM static constexpr uint8_t lut_partial[70] = {
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, //LUT0: BB: VS 0 ~7
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT1: BW: VS 0 ~7
0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT2: WB: VS 0 ~7
Expand Down
8 changes: 6 additions & 2 deletions src/Displays/DEPG0290BNS75A/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "DEPG0290BNS75A.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t DEPG0290BNS75A::lut_partial[];

// Have to initialize because of GFX class
DEPG0290BNS75A::DEPG0290BNS75A( uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {
// Store the config
Expand Down Expand Up @@ -195,8 +199,8 @@ void DEPG0290BNS75A::setFastmode(FastmodeList::Fastmode mode) {

// Load the fastmode lut
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_partial); i++)
sendData(lut_partial[i]);
for(uint8_t i=0;i < sizeof(lut_partial); i++)
sendData(pgm_read_byte_near(lut_partial + i));

wait();

Expand Down
2 changes: 1 addition & 1 deletion src/Displays/DEPG0290BNS800/DEPG0290BNS800.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DEPG0290BNS800 : public GFX {

// Look Up Table for the "partial refresh" operation
// Modified from Heltec source
const unsigned char lut_partial[153] = {
PROGMEM static constexpr uint8_t lut_partial[153] = {
0x40, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x40, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Expand Down
6 changes: 5 additions & 1 deletion src/Displays/DEPG0290BNS800/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "DEPG0290BNS800.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t DEPG0290BNS800::lut_partial[];

// Have to initialize because of GFX class
DEPG0290BNS800::DEPG0290BNS800( uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {
// Store the config
Expand Down Expand Up @@ -159,7 +163,7 @@ void DEPG0290BNS800::setFastmode(FastmodeList::Fastmode mode) {
// Load the fastmode lut
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_partial); i++)
sendData(lut_partial[i]);
sendData(pgm_read_byte_near(lut_partial+i));

wait();

Expand Down
4 changes: 2 additions & 2 deletions src/Displays/GDE029A1/GDE029A1.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class GDE029A1 : public GFX {
// Look Up Table for both "refresh" operations
// lut_full operation lengthened slightly, to prevent ghost images forming
// From Heltec source
const unsigned char lut_full[30] = {
PROGMEM static constexpr uint8_t lut_full[30] = {
0x50, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
0x55, 0xAA, 0x11, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0x1F, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_partial[30] = {
PROGMEM static constexpr uint8_t lut_partial[30] = {
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
9 changes: 7 additions & 2 deletions src/Displays/GDE029A1/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "GDE029A1.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t GDE029A1::lut_full[];
PROGMEM constexpr uint8_t GDE029A1::lut_partial[];

// Constructor
GDE029A1::GDE029A1( uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {
// Store the config
Expand Down Expand Up @@ -161,7 +166,7 @@ void GDE029A1::reset() {
// Load the Look Up Table (LUT) for full update
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_full); i++)
sendData(lut_full[i]);
sendData(pgm_read_byte_near(lut_full + i));

wait();
}
Expand Down Expand Up @@ -224,7 +229,7 @@ void GDE029A1::setFastmode(FastmodeList::Fastmode mode) {
// Load the LUT for partial update
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_partial); i++)
sendData(lut_partial[i]);
sendData(pgm_read_byte_near(lut_partial + i));

wait();

Expand Down
4 changes: 2 additions & 2 deletions src/Displays/GDEP015OC1/GDEP015OC1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class GDEP015OC1 : public GFX {

// Look Up Table for "refresh" operations
// Unmodified from Heltec source
const unsigned char lut_full[30] = {
PROGMEM static constexpr uint8_t lut_full[30] = {
0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_partial[30] = {
PROGMEM static constexpr uint8_t lut_partial[30] = {
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
9 changes: 7 additions & 2 deletions src/Displays/GDEP015OC1/hardware.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "GDEP015OC1.h"

// Out-of-line definition for LUT
// Required for an in-class PROGMEM definition
PROGMEM constexpr uint8_t GDEP015OC1::lut_full[];
PROGMEM constexpr uint8_t GDEP015OC1::lut_partial[];

// Constructor
GDEP015OC1::GDEP015OC1( uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t page_height) : GFX(panel_width, panel_height) {
// Store the config
Expand Down Expand Up @@ -164,7 +169,7 @@ void GDEP015OC1::reset() {
// Load the Look Up Table (LUT) for full update
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_full); i++)
sendData(lut_full[i]);
sendData(pgm_read_byte_near(lut_full + i));

wait();
}
Expand Down Expand Up @@ -227,7 +232,7 @@ void GDEP015OC1::setFastmode(FastmodeList::Fastmode mode) {
// Load the LUT for partial update
sendCommand(0x32);
for(uint8_t i=0;i < sizeof(lut_partial); i++)
sendData(lut_partial[i]);
sendData(pgm_read_byte_near(lut_partial + i));

wait();

Expand Down

0 comments on commit c6d2fa7

Please sign in to comment.