Skip to content

Commit 173787b

Browse files
committed
Add Full update threshold functionality
1 parent d173802 commit 173787b

File tree

8 files changed

+251
-0
lines changed

8 files changed

+251
-0
lines changed

src/Inkplate.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Inkplate : public System, public Graphics
7777
#if !defined(ARDUINO_INKPLATECOLOR) || !defined(ARDUINO_INKPLATE4) || !defined(ARDUINO_INKPLATE7) || \
7878
!defined(ARDUINO_INKPLATE2)
7979
uint32_t partialUpdate(bool _forced = false, bool leaveOn = false);
80+
void setFullUpdateThreshold(uint16_t _numberOfPartialUpdates);
8081
int einkOn();
8182
void einkOff();
8283
void preloadScreen();
@@ -175,6 +176,10 @@ class Inkplate : public System, public Graphics
175176
uint32_t pinLUT[256];
176177
uint32_t *GLUT;
177178
uint32_t *GLUT2;
179+
180+
uint16_t _partialUpdateLimiter = 0;
181+
uint16_t _partialUpdateCounter = 0;
182+
178183
#endif
179184

180185
uint8_t _beginDone = 0;

src/boards/Inkplate10.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
424424
return 0;
425425
}
426426

427+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
428+
{
429+
// Force full update.
430+
display1b(leaveOn);
431+
432+
// Reset the counter!
433+
_partialUpdateCounter = 0;
434+
435+
// Go back!
436+
return 0;
437+
}
438+
427439
uint32_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
428440
uint32_t _send;
429441
uint8_t data = 0;
@@ -500,9 +512,32 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
500512

501513
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
502514

515+
if(_partialUpdateLimiter!=0)
516+
_partialUpdateCounter++;
517+
503518
return changeCount;
504519
}
505520

521+
/**
522+
* @brief Set the number of partial updates afterwhich full screen update is performed.
523+
*
524+
* @param uint16_t _numberOfPartialUpdates
525+
* Number of allowed partial updates afterwhich full update is performed.
526+
* 0 = disabled, no automatic full update will be performed.
527+
*
528+
* @note By default, this is disabled, but to keep best image quality perform a full update
529+
* every 60-80 partial updates.
530+
*/
531+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
532+
{
533+
// Copy the value into the local variable.
534+
_partialUpdateLimiter = _numberOfPartialUpdates;
535+
536+
// If the limiter is enabled, force full update.
537+
if (_numberOfPartialUpdates != 0)
538+
_blockPartial = 1;
539+
}
540+
506541
/**
507542
* @brief clean function cleans screen of any potential burn in
508543
*

src/boards/Inkplate4TEMPERA.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
466466
return 0;
467467
}
468468

469+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
470+
{
471+
// Force full update.
472+
display1b(leaveOn);
473+
474+
// Reset the counter!
475+
_partialUpdateCounter = 0;
476+
477+
// Go back!
478+
return 0;
479+
}
480+
469481
uint32_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
470482
// uint32_t _send;
471483
uint8_t data;
@@ -530,9 +542,33 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
530542
einkOff();
531543
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
532544

545+
if(_partialUpdateLimiter!=0)
546+
_partialUpdateCounter++;
547+
533548
return changeCount;
534549
}
535550

551+
/**
552+
* @brief Set the number of partial updates afterwhich full screen update is performed.
553+
*
554+
* @param uint16_t _numberOfPartialUpdates
555+
* Number of allowed partial updates afterwhich full update is performed.
556+
* 0 = disabled, no automatic full update will be performed.
557+
*
558+
* @note By default, this is disabled, but to keep best image quality perform a full update
559+
* every 60-80 partial updates.
560+
*/
561+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
562+
{
563+
// Copy the value into the local variable.
564+
_partialUpdateLimiter = _numberOfPartialUpdates;
565+
566+
// If the limiter is enabled, force full update.
567+
if (_numberOfPartialUpdates != 0)
568+
_blockPartial = 1;
569+
}
570+
571+
536572
/**
537573
* @brief Wake a single or multiple peripherals for Inkplate 4TEMPERA.
538574
* They are in deep sleep by default so this function MUST be called

src/boards/Inkplate5.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
490490
return 0;
491491
}
492492

493+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
494+
{
495+
// Force full update.
496+
display1b(leaveOn);
497+
498+
// Reset the counter!
499+
_partialUpdateCounter = 0;
500+
501+
// Go back!
502+
return 0;
503+
}
504+
493505
uint16_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
494506
uint32_t _send;
495507
uint8_t data = 0;
@@ -560,9 +572,32 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
560572

561573
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
562574

575+
if(_partialUpdateLimiter!=0)
576+
_partialUpdateCounter++;
577+
563578
return changeCount;
564579
}
565580

581+
/**
582+
* @brief Set the number of partial updates afterwhich full screen update is performed.
583+
*
584+
* @param uint16_t _numberOfPartialUpdates
585+
* Number of allowed partial updates afterwhich full update is performed.
586+
* 0 = disabled, no automatic full update will be performed.
587+
*
588+
* @note By default, this is disabled, but to keep best image quality perform a full update
589+
* every 60-80 partial updates.
590+
*/
591+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
592+
{
593+
// Copy the value into the local variable.
594+
_partialUpdateLimiter = _numberOfPartialUpdates;
595+
596+
// If the limiter is enabled, force full update.
597+
if (_numberOfPartialUpdates != 0)
598+
_blockPartial = 1;
599+
}
600+
566601
/**
567602
* @brief clean function cleans screen of any potential burn in
568603
*

src/boards/Inkplate5V2.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
430430
return 0;
431431
}
432432

433+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
434+
{
435+
// Force full update.
436+
display1b(leaveOn);
437+
438+
// Reset the counter!
439+
_partialUpdateCounter = 0;
440+
441+
// Go back!
442+
return 0;
443+
}
444+
433445
uint32_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
434446
uint32_t _send;
435447
uint8_t data = 0;
@@ -501,9 +513,32 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
501513

502514
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
503515

516+
if(_partialUpdateLimiter!=0)
517+
_partialUpdateCounter++;
518+
504519
return changeCount;
505520
}
506521

522+
/**
523+
* @brief Set the number of partial updates afterwhich full screen update is performed.
524+
*
525+
* @param uint16_t _numberOfPartialUpdates
526+
* Number of allowed partial updates afterwhich full update is performed.
527+
* 0 = disabled, no automatic full update will be performed.
528+
*
529+
* @note By default, this is disabled, but to keep best image quality perform a full update
530+
* every 60-80 partial updates.
531+
*/
532+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
533+
{
534+
// Copy the value into the local variable.
535+
_partialUpdateLimiter = _numberOfPartialUpdates;
536+
537+
// If the limiter is enabled, force full update.
538+
if (_numberOfPartialUpdates != 0)
539+
_blockPartial = 1;
540+
}
541+
507542
/**
508543
* @brief clean function cleans screen of any potential burn in
509544
*

src/boards/Inkplate6.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
417417
return 0;
418418
}
419419

420+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
421+
{
422+
// Force full update.
423+
display1b(leaveOn);
424+
425+
// Reset the counter!
426+
_partialUpdateCounter = 0;
427+
428+
// Go back!
429+
return 0;
430+
}
431+
420432
uint16_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
421433
uint32_t _send;
422434
uint8_t data = 0;
@@ -495,9 +507,32 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
495507

496508
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
497509

510+
if(_partialUpdateLimiter!=0)
511+
_partialUpdateCounter++;
512+
498513
return changeCount;
499514
}
500515

516+
/**
517+
* @brief Set the number of partial updates afterwhich full screen update is performed.
518+
*
519+
* @param uint16_t _numberOfPartialUpdates
520+
* Number of allowed partial updates afterwhich full update is performed.
521+
* 0 = disabled, no automatic full update will be performed.
522+
*
523+
* @note By default, this is disabled, but to keep best image quality perform a full update
524+
* every 60-80 partial updates.
525+
*/
526+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
527+
{
528+
// Copy the value into the local variable.
529+
_partialUpdateLimiter = _numberOfPartialUpdates;
530+
531+
// If the limiter is enabled, force full update.
532+
if (_numberOfPartialUpdates != 0)
533+
_blockPartial = 1;
534+
}
535+
501536
/**
502537
* @brief clean function cleans screen of any potential burn in
503538
*

src/boards/Inkplate6FLICK.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
470470
return 0;
471471
}
472472

473+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
474+
{
475+
// Force full update.
476+
display1b(leaveOn);
477+
478+
// Reset the counter!
479+
_partialUpdateCounter = 0;
480+
481+
// Go back!
482+
return 0;
483+
}
484+
473485
uint32_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
474486
uint32_t _send;
475487
uint8_t data = 0;
@@ -540,7 +552,30 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
540552

541553
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
542554

555+
if(_partialUpdateLimiter!=0)
556+
_partialUpdateCounter++;
557+
543558
return changeCount;
544559
}
545560

561+
/**
562+
* @brief Set the number of partial updates afterwhich full screen update is performed.
563+
*
564+
* @param uint16_t _numberOfPartialUpdates
565+
* Number of allowed partial updates afterwhich full update is performed.
566+
* 0 = disabled, no automatic full update will be performed.
567+
*
568+
* @note By default, this is disabled, but to keep best image quality perform a full update
569+
* every 60-80 partial updates.
570+
*/
571+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
572+
{
573+
// Copy the value into the local variable.
574+
_partialUpdateLimiter = _numberOfPartialUpdates;
575+
576+
// If the limiter is enabled, force full update.
577+
if (_numberOfPartialUpdates != 0)
578+
_blockPartial = 1;
579+
}
580+
546581
#endif

src/boards/Inkplate6plus.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,18 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
480480
return 0;
481481
}
482482

483+
if(_partialUpdateCounter>=_partialUpdateLimiter && _partialUpdateLimiter != 0)
484+
{
485+
// Force full update.
486+
display1b(leaveOn);
487+
488+
// Reset the counter!
489+
_partialUpdateCounter = 0;
490+
491+
// Go back!
492+
return 0;
493+
}
494+
483495
uint32_t _pos = (E_INK_WIDTH * E_INK_HEIGHT / 8) - 1;
484496
// uint32_t _send;
485497
uint8_t data;
@@ -544,9 +556,32 @@ uint32_t Inkplate::partialUpdate(bool _forced, bool leaveOn)
544556
einkOff();
545557
memcpy(DMemoryNew, _partial, E_INK_WIDTH * E_INK_HEIGHT / 8);
546558

559+
if(_partialUpdateLimiter!=0)
560+
_partialUpdateCounter++;
561+
547562
return changeCount;
548563
}
549564

565+
/**
566+
* @brief Set the number of partial updates afterwhich full screen update is performed.
567+
*
568+
* @param uint16_t _numberOfPartialUpdates
569+
* Number of allowed partial updates afterwhich full update is performed.
570+
* 0 = disabled, no automatic full update will be performed.
571+
*
572+
* @note By default, this is disabled, but to keep best image quality perform a full update
573+
* every 60-80 partial updates.
574+
*/
575+
void Inkplate::setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)
576+
{
577+
// Copy the value into the local variable.
578+
_partialUpdateLimiter = _numberOfPartialUpdates;
579+
580+
// If the limiter is enabled, force full update.
581+
if (_numberOfPartialUpdates != 0)
582+
_blockPartial = 1;
583+
}
584+
550585
void Inkplate::setInkplatePowerMode(uint8_t _mode)
551586
{
552587
pwrMode = _mode;

0 commit comments

Comments
 (0)