def show(self): tft = self.tft width = self.width dx = 5 x0 = self.x0 x1 = self.x1 y0 = self.y0 y1 = self.y1 height = y1 - y0 if self.divisions > 0: dy = height / (self.divisions) # Tick marks for tick in range(self.divisions + 1): ypos = int(y0 + dy * tick) tft.draw_hline(x0, ypos, dx, self.fgcolor) tft.draw_hline(x1 - dx, ypos, dx, self.fgcolor) if self.legends is not None and self.font is not None: # Legends if len(self.legends) <= 1: dy = 0 else: dy = height / (len(self.legends) - 1) yl = self.y1 # Start at bottom for legend in self.legends: print_centered(tft, int(self.x0 + self.width / 2), int(yl), legend, self.fontcolor, self.font) yl -= dy if self.ptr_y is not None: # Restore background if it was saved tft.setXY(x0, self.ptr_y, x1, self.ptr_y) TFT_io.tft_write_data_AS(self.ptrbuf, self.ptrbytes) self.ptr_y = int(self.y1 - self._value * height) # y position of slider tft.setXY(x0, self.ptr_y, x1, self.ptr_y) # Read background TFT_io.tft_read_cmd_data_AS(0x2e, self.ptrbuf, self.ptrbytes) tft.draw_hline(x0, self.ptr_y, width, self.pointercolor) # Draw pointer
def render_bg(self, tft): if self.slide_y is not None: tft.setXY(*self.slide_coords()) TFT_io.tft_write_data_AS(self.slidebuf, self.slidebytes)