Skip to content

Commit d5f2032

Browse files
committed
libs/driver/fpc1020a: Remove firmware version restriction.
Signed-off-by: lbuque <[email protected]>
1 parent c99eda5 commit d5f2032

File tree

1 file changed

+9
-15
lines changed
  • m5stack/libs/driver/fpc1020a/fpc1020a

1 file changed

+9
-15
lines changed

m5stack/libs/driver/fpc1020a/fpc1020a/api.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,18 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
from machine import UART
5+
import machine
66
from micropython import const
7-
8-
try:
9-
import struct
10-
except ImportError:
11-
import ustruct as struct
12-
13-
try:
14-
from typing import Literal, Union
15-
except ImportError:
16-
pass
17-
7+
import struct
8+
import sys
189
import time
1910
import binascii
20-
11+
import warnings
2112
from . import types as t
2213

14+
if sys.platform != "esp32":
15+
from typing import Literal, Union
16+
2317

2418
class CommandId:
2519
SLEEP = const(0x2C)
@@ -107,15 +101,15 @@ class FPC1020A:
107101
REPEAT_ALLOWED = 0x00
108102
NO_REPETITION = 0x01
109103

110-
def __init__(self, uart: UART, verbose=False) -> None:
104+
def __init__(self, uart: machine.UART, verbose=False) -> None:
111105
self._uart = uart
112106
self._verbose = verbose
113107
self._add_mode = self.NO_REPETITION
114108
self._match_level = 5
115109
while self._uart.any():
116110
self._uart.read(self._uart.any())
117111
if self.get_version() not in ("B1.10.00", "B1.07.00"):
118-
raise RuntimeError("FPC1020A not found")
112+
warnings.warn("Version mismatch or no device found")
119113

120114
def sleep(self) -> bool:
121115
"""After calling this method successfully, FPC1020A will not be able to

0 commit comments

Comments
 (0)