|
1 | 1 | import sys |
2 | | -import argparse |
3 | | -import importlib |
| 2 | +from sys import implementation |
4 | 3 |
|
5 | 4 | # This loads BT82x family definitions only. |
6 | | -import bteve2 as eve |
7 | | - |
8 | | -def run(app, minimal = False): |
9 | | - progname = sys.argv[0] |
10 | | - width = 1920 |
11 | | - height = 1200 |
12 | | - parser = argparse.ArgumentParser(description="EVE demo") |
13 | | - parser.add_argument("--connector", default="ft4232h", help="the connection method for EVE") |
14 | | - parser.add_argument("--width", default=str(width), help="panel width in pixels") |
15 | | - parser.add_argument("--height", default=str(height), help="panel height in pixels") |
16 | | - (args, rem) = parser.parse_known_args() |
17 | | - rem.insert(0, progname) |
18 | | - sys.argv = rem |
19 | | - |
20 | | - width = int(args.width, 0) |
21 | | - height = int(args.height, 0) |
22 | | - connector_dir = "connectors/" |
23 | | - |
24 | | - sys.path.append(connector_dir) |
25 | | - try: |
26 | | - connector = importlib.import_module(args.connector) |
27 | | - except ModuleNotFoundError: |
28 | | - print(f"Connector '{args.connector}' not found in '{connector_dir}'") |
29 | | - sys.exit(1) |
30 | | - # Create an connector to BT82x family devices only. |
31 | | - gd = connector.EVE2() |
32 | | - gd.register(gd) |
33 | | - gd.eve = eve |
34 | | - |
35 | | - if not minimal: |
36 | | - gd.cmd_regwrite(eve.REG_SC0_SIZE, 2) |
37 | | - gd.cmd_regwrite(eve.REG_SC0_PTR0, 10 << 20) |
38 | | - gd.cmd_regwrite(eve.REG_SC0_PTR1, 18 << 20) |
39 | | - gd.panel(eve.Surface(eve.SWAPCHAIN_0, eve.RGB6, width, height)) |
40 | | - gd.cmd_regwrite(eve.REG_RE_DITHER, 1) |
41 | | - app(gd) |
42 | | - gd.finish() |
43 | | - else: |
44 | | - app(gd) |
| 5 | +import bteve2 |
| 6 | + |
| 7 | +if implementation.name != "circuitpython": |
| 8 | + import argparse |
| 9 | + |
| 10 | +class run: |
| 11 | + def __init__(self, app, minimal = False, connector=None, panel="HD"): |
| 12 | + if implementation.name != "circuitpython": |
| 13 | + if connector == None: |
| 14 | + connector = "ft4222module" |
| 15 | + progname = sys.argv[0] |
| 16 | + |
| 17 | + # Parse arguments |
| 18 | + parser = argparse.ArgumentParser(description="EVE demo") |
| 19 | + parser.add_argument("--connector", help="the connection method for EVE") |
| 20 | + parser.add_argument("--panel", default=str("HD"), help="panel type") |
| 21 | + (args, rem) = parser.parse_known_args() |
| 22 | + # Persist arguments to target program |
| 23 | + rem.insert(0, progname) |
| 24 | + sys.argv = rem |
| 25 | + # Update any arguments that match |
| 26 | + if (args.connector): connector = args.connector |
| 27 | + if (args.panel): paneltype = args.panel |
| 28 | + elif implementation.name == "circuitpython": |
| 29 | + connector = "circuitpython" |
| 30 | + paneltype = "HD" |
| 31 | + |
| 32 | + # Create an connector to BT82x family devices only. |
| 33 | + eve = bteve2.EVE2(connector) |
| 34 | + |
| 35 | + if paneltype == "WQVGA": |
| 36 | + |
| 37 | + surface = bteve2.Surface(eve.SWAPCHAIN_0, eve.FORMAT_RGB6, 480, 272) |
| 38 | + panel = bteve2.Panel(eve.WQVGA, 548, 43, 0, 41, 292, 12, 0, 10, 5, 0, 1, 0, 1, None) |
| 39 | + touch = bteve2.Touch("Focaltech FT5206", 0x38, 1) |
| 40 | + |
| 41 | + elif paneltype == "WVGA": |
| 42 | + |
| 43 | + surface = bteve2.Surface(eve.SWAPCHAIN_0, eve.FORMAT_RGB6, 800, 480) |
| 44 | + panel = bteve2.Panel(eve.WVGA, 928, 88, 0, 48, 525, 32, 0, 3, 2, 0, 1, 0, 1, None) |
| 45 | + touch = bteve2.Touch("Focaltech FT5206", 0x38, 1) |
| 46 | + |
| 47 | + elif paneltype == "WSVGA": |
| 48 | + |
| 49 | + surface = bteve2.Surface(eve.SWAPCHAIN_0, eve.FORMAT_RGB6, 1024, 600) |
| 50 | + panel = bteve2.Panel(eve.WSVGA, 1344, 160, 0, 100, 635, 23, 0, 10, 1, 0, 1, 0, 1, 0xd12) |
| 51 | + touch = bteve2.Touch("Focaltech FT5206", 0x38, 1) |
| 52 | + |
| 53 | + elif paneltype == "WXGA": |
| 54 | + |
| 55 | + surface = bteve2.Surface(eve.SWAPCHAIN_0, eve.FORMAT_RGB6, 1280, 800) |
| 56 | + panel = bteve2.Panel(eve.WXGA, 1411, 120, 0, 100, 815, 14, 0, 10, 1, 0, 0, 0, 0, 0x8b1) |
| 57 | + touch = bteve2.Touch("Focaltech FT5206", 0x38, 1) |
| 58 | + |
| 59 | + elif paneltype == "HD": |
| 60 | + |
| 61 | + surface = bteve2.Surface(eve.SWAPCHAIN_0, eve.FORMAT_RGB6, 1920, 1200) |
| 62 | + panel = bteve2.Panel(eve.HD, 2100,50, 0, 30, 1245,10, 0, 3, 2, 0, 0, 0, 1) |
| 63 | + touch = bteve2.Touch("Goodix GT911", 0x5d, 2) |
| 64 | + |
| 65 | + else: |
| 66 | + raise (f"panel type unknown") |
| 67 | + |
| 68 | + # Check that there is a write method for the connector. |
| 69 | + eve.register(eve) |
| 70 | + |
| 71 | + if not minimal: |
| 72 | + scrsize = (eve.EVE_DISP_WIDTH * eve.EVE_DISP_HEIGHT * 3) |
| 73 | + eve.CMD_REGWRITE(eve.REG_SC0_SIZE, 2) |
| 74 | + eve.CMD_REGWRITE(eve.REG_SC0_PTR0, 0x7a00000) |
| 75 | + eve.CMD_REGWRITE(eve.REG_SC0_PTR1, 0x7a00000 + scrsize) |
| 76 | + eve.panel(surface, panel, touch) |
| 77 | + app(eve) |
| 78 | + eve.LIB_EndCoProList() |
| 79 | + eve.LIB_AwaitCoProEmpty() |
| 80 | + else: |
| 81 | + app(eve) |
0 commit comments