ov2640_displayio_kaluga1_3_st7789.py
1 # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 # SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries 3 # 4 # SPDX-License-Identifier: Unlicense 5 6 """ 7 The Kaluga development kit comes in two versions (v1.2 and v1.3); this demo is 8 tested on v1.3. 9 10 The v1.3 development kit's LCD can have one of two chips, the ili9341 or 11 st7789. This demo is for the ili9341. There is no marking to distinguish the 12 two chips. If the visible portion of the display's flexible cable has a bunch 13 of straight lines, it may be an ili9341. If it has a bunch of wiggly traces, 14 it may be an st7789. If in doubt, try both demos. 15 16 The audio board must be mounted between the Kaluga and the LCD, it provides the 17 I2C pull-ups(!) 18 """ 19 20 import board 21 import busio 22 import displayio 23 from adafruit_st7789 import ST7789 24 import adafruit_ov2640 25 26 # Pylint is unable to see that the "size" property of OV2640_GrandCentral exists 27 # pylint: disable=attribute-defined-outside-init 28 29 # Release any resources currently in use for the displays 30 displayio.release_displays() 31 32 spi = busio.SPI(MOSI=board.LCD_MOSI, clock=board.LCD_CLK) 33 display_bus = displayio.FourWire( 34 spi, command=board.LCD_D_C, chip_select=board.LCD_CS, reset=board.LCD_RST 35 ) 36 display = ST7789( 37 display_bus, width=320, height=240, rotation=90, reverse_bytes_in_word=True 38 ) 39 40 bus = busio.I2C(scl=board.CAMERA_SIOC, sda=board.CAMERA_SIOD) 41 cam = adafruit_ov2640.OV2640( 42 bus, 43 data_pins=board.CAMERA_DATA, 44 clock=board.CAMERA_PCLK, 45 vsync=board.CAMERA_VSYNC, 46 href=board.CAMERA_HREF, 47 mclk=board.CAMERA_XCLK, 48 mclk_frequency=20_000_000, 49 size=adafruit_ov2640.OV2640_SIZE_QVGA, 50 ) 51 52 # cam.flip_x = False 53 # cam.flip_y = True 54 pid = cam.product_id 55 ver = cam.product_version 56 print(f"Detected pid={pid:x} ver={ver:x}") 57 # cam.test_pattern = True 58 59 g = displayio.Group(scale=1) 60 bitmap = displayio.Bitmap(320, 240, 65536) 61 tg = displayio.TileGrid( 62 bitmap, 63 pixel_shader=displayio.ColorConverter( 64 input_colorspace=displayio.Colorspace.BGR565_SWAPPED 65 ), 66 ) 67 g.append(tg) 68 display.root_group = g 69 70 display.auto_refresh = False 71 while True: 72 cam.capture(bitmap) 73 bitmap.dirty() 74 display.refresh(minimum_frames_per_second=0) 75 print(".") 76 77 cam.deinit()