示例#1
0
def initialise(settings=configuration.oled.settings):
  global lock_title, width, height, font_size, bottom_row
  parameter = configuration.main.parameter

  Pin(int(settings["enable_pin"]), Pin.OUT).value(1)
  addresses = settings["addresses"]
  scl_pin = int(settings["scl_pin"])
  sda_pin = int(settings["sda_pin"])

  lock_title = parameter("lock_title", settings)
  width = int(settings["width"])
  height = int(settings["height"])
  font_size = int(settings["font_size"])
  bottom_row = height - font_size

  i2c = machine.I2C(scl=Pin(scl_pin), sda=Pin(sda_pin))
# i2c.scan()
  for addr in addresses:
    oleds.append(ssd1306.SSD1306_I2C(width, height, i2c, addr=addr))

  oleds_clear(bg)
  write_title()  # includes oled.show()

  mqtt.add_message_handler(on_oled_message, "$me/in")
  if parameter("logger_enabled"):
    mqtt.add_message_handler(on_oled_log_message, "$all/log")
示例#2
0
def initialise():
    global schedule, menu

    schedule = configuration.schedule.settings
    oled.oleds_clear(oled.BG)
    event.add_timer_handler(titlebar, 5000)
    prefix = configuration.schedule.settings['topicprefix']

    for topic in configuration.schedule.settings['topics']:
        mqtt.add_message_handler(on_schedule_message, prefix + topic)
示例#3
0
def initialise(settings=configuration.led.settings):
    global apa106, length, length_x, np, zigzag

    parameter = configuration.main.parameter
    apa106 = parameter("apa106", settings)
    zigzag = parameter("zigzag", settings)

    length = linear(settings["dimension"])
    length_x = settings["dimension"][0]
    np = NeoPixel(Pin(settings["neopixel_pin"]), length, timing=True)

    mqtt.add_message_handler(on_led_message, "$me/in")
示例#4
0
def initialise(settings=configuration.lolibot.settings):
    global duty_cycle_max, duty_cycle_min, pwm_frequency
    global left_motor1, left_motor2, right_motor1, right_motor2

    if "duty_cycle_max" in settings:
        duty_cycle_max = int(settings["duty_cycle_max"])
    if "duty_cycle_min" in settings:
        duty_cycle_min = int(settings["duty_cycle_min"])
    if "pwm_frequency" in settings:
        pwm_frequency = int(settings["pwm_frequency"])

    left_motor1 = initialise_motor(settings, "left_motor_pin1")
    left_motor2 = initialise_motor(settings, "left_motor_pin2")
    right_motor1 = initialise_motor(settings, "right_motor_pin1")
    right_motor2 = initialise_motor(settings, "right_motor_pin2")

    servo = Pin(settings["servo_pin"], Pin.OUT)

    scl = settings["scl_pin"]
    sda = settings["sda_pin"]

    mqtt.add_message_handler(on_lolibot_message, "$me/in")
示例#5
0
def initialise(settings=configuration.oled.settings):
  global oled, width, height, font_size, bottom_row, lock_title
  parameter = configuration.boot.parameter

  Pin(int(settings["enable_pin"]), Pin.OUT).value(1)
  scl_pin = int(settings["scl_pin"])
  sda_pin = int(settings["sda_pin"])
  width = int(settings["width"])
  height = int(settings["height"])
  font_size = int(settings["font_size"])
  bottom_row = height - font_size

  i2c = machine.I2C(scl=Pin(scl_pin), sda=Pin(sda_pin))
# i2c.scan()
  oled = ssd1306.SSD1306_I2C(width, height, i2c)

  oled.fill(bg)
  write_title()
  lock_title = parameter("lock_title", settings)

  mqtt.add_message_handler(on_oled_message, "$me/in")
  if parameter("logger_enabled"):
    mqtt.add_message_handler(on_oled_log_message, "$all/log")
示例#6
0
def initialise():
  event.add_timer_handler(handle_pins_input, 50)  # 20 Hz
  mqtt.add_message_handler(on_nodebots_message, "$me/in")
def initialise():
    event.add_event_handler(handle_leds, step_speed)
    mqtt.add_message_handler(on_audrey_message, "$me/in")