File tree Expand file tree Collapse file tree 3 files changed +23
-36
lines changed Expand file tree Collapse file tree 3 files changed +23
-36
lines changed Original file line number Diff line number Diff line change 1
1
"""Contains modules for interfacing with the PSLab's I2C, SPI, and UART buses."""
2
2
3
- from pslab .bus .i2c import I2CMaster , I2CSlave
4
- from pslab .bus .spi import SPIMaster , SPISlave
5
- from pslab .bus .uart import UART
3
+ import sys
4
+
5
+
6
+ class classmethod_ (classmethod ):
7
+ """Support chaining classmethod and property."""
8
+
9
+ def __init__ (self , f ):
10
+ self .f = f
11
+ super ().__init__ (f )
12
+
13
+ def __get__ (self , obj , cls = None ):
14
+ # classmethod() to support chained decorators; new in python 3.9.
15
+ if sys .version_info < (3 , 9 ) and isinstance (self .f , property ):
16
+ return self .f .__get__ (cls )
17
+ else :
18
+ return super ().__get__ (obj , cls )
19
+
20
+
21
+ from pslab .bus .i2c import I2CMaster , I2CSlave # noqa: E402
22
+ from pslab .bus .spi import SPIMaster , SPISlave # noqa: E402
23
+ from pslab .bus .uart import UART # noqa: E402
6
24
7
25
__all__ = (
8
26
"I2CMaster" ,
Original file line number Diff line number Diff line change 19
19
0
20
20
"""
21
21
22
- import sys
23
22
from typing import List , Tuple
24
23
25
24
import pslab .protocol as CP
25
+ from pslab .bus import classmethod_
26
26
from pslab .serial_handler import SerialHandler
27
27
28
28
__all__ = (
38
38
_SMP = 1
39
39
40
40
41
- class classmethod_ (classmethod ):
42
- """Support chaining classmethod and property."""
43
-
44
- def __init__ (self , f ):
45
- self .f = f
46
- super ().__init__ (f )
47
-
48
- def __get__ (self , obj , cls = None ):
49
- # classmethod() to support chained decorators; new in python 3.9.
50
- if sys .version_info < (3 , 9 ) and isinstance (self .f , property ):
51
- return self .f .__get__ (cls )
52
- else :
53
- return super ().__get__ (obj , cls )
54
-
55
-
56
41
class _SPIPrimitive :
57
42
"""SPI primitive commands.
58
43
Original file line number Diff line number Diff line change 13
13
>>> bus.write_byte(0x55)
14
14
"""
15
15
16
- import sys
17
16
from typing import Tuple
18
17
19
18
import pslab .protocol as CP
19
+ from pslab .bus import classmethod_
20
20
from pslab .serial_handler import SerialHandler
21
21
22
22
__all__ = "UART"
23
23
_BRGVAL = 0x22 # BaudRate = 460800.
24
24
_MODE = (0 , 0 ) # 8-bit data and no parity, 1 stop bit.
25
25
26
26
27
- class classmethod_ (classmethod ):
28
- """Support chaining classmethod and property."""
29
-
30
- def __init__ (self , f ):
31
- self .f = f
32
- super ().__init__ (f )
33
-
34
- def __get__ (self , obj , cls = None ):
35
- """Check python version and return appropriate getter."""
36
- # classmethod() to support chained decorators; new in python 3.9.
37
- if sys .version_info < (3 , 9 ) and isinstance (self .f , property ):
38
- return self .f .__get__ (cls )
39
- else :
40
- return super ().__get__ (obj , cls )
41
-
42
-
43
27
class _UARTPrimitive :
44
28
"""UART primitive commands.
45
29
You can’t perform that action at this time.
0 commit comments