Exemple #1
0
def oled_intit():
    global oled
    from lib import ssd1306
    time.sleep_ms(1000)
    i2c = machine.I2C(-1, machine.Pin(pinout.I2C_SCL_PIN),
                      machine.Pin(pinout.I2C_SDA_PIN))
    oled = ssd1306.SSD1306_I2C(128, 64, i2c)
def print_lcd(msg, t=None, ltemp=False, lco2=False, lgps=False, ldust=False):
    """

    :param msg:
    :return:
    """
    i2c = init_i2c()
# 
    # # Initialize the reset pin
    res_pin = Pin('P11', mode=Pin.OUT)
# 
    # # Initialize the SSD1306 display
    d = ssd1306.SSD1306_I2C(64, 48, i2c, res=res_pin)
    # l1_pos = 0  #1st line
    # l2_pos = 10 #2nd line
    # l3_pos = 20 #3rd line
    # l4_pos = 30 #4th line

    # Power on and clear screen
    #d.poweron()
    d.fill(0)

    # Add text
    # d.text(string=str(msg), x=0, y=0)
    d.text(str(msg), 0, 0)
    if t:
        d.text(str(t), 0, 10)
    if ltemp:
        d.text("temp", 0, 20)
    if lco2:
        d.text("co2", 32, 20)
    if lgps:
        d.text("gps", 0, 30)
    if ldust:
        d.text("dust", 32, 30)

    # d.text('Welcome', 0, l1_pos)
    # d.text('to IIoT', 0, l2_pos)
    # d.text('Summer', 0, l3_pos)
    # d.text('school!', 0, l4_pos)
    # Update the screen and power it Off
    d.show()
Exemple #3
0
Debug = True
place = "PP1" # name group of IoT
minute = 10 # 1/10 for data send
#--- setup ---
isTemp = True
isLight = True
isPressure = False
isAD = False #TODO
isPH = False #TODO

pinout = set_pinout()
led = Pin(pinout.BUILT_IN_LED, Pin.OUT) # BUILT_IN_LED

if Debug: print("init i2c oled >")
i2c = machine.I2C(-1, machine.Pin(pinout.I2C_SCL_PIN), machine.Pin(pinout.I2C_SDA_PIN))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
time.sleep_ms(100)

# magic constants )
aa = 16 # one segment size
y0 = 9  # y possition
x0 = aa+5
xb0 = 0 # display bar possition
yb0 = 58
ydown = 57

def draw_icon(icon, posx, posy):
  for y, row in enumerate(icon):
    for x, c in enumerate(row):
        oled.pixel(x+posx, y+posy, c)
Exemple #4
0

# ==================== Entry Point ====================

if __name__ == "__main__":
    """
  Entry point at functional execution.
  """
    try:
        # load configuration values
        load_settings(CONFIG_FILE)

        # gobal devices initialization (I2C OLED SSD1306)
        i2c = I2C(scl=Pin(OLED_PIN_SCL), sda=Pin(OLED_PIN_SDA))
        oled = ssd1306.SSD1306_I2C(width=OLED_WIDTH,
                                   height=OLED_HEIGHT,
                                   i2c=i2c)
        detect_i2c_device(i2c, "SSD1306", OLED_ADDRESS)

        # gobal devices initialization (I2C BME280)
        i2c = I2C(scl=Pin(BME280_PIN_SCL), sda=Pin(BME280_PIN_SDA))
        bme = bme280.BME280(i2c=i2c, unit=DISPLAY_TEMPERATURE_UNIT)
        detect_i2c_device(i2c, "BME280", BME280_ADDRESS)

        # gobal devices initialization (1-Wire DS18B20)
        ow = onewire.OneWire(pin=Pin(DS18_PIN_DQ))
        ds18 = ds18.DS18(ow=ow,
                         reading_wait=DS18_READING_WAIT,
                         unit=DISPLAY_TEMPERATURE_UNIT)
        detect_ow_device(ds18, "DS18X20", DS18_ADDRESS)
Exemple #5
0
def oled_intit():
    print("OLED present: {0}".format(isOLED))
    global oled
    from lib import ssd1306
    sleep(1)
    oled = ssd1306.SSD1306_I2C(OLEDX, OLEDY, i2c)