Пример #1
0
 def draw(self, disp, x=0, y=0):
     print("{:d}x{:d} image".format(self.width, self.height))
     print("{:d}-bit encoding detected".format(self.bpp))
     line = 0
     line_size = self.width * (self.bpp // 8)
     if line_size % 4 != 0:
         line_size += 4 - line_size % 4
     current_line_data = b""
     with open(self.filename, "rb") as f:
         f.seek(self.data)
         disp.set_window(x, y, self.width, self.height)
         for line in range(self.height):
             current_line_data = b""
             line_data = f.read(line_size)
             for i in range(0, line_size, self.bpp // 8):
                 if (line_size - i) < self.bpp // 8:
                     break
                 if self.bpp == 16:
                     color = convert_555_to_565(line_data[i]
                                                | line_data[i + 1] << 8)
                 if self.bpp == 24 or self.bpp == 32:
                     color = color565(line_data[i + 2], line_data[i + 1],
                                      line_data[i])
                 current_line_data = current_line_data + struct.pack(
                     ">H", color)
             disp.setxy(x, self.height - line + y)
             disp.push_pixels(current_line_data)
         disp.set_window(0, 0, disp.width, disp.height)
Пример #2
0
 def draw(self, disp, x=0, y=0):
     line = 0
     line_size = self.width * (self.bpp // 8)
     if line_size % 4 != 0:
         line_size += (4 - line_size % 4)
     current_line_data = b''
     with open(self.filename, 'rb') as f:
         f.seek(self.data)
         disp.set_window(x, y, self.width, self.height)
         for line in range(self.height):
             current_line_data = b''
             line_data = f.read(line_size)
             for i in range(0, line_size, self.bpp // 8):
                 if (line_size - i) < self.bpp // 8:
                     break
                 if self.bpp == 16:
                     color = convert_555_to_565(line_data[i]
                                                | line_data[i + 1] << 8)
                 if self.bpp == 24 or self.bpp == 32:
                     color = color565(line_data[i + 2], line_data[i + 1],
                                      line_data[i])
                 current_line_data = current_line_data + struct.pack(
                     ">H", color)
             disp.setxy(x, self.height - line + y)
             disp.push_pixels(current_line_data)
         disp.set_window(0, 0, disp.width, disp.height)
Пример #3
0
# SPDX-License-Identifier: MIT

# Quick bitmap test of RA8875 with Feather M4
import busio
import digitalio
import board

import adafruit_ra8875.ra8875 as ra8875
from adafruit_ra8875.ra8875 import color565

try:
    import struct
except ImportError:
    import ustruct as struct

WHITE = color565(255, 255, 255)

# Configuration for CS and RST pins:
cs_pin = digitalio.DigitalInOut(board.D9)
rst_pin = digitalio.DigitalInOut(board.D10)

# Config for display baudrate (default max is 6mhz):
BAUDRATE = 8000000

# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

# Create and setup the RA8875 display:
display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE)
display.init()
display.fill(WHITE)
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# Quick test of RA8875 with Feather M4
import time
import busio
import digitalio
import board

from adafruit_ra8875 import ra8875
from adafruit_ra8875.ra8875 import color565

BLACK = color565(0, 0, 0)
RED = color565(255, 0, 0)
BLUE = color565(0, 255, 0)
GREEN = color565(0, 0, 255)
YELLOW = color565(255, 255, 0)
CYAN = color565(0, 255, 255)
MAGENTA = color565(255, 0, 255)
WHITE = color565(255, 255, 255)

# Configuration for CS and RST pins:
cs_pin = digitalio.DigitalInOut(board.D9)
rst_pin = digitalio.DigitalInOut(board.D10)
int_pin = digitalio.DigitalInOut(board.D11)

# Config for display baudrate (default max is 6mhz):
BAUDRATE = 6000000

# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
Пример #5
0
esp32_reset = DigitalInOut(board.RTS)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset, gpio0_pin=dtr, debug=False)
requests.set_interface(esp)

# Connect SAM32 to the card and mount the filesystem
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

# Set up BME680 as an I2C device
i2c = I2C(board.SCL, board.SDA)
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False)
bme680.sea_level_pressure = 1013.25

# Set commonly used fill colors as constants
WHITE = color565(255, 255, 255)
BLACK = color565(0, 0, 0)

# Config for display baudrate (default max is 6mhz)
BAUDRATE = 8000000

# Create and setup the RA8875 display
display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE)
display.init()
display.fill(BLACK)

# Create strings to hold weather and time URLs
LOCATION = "Palo Alto, US"
WEATHER_URL = "http://api.openweathermap.org/data/2.5/weather?q="+LOCATION
WEATHER_URL += "&appid="+secrets['openweather_token']
TIME_URL = "http://worldtimeapi.org/api/timezone/" + secrets['timezone']