Skip to content

Commit

Permalink
Adaptive screen updates for all kinds of displays
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AnHardt committed Dec 13, 2016
1 parent 0772c8e commit d0e24e0
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 644 deletions.
30 changes: 0 additions & 30 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[
int freeMemory() { return SdFatUtil::FreeRam(); }
#else
extern "C" {
extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern char __bss_end;
extern char __heap_start;
extern void* __brkval;

int freeMemory() {
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/Cartesio/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/Felix/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/Hephestos/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/Hephestos_2/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/K8200/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,36 +520,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/K8400/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/RigidBot/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
30 changes: 0 additions & 30 deletions Marlin/example_configurations/SCARA/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,36 +507,6 @@
#define BABYSTEP_MULTIPLICATOR 1 //faster movements
#endif

//
// Ensure Smooth Moves
//
// Enable this option to prevent the machine from stuttering when printing multiple short segments.
// This feature uses two strategies to eliminate stuttering:
//
// 1. During short segments a Graphical LCD update may take so much time that the planner buffer gets
// completely drained. When this happens pauses are introduced between short segments, and print moves
// will become jerky until a longer segment provides enough time for the buffer to be filled again.
// This jerkiness negatively affects print quality. The ENSURE_SMOOTH_MOVES option addresses the issue
// by pausing the LCD until there's enough time to safely update.
//
// NOTE: This will cause the Info Screen to lag and controller buttons may become unresponsive.
// Enable ALWAYS_ALLOW_MENU to keep the controller responsive.
//
// 2. No block is allowed to take less time than MIN_BLOCK_TIME. That's the time it takes in the main
// loop to add a new block to the buffer, check temperatures, etc., including all blocked time due to
// interrupts (without LCD update). By enforcing a minimum time-per-move, the buffer is prevented from
// draining.
//
//#define ENSURE_SMOOTH_MOVES
#if ENABLED(ENSURE_SMOOTH_MOVES)
//#define ALWAYS_ALLOW_MENU // If enabled, the menu will always be responsive.
// WARNING: Menu navigation during short moves may cause stuttering!
#define LCD_UPDATE_THRESHOLD 135 // (ms) Minimum duration for the current segment to allow an LCD update.
// Default value is good for graphical LCDs (e.g., REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER).
// You may try to lower this value until you printer starts stuttering again as if ENSURE_SMOOTH_MOVES is disabled.
#define MIN_BLOCK_TIME 6 // (ms) Minimum duration of a single block. You shouldn't need to modify this.
#endif

// @section extruder

// extruder advance constant (s2/mm3)
Expand Down
Loading

0 comments on commit d0e24e0

Please sign in to comment.