Beispiel #1
0
def on_oled_message(topic, payload_in):
  if payload_in == "(oled:clear)":
    oleds_clear(bg)
    return True

  if payload_in.startswith("(oled:log "):
    log(payload_in[10:-1])
    return True

  if payload_in.startswith("(oled:pixel "):
    tokens = [int(token) for token in payload_in[12:-1].split()]
    for oled in oleds:
      oled.pixel(tokens[0], height - tokens[1] - 1, fg)
      oled.show()
    return True

  if payload_in.startswith("(oled:text "):
    tokens = payload_in[11:-1].split()
    text = " ".join(tokens[2:])
    for oled in oleds:
      oled.text(text, int(tokens[0]), height - font_size - int(tokens[1]), fg)
      oled.show()
    return True

  return False
Beispiel #2
0
def log(text):
  for oled in oleds:
    oled.scroll(0, -font_size)
    oled.fill_rect(0, bottom_row, width, font_size, bg)
    oled.text(text, 0, bottom_row, fg)
    oled.show()
  if lock_title: write_title()
Beispiel #3
0
def write_title():
  oled.fill_rect(0, 0, width, font_size, fg)
  oled.text("Aiko 0.0", 0, 0, bg)
  oled.show()
Beispiel #4
0
def test(text="Line "):
  oled.fill(bg)
  for y in range(0, height, font_size):
    oled.text(text + str(y), 0, y, fg)
  oled.show()
Beispiel #5
0
def write_title():
  for oled in oleds:
    oled.fill_rect(0, 0, width, font_size, fg)
    oled.text(title, 0, 0, bg)
    oled.show()