def interrupt(p): d.measure() display.clear() display.draw_text(40, 30, "Temp: " + str(d.temperature()), font, color565(0, 0, 255)) display.draw_text(38, 40, "Hum: " + str(d.humidity()), font, color565(0, 0, 255))
def test(): """Test code.""" # Baud rate of 14500000 seems about the max spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) x, y = 0, 0 angle = 0.0 # Loop all angles from 0 to 2 * PI radians while angle < PI2: # Calculate x, y from a vector with known length and angle x = int(CENTER_X * sin(angle) + HALF_WIDTH) y = int(CENTER_Y * cos(angle) + HALF_HEIGHT) color = color565(*hsv_to_rgb(angle / PI2, 1, 1)) display.draw_line(x, y, CENTER_X, CENTER_Y, color) angle += ANGLE_STEP_SIZE sleep(5) for r in range(CENTER_X, 0, -1): color = color565(*hsv_to_rgb(r / HALF_WIDTH, 1, 1)) display.fill_circle(CENTER_X, CENTER_Y, r, color) sleep(9) display.cleanup()
def mpu9250_test(c): import mpu6500 try: mpu = mpu6500.MPU6500(c.i2c) print(mpu.acceleration) print(mpu.gyro) print(mpu.whoami) # <- 113 while True: if c.interrupt(): c.display.clear() break (x, y, z) = mpu.acceleration print(x, y) print(abs(int(y * 3))) print(abs(int(x * 3))) c.display.draw_vline(64, 64, abs(int(y * 3)), color565(255, 0, 0)) c.display.draw_hline(64, 64, abs(int(x * 3)), color565(0, 0, 255)) c.display.clear() c.display.fill_circle(64, 64, 10, color565(255, 255, 255)) time.sleep(2) except Exception as e: c.display.clear() c.display.draw_text(0, 40, str(e), font, color565(0, 0, 255)) finally: time.sleep(2)
def update(self, screen, needs_full_redraw=False): from ssd1351 import color565 if needs_full_redraw: screen.fill_rectangle(0, 0, 127, 9, color565(0, 0, 0)) screen.draw_text(0, 0, "Light Effect", display.FONT_FIXED, color565(255, 255, 255)) if self._dirty or needs_full_redraw: self._dirty = False screen.fill_rectangle(0, 9, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 9 + self._y0, self.light_show.effect, display.FONT_FIXED, color565(0, 255, 0))
def read_septic(): buf = uart.readline() if len(buf) > 3: height = (buf[1] * 256 + buf[2]) print(height) septic_level = (int)((height / MAX_SEPTIC) * 120) # print(barsize) if septic_level > 0: display.fill_hrect(1, 93, septic_level, 18, color565(0, 255, 0)) display.fill_hrect(septic_level + 1, 93, 121 - septic_level, 18, color565(0, 0, 0)) display.draw_text(50, 80, str(septic_level) + '/' + str(MAX_SEPTIC), bally, color565(255, 255, 255))
def test(): """CircuitPython Text, Shape & Sprite""" if implementation.name != 'circuitpython': print() print('This demo is for CircuitPython only!') exit() try: # Configuratoin for CS and DC pins: cs_pin = DigitalInOut(board.P0_15) dc_pin = DigitalInOut(board.P0_17) rst_pin = DigitalInOut(board.P0_20) # Setup SPI bus using hardware SPI: spi = SPI(clock=board.P0_24, MOSI=board.P0_22) # Create the SSD1351 display: display = Display(spi, dc=dc_pin, cs=cs_pin, rst=rst_pin) display.clear() # Load Fixed Font fixed = XglcdFont('fonts/FixedFont5x8.c', 5, 8, letter_count=96) # Title WIDTH = 128 text = 'CircuitPython Demo' # Measure text and center length = fixed.measure_text(text) x = int((WIDTH / 2) - (length / 2)) display.draw_text(x, 6, text, fixed, color565(255, 255, 0)) # Draw title outline display.draw_rectangle(0, 0, 127, 20, color565(0, 255, 0)) # Load sprite logo = BouncingSprite('images/blinka45x48.raw', 45, 48, 128, 128, 1, display) while True: timer = monotonic() logo.update_pos() logo.draw() # Attempt to set framerate to 30 FPS timer_dif = .033333333 - (monotonic() - timer) if timer_dif > 0: sleep(timer_dif) except KeyboardInterrupt: display.cleanup()
def game_over(self): """Display game over.""" game_over_width = self.xfont.measure_text('GAME OVER') self.display.draw_text( (self.display.width // 2) - (game_over_width // 2), int(self.display.height / 1.5), 'GAME OVER', self.xfont, color565(255, 255, 255))
def test(): """Scrolling Marquee""" try: # Implementation dependant pin and SPI configuration if implementation.name == 'circuitpython': import board from busio import SPI from digitalio import DigitalInOut cs_pin = DigitalInOut(board.P0_15) dc_pin = DigitalInOut(board.P0_17) rst_pin = DigitalInOut(board.P0_20) spi = SPI(clock=board.P0_24, MOSI=board.P0_22) else: from machine import Pin, SPI cs_pin = Pin(5) dc_pin = Pin(17) rst_pin = Pin(16) spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) # Create the SSD1351 display: display = Display(spi, dc=dc_pin, cs=cs_pin, rst=rst_pin) display.clear() # Draw non-moving circles display.fill_circle(63, 63, 63, color565(27, 72, 156)) display.fill_circle(63, 63, 53, color565(0, 0, 0)) display.fill_circle(63, 63, 43, color565(189, 0, 36)) display.fill_circle(63, 63, 33, color565(0, 0, 0)) # Load Marquee image display.draw_image('images\Rototron128x26.raw', 0, 50, 128, 26) # Set up scrolling display.set_scroll(horiz_offset=1, vert_start_row=50, vert_row_count=26, vert_offset=0, speed=1) display.scroll(True) while True: # Do nothing, scrolling handled by hardware sleep(1) except KeyboardInterrupt: display.cleanup()
def polygon_select(): e = c.encoder display = c.display colors = [ (255, 0, 0), (153, 50, 0), (0, 255, 0), (0, 0, 255), (0, 0, 0), (255, 255, 0), (0, 255, 255), ] names = [ 'Victor', 'Olav', 'Ina', 'Dagfinn', 'Sebastian', 'Anna', 'Christine', ] numcolors = len(colors) val = e.value try: while True: if c.interrupt(): display.clear(color565(0, 0, 0)) break if e.value != val: val = e.value i = val % numcolors color = colors[i] display.clear(color565(*color)) display.fill_polygon(sides=i + 3, x0=64, y0=64, r=35, color=color565(255, 255, 255)) display.draw_text(50, 60, names[i], font, color565(255, 255, 255)) sleep_ms(100) finally: display.clear()
def test(): """Test code.""" spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.draw_text8x8(0, 0, 'Built-in', color565(255, 0, 255)) display.draw_text8x8(16, 16, 'MicroPython', color565(255, 255, 0)) display.draw_text8x8(32, 32, '8x8 Font', color565(0, 0, 255)) display.draw_text8x8(63, 120, "Portrait", color565(0, 255, 0)) display.draw_text8x8(0, 56, "Landscape", color565(255, 0, 0), landscape=True) sleep(9) display.cleanup()
def front_test(c): display = c.display enc = c.encoder enc_sw = c.encoder_sw joy = c.joystick joy_sw = c.joystick_sw colors = [color565(255, 0, 0), color565(0, 255, 0), color565(0, 0, 255)] while True: color = colors[enc.value % len(colors)] if c.interrupt(): display.clear() break x = 127 - (max(6, min(120, int(joy.x.read() / 32)))) y = max(6, min(120, int(joy.y.read() / 32))) display.clear() display.fill_circle(x, y, 6, color) display.draw_text(0, 64, "joystick: {}".format(joy_sw.value()), font, color565(255, 0, 0)) if not c.button_left.value(): display.fill_circle(30, 10, 10, color565(0, 255, 0)) if not c.button_right.value(): display.fill_circle(50, 10, 10, color565(0, 0, 255)) c.beeper.duty(10) else: c.beeper.duty(0) display.fill_circle(64, 64, 10, color565(255, 255, 255)) time.sleep(2)
def read_water(): val = adc.read() val = val * (3.3 / 4095) water_level = (int)((val / 3.3) * 120) # print(round(val, 2), "V") color = color565(0, 255, 0) if water_level < 40: color = color565(255, 255, 0) if water_level < 20: color = color565(255, 0, 0) if water_level > 0: display.fill_hrect(1, 53, water_level, 18, color) display.fill_hrect(water_level + 1, 53, 121 - water_level, 18, color565(0, 0, 0)) display.draw_text(37, 40, str(water_level) + '/' + str(MAX_WATER) + ' ', bally, color565(255, 255, 255))
def mic_test(c): display = c.display mic = c.mic display.clear() try: while True: for i in range(127): val = int(mic.read()) display.draw_vline( i % 127, 0, min(max(int(val / 15) - 44, 10), 127), color565((i * 2 % 255), 255 - (i * 2 % 255), 255 - int( ((i * 2 % 255) / 2)))) sleep(0.01) display.clear(color565(0, 0, 0)) gc.collect() finally: display.clear(color565(0, 0, 0)) gc.collect()
def all_test(c): tests = [ mic_test, front_test, bme280_test, mpu9250_test, ] for test_func in tests: test_func(c) c.display.clear() c.display.fill_circle(64, 64, 20, color565(0, 255, 0))
def mic_test(c): display = c.display mic = c.mic display.clear() while True: if c.interrupt(): display.clear() break for i in range(127): val = int(mic.read()) display.draw_vline( i % 127, 0, min(max(int(val / 15) - 44, 10), 127), color565((i * 2 % 255), 255 - (i * 2 % 255), 255 - int( ((i * 2 % 255) / 2)))) time.sleep(0.01) display.clear() gc.collect() display.fill_circle(64, 64, 10, color565(255, 255, 255)) time.sleep(2)
def test(): """Bouncing box.""" try: # Baud rate of 14500000 seems about the max spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.clear() colors = [ color565(255, 0, 0), color565(0, 255, 0), color565(0, 0, 255), color565(255, 255, 0), color565(0, 255, 255), color565(255, 0, 255) ] sizes = [12, 11, 10, 9, 8, 7] boxes = [Box(128, 128, sizes[i], display, colors[i]) for i in range(6)] while True: timer = ticks_us() for b in boxes: b.update_pos() b.draw() # Attempt to set framerate to 30 FPS timer_dif = 33333 - ticks_diff(ticks_us(), timer) if timer_dif > 0: sleep_us(timer_dif) except KeyboardInterrupt: display.cleanup()
def display_dot(): c = controller_box.ControllerBox() color = color565(255, 0, 0) black = color565(0, 0, 0) display = c.display joy_x = c.joystick.x joy_y = c.joystick.y w = 40 h = 64 # buf = display.load_sprite('gdg_small.raw', 40, 64) prev = (0, 0) while True: if c.interrupt(): display.clear(black) break x = 127 - (max(6, min(120, int(joy_x.read() / 32)))) y = max(6, min(120, int(joy_y.read() / 32))) display.clear(black) display.fill_circle(x, y, 6, color)
def test(): """Test code.""" # Baud rate of 14500000 seems about the max spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) c = 0 for x in range(0, 128, 16): for y in range(0, 128, 16): color = color565(*hsv_to_rgb(c / 64, 1, 1)) display.fill_circle(x + 7, y + 7, 7, color) c += 1 sleep(9) display.cleanup()
def __init__(self, display): """Initialize score. Args: display (SSD1351): OLED display. """ margin = 5 self.display = display self.xfont = XglcdFont('fonts/NeatoReduced5x7.c', 5, 7) self.display.draw_text(margin, 0, 'SCORE:', self.xfont, color565(255, 0, 0)) text_length = self.xfont.measure_text('SCORE: ') self.x = text_length + margin self.y = 0 self.value = 0 self.draw()
def test(): """Test code.""" spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.contrast(0) display.draw_image('images/MicroPython128x128.raw', 0, 0, 128, 128) fixed_font = XglcdFont('fonts/FixedFont5x8.c', 5, 8) contrast_range = list(range(1, 16)) + list(reversed(range(15))) for c in contrast_range: display.contrast(c) display.draw_text(30, 120, 'contrast: {0:02d}'.format(c), fixed_font, color565(255, 255, 255)) sleep(1) display.cleanup()
def test(): """Test code.""" spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.draw_image('images/Tabby128x128.raw', 0, 0, 128, 128) print("Loading fonts, please wait.") fixed_font = XglcdFont('fonts/FixedFont5x8.c', 5, 8) unispace = XglcdFont('fonts/Unispace12x24.c', 12, 24) print("Fonts loaded.") display.draw_text(0, 0, 'Not transparent', fixed_font, color565(255, 0, 255)) display.draw_text(0, 80, 'Transparent', unispace, color565(0, 128, 255), spacing=0, transparent=True) display.draw_text(0, 103, 'Background', unispace, color565(0, 128, 255), color565(255, 255, 255), spacing=0) display.draw_text(103, 20, 'Test', unispace, color565(0, 255, 128), landscape=True, spacing=2, transparent=True) display.draw_text(0, 20, 'Test', unispace, color565(128, 255, 0), landscape=True) sleep(9) display.cleanup()
def bme280_test(c): import bme280 from ssd1351 import color565 from xglcd_font import XglcdFont font = XglcdFont('fonts/Bally7x9.c', 7, 9) try: bme = bme280.BME280(i2c=c.i2c) c.display.clear() (t, p, h) = bme.read_compensated_data() c.display.draw_text(0, 0, bme.values[0], font, color565(255, 0, 0)) c.display.draw_text(0, 20, bme.values[1], font, color565(0, 255, 0)) c.display.draw_text(0, 40, bme.values[2], font, color565(0, 0, 255)) c.display.draw_hline(0, 50, (h // 1024) * 128 // 100, color565(0, 0, 255)) print(bme.values) time.sleep(3) c.display.fill_circle(64, 64, 10, color565(255, 255, 255)) except Exception as e: c.display.clear() c.display.draw_text(0, 40, str(e), font, color565(0, 0, 255)) finally: time.sleep(2)
def test(): """Test code.""" # Baud rate of 14500000 seems about the max spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) print('spi started') display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) print('display started') display.clear(color565(64, 0, 255)) sleep(1) display.clear() display.draw_hline(10, 127, 63, color565(255, 0, 255)) sleep(1) display.draw_vline(10, 0, 127, color565(0, 255, 255)) sleep(1) display.fill_hrect(23, 50, 30, 75, color565(255, 255, 255)) sleep(1) display.draw_hline(0, 0, 127, color565(255, 0, 0)) sleep(1) display.draw_line(127, 0, 64, 127, color565(255, 255, 0)) sleep(2) display.clear() coords = [[0, 63], [78, 80], [122, 92], [50, 50], [78, 15], [0, 63]] display.draw_lines(coords, color565(0, 255, 255)) sleep(1) display.clear() display.fill_polygon(7, 63, 63, 50, color565(0, 255, 0)) sleep(1) display.fill_rectangle(0, 0, 15, 127, color565(255, 0, 0)) sleep(1) display.clear() display.fill_rectangle(0, 0, 63, 63, color565(128, 128, 255)) sleep(1) display.draw_rectangle(0, 64, 63, 63, color565(255, 0, 255)) sleep(1) display.fill_rectangle(64, 0, 63, 63, color565(128, 0, 255)) sleep(1) display.draw_polygon(3, 96, 96, 30, color565(0, 64, 255), rotate=15) sleep(3) display.clear() display.fill_circle(32, 32, 30, color565(0, 255, 0)) sleep(1) display.draw_circle(32, 96, 30, color565(0, 0, 255)) sleep(1) display.fill_ellipse(96, 32, 30, 16, color565(255, 0, 0)) sleep(1) display.draw_ellipse(96, 96, 16, 30, color565(255, 255, 0)) sleep(5) display.cleanup()
def update(self, display, needs_full_redraw=False): display.draw_text(0, self.y, "Unispace", FONT_UNISPACE, color565(255, 128, 0)) self.y += 24 if self.y > 100: self.y = 0
def test(): """Test code.""" spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) print("Loading fonts, please wait.") arcadepix = XglcdFont('fonts/ArcadePix9x11.c', 9, 11) bally = XglcdFont('fonts/Bally7x9.c', 7, 9) broadway = XglcdFont('fonts/Broadway17x15.c', 17, 15) espresso_dolce = XglcdFont('fonts/EspressoDolce18x24.c', 18, 24) fixed_font = XglcdFont('fonts/FixedFont5x8.c', 5, 8) neato = XglcdFont('fonts/Neato5x7.c', 5, 7, letter_count=223) robotron = XglcdFont('fonts/Robotron7x11.c', 7, 11) unispace = XglcdFont('fonts/Unispace12x24.c', 12, 24) wendy = XglcdFont('fonts/Wendy7x8.c', 7, 8) print("Fonts loaded.") display.draw_text(0, 0, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0)) display.draw_text(0, 12, 'Bally 7x9', bally, color565(0, 255, 0)) display.draw_text(0, 23, 'Broadway', broadway, color565(0, 0, 255)) display.draw_text(0, 36, 'Espresso', espresso_dolce, color565(0, 255, 255)) display.draw_text(0, 64, 'Fixed Font 5x8', fixed_font, color565(255, 0, 255)) display.draw_text(0, 76, 'Neato 5x7', neato, color565(255, 255, 0)) display.draw_text(0, 85, 'Robotron 7x11', robotron, color565(255, 255, 255)) display.draw_text(0, 96, 'Unispace', unispace, color565(255, 128, 0)) display.draw_text(0, 120, 'Wendy 7x8', wendy, color565(255, 0, 128)) sleep(9) display.clear() display.draw_text(0, 0, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0), landscape=True) display.draw_text(12, 0, 'Bally 7x9', bally, color565(0, 255, 0), landscape=True) display.draw_text(23, 0, 'Broadway', broadway, color565(0, 0, 255), landscape=True) display.draw_text(36, 0, 'Espresso', espresso_dolce, color565(0, 255, 255), landscape=True) display.draw_text(64, 0, 'Fixed Font 5x8', fixed_font, color565(255, 0, 255), landscape=True) display.draw_text(76, 0, 'Neato 5x7', neato, color565(255, 255, 0), landscape=True) display.draw_text(85, 0, 'Robotron 7x11', robotron, color565(255, 255, 255), landscape=True) display.draw_text(96, 0, 'Unispace', unispace, color565(255, 128, 0), landscape=True) display.draw_text(120, 0, 'Wendy 7x8', wendy, color565(255, 0, 128), landscape=True) sleep(9) display.clear() display.draw_text(0, 0, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0), background=color565(0, 255, 255)) display.draw_text(0, 12, 'Bally 7x9', bally, color565(0, 255, 0), background=color565(0, 0, 128)) display.draw_text(0, 23, 'Broadway', broadway, color565(0, 0, 255), background=color565(255, 255, 0)) display.draw_text(0, 36, 'Espresso', espresso_dolce, color565(0, 255, 255), background=color565(255, 0, 0)) display.draw_text(0, 64, 'Fixed Font 5x8', fixed_font, color565(255, 0, 255), background=color565(0, 128, 0)) display.draw_text(0, 76, 'Neato 5x7', neato, color565(255, 255, 0), background=color565(0, 0, 255)) display.draw_text(0, 85, 'Robotron 7x11', robotron, color565(255, 255, 255), background=color565(128, 128, 128)) display.draw_text(0, 96, 'Unispace', unispace, color565(255, 128, 0), background=color565(0, 128, 255)) display.draw_text(0, 120, 'Wendy 7x8', wendy, color565(255, 0, 128), background=color565(255, 255, 255)) sleep(9) display.cleanup()
from machine import Pin, SPI, ADC from time import sleep from ssd1351 import Display, color565 def setup_display(): #mosi=sda spi = SPI(2, 14500000, miso=Pin(19), mosi=Pin(18), sck=Pin(5)) display = Display(spi, rst=Pin(26), dc=Pin(25), cs=Pin(4)) return display def cleanup_display(display): print('clearing display') display.clear() display.cleanup() display = setup_display() from xglcd_font import XglcdFont font = XglcdFont('fonts/Bally7x9.c', 7, 9) display.draw_text(40, 30, "EDC", font, color565(0, 0, 255)) display.draw_text(38, 40, "2018", font, color565(0, 0, 255))
def draw(self): """Draw score value.""" self.display.draw_text(self.x, self.y, str(self.value), self.xfont, color565(255, 255, 255))
def update(self, screen, needs_full_redraw=False): from ssd1351 import color565 if needs_full_redraw: screen.fill_rectangle(0, 0, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 0 + self._y0, "Speed (km/h)", display.FONT_FIXED, color565(255, 255, 255)) screen.fill_rectangle(0, 45, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 45 + self._y0, "Top Speed (km/h)", display.FONT_FIXED, color565(255, 255, 255)) screen.fill_rectangle(0, 63, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 63 + self._y0, "Distance (km)", display.FONT_FIXED, color565(255, 255, 255)) screen.fill_rectangle(0, 91, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 91 + self._y0, "Total Distance (km)", display.FONT_FIXED, color565(255, 255, 255)) if self._speed != self._speedometer.speed or needs_full_redraw: self._speed = self._speedometer.speed screen.fill_rectangle(0, 9, 127, 25, color565(0, 0, 0)) screen.draw_text(self._x0, 9 + self._y0, "{:.2f}".format(self._speed), display.FONT_UNISPACE, color565(0, 255, 0)) if self._top_speed != self._speedometer.top_speed or needs_full_redraw: self._top_speed = self._speedometer.top_speed screen.fill_rectangle(0, 54, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 54 + self._y0, "{:.2f}".format(self._top_speed), display.FONT_FIXED, color565(0, 255, 0)) if self._trip != self._speedometer.trip or needs_full_redraw: self._trip = self._speedometer.trip screen.fill_rectangle(0, 72, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 72 + self._y0, "{:.2f}".format(self._trip / 1000.0), display.FONT_FIXED, color565(0, 255, 0)) if self._distance != self._speedometer.distance or needs_full_redraw: self._distance = self._speedometer.distance screen.fill_rectangle(0, 100, 127, 9, color565(0, 0, 0)) screen.draw_text(self._x0, 100 + self._y0, "{:.2f}".format(self._distance / 1000.0), display.FONT_FIXED, color565(0, 255, 0))
from machine import Pin, SPI from ssd1351 import Display, color565 from bitmap_font import BitmapFont s = "0x10,0x00,0x11,0xFC,0x10,0x04,0x10,0x08,0xFC,0x10,0x24,0x20,0x24,0x24,0x27,0xFE,0x24,0x20,0x44,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x44,0x20,0x84,0xA0,0x00,0x40" spi = SPI(2, sck=Pin(18), mosi=Pin(23), miso=Pin(19), baudrate=14500000) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) while True: s = input("please input:") arcadepix = BitmapFont(s, 16, 16) display.draw_bitmap(32, 64, arcadepix, color565(100, 100, 100)) # buf, w, h = arcadepix.get_buf(color) # print(w,h,buf) # arcadepix = XglcdFont('', 9, 11) # buf, w, h = arcadepix.get_letter('A',color) # print(w,h,buf)
display.fill_hrect(water_level + 1, 53, 121 - water_level, 18, color565(0, 0, 0)) display.draw_text(37, 40, str(water_level) + '/' + str(MAX_WATER) + ' ', bally, color565(255, 255, 255)) if spi is None: spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.draw_image('MicroPython128x128.raw', 0, 0, 128, 128) sleep(1) display.clear() bally = XglcdFont('Bally7x9.c', 7, 9) display.draw_text(0, 0, 'Diesel:', bally, color565(255, 255, 255)) display.draw_text(0, 40, 'Vann:', bally, color565(255, 255, 255)) display.draw_text(0, 80, 'Septik:', bally, color565(255, 255, 255)) display.draw_rectangle(0, 12, 120, 20, color565(255, 255, 255)) display.draw_rectangle(0, 52, 120, 20, color565(255, 255, 255)) display.draw_rectangle(0, 92, 120, 20, color565(255, 255, 255)) adc = ADC(Pin(35)) adc.atten(adc.ATTN_11DB) #normalized to 3.3v while True: # read_septic() read_water() sleep(0.1)