I am very new to coding and electronics and taking this as a hobby now that I’ve retired. I have bought three 64wx32h led matrices which work with an interstate75w and PICOw onboard. I’ve got to display stuff on one matrix with demo codes, but want to rotate the display to 64hX32w. After that I want to daisy chain 3x matrices to show 1 digit in each, in a cricket scoreboard for the local kiddos playing. Display to look like [3] [0] [2]. Could anyone give me some direction please? Thanks. Hardware that I bought listed below.
I have two 64 x 32 panels stacked vertically for a physical 64 x 64. As far as the Interstate 75 is concerned, electronically it is 128 x 32. I had to code for 128 x 32. I’m displaying text weather info.
i75 = Interstate75(display=Interstate75.DISPLAY_INTERSTATE75_128X32)
And text on the second display ends up something like this.
graphics.text(f"{describe_month(month)} {date}", 69, 1, scale=2)
It’s slightly indented (69), I think 64, 1 is the first pixel. It’s been a while since I coded on this setup.
Physically it’s 1, 33 but electronically 64,1. I hope I got that right? I’ll post my full file.
Warning, wall of text / code to follow. ;)
import time
import machine
import micropython
from interstate75 import Interstate75
from interstate75 import Interstate75, SWITCH_A, SWITCH_B
i75 = Interstate75(display=Interstate75.DISPLAY_INTERSTATE75_128X32)
graphics = i75.display
graphics.set_font("bitmap8")
BACKLIGHT_LOW = micropython.const(0.25)
BACKLIGHT_HIGH = micropython.const(1.0)
LUMINANCE_LOW = micropython.const(0)
LUMINANCE_HIGH = micropython.const(10) # 65535 to use the full range.
brightness = (1.0)
t_color = graphics.create_pen_hsv(0,0,0)
h_color = graphics.create_pen_hsv(0,0,0)
p_color = graphics.create_pen_hsv(0,0,0)
black = graphics.create_pen_hsv(0, 0, 0)
red = graphics.create_pen_hsv(1 / 360, 1.0, brightness)
green = graphics.create_pen_hsv(130 / 360, 1.0, brightness)
blue = graphics.create_pen_hsv(250 / 360, 1.0, brightness)
yellow = graphics.create_pen_hsv(60 / 360, 1.0, brightness)
orange = graphics.create_pen_hsv(30 / 360, 1.0, brightness)
white = graphics.create_pen_hsv(1.0, 0, brightness)
graphics.set_pen(black)
graphics.clear()
i75.update(graphics)
i75.set_led(0, 0 ,0)
from pimoroni_i2c import PimoroniI2C
i2c = PimoroniI2C(sda=(20), scl=(21))
from breakout_bme280 import BreakoutBME280
bme_in = BreakoutBME280(i2c,0x77)
temp_in, press_in, hum_in = bme_in.read()
bme_out = BreakoutBME280(i2c,0x76)
temp_out, press_out, hum_out = bme_out.read()
time.sleep(0.5)
from breakout_ltr559 import BreakoutLTR559
ltr = BreakoutLTR559(i2c)
part_id = ltr.part_id()
from breakout_rtc import BreakoutRTC
from machine import RTC
RV3028 = BreakoutRTC(i2c)
rtc = BreakoutRTC(i2c)
if rtc.is_12_hour:
rtc.set_24_hour()
RV3028.update_time()
hour = rtc.get_hours()
minute = rtc.get_minutes()
month = rtc.get_month()
date = rtc.get_date()
if rtc.read_periodic_update_interrupt_flag():
rtc.clear_periodic_update_interrupt_flag()
if rtc.update_time():
rtc_date = rtc.string_date()
rtc_time = rtc.string_time()
time.sleep (0.5)
def describe_weekday(weekday):
if weekday == 0:
description = "Mon"
if weekday == 1:
description = "Tues"
if weekday == 2:
description = "Wed"
if weekday == 3:
description = "Thurs"
if weekday == 4:
description = "Fri"
if weekday == 5:
description = "Sat"
if weekday == 6:
description = "Sun"
return description
def describe_month(month):
month = rtc.get_month()
if month == 1:
description = "Jan"
elif month == 2:
description = "Feb"
elif month == 3:
description = "Mar"
elif month == 4:
description = "Apr"
elif month == 5:
description = "May"
elif month == 6:
description = "Jun"
elif month == 7:
description = "Jul"
elif month == 8:
description = "Aug"
elif month == 9:
description = "Sept"
elif month == 10:
description = "Oct"
elif month == 11:
description = "Nov"
elif month == 12:
description = "Dec"
return description
def describe_date(date):
date = rtc.get_date()
if date == 1:
description = "st"
elif date == 2:
description = "nd"
elif date == 3:
description = "rd"
elif date == 21:
description = "st"
elif date == 22:
description = "nd"
elif date == 23:
description = "rd"
elif date == 31:
description = "st"
else:
description = "th"
return description
def auto_brightness(previous: float) -> (float, float):
luminance = reading[BreakoutLTR559.LUX]
luminance_frac = max(0.0, float(luminance - LUMINANCE_LOW))
luminance_frac = min(1.0, luminance_frac / (LUMINANCE_HIGH - LUMINANCE_LOW))
backlight = BACKLIGHT_LOW + (luminance_frac * (BACKLIGHT_HIGH - BACKLIGHT_LOW))
# Use the previous value to smooth out changes to reduce flickering.
# The "32" value here controls how quickly it reacts (larger = slower).
# The rate at which the main loop calls us also affects that!
backlight_diff = backlight - previous
backlight = previous + (backlight_diff * (1.0 / 8.0))
if backlight > 1:
backlight == 1
return (luminance, backlight)
backlight = BACKLIGHT_LOW
start_time = time.time()
while True:
reading = ltr.get_reading()
lux = reading[BreakoutLTR559.LUX]
(luminance, backlight) = auto_brightness(backlight)
time.sleep(0.1)
brightness = backlight
black = graphics.create_pen_hsv(0, 0, 0)
red = graphics.create_pen_hsv(1 / 360, 1.0, brightness)
green = graphics.create_pen_hsv(130 / 360, 1.0, brightness)
blue = graphics.create_pen_hsv(250 / 360, 1.0, brightness)
yellow = graphics.create_pen_hsv(60 / 360, 1.0, brightness)
orange = graphics.create_pen_hsv(30 / 360, 1.0, brightness)
white = graphics.create_pen_hsv(1.0, 0, brightness)
time_elapsed = time.time() - start_time
RV3028.update_time()
hour = rtc.get_hours()
minute = rtc.get_minutes()
month = rtc.get_month()
date = rtc.get_date()
weekday = rtc.get_weekday()
if rtc.read_periodic_update_interrupt_flag():
rtc.clear_periodic_update_interrupt_flag()
if rtc.update_time():
rtc_date = rtc.string_date()
rtc_time = rtc.string_time()
graphics.set_pen(white)
if hour == 0:
graphics.text(f"{12}:{minute:02}", 1, 1, scale=2)
graphics.text("AM", 43, 1, scale=2)
elif 0 <= hour < 10:
graphics.text(f"{hour:1}:{minute:02}", 5, 1, scale=2)
graphics.text("AM", 43, 1, scale=2)
elif 10 <= hour < 12:
graphics.text(f"{hour:2}:{minute:02}", 1, 1, scale=2)
graphics.text("AM", 43, 1, scale=2)
elif hour == 12:
graphics.text(f"{hour:2}:{minute:02}", 1, 1, scale=2)
graphics.text("PM", 43, 1, scale=2)
elif hour > 12:
hour = hour - 12
if hour < 10:
graphics.text(f"{hour:1}:{minute:02}", 5, 1, scale=2)
graphics.text("PM", 43, 1, scale=2)
elif 10 <= hour < 12:
graphics.text(f"{hour:2}:{minute:02}", 1, 1, scale=2)
graphics.text("PM", 43, 1, scale=2)
elif hour == 12:
graphics.text(f"{hour:2}:{minute:02}", 1, 1, scale=2)
graphics.text("AM", 43, 1, scale=2)
graphics.set_pen(white)
graphics.text(f"{describe_weekday(weekday)}", 5, 17, scale=2)
graphics.text(f"{describe_month(month)} {date}", 69, 1, scale=2)
#graphics.text(f"{date}{describe_date(date)}", 69, 17, scale=2)
i75.update(graphics)
time.sleep(5)
graphics.set_pen(black)
graphics.clear()
graphics.set_pen(white)
graphics.text("In", 25, 1, scale=2)
temp_in, press_in, hum_in = bme_in.read()
temp_in = round(temp_in)
if temp_in < -10:
t_color = white
elif -10 <= temp_in <= 0:
t_color = blue
elif 0 < temp_in <= 12:
t_color = yellow
elif 12 < temp_in <= 16:
t_color = green
elif 16 < temp_in <= 24:
t_color = green
elif 24 < temp_in <= 27:
t_color = orange
elif tempin > 27:
t_color = red
graphics.set_pen(t_color)
graphics.text("{:0.0f}°C" .format(temp_in), 5, 17, scale=2)
hum_in = round(hum_in)
if hum_in < 30:
h_color = red
elif 30 <= hum_in <= 60:
h_color = green
elif 60 < hum_in < 80:
h_color = yellow
elif hum_in >= 80:
h_color = orange
graphics.set_pen(h_color)
graphics.text("{:0.0f}%".format(hum_in), 69, 1, scale=2)
graphics.text("RH", 107, 1, scale=2)
press_in = press_in / 100
press_in = round(press_in)
if press_in < 982:
p_color = red
elif 982 <= press_in < 1004:
p_color = yellow
elif 1004 <= press_in < 1026:
p_color = green
elif 1026 <= press_in < 1048:
p_color = blue
elif press_in >= 1048:
p_color = orange
graphics.set_pen(p_color)
graphics.text("{:0.0f}" .format(press_in), 69, 17, scale=2)
graphics.text("mb", 107, 17, scale=2)
i75.update(graphics)
time.sleep(5)
graphics.set_pen(black)
graphics.clear()
graphics.set_pen(white)
graphics.text("Out", 20, 1, scale=2)
temp_out, press_out, hum_out = bme_out.read()
temp_out = round(temp_out)
if temp_out < -10:
t_color = white
elif -10 <= temp_out <= 0:
t_color = blue
elif 0 < temp_out <= 12:
t_color = yellow
elif 12 < temp_out <= 16:
t_color = green
elif 16 < temperature <= 24:
t_color = green
elif 24 < temp_out <= 27:
t_color = orange
elif temp_out > 27:
t_color = red
graphics.set_pen(t_color)
graphics.text("{:0.0f}°C" .format(temp_out), 5, 17, scale=2)
hum_out = round(hum_out)
if hum_out < 30:
h_color = red
elif 30 <= hum_out <= 60:
h_color = green
elif 60 < hum_out < 80:
h_color = yellow
elif hum_out >= 80:
h_color = orange
graphics.set_pen(h_color)
graphics.text("{:0.0f}%".format(hum_out), 69, 1, scale=2)
graphics.text("RH", 107, 1, scale=2)
press_out = press_out / 100
press_out = round(press_out)
if press_out < 982:
p_color = red
elif 982 <= press_out < 1004:
p_color = yellow
elif 1004 <= press_out < 1026:
p_color = green
elif 1026 <= press_out < 1048:
p_color = blue
elif press_out >= 1048:
p_color = orange
graphics.set_pen(p_color)
graphics.text("{:0.0f}" .format(press_in), 69, 17, scale=2)
graphics.text("mb", 107, 17, scale=2)
i75.update(graphics)
time.sleep(5)
graphics.set_pen(black)
graphics.clear()