Merge lp:~pwlars/uci-phone-masher/show-offset into lp:uci-phone-masher

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: 8
Merged at revision: 8
Proposed branch: lp:~pwlars/uci-phone-masher/show-offset
Merge into: lp:uci-phone-masher
Prerequisite: lp:~pwlars/uci-phone-masher/set-offset
Diff against target: 74 lines (+15/-8)
4 files modified
uci_phone_masher/__init__.py (+4/-2)
uci_phone_masher/controller.py (+1/-1)
uci_phone_masher/model.py (+7/-2)
uci_phone_masher/tests/test_model.py (+3/-3)
To merge this branch: bzr merge lp:~pwlars/uci-phone-masher/show-offset
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+292580@code.launchpad.net

Commit message

Show button offset when querying button state

Description of the change

Show button offset when querying button state

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'uci_phone_masher/__init__.py'
2--- uci_phone_masher/__init__.py 2016-04-21 19:18:35 +0000
3+++ uci_phone_masher/__init__.py 2016-04-21 19:18:35 +0000
4@@ -68,13 +68,15 @@
5
6 def get_all():
7 controller = current_app.extensions['BUTTONCONTROLLER']
8- return jsonify(button_states=controller.model.data)
9+ return jsonify(button_states=controller.model.states,
10+ offsets=controller.model.offsets)
11
12
13 def get_button(button_num):
14 controller = current_app.extensions['BUTTONCONTROLLER']
15 return jsonify(
16- button_states=controller.model.get_button_state(int(button_num)))
17+ button_states=controller.model.get_button_state(int(button_num)),
18+ offset=controller.model.get_button_offset(int(button_num)))
19
20
21 def set_button_state(button_num, state):
22
23=== modified file 'uci_phone_masher/controller.py'
24--- uci_phone_masher/controller.py 2016-04-21 19:18:35 +0000
25+++ uci_phone_masher/controller.py 2016-04-21 19:18:35 +0000
26@@ -72,7 +72,7 @@
27 self.pwm.setPWMFreq(60)
28
29 # Initialize all servos to the 'off' position
30- for button in self.model.data.keys():
31+ for button in self.model.states.keys():
32 self.unpress(button)
33
34 def press(self, channel):
35
36=== modified file 'uci_phone_masher/model.py'
37--- uci_phone_masher/model.py 2016-04-21 19:18:35 +0000
38+++ uci_phone_masher/model.py 2016-04-21 19:18:35 +0000
39@@ -45,10 +45,15 @@
40 self._offset = initial_offset
41
42 @property
43- def data(self):
44- """Get a copy of the model's underlying data structure."""
45+ def states(self):
46+ """Get a copy of the all button states."""
47 return self._buttons.copy()
48
49+ @property
50+ def offsets(self):
51+ """Get a copy of the all button offsets."""
52+ return self._offset.copy()
53+
54 def set_button_state(self, button_num, state):
55 """Modify the model by setting a button's state.
56
57
58=== modified file 'uci_phone_masher/tests/test_model.py'
59--- uci_phone_masher/tests/test_model.py 2015-03-31 14:17:43 +0000
60+++ uci_phone_masher/tests/test_model.py 2016-04-21 19:18:35 +0000
61@@ -53,10 +53,10 @@
62 model2 = model.set_button_state(1, "on")
63 self.assertNotEqual(model, model2)
64
65- def test_model_data_property_is_deep_copy(self):
66+ def test_model_states_property_is_deep_copy(self):
67 model = ButtonModel()
68- data = model.data
69- data[1] = "foo"
70+ states = model.states
71+ states[1] = "foo"
72 self.assertNotEqual("foo", model.get_button_state(1))
73
74 def test_model_equality(self):

Subscribers

People subscribed via source and target branches