Skip to content

Commit e42f4c0

Browse files
committed
Support for 'fake' platform type
1 parent 3de7d34 commit e42f4c0

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

ev3dev/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_current_platform():
4444
"""
4545
Look in /sys/class/board-info/ to determine the platform type.
4646
47-
This can return 'ev3', 'evb', 'pistorms', 'brickpi' or 'brickpi3'.
47+
This can return 'ev3', 'evb', 'pistorms', 'brickpi', 'brickpi3' or 'fake'.
4848
"""
4949
board_info_dir = '/sys/class/board-info/'
5050

@@ -74,6 +74,10 @@ def get_current_platform():
7474

7575
elif value == 'Dexter Industries BrickPi3':
7676
return 'brickpi3'
77+
78+
elif value == 'FAKE-SYS':
79+
return 'fake'
80+
7781
return None
7882

7983

ev3dev/_platform/fake.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
OUTPUT_A = 'outA'
3+
OUTPUT_B = 'outB'
4+
OUTPUT_C = 'outC'
5+
OUTPUT_D = 'outD'
6+
7+
INPUT_1 = 'in1'
8+
INPUT_2 = 'in2'
9+
INPUT_3 = 'in3'
10+
INPUT_4 = 'in4'
11+
12+
BUTTONS_FILENAME = None
13+
EVDEV_DEVICE_NAME = None
14+
15+
LEDS = {}
16+
LED_GROUPS = {}
17+
LED_COLORS = {}

ev3dev/button.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
elif platform == 'brickpi3':
6161
from ev3dev._platform.brickpi3 import BUTTONS_FILENAME, EVDEV_DEVICE_NAME
6262

63+
elif platform == 'fake':
64+
from ev3dev._platform.fake import BUTTONS_FILENAME, EVDEV_DEVICE_NAME
65+
6366
else:
6467
raise Exception("Unsupported platform '%s'" % platform)
6568

ev3dev/led.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
elif platform == 'brickpi3':
5353
from ev3dev._platform.brickpi3 import LEDS, LED_GROUPS, LED_COLORS
5454

55+
elif platform == 'fake':
56+
from ev3dev._platform.fake import LEDS, LED_GROUPS, LED_COLORS
57+
5558
else:
5659
raise Exception("Unsupported platform '%s'" % platform)
5760

ev3dev/motor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
elif platform == 'brickpi3':
5757
from ev3dev._platform.brickpi3 import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D
5858

59+
elif platform == 'fake':
60+
from ev3dev._platform.fake import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D
61+
5962
else:
6063
raise Exception("Unsupported platform '%s'" % platform)
6164

ev3dev/sensor/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
elif platform == 'brickpi3':
5353
from ev3dev._platform.brickpi3 import INPUT_1, INPUT_2, INPUT_3, INPUT_4
5454

55+
elif platform == 'fake':
56+
from ev3dev._platform.fake import INPUT_1, INPUT_2, INPUT_3, INPUT_4
57+
5558
else:
5659
raise Exception("Unsupported platform '%s'" % platform)
5760

0 commit comments

Comments
 (0)