Skip to content

Commit eaad1ce

Browse files
Fixed partial update example
1 parent 658f018 commit eaad1ce

File tree

6 files changed

+95
-164
lines changed

6 files changed

+95
-164
lines changed

examples/Inkplate10/Basic/Inkplate10_Partial_Update/Inkplate10_Partial_Update.ino

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const char text[] = "This is partial update on Inkplate 10 e-paper display! :)";
2929
// This variable is used for moving the text (scrolling)
3030
int offset = 1200;
3131

32-
// Variable that keeps count on how much screen has been partially updated
33-
int n = 0;
32+
int partialUpdates=9;
3433

3534
void setup()
3635
{
@@ -40,50 +39,31 @@ void setup()
4039
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
4140
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
4241
display.setTextWrap(false); // Disable text wraping
42+
display.setFullUpdateThreshold(partialUpdates); //Set the number of partial updates before doing a full update
4343
}
4444

4545
void loop()
4646
{
4747
// BASIC USAGE
4848

4949
display.clearDisplay(); // Clear content in frame buffer
50-
display.setCursor(offset, 400); // Set new position for text
50+
display.setCursor(offset, 300); // Set new position for text
5151
display.print(text); // Write text at new position
52-
if (n > 9)
53-
{ // Check if you need to do full refresh or you can do partial update
54-
display.display(); // Do a full refresh
55-
n = 0;
56-
}
57-
else
58-
{
59-
display.partialUpdate(); // Do partial update
60-
n++; // Keep track on how many times screen has been partially updated
61-
}
52+
display.partialUpdate(false, true); // Do partial update
6253
offset -= 20; // Move text into new position
6354
if (offset < 0)
64-
offset = 1200; // Text is scrolled till the end of the screen? Get it back on the start!
65-
delay(500); // Delay between refreshes.
55+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
56+
delay(500); // Delay between refreshes.
6657

6758
// ADVANCED USAGE
6859

6960
display.clearDisplay(); // Clear content in frame buffer
70-
display.setCursor(offset, 400); // Set new position for text
61+
display.setCursor(offset, 300); // Set new position for text
7162
display.print(text); // Write text at new position
72-
7363
display.einkOn(); // Turn on e-ink display
74-
if (n > 9) // Check if you need to do full refresh or you can do partial update
75-
{
76-
display.einkOff(); // Turn off e-ink display after partial updates
77-
display.display(); // Do a full refresh
78-
n = 0;
79-
}
80-
else
81-
{
82-
display.partialUpdate(false, true); // Do partial update
83-
n++; // Keep track on how many times screen has been partially updated
84-
}
64+
display.partialUpdate(false, true); // Do partial update
8565
offset -= 20; // Move text into new position
8666
if (offset < 0)
87-
offset = 1200; // Text is scrolled till the end of the screen? Get it back on the start!
88-
delay(500); // Delay between refreshes.
67+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
68+
delay(500); // Delay between refreshes.
8969
}

examples/Inkplate5/Basic/Inkplate5_Partial_Update/Inkplate5_Partial_Update.ino

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const char text[] = "This is partial update on Inkplate 5 e-paper display! :)";
2929
// This variable is used for moving the text (scrolling)
3030
int offset = E_INK_WIDTH;
3131

32-
// Variable that keeps count on how much screen has been partially updated
33-
int n = 0;
32+
int partialUpdates=9;
3433

3534
void setup()
3635
{
@@ -40,51 +39,32 @@ void setup()
4039
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
4140
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
4241
display.setTextWrap(false); // Disable text wraping
42+
display.setFullUpdateThreshold(partialUpdates); //Set the number of partial updates before doing a full update
43+
4344
}
4445

4546
void loop()
4647
{
4748
// BASIC USAGE
4849

4950
display.clearDisplay(); // Clear content in frame buffer
50-
display.setCursor(offset, 260); // Set new position for text
51+
display.setCursor(offset, 300); // Set new position for text
5152
display.print(text); // Write text at new position
52-
if (n > 9)
53-
{
54-
// Check if you need to do full refresh or you can do partial update
55-
display.display(); // Do a full refresh
56-
n = 0;
57-
}
58-
else
59-
{
60-
display.partialUpdate(); // Do partial update
61-
n++; // Keep track on how many times screen has been partially updated
62-
}
53+
display.partialUpdate(false, true); // Do partial update
6354
offset -= 20; // Move text into new position
6455
if (offset < 0)
65-
offset = E_INK_WIDTH; // Text is scrolled till the end of the screen? Get it back on the start!
66-
delay(500); // Delay between refreshes.
56+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
57+
delay(500); // Delay between refreshes.
6758

6859
// ADVANCED USAGE
6960

7061
display.clearDisplay(); // Clear content in frame buffer
71-
display.setCursor(offset, 260); // Set new position for text
62+
display.setCursor(offset, 300); // Set new position for text
7263
display.print(text); // Write text at new position
73-
7464
display.einkOn(); // Turn on e-ink display
75-
if (n > 9) // Check if you need to do full refresh or you can do partial update
76-
{
77-
display.einkOff(); // Turn off e-ink display after partial updates
78-
display.display(); // Do a full refresh
79-
n = 0;
80-
}
81-
else
82-
{
83-
display.partialUpdate(false, true); // Do partial update
84-
n++; // Keep track on how many times screen has been partially updated
85-
}
65+
display.partialUpdate(false, true); // Do partial update
8666
offset -= 20; // Move text into new position
8767
if (offset < 0)
88-
offset = E_INK_WIDTH; // Text is scrolled till the end of the screen? Get it back on the start!
89-
delay(500); // Delay between refreshes.
68+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
69+
delay(500); // Delay between refreshes.
9070
}

examples/Inkplate5V2/Basic/Inkplate5V2_Partial_Update/Inkplate5V2_Partial_Update.ino

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const char text[] = "This is partial update on Inkplate 5V2 e-paper display! :)"
2929
// This variable is used for moving the text (scrolling)
3030
int offset = E_INK_WIDTH;
3131

32-
// Variable that keeps count on how much screen has been partially updated
33-
int n = 0;
32+
int partialUpdates=9;
3433

3534
void setup()
3635
{
@@ -40,51 +39,31 @@ void setup()
4039
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
4140
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
4241
display.setTextWrap(false); // Disable text wraping
42+
display.setFullUpdateThreshold(partialUpdates); //Set the number of partial updates before doing a full update
4343
}
4444

4545
void loop()
4646
{
4747
// BASIC USAGE
4848

4949
display.clearDisplay(); // Clear content in frame buffer
50-
display.setCursor(offset, 380); // Set new position for text
50+
display.setCursor(offset, 300); // Set new position for text
5151
display.print(text); // Write text at new position
52-
if (n > 9)
53-
{
54-
// Check if you need to do full refresh or you can do partial update
55-
display.display(); // Do a full refresh
56-
n = 0;
57-
}
58-
else
59-
{
60-
display.partialUpdate(); // Do partial update
61-
n++; // Keep track on how many times screen has been partially updated
62-
}
52+
display.partialUpdate(false, true); // Do partial update
6353
offset -= 20; // Move text into new position
6454
if (offset < 0)
65-
offset = E_INK_WIDTH; // Text is scrolled till the end of the screen? Get it back on the start!
66-
delay(500); // Delay between refreshes.
55+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
56+
delay(500); // Delay between refreshes.
6757

6858
// ADVANCED USAGE
6959

7060
display.clearDisplay(); // Clear content in frame buffer
71-
display.setCursor(offset, 380); // Set new position for text
61+
display.setCursor(offset, 300); // Set new position for text
7262
display.print(text); // Write text at new position
73-
7463
display.einkOn(); // Turn on e-ink display
75-
if (n > 9) // Check if you need to do full refresh or you can do partial update
76-
{
77-
display.einkOff(); // Turn off e-ink display after partial updates
78-
display.display(); // Do a full refresh
79-
n = 0;
80-
}
81-
else
82-
{
83-
display.partialUpdate(false, true); // Do partial update
84-
n++; // Keep track on how many times screen has been partially updated
85-
}
64+
display.partialUpdate(false, true); // Do partial update
8665
offset -= 20; // Move text into new position
8766
if (offset < 0)
88-
offset = E_INK_WIDTH; // Text is scrolled till the end of the screen? Get it back on the start!
89-
delay(500); // Delay between refreshes.
67+
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
68+
delay(500); // Delay between refreshes.
9069
}

examples/Inkplate6/Basic/Inkplate6_Partial_Update/Inkplate6_Partial_Update.ino

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const char text[] = "This is partial update on Inkplate 6 e-paper display! :)";
2929
// This variable is used for moving the text (scrolling)
3030
int offset = 800;
3131

32-
// Variable that keeps count on how much screen has been partially updated
33-
int n = 0;
32+
int partialUpdates=9;
3433
void setup()
3534
{
3635
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
@@ -39,6 +38,7 @@ void setup()
3938
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
4039
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
4140
display.setTextWrap(false); // Disable text wraping
41+
display.setFullUpdateThreshold(partialUpdates); //Set the number of partial updates before doing a full update
4242
}
4343

4444
void loop()
@@ -48,16 +48,7 @@ void loop()
4848
display.clearDisplay(); // Clear content in frame buffer
4949
display.setCursor(offset, 300); // Set new position for text
5050
display.print(text); // Write text at new position
51-
if (n > 9)
52-
{ // Check if you need to do full refresh or you can do partial update
53-
display.display(); // Do a full refresh
54-
n = 0;
55-
}
56-
else
57-
{
58-
display.partialUpdate(false, true); // Do partial update
59-
n++; // Keep track on how many times screen has been partially updated
60-
}
51+
display.partialUpdate(false, true); // Do partial update
6152
offset -= 20; // Move text into new position
6253
if (offset < 0)
6354
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
@@ -68,19 +59,8 @@ void loop()
6859
display.clearDisplay(); // Clear content in frame buffer
6960
display.setCursor(offset, 300); // Set new position for text
7061
display.print(text); // Write text at new position
71-
7262
display.einkOn(); // Turn on e-ink display
73-
if (n > 9) // Check if you need to do full refresh or you can do partial update
74-
{
75-
display.einkOff(); // Turn off e-ink display after partial updates
76-
display.display(); // Do a full refresh
77-
n = 0;
78-
}
79-
else
80-
{
81-
display.partialUpdate(false, true); // Do partial update
82-
n++; // Keep track on how many times screen has been partially updated
83-
}
63+
display.partialUpdate(false, true); // Do partial update
8464
offset -= 20; // Move text into new position
8565
if (offset < 0)
8666
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!

examples/Inkplate6FLICK/Basic/Inkplate6FLICK_Partial_Update/Inkplate6FLICK_Partial_Update.ino

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const char text[] = "This is partial update on Inkplate 6FLICK e-paper display!
2929
// This variable is used for moving the text (scrolling)
3030
int offset = 800;
3131

32-
// Variable that keeps count on how much screen has been partially updated
33-
int n = 0;
32+
int partialUpdates=9;
33+
3434

3535
void setup()
3636
{
@@ -40,6 +40,8 @@ void setup()
4040
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
4141
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
4242
display.setTextWrap(false); // Disable text wraping
43+
display.setFullUpdateThreshold(partialUpdates); //Set the number of partial updates before doing a full update
44+
4345
}
4446

4547
void loop()
@@ -49,16 +51,7 @@ void loop()
4951
display.clearDisplay(); // Clear content in frame buffer
5052
display.setCursor(offset, 300); // Set new position for text
5153
display.print(text); // Write text at new position
52-
if (n > 9)
53-
{ // Check if you need to do full refresh or you can do partial update
54-
display.display(); // Do a full refresh
55-
n = 0;
56-
}
57-
else
58-
{
59-
display.partialUpdate(); // Do partial update
60-
n++; // Keep track on how many times screen has been partially updated
61-
}
54+
display.partialUpdate(false, true); // Do partial update
6255
offset -= 20; // Move text into new position
6356
if (offset < 0)
6457
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
@@ -69,19 +62,8 @@ void loop()
6962
display.clearDisplay(); // Clear content in frame buffer
7063
display.setCursor(offset, 300); // Set new position for text
7164
display.print(text); // Write text at new position
72-
7365
display.einkOn(); // Turn on e-ink display
74-
if (n > 9) // Check if you need to do full refresh or you can do partial update
75-
{
76-
display.einkOff(); // Turn off e-ink display after partial updates
77-
display.display(); // Do a full refresh
78-
n = 0;
79-
}
80-
else
81-
{
82-
display.partialUpdate(false, true); // Do partial update
83-
n++; // Keep track on how many times screen has been partially updated
84-
}
66+
display.partialUpdate(false, true); // Do partial update
8567
offset -= 20; // Move text into new position
8668
if (offset < 0)
8769
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!

0 commit comments

Comments
 (0)