def _init_display():
        # Initialize the display
        # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/display
        # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/issues/310
        tft = TFT()
        tft.init(tft.ST7789,
                 rst_pin=23,
                 backl_pin=4,
                 miso=0,
                 mosi=19,
                 clk=18,
                 cs=5,
                 dc=16,
                 width=235,
                 height=340,
                 backl_on=1)

        # Invert colors
        tft.tft_writecmd(0x21)

        # Set orientation (optional)
        tft.orient(tft.LANDSCAPE)

        return tft
Exemple #2
0
if TFT_present:
    pwm = PWM(TFT_PIN_BL, freq=12000, duty=0)

    tft = TFT()
    tft.init(tft.ST7789,
             miso=TFT_PIN_MISO,
             mosi=TFT_PIN_MOSI,
             clk=TFT_PIN_CLK,
             cs=TFT_PIN_SS,
             dc=TFT_PIN_DC,
             rot=tft.PORTRAIT_FLIP,
             color_bits=tft.COLOR_BITS16,
             splash=False,
             height=240)

    tft.tft_writecmd(ST7789_INVON)

    tft.clear(tft.NAVY)

    tft.image(0, 0, ICON_LOGO)
    width, height = tft.screensize()
    tft.rect(1, 1, width - 1, height - 1, tft.WHITE)

    Backlight = True
    backlight(Backlight)

    bl_timer = Timer(2)
    bl_timer.init(period=BL_OFF_TIME,
                  mode=bl_timer.ONE_SHOT,
                  callback=bl_timer_cb)