Skip to content

Commit 6fa51ab

Browse files
author
James Boulton
committed
DashIO Comms module working
1 parent 90c0db3 commit 6fa51ab

13 files changed

+204
-167
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,20 @@ dmypy.json
132132

133133
# End of https://www.gitignore.io/api/python
134134
.vscode/
135+
.VScode*
135136
*.ini
136137
.DS_Store
137138
pylint.out
138139
.noseids
139140
*.c64
141+
*.pdf
142+
*.gpx
143+
*.zip
144+
*.cfg
145+
scratch.py
146+
*_debug.py
147+
*.service
148+
*_text.py
149+
*_test.py
150+
ttn.py
151+
a

Examples/RaspberryPi/TestBLE.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import platform
3333
import zmq
3434

35-
from dashio.bleconnection import BLEConnection
35+
from dashio.ble_connection import BLEConnection
3636

3737

3838
class TestControls:

Examples/RaspberryPi/ble_set_wifi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import shortuuid
3333

3434
import dashio
35-
from dashio import bleconnection
35+
from dashio import ble_connection
3636

3737
shutdown = False
3838

@@ -157,7 +157,7 @@ def set_name_callback(msg):
157157
device.set_wifi_callback(set_wifi_callback)
158158
device.set_name_callback(set_name_callback)
159159

160-
dash_conn = bleconnection.BLEConnection(ble_uuid=config_file_parser.get('DEFAULT', 'BLE_UUID'))
160+
dash_conn = ble_connection.BLEConnection(ble_uuid=config_file_parser.get('DEFAULT', 'BLE_UUID'))
161161
dash_conn.add_device(device)
162162

163163
while not shutdown:

Examples/serial_coms_module.py Examples/dashio_coms_module.py

+3-20
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,6 @@ def text_cntrl_message_handler(self, msg):
116116
def selector_ctrl_handler(self, msg):
117117
print(self.selector_ctrl.selection_list[int(msg[3])])
118118

119-
def _coms_reboot_msg(self, msg):
120-
logging.debug("RBT: %s", msg)
121-
msg = dashio.set_comms_module_passthough(msg[0])
122-
self.serial_con.serial_com.write(msg.encode())
123-
msg = dashio.enable_comms_module_ble(msg[0], True)
124-
self.serial_con.serial_com.write(msg.encode())
125-
126-
def _comms_device_id_msg(self, msg):
127-
logging.debug("Comms Module Device ID: %s", msg)
128-
msg = dashio.reboot_comms_module(msg[0])
129-
self.serial_con.serial_com.write(msg.encode())
130-
131119
def __init__(self):
132120

133121
# Catch CNTRL-C signal
@@ -142,11 +130,9 @@ def __init__(self):
142130
self.device = dashio.Device("ControlTest", args.device_id, args.device_name, context=context)
143131
# self.device.use_cfg64()
144132

145-
self.serial_con = dashio.SerialConnection(serial_port=args.serial, baud_rate=115200, context=context)
146-
self.serial_con.set_crtl_reboot_callback(self._coms_reboot_msg)
147-
self.serial_con.set_crtl_device_id_callback(self._comms_device_id_msg)
133+
self.dcm = dashio.DashIOCommsModuleConnection(serial_port=args.serial, baud_rate=115200, context=context)
148134
self.device.config_revision = 2
149-
self.serial_con.add_device(self.device)
135+
self.dcm.add_device(self.device)
150136

151137
self.page_name = "TestTCP: " + platform.node()
152138

@@ -252,14 +238,11 @@ def __init__(self):
252238
self.device.add_control(self.up_btn)
253239
self.device.config_revision = 1
254240

255-
msg = dashio.reguest_comms_module_device_id()
256-
self.serial_con.serial_com.write(msg.encode())
257-
258241
while not self.shutdown:
259242
time.sleep(1)
260243
# self.comp_control.direction_value = random.random() * 360
261244

262-
self.serial_con.close()
245+
self.dcm.close()
263246
self.device.close()
264247

265248

Examples/tcp_example.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,19 @@ def __init__(self):
151151
self.page_test.add_control(self.down_btn)
152152

153153
self.sldr_cntrl = dashio.Slider(
154-
"SLDR", title="Slider", bar_max=10, slider_enabled=True, red_value=10, control_position=dashio.ControlPosition(0.02, 0.13, 0.22, 0.73)
154+
"SLDR", title="Slider", bar_max=10, slider_enabled=True, red_value=10, bar_mode=dashio.BarMode.MSG, control_position=dashio.ControlPosition(0.02, 0.13, 0.22, 0.73)
155155
)
156156
self.sldr_cntrl.add_receive_message_callback(self.slider_event_handler)
157157
self.page_test.add_control(self.sldr_cntrl)
158158

159159
self.sldr_dbl_cntrl = dashio.Slider(
160-
"SLDR_DBL", title="Slider Double", bar_max=5, slider_enabled=True, red_value=5, control_position=dashio.ControlPosition(0.78, 0.01, 0.2, 0.98)
160+
"SLDR_DBL", title="Slider Double", bar_max=5, slider_enabled=True, red_value=5, bar_mode=dashio.BarMode.MSG, control_position=dashio.ControlPosition(0.78, 0.01, 0.2, 0.98)
161161
)
162162
self.sldr_dbl_cntrl.bar2_value = 0
163163
self.sldr_dbl_cntrl.add_receive_message_callback(self.slider_dbl_event_handler)
164164
self.page_test.add_control(self.sldr_dbl_cntrl)
165165

166-
self.knb_control = dashio.Knob("KNB", title="A Knob", dial_max=10, red_value=10, control_position=dashio.ControlPosition(0.24, 0.14, 0.54, 0.21))
166+
self.knb_control = dashio.Knob("KNB", title="A Knob", dial_max=10, red_value=10, dial_mode=dashio.DialMode.MSG, control_position=dashio.ControlPosition(0.24, 0.14, 0.54, 0.21))
167167
self.knb_control.add_receive_message_callback(self.knob_event_handler)
168168
self.page_test.add_control(self.knb_control)
169169

dashio/__init__.py

+6-34
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,13 @@
3434
"""
3535

3636
from .device import Device
37-
from .tcpconnection import TCPConnection
38-
from .mqttconnection import MQTTConnection
39-
from .zmqconnection import ZMQConnection
40-
from .dashconnection import DashConnection
41-
from .serialconnection import SerialConnection
37+
from .tcp_connection import TCPConnection
38+
from .mqtt_connection import MQTTConnection
39+
from .zmq_connection import ZMQConnection
40+
from .dash_connection import DashConnection
41+
from .comms_module_connection import DashIOCommsModuleConnection
4242
from .schedular import Schedular
4343
from .load_config import decode_cfg64, encode_cfg64, load_all_controls_from_config, get_control_dict_from_config, get_control_from_config
44-
from .comms_module import (
45-
enable_comms_module_ble,
46-
enable_comms_module_dash,
47-
enable_comms_module_tcp,
48-
set_comms_module_dash,
49-
set_comms_module_name,
50-
set_comms_module_normal,
51-
set_comms_module_passthough,
52-
set_comms_module_tcp_port,
53-
set_comms_module_wifi,
54-
get_comms_module_active_connections,
55-
reguest_comms_module_device_id,
56-
reboot_comms_module,
57-
comms_module_sleep
58-
)
5944
# from .bleconnection import BLEConnection
6045
from .iotcontrol.enums import (
6146
Color,
@@ -113,21 +98,8 @@
11398
'ZMQConnection',
11499
'DashConnection',
115100
'ConnectionState',
116-
'SerialConnection',
101+
'DashIOCommsModuleConnection',
117102
'Schedular',
118-
'enable_comms_module_ble',
119-
'enable_comms_module_dash',
120-
'enable_comms_module_tcp',
121-
'set_comms_module_dash',
122-
'set_comms_module_name',
123-
'set_comms_module_normal',
124-
'set_comms_module_passthough',
125-
'set_comms_module_tcp_port',
126-
'set_comms_module_wifi',
127-
'get_comms_module_active_connections',
128-
'reguest_comms_module_device_id',
129-
'reboot_comms_module',
130-
'comms_module_sleep',
131103
'decode_cfg64',
132104
'encode_cfg64',
133105
'load_all_controls_from_config',
File renamed without changes.

dashio/comms_module.py

-89
This file was deleted.

0 commit comments

Comments
 (0)