コード例 #1
0
    def __init__(self):
        self.image = Image.new(
            Config.DISPLAY_IMAGE_MODE, (Config.DISPLAY_WIDTH, Config.DISPLAY_HEIGHT))
        self.font = ImageFont.load_default()
        self.draw = ImageDraw.Draw(self.image)
        self.pygame_instance = None
        self.pygame_screen = None
        self.ssd1306 = None

        if Config.UI_OUT is UI_OUT.PYGAME:
            pygame.display.set_caption("PISDUP EMU")
            self.pygame_screen = pygame.display.set_mode(self.image.size)

        if Config.UI_OUT is UI_OUT.SD11306:
            self.ssd1306 = SSD1306_I2C(Config.DISPLAY_WIDTH, Config.DISPLAY_HEIGHT, busio.I2C(
                SCL, SDA), addr=Config.I2C_DISPLAY_ADDR, reset=None)
            self.ssd1306.fill(DisplayColor.BLACK)
コード例 #2
0
ファイル: oled.py プロジェクト: yavimaya/Retropie-CRT-Edition
 def prepare(self):
     set_procname(PNAME_OLED)
     if self.detect():
         i2c = busio.I2C(D1, D0) # Create the I2C interface.
         # Create the SSD1306 OLED class.
         # The first two parameters are the pixel width and pixel height.
         self.m_oDisplay = SSD1306_I2C(128, 64, i2c, addr=0x3C)
         # Create blank image for drawing.
         # Make sure to create image with mode '1' for 1-bit color.
         self.m_iDspWidth = self.m_oDisplay.width
         self.m_iDspHeight = self.m_oDisplay.height
         self.m_oOutput = Image.new("1", (self.m_iDspWidth, self.m_iDspHeight), color=0)
         self.m_oDraw = ImageDraw.Draw(self.m_oOutput)
         self.get_config()
         self.get_assets()
         self.clear_screen()
     else:
         logging.info("Exiting piCRT display module")
         sys.exit()
コード例 #3
0
    def __init__(self, width, height, i2c, folder, data):

        disp = SSD1306_I2C(width, height, i2c)  # Pixel width and height.
        disp.fill(0)
        disp.show()
        image = Image.new('1', (width, height))
        draw = ImageDraw.Draw(image)
        draw.rectangle((0, 0, width, height), outline=0, fill=0)  # Clear image
        padding = -9
        self.data = data
        self.top = padding
        self.bottom = height - padding
        self.x = 0  # Move left to right keeping track of the current x position for drawing shapes.
        self.image = image
        self.folder = folder
        self.width = width
        self.height = height
        self.lang = 'ru'
        self.disp = disp
        self.draw = draw
        self.vals = {
            'temperature': {
                'en': 'TEMPERATURE',
                'ru': 'ТЕМПЕРАТУРА',
            },
            'humidity': {
                'en': 'HUMIDITY',
                'ru': 'ВЛАЖНОСТЬ',
            }
        }

        # MENU
        self.mode = 'large_humidity'
        #self.mode = 'main_menu'
        self.select = 0
        self.boo = False
        self.controls = {}
コード例 #4
0
ファイル: ssd1306.py プロジェクト: frantp/piot
 def __init__(self, width, height, addr=0x3C, reset=None):
     super().__init__()
     i2c = busio.I2C(board.SCL, board.SDA)
     self._disp = SSD1306_I2C(width, height, i2c, addr=addr, reset=reset)
     self._buffer = {}
コード例 #5
0
 def ssd1306(self, signal, width, height):
     from adafruit_ssd1306 import SSD1306_I2C  # pip3 install adafruit-ssd1306
     self.i2c_init()
     self.io[signal] = SSD1306_I2C(width, height, self.i2c)
コード例 #6
0
ファイル: stats.py プロジェクト: pashutk/pisdup
import time
import subprocess

from board import SCL, SDA
import busio
from PIL import Image, ImageDraw, ImageFont
from adafruit_ssd1306 import SSD1306_I2C

i2c = busio.I2C(SCL, SDA)
disp = SSD1306_I2C(128, 64, i2c, addr=0x3c, reset=None)
disp.fill(0)
disp.show()
width = disp.width
height = disp.height
# print(width)
# print(height)
image = Image.new("1", (width, height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, width, height), outline=0, fill=0)
# draw.rectangle((0, 0, 20, 20), outline=0, fill=255)

disp.image(image)
disp.show()

i = 0
while True:
    if i > width - 2:
        i = 0
    i = i + 1
    # disp.fill(0)
    draw.rectangle((0, 0, width, height), outline=0, fill=0)
コード例 #7
0
ractl_cmd = RaCtlCmds(sock_cmd=sock_cmd, token=TOKEN)

WIDTH = 128
BORDER = 5

# How long to delay between each update
DELAY_TIME_MS = 1000

# Define the Reset Pin
OLED_RESET = None

# init i2c
I2C = I2C()

# 128x32 display with hardware I2C:
OLED = SSD1306_I2C(WIDTH, HEIGHT, I2C, addr=0x3C, reset=OLED_RESET)
OLED.rotation = ROTATION

print("Running with the following display:")
print(OLED)
print()
print("Will update the OLED display every " + str(DELAY_TIME_MS) +
      "ms (approximately)")

# Show a startup splash bitmap image before starting the main loop
# Convert the image to mode '1' for 1-bit color (monochrome)
# Make sure the splash bitmap image is in the same dir as this script
IMAGE = Image.open(f"resources/splash_start_{HEIGHT}.bmp").convert("1")
OLED.image(IMAGE)
OLED.show()