-
Notifications
You must be signed in to change notification settings - Fork 7
/
io_wrapper_dummy.py
145 lines (107 loc) · 2.61 KB
/
io_wrapper_dummy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 15 11:56:25 2017
@author: Mark Dammer
This is a hardware independent replacement for the original io_wrapper.py.
It does not interface to any specific IO board, but returns random values for
the sensors and prints the output values to the console.
"""
from __future__ import division
import random
explorerhat = False
# Inputs: Digital
def input_one_read():
digital = bool(random.getrandbits(1))
return digital
def input_two_read():
digital = bool(random.getrandbits(1))
return digital
def input_three_read():
digital = bool(random.getrandbits(1))
return digital
def input_four_read():
digital = bool(random.getrandbits(1))
return digital
# Inputs: Analog
def analog_one_read():
analog = random.randrange(0, 5000) / 1000
return analog
def analog_two_read():
analog = random.randrange(0, 5000) / 1000
return analog
def analog_three_read():
analog = random.randrange(0, 5000) / 1000
return analog
def analog_four_read():
analog = random.randrange(0, 5000) / 1000
return analog
# Outputs: Motors
def motor_one_speed(speed):
print('Motor One: ' + str(speed))
return
def motor_two_speed(speed):
print('Motor Two: ' + str(speed))
return
# Outputs: Digital
def output_one_on():
print('Output One On')
return
def output_one_off():
print('Output One Off')
return
def output_two_on():
print('Output Two On')
return
def output_two_off():
print('Output Two Off')
return
def output_three_on():
print('Output Three On')
return
def output_three_off():
print('Output Three Off')
return
def output_four_on():
print('Output Four On')
return
def output_four_off():
print('Output Four Off')
return
# Outputs: LEDs
def light_blue_on():
print('Light Blue On')
return
def light_blue_blink(freq):
print('Light Blue Blink: ' + str(freq))
return
def light_blue_off():
print('Light Blue Off')
return
def light_yellow_on():
print('Light Yellow On')
return
def light_yellow_blink(freq):
print('Light Yellow Blink: ' + str(freq))
return
def light_yellow_off():
print('Light Yellow Off')
return
def light_red_on():
print('Light Red On')
return
def light_red_blink(freq):
print('Light Red Blink: ' + str(freq))
return
def light_red_off():
print('Light Red Off')
return
def light_green_on():
print('Light Green On')
return
def light_green_blink(freq):
print('Light Green Blink: ' + str(freq))
return
def light_green_off():
print('Light Green Off')
return