278 views|1 replies

13

Posts

3

Resources
The OP
 

【Follow me Season 2 Episode 1】Optional Task: Using SH1107 OLDE Screen [Copy link]

 This post was last edited by disk0 on 2024-8-18 17:29

Task understanding

During the ordering phase, the difference was placed on M5's SH1107

Because CPX has no display module, the sensor reading can be more intuitive

Code section

import board
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_sh1107
import gc
import os
import busio
import random
import time
import analogio
import adafruit_thermistor

gc.enable()

# release any currently configured displays
displayio.release_displays()


# Setup I2C
i2c = busio.I2C(board.SCL, board.SDA)  # uses board.SCL and board.SDA
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)


# SH1107 is vertically oriented 64x128
WIDTH = 128
HEIGHT = 64

display = adafruit_displayio_sh1107.SH1107(
    display_bus, width=WIDTH, height=HEIGHT, rotation=0
)

splash = displayio.Group()
display.root_group = splash

default_text = " "*7
text_area = label.Label(terminalio.FONT, text=default_text, scale=2, color=0xFFFFFF, x=0, y=10)

display.root_group =text_area

sensor_light = analogio.AnalogIn(board.LIGHT)
sensor_temp = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950)

while True:
    gc.collect()
    print('mem_free',gc.mem_free())
    temp_value = str(round(sensor_temp.temperature,1))
    light_value = str(sensor_light.value)
    show_value = temp_value + '/' + light_value
    # show_value = 'T/L' + '\n' + show_value
    text_new= show_value
    text_area.text = text_new
    time.sleep(1)

Main logic

1. The main part is sensor reading, please refer to

2. The headers need to be imported into the lib folder: adafruit_display_text and adafruit_displayio_sh1107

3. Line 33~42 mainly instantiates the display part, and finally in the large loop periodically updates the sensor value to the text in the display area

exhibit

This post is from DigiKey Technology Zone

Latest reply

sh1107 display module, I guess you just bought an extra display module   Details Published on 2024-8-18 21:33
 
 

6027

Posts

6

Resources
2
 

sh1107 display module, I guess you just bought an extra display module

This post is from DigiKey Technology Zone
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list