Adaptive screen updates for all kinds of displays

The target here is to update the screens of graphical and char base
displays as fast as possible, without draining the planner buffer too much.

For that measure the time it takes to draw and transfer one
(partial) screen to the display. Build a max. value from that.
Because ther can be large differences, depending on how much the display
updates are interrupted, the max value is decreased by one ms/s. This way
it can shrink again.
On the other side we keep track on how much time it takes to empty the
planner buffer.
Now we draw the next (partial) display update only then, when we do not
drain the planner buffer to much. We draw only when the time in the
buffer is two times larger than a update takes, or the buffer is empty anyway.

When we have begun to draw a screen we do not wait until the next 100ms
time slot comes. We draw the next partial screen as fast as possible, but
give the system a chance to refill the buffers a bit.

When we see, during drawing a screen, the screen contend has changed,
we stop the current draw and begin to draw the new content from the top.
This commit is contained in:
AnHardt
2016-12-12 14:35:02 +01:00
parent 0772c8e55f
commit d0e24e0876
23 changed files with 98 additions and 644 deletions

View File

@ -124,9 +124,7 @@ typedef struct {
uint32_t valve_pressure, e_to_p_pressure;
#endif
#if ENABLED(ENSURE_SMOOTH_MOVES)
uint32_t segment_time;
#endif
uint32_t segment_time;
} block_t;
@ -214,7 +212,7 @@ class Planner {
static float extruder_advance_k;
#endif
#if ENABLED(ENSURE_SMOOTH_MOVES)
#if ENABLED(ULTRA_LCD)
volatile static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
#endif
@ -381,33 +379,35 @@ class Planner {
static block_t* get_current_block() {
if (blocks_queued()) {
block_t* block = &block_buffer[block_buffer_tail];
#if ENABLED(ENSURE_SMOOTH_MOVES)
#if ENABLED(ULTRA_LCD)
block_buffer_runtime_us -= block->segment_time; //We can't be sure how long an active block will take, so don't count it.
#endif
SBI(block->flag, BLOCK_BIT_BUSY);
return block;
}
else {
#if ENABLED(ENSURE_SMOOTH_MOVES)
#if ENABLED(ULTRA_LCD)
clear_block_buffer_runtime(); // paranoia. Buffer is empty now - so reset accumulated time to zero.
#endif
return NULL;
}
}
#if ENABLED(ENSURE_SMOOTH_MOVES)
static bool long_move() {
#if ENABLED(ULTRA_LCD)
static millis_t block_buffer_runtime() {
CRITICAL_SECTION_START
uint32_t bbru = block_buffer_runtime_us;
millis_t bbru = block_buffer_runtime_us;
CRITICAL_SECTION_END
return !bbru || bbru > (LCD_UPDATE_THRESHOLD) * 1000UL + (MIN_BLOCK_TIME) * 3000UL;
return bbru;
}
static void clear_block_buffer_runtime(){
CRITICAL_SECTION_START
block_buffer_runtime_us = 0;
CRITICAL_SECTION_END
}
#endif
#if ENABLED(AUTOTEMP)