def get_display_driver(): """ Get the dispay driver @return disp: display driver on which we display image """ # Config for display baudrate (default max is 24mhz): BAUDRATE = 24000000 # Configuration for CS and DC pins cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D17) reset_pin = digitalio.DigitalInOut(board.D27) # Setup SPI bus using hardware SPI: spi = board.SPI() #initialize st7735 display driver for 1.44" TFT disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE) return disp
def initialize(self): spi = board.SPI() self.display = st7735.ST7735R(spi, rotation=self.rotation, cs=ST7735Controller.cs_pin, dc=ST7735Controller.dc_pin, rst=ST7735Controller.reset_pin, baudrate=ST7735Controller.BAUDRATE) if self.display.rotation % 180 == 90: self.display_height = self.display.width self.display_width = self.display.height else: self.display_height = self.display.height self.display_width = self.display.width
def __init__(self, upside_down=False, name='screen'): cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D24) reset_pin = digitalio.DigitalInOut(board.D25) BAUDRATE = 40000000 spi = board.SPI() self.name = name self.active = False rotation_angle = 90 if not upside_down else 270 self.disp = st7735.ST7735R(spi, rotation=rotation_angle, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE) self.bgcolor = color565(0, 0, 0) self.led = LED(config.screen_led_pin, initial_value=True) # --- swap width/height, if if self.disp.rotation % 180 == 90: height, width = self.disp.width, self.disp.height else: width, height = self.disp.width, self.disp.height self.width, self.height = width, height logger.debug(F" ---> disp {self.disp.width},{self.disp.height}") self.boldfont = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "DejaVuSansMono-Bold.ttf"), 33) self.boldsmall = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "DejaVuSansMono-Bold.ttf"), 22) self.font = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "ariallgt.ttf"), 30) self.smallfont = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "ariallgt.ttf"), 20) self.oldfont = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "FreeMono.ttf"), 20) self.largefont = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "FreeMono.ttf"), 30) self.hugefont = ImageFont.truetype(pkg_resources.resource_filename("timemachine.fonts", "FreeMono.ttf"), 40) self.image = Image.new("RGB", (width, height)) self.draw = ImageDraw.Draw(self.image) # draw using this object. Display image when complete. self.staged_date = None self.selected_date = None self.staged_date_bbox = Bbox(0, 0, 160, 31) # self.selected_date_bbox = Bbox(0,100,130,128) self.selected_date_bbox = Bbox(0, 100, 160, 128) self.venue_bbox = Bbox(0, 31, 160, 56) self.nevents_bbox = Bbox(148, 31, 160, 56) self.track1_bbox = Bbox(0, 55, 160, 77) self.track2_bbox = Bbox(0, 78, 160, 100) self.playstate_bbox = Bbox(130, 100, 160, 128) self.sbd_bbox = Bbox(155, 100, 160, 108) self.exp_bbox = Bbox(0, 55, 160, 100) self.update_now = True self.sleeping = False
def __init__(self): """ Create a lcd_dislpay object """ # Create the display for 1.8" ST7735R: self.disp = st7735.ST7735R( SPI, rotation=ROTATION, cs=CS_PIN, dc=DC_PIN, rst=RESET_PIN, baudrate=BAUDRATE, ) # Set display dimensions. # We swap height/width to rotate display to landscape self.width = self.disp.height self.height = self.disp.width # Initialize to an empty black screen self.clear_screen()
def __init__(self): """ Create a lcd_display object """ # Create the display for 1.8" ST7735R: self.disp = st7735.ST7735R( SPI, rotation=ROTATION, cs=CS_PIN, dc=DC_PIN, rst=RESET_PIN, baudrate=BAUDRATE, ) # Set display dimensions. # We swap height/width to rotate display to landscape self.width = self.disp.height self.height = self.disp.width # Create blank image for drawing self.image = Image.new(COLOUR_MODEL, (self.width, self.height)) # Get drawing object to draw on image self.draw = ImageDraw.Draw(self.image) # Initialize to an empty black screen self.clear_screen()
cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D25) reset_pin = digitalio.DigitalInOut(board.D24) # Config for display baudrate (default max is 24mhz): BAUDRATE = 24000000 # Setup SPI bus using hardware SPI: spi = board.SPI() # pylint: disable=line-too-long # Create the display: disp = st7735.ST7735R( spi, rotation=90, # 1.8" ST7735R cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE, ) # pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. if disp.rotation % 180 == 90: height = disp.width # we swap height/width to rotate it to landscape! width = disp.height else: width = disp.width # we swap height/width to rotate it to landscape! height = disp.height image = Image.new("RGB", (width, height))
# Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D24) reset_pin = digitalio.DigitalInOut(board.D25) # Config for display baudrate (default max is 24mhz): BAUDRATE = 24000000 # Setup SPI bus using hardware SPI: spi = board.SPI() camera =PiCamera() camera.resolution = (128, 128) disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE) width = disp.width # we swap height/width to rotate it to landscape! height = disp.height image = Image.new('RGB', (width, height)) camera.framerate = 30 # Get drawing object to draw on image. draw = ImageDraw.Draw(image) while(True): camera.capture('/home/pi/Desktop/picture 1.bmp') image = Image.open("picture 1.bmp") # Scale the image to the smaller screen dimension
# pylint: disable=line-too-long # Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R disp = st7735.ST7735R( spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R # disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE, ) # pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. if disp.rotation % 180 == 90: height = disp.width # we swap height/width to rotate it to landscape! width = disp.height else:
def print(lineNumber, lineText): import digitalio import board from PIL import Image, ImageDraw, ImageFont import adafruit_rgb_display.st7735 as st7735 BORDER = 20 FONTSIZE = 24 #pins for SPI communication and reset cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D25) reset_pin = digitalio.DigitalInOut(board.D24) BAUDRATE = 24000000 spi = board.SPI() disp = st7735.ST7735R(spi, rotation=90, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE, ) height = disp.width width = disp.height image = Image.new("RGB", (width, height)) draw = ImageDraw.Draw(image) font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE) (font_width, font_height) = font.getsize(lineText) #line 1 if lineNumber == 1: draw.text((0,0),lineText,font=font,fill=(255,255,0), ) #line 2 elif lineNumber == 2: draw.text((0, font_height),lineText,font=font,fill=(255,255,0), ) #line 3 elif lineNumber == 3: draw.text((0,font_height*2),lineText,font=font,fill=(255,255,0), ) #line 4 elif lineNumber == 4: draw.text((0,font_height*3),lineText,font=font,fill=(255,255,0), ) elif lineNumber == 5: image = Image.open("kukka.jpg") #line 5 does not fit using this font size (24) """ draw.text( (width // 2 - font_width // 2, height // 2 - font_height // 2), text, font=font, fill=(255, 255, 0), )""" disp.image(image)
# Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R # disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 #disp = ili9341.ILI9341( disp = st7735.ST7735R( spi, rotation=0, # 2.2", 2.4", 2.8", 3.2" ILI9341 cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE, ) # pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. print(disp.width) print(disp.height) """ if disp.rotation % 180 == 90: height = disp.width # we swap height/width to rotate it to landscape! width = disp.height else:
# First define some constants to allow easy resizing of shapes. BORDER = 20 FONTSIZE = 24 # Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) dc_pin = digitalio.DigitalInOut(board.D24) reset_pin = digitalio.DigitalInOut(board.D25) # Config for display baudrate (default max is 24mhz): BAUDRATE = 24000000 # Setup SPI bus using hardware SPI: spi = board.SPI() disp = st7735.ST7735R( spi, rotation=90, height=160, width=120, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE, ) # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. if disp.rotation % 180 == 90: height = disp.width # we swap height/width to rotate it to landscape! width = disp.height else: width = disp.width # we swap height/width to rotate it to landscape! height = disp.height print("Width " + str(width) + " Height " + str(height)) image = Image.new("RGB", (width, height))