#!/usr/bin/env python
import board
import digitalio
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306
from time import sleep
from ccs811 import CCS811
# SEN-CCS811の利⽤
ccs811 = CCS811()
# SSD1306のピン設定
DEVICE_ADR = 0x3C
DISP_WIDTH = 128
DISP_HEIGHT = 64
def main():
# Setting some variables for our reset pin etc.
RESET_PIN = digitalio.DigitalInOut(board.D4)
# Very important… This lets py-gaugette ʻknowʼ what pins to use in order to reset the display
i2c = board.I2C()
oled = adafruit_ssd1306.SSD1306_I2C(DISP_WIDTH, DISP_HEIGHT, i2c, addr=DEVICE_ADR, reset=RESET_PIN)
while(True):
# Clear display.
oled.fill(0)
oled.show()
# Create blank image for drawing.
image = Image.new(“1”, (oled.width, oled.height))
draw = ImageDraw.Draw(image)
# Load a font in 2 different sizes.
font = ImageFont.truetype(“/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf”, 28)
font2 = ImageFont.truetype(“/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf”, 14)
voc, co2 = ccs811.get()
print(f”TVOC:{voc:4d} ppb, eCO2:{co2:4d} ppm”)
sleep(1)