def init_gui_esp32(self):

        # Initialize ILI9341 display

        from ili9XXX import ili9341

        self.disp = ili9341(dc=32, cs=33, power=-1, backlight=-1)

        # Register raw resistive touch driver
        """
        import rtch
        self.touch = rtch.touch(xp = 32, yp = 33, xm = 25, ym = 26, touch_rail = 27, touch_sense = 33)
        self.touch.init()
        indev_drv = lv.indev_drv_t()
        lv.indev_drv_init(indev_drv) 
        indev_drv.type = lv.INDEV_TYPE.POINTER
        indev_drv.read_cb = self.touch.read
        lv.indev_drv_register(indev_drv)
        """

        # Register xpt2046 touch driver

        from xpt2046 import xpt2046

        self.touch = xpt2046()
def getdisplay_landscape():
    global display
    global touch
    # Import ILI9341 driver and initialized it
    #display = ili9341(miso=19, mosi=23, clk=18, cs=26, dc=5, rst=33, power=-1, backlight=-1, mhz=40, factor=4, hybrid=False, rot=LANDSCAPE)
    display = ili9341(miso=19,
                      mosi=23,
                      clk=18,
                      cs=26,
                      dc=5,
                      rst=33,
                      power=-1,
                      backlight=-1,
                      mhz=40,
                      factor=4,
                      hybrid=True,
                      width=320,
                      height=240,
                      rot=LANDSCAPE)

    # Import XPT2046 driver and initalize it
    #touch = xpt2046(cs=27, transpose=False, cal_x0=258, cal_y0=420, cal_x1=3884, cal_y1=3945)
    touch = xpt2046(cs=27,
                    transpose=False,
                    cal_x0=3865,
                    cal_y0=329,
                    cal_x1=399,
                    cal_y1=3870)
    print("Display in landscape mode")
def getdisplay_portrait():
    global display
    global touch
    if display is not None:
        return display
    # Import ILI9341 driver and initialized it
    #display = ili9341(miso=19, mosi=23, clk=18, cs=26, dc=5, rst=33, power=-1, backlight=-1, mhz=40, factor=4, hybrid=True, rot=MADCTL_MY)
    display = ili9341(miso=19,
                      mosi=23,
                      clk=18,
                      cs=26,
                      dc=5,
                      rst=33,
                      power=-1,
                      backlight=-1,
                      mhz=40,
                      factor=4,
                      hybrid=False,
                      rot=MADCTL_MY)

    # Import XPT2046 driver and initalize it
    touch = xpt2046(cs=27,
                    transpose=True,
                    cal_x0=258,
                    cal_y0=420,
                    cal_x1=3884,
                    cal_y1=3945)
    print("Display in portrait mode")
Esempio n. 4
0
    def init_gui_esp32(self):

        import lvesp32

        # Initialize ILI9341 display
        from ili9XXX import ili9341

        self.disp = ili9341(miso=19,
                            mosi=23,
                            clk=18,
                            cs=5,
                            dc=32,
                            rst=27,
                            spihost=1,
                            power=-1,
                            backlight=33,
                            backlight_on=1,
                            mhz=80,
                            factor=4,
                            hybrid=True)

        # Register xpt2046 touch driver
        from xpt2046 import xpt2046

        self.touch = xpt2046(cs=26,
                             spihost=1,
                             mhz=5,
                             max_cmds=16,
                             cal_x0=3783,
                             cal_y0=3948,
                             cal_x1=242,
                             cal_y1=423,
                             transpose=True,
                             samples=3)
    def init_gui_ili9341(self):

        import lvesp32

        # Initialize ILI9341 display

        from ili9XXX import ili9341, LANDSCAPE
        from xpt2046 import xpt2046
        import espidf as esp

        if self.orientation == ORIENT_PORTRAIT:
            print("Running the ili9341 lvgl version in portait mode")

            # Initialize ILI9341 display in prtrait mode
            # the following are the settings for the Lolin tft 2.4 display
            # self.disp = ili9341(miso=19,mosi=23,clk=18, cs=26, dc=5, rst=-1, power=-1, backlight=-1, spihost=esp.VSPI_HOST)
            # self.touch = xpt2046(spihost=esp.VSPI_HOST,cal_x0=3751, cal_x1 = 210, cal_y0=3906, cal_y1 = 283, transpose=True)

            self.disp = ili9341()
            self.touch = xpt2046()

        elif self.orientation == ORIENT_LANDSCAPE:
            print("Running the ili9341 lvgl version in landscape mode")
            # Initialize ILI9341 display
            # the following are the settings for the Lolin tft 2.4 display
            # self.disp = ili9341(miso=19,mosi=23,clk=18, cs=26, dc=5, rst=-1, power=-1, backlight=-1, backlight_on=0,
            #                     spihost=esp.VSPI_HOST, width=320, height=240, rot=LANDSCAPE)
            # self.touch = xpt2046(spihost=esp.VSPI_HOST,cal_x0=3799, cal_x1 = 353, cal_y0=220, cal_y1 = 3719, transpose=False)

            # Register xpt2046 touch driver
            self.disp = ili9341(width=320, height=240, rot=LANDSCAPE)
            self.touch = xpt2046(cal_x0=3799,
                                 cal_x1=353,
                                 cal_y0=220,
                                 cal_y1=3719,
                                 transpose=False)

        else:
            raise RuntimeError("Invalid orientation")

        self.type = "ili9341"
        '''
Esempio n. 6
0
    def init_gui_esp32(self):

        import lvesp32

        # Initialize ILI9341 display

        from ili9XXX import ili9341
        self.disp = ili9341()

        # Register raw resistive touch driver
        '''
        import rtch
        touch = rtch.touch(xp = 32, yp = 33, xm = 25, ym = 26, touch_rail = 27, touch_sense = 33)
        touch.init()
        indev_drv = lv.indev_drv_t()
        lv.indev_drv_init(indev_drv) 
        indev_drv.type = lv.INDEV_TYPE.POINTER;
        indev_drv.read_cb = touch.read;
        lv.indev_drv_register(indev_drv);
        '''

        from xpt2046 import xpt2046
        self.touch = xpt2046()
Esempio n. 7
0
    def init_gui_esp32(self):

        # Initialize ILI9341 display
        from ili9XXX import ili9341

        self.disp = ili9341(miso=19,
                            mosi=23,
                            clk=18,
                            cs=5,
                            dc=32,
                            rst=27,
                            spihost=1,
                            power=-1,
                            backlight=33,
                            backlight_on=1,
                            mhz=80,
                            factor=4,
                            double_buffer=True,
                            hybrid=True,
                            asynchronous=True,
                            initialize=True)

        self.disp.send_cmd(0x21)

        # Register xpt2046 touch driver
        from xpt2046 import xpt2046

        self.touch = xpt2046(cs=26,
                             spihost=1,
                             mhz=5,
                             max_cmds=16,
                             cal_x0=242,
                             cal_y0=423 - 300,
                             cal_x1=3783,
                             cal_y1=3948 - 300,
                             transpose=True,
                             samples=3)
Esempio n. 8
0
import sys
sys.path.append(
    '')  # See: https://github.com/micropython/micropython/issues/6419

import lvgl as lv
lv.init()
# lv.log_register_print_cb(lambda msg: print(msg))

# Initialize ILI9341 display

import espidf as esp
from ili9XXX import ili9341, COLOR_MODE_BGR, LANDSCAPE, PORTRAIT

disp = ili9341(dc=32, cs=33, power=-1, backlight=-1)

# The call below is for a Lolin TFT-2.4 board
# disp = ili9341(miso=19,mosi=23,clk=18, cs=26, dc=5, rst=-1, power=-1, backlight=-1, backlight_on=0, power_on=0,
#               spihost=esp.VSPI_HOST, mhz=40, factor=4, hybrid=True, width=240, height=320,
#               colormode=COLOR_MODE_BGR, rot=PORTRAIT, invert=False, double_buffer=True, half_duplex=True)

# In order to calibrate in landscape mode please use:
# disp = ili9341(rot=LANDSCAPE,width=320,height=240))

HRES = lv.scr_act().get_disp().driver.hor_res
VRES = lv.scr_act().get_disp().driver.ver_res

# Register xpt touch driver
from xpt2046 import xpt2046
touch = xpt2046(cal_x0=0, cal_x1=HRES, cal_y0=0, cal_y1=VRES)

# The call below is for a Lolin TFT-2.4 board
Esempio n. 9
0
    w, h = h, w
    transp = True
else:
    transp = False

disp = ili9341(miso=19,
               mosi=23,
               clk=18,
               cs=26,
               dc=5,
               rst=-1,
               power=-1,
               backlight=-1,
               backlight_on=0,
               power_on=0,
               spihost=esp.VSPI_HOST,
               mhz=40,
               factor=4,
               hybrid=True,
               width=w,
               height=h,
               colormode=COLOR_MODE_BGR,
               rot=orientation,
               invert=False,
               double_buffer=True,
               half_duplex=True)

HRES = disp.width
VRES = disp.height
# HRES =  lv.scr_act().get_disp().driver.hor_res
# VRES =  lv.scr_act().get_disp().driver.ver_res
Esempio n. 10
0
import lvgl as lv
lv.init()

lv.log_register_print_cb(lambda level, path, line, msg: print(
    'LOG: %s(%d): %s' % (path, line, msg)))

# Initialize ILI9341 display

import lvesp32
from ili9XXX import ili9341
disp = ili9341()

HRES = lv.disp_get_hor_res(lv.disp_t.cast(None))
VRES = lv.disp_get_ver_res(lv.disp_t.cast(None))

# Register raw resistive touch driver
'''
import rtch
touch = rtch.touch(xp = 32, yp = 33, xm = 25, ym = 26, touch_rail = 27, touch_sense = 33, cal_x0=0, cal_x1 = HRES, cal_y0=0, cal_y1 = VRES)
touch.init()
indev_drv = lv.indev_drv_t()
lv.indev_drv_init(indev_drv) 
indev_drv.type = lv.INDEV_TYPE.POINTER;
indev_drv.read_cb = touch.read;
lv.indev_drv_register(indev_drv);
'''

# Register xpt touch driver
import xpt2046 as xpt2046
touch = xpt2046.xpt2046(cal_x0=0, cal_x1=HRES, cal_y0=0, cal_y1=VRES)
##################################################################################################

# Default resolution match ili9341
HOR_RES = 240
VER_RES = 320

# Try initialize ili9341/xpt2046
try:
    from ili9XXX import ili9341
    from xpt2046 import xpt2046

    # Initialize and register drivers

    disp = ili9341(dc=32,
                   cs=33,
                   power=-1,
                   backlight=-1,
                   asynchronous=True,
                   initialize=True)
    touch = xpt2046()

except ImportError:
    pass

# Try to initialize SDL
try:
    import SDL

    # Initialize driver

    SDL.init(w=HOR_RES, h=VER_RES, auto_refresh=False)
    event_loop = lv_utils.event_loop(refresh_cb=SDL.refresh, asynchronous=True)
Esempio n. 12
0
    def display_driver_ili9341(self):

        import lvesp32

        # Initialize ILI9341 display

        from ili9XXX import ili9341, LANDSCAPE
        from xpt2046 import xpt2046
        import espidf as esp
        if self.orientation:
            print("Running the ili9341 lvgl version in portait mode")
            # Initialize ILI9341 display in prtrait mode
            self.disp = ili9341(miso=19,
                                mosi=23,
                                clk=18,
                                cs=26,
                                dc=5,
                                rst=-1,
                                power=-1,
                                backlight=-1,
                                spihost=esp.VSPI_HOST)
            self.touch = xpt2046(spihost=esp.VSPI_HOST,
                                 cal_x0=3751,
                                 cal_x1=210,
                                 cal_y0=3906,
                                 cal_y1=283,
                                 transpose=True)
            self.type = "ili9341"
            # self.disp = ili9341()
            # self.touch = xpt2046()
        else:
            print("Running the ili9341 lvgl version in landscape mode")
            # Initialize ILI9341 display
            self.disp = ili9341(miso=19,
                                mosi=23,
                                clk=18,
                                cs=26,
                                dc=5,
                                rst=-1,
                                power=-1,
                                backlight=-1,
                                backlight_on=0,
                                spihost=esp.VSPI_HOST,
                                width=320,
                                height=240,
                                rot=LANDSCAPE)

            # Register xpt2046 touch driver
            self.touch = xpt2046(spihost=esp.VSPI_HOST,
                                 cal_x0=3799,
                                 cal_x1=353,
                                 cal_y0=220,
                                 cal_y1=3719,
                                 transpose=False)
            # self.disp(rot=LANDSCAPE)
            # self.touch = xpt2046(transpose = False)
            self.type = "ili9341"
        # self.disp = ili9341()

        # Register raw resistive touch driver
        '''