Merge pull request #5512 from AnHardt/speed-compare-bbr
Optimize handling of block_buffer_runtime()
This commit is contained in:
commit
82fde7df2e
@ -395,10 +395,16 @@ class Planner {
|
|||||||
|
|
||||||
#if ENABLED(ULTRA_LCD)
|
#if ENABLED(ULTRA_LCD)
|
||||||
|
|
||||||
static millis_t block_buffer_runtime() {
|
static uint16_t block_buffer_runtime() {
|
||||||
CRITICAL_SECTION_START
|
CRITICAL_SECTION_START
|
||||||
millis_t bbru = block_buffer_runtime_us;
|
millis_t bbru = block_buffer_runtime_us;
|
||||||
CRITICAL_SECTION_END
|
CRITICAL_SECTION_END
|
||||||
|
// To translate µs to ms a division by 1000 would be required.
|
||||||
|
// We introduce 2.4% error here by dividing by 1024.
|
||||||
|
// Doesn't matter because block_buffer_runtime_us is already too small an estimation.
|
||||||
|
bbru >>= 10;
|
||||||
|
// limit to about a minute.
|
||||||
|
NOMORE(bbru, 0xfffful);
|
||||||
return bbru;
|
return bbru;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void lcd_status_screen();
|
|||||||
millis_t next_lcd_update_ms;
|
millis_t next_lcd_update_ms;
|
||||||
|
|
||||||
uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
|
uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
|
||||||
millis_t max_display_update_time = 0;
|
uint16_t max_display_update_time = 0;
|
||||||
|
|
||||||
#if ENABLED(DOGLCD)
|
#if ENABLED(DOGLCD)
|
||||||
bool drawing_screen = false;
|
bool drawing_screen = false;
|
||||||
@ -2978,12 +2978,13 @@ void lcd_update() {
|
|||||||
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
millis_t bbr = planner.block_buffer_runtime();
|
// then we want to use 1/2 of the time only.
|
||||||
|
uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
|
||||||
|
|
||||||
#if ENABLED(DOGLCD)
|
#if ENABLED(DOGLCD)
|
||||||
if ((lcdDrawUpdate || drawing_screen) && (!bbr || (bbr > 2 * max_display_update_time * 1000)))
|
if ((lcdDrawUpdate || drawing_screen) && (!bbr2 || (bbr2 > max_display_update_time)))
|
||||||
#else
|
#else
|
||||||
if (lcdDrawUpdate && (!bbr || (bbr > 2 * max_display_update_time * 1000)))
|
if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if ENABLED(DOGLCD)
|
#if ENABLED(DOGLCD)
|
||||||
|
Loading…
Reference in New Issue
Block a user