@@ -445,42 +445,52 @@ def _draw_vline(self, x1, y1, y2, colidx):
445445
446446 # def _clear_plot_bitmap(self): ### woz here
447447
448- # This is almost always going to be quicker
449- # than the slow _clear_plot_bitmap implemented on 5.0.0
450- def _undraw_bitmap (self ):
451- if not self ._plot_dirty :
452- return
448+ def _redraw_all_col_idx (self , col_idx_list ):
453449 x_cols = min (self ._data_values , self ._plot_width )
454450 wrapMode = self ._mode == "wrap"
455451 if wrapMode :
456452 x_data_idx = (self ._data_idx - self ._x_pos ) % self ._data_size
457453 else :
458454 x_data_idx = (self ._data_idx - x_cols ) % self ._data_size
459455
460- colidx = self .TRANSPARENT_IDX
461456 for ch_idx in range (self ._channels ):
457+ col_idx = col_idx_list [ch_idx ]
462458 data_idx = x_data_idx
463459 for x_pos in range (x_cols ):
464460 # "jump" the gap in the circular buffer for wrap mode
465461 if wrapMode and x_pos == self ._x_pos :
466462 data_idx = (data_idx + self ._data_size - self ._plot_width ) % self ._data_size
467- # TODO - inhibit line drawing in BOTH VERSIONS
463+ # ideally this should inhibit lines between wrapped data
468464
469465 y_pos = self ._data_y_pos [ch_idx ][data_idx ]
470466 if self ._style == "lines" and x_pos != 0 :
471467 # Python supports negative array index
472468 prev_y_pos = self ._data_y_pos [ch_idx ][data_idx - 1 ]
473- self ._draw_vline (x_pos , prev_y_pos , y_pos , colidx )
469+ self ._draw_vline (x_pos , prev_y_pos , y_pos , col_idx )
474470 else :
475471 if 0 <= y_pos <= self ._plot_height_m1 :
476- self ._displayio_plot [x_pos , y_pos ] = colidx
472+ self ._displayio_plot [x_pos , y_pos ] = col_idx
477473 data_idx += 1
478474 if data_idx >= self ._data_size :
479475 data_idx = 0
480476
477+ # This is almost always going to be quicker
478+ # than the slow _clear_plot_bitmap implemented on 5.0.0 displayio
479+ def _undraw_bitmap (self ):
480+ if not self ._plot_dirty :
481+ return
482+
483+ self ._redraw_all_col_idx ([self .TRANSPARENT_IDX ] * self ._channels )
481484 self ._plot_dirty = False
482485
486+
487+ def _redraw_all (self ):
488+ self ._redraw_all_col_idx (self ._channel_colidx )
489+ self ._plot_dirty = True
490+
491+
483492 def _undraw_column (self , x_pos , data_idx ):
493+ """Undraw a single column at x_pos based on data from data_idx."""
484494 colidx = self .TRANSPARENT_IDX
485495 for ch_idx in range (self ._channels ):
486496 y_pos = self ._data_y_pos [ch_idx ][data_idx ]
@@ -492,47 +502,10 @@ def _undraw_column(self, x_pos, data_idx):
492502 if 0 <= y_pos <= self ._plot_height_m1 :
493503 self ._displayio_plot [x_pos , y_pos ] = colidx
494504
495- # TODO - This is a cut and paste from _undraw_bitmap()
496- # TODO - This is a cut and paste from _undraw_bitmap()
497- # TODO - This is a cut and paste from _undraw_bitmap()
498- # TODO - This is a cut and paste from _undraw_bitmap()
499-
500- # TODO - time to clean this up and review _data_redraw()
501- def _data_redraw_all (self ):
502- x_cols = min (self ._data_values , self ._plot_width )
503- wrapMode = self ._mode == "wrap"
504- if wrapMode :
505- x_data_idx = (self ._data_idx - self ._x_pos ) % self ._data_size
506- else :
507- x_data_idx = (self ._data_idx - x_cols ) % self ._data_size
508-
509- for ch_idx in range (self ._channels ):
510- colidx = self ._channel_colidx [ch_idx ]
511- data_idx = x_data_idx
512- for x_pos in range (x_cols ):
513- # "jump" the gap in the circular buffer for wrap mode
514- if wrapMode and x_pos == self ._x_pos :
515- data_idx = (data_idx + self ._data_size - self ._plot_width ) % self ._data_size
516- # TODO - inhibit line drawing in BOTH VERSIONS
517-
518- y_pos = self ._data_y_pos [ch_idx ][data_idx ]
519- if self ._style == "lines" and x_pos != 0 :
520- # Python supports negative array index
521- prev_y_pos = self ._data_y_pos [ch_idx ][data_idx - 1 ]
522- self ._draw_vline (x_pos , prev_y_pos , y_pos , colidx )
523- else :
524- if 0 <= y_pos <= self ._plot_height_m1 :
525- self ._displayio_plot [x_pos , y_pos ] = colidx
526- data_idx += 1
527- if data_idx >= self ._data_size :
528- data_idx = 0
529-
530- self ._plot_dirty = True
531-
532- # TODO - very similar code to _undraw_bitmap although that is now
533- # more sophisticated as it support wrap mode
534- def _data_redraw (self , x1 , x2 , x1_data_idx ):
535- """Redraw data from x1 to x2 inclusive."""
505+ # very similar code to _undraw_bitmap although that is now
506+ # more sophisticated as it supports wrap mode
507+ def _redraw_for_scroll (self , x1 , x2 , x1_data_idx ):
508+ """Redraw data from x1 to x2 inclusive for scroll mode only."""
536509 for ch_idx in range (self ._channels ):
537510 colidx = self ._channel_colidx [ch_idx ]
538511 data_idx = x1_data_idx
@@ -703,8 +676,9 @@ def data_add(self, values):
703676 sc_data_idx = ((data_idx + self ._scroll_px - self ._plot_width )
704677 % self ._data_size )
705678 self ._data_values -= self ._scroll_px
706- self ._data_redraw (0 , self ._plot_width - 1 - self ._scroll_px ,
707- sc_data_idx )
679+ self ._redraw_for_scroll (0 ,
680+ self ._plot_width - 1 - self ._scroll_px ,
681+ sc_data_idx )
708682 x_pos = self ._plot_width - self ._scroll_px
709683
710684 elif self ._scale_mode == "pixel" :
@@ -768,7 +742,7 @@ def _change_y_range(self, new_plot_min, new_plot_max, redraw_plot=True):
768742 self ._undraw_bitmap ()
769743 self ._recalc_y_pos () ## calculates new y positions
770744 if redraw_plot :
771- self ._data_redraw_all ()
745+ self ._redraw_all ()
772746
773747 @property
774748 def title (self ):
0 commit comments