Merge lp:~pwlars/uci-phone-masher/debug-memory-controller into lp:uci-phone-masher

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: 10
Merged at revision: 10
Proposed branch: lp:~pwlars/uci-phone-masher/debug-memory-controller
Merge into: lp:uci-phone-masher
Diff against target: 36 lines (+14/-1)
1 file modified
uci_phone_masher/controller.py (+14/-1)
To merge this branch: bzr merge lp:~pwlars/uci-phone-masher/debug-memory-controller
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+292764@code.launchpad.net

Description of the change

These are just some useful debugging messages to use when messing with the memory controller, which is only used for testing, as it doesn't even try to use servos if they are connected

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/controller.py'
2--- uci_phone_masher/controller.py 2016-04-21 19:16:40 +0000
3+++ uci_phone_masher/controller.py 2016-04-25 08:10:53 +0000
4@@ -24,6 +24,9 @@
5 'PhoneControllerMemory',
6 ]
7
8+# Default pwm for a "pressed" button state - use offset to adjust this
9+DEFAULT_PWM_PRESS = 193
10+
11
12 class PhoneControllerBase(object):
13
14@@ -77,7 +80,8 @@
15
16 def press(self, channel):
17 super(PhoneControllerI2C, self).press(channel)
18- self.pwm.setPWM(channel, 0, 193)
19+ offset = self._model.get_button_offset(channel)
20+ self.pwm.setPWM(channel, 0, DEFAULT_PWM_PRESS + offset)
21
22 def unpress(self, channel):
23 super(PhoneControllerI2C, self).unpress(channel)
24@@ -95,3 +99,12 @@
25 Used when we don't have i2c available, or we're testing.
26
27 """
28+ def set_offset(self, button_num, offset):
29+ super(PhoneControllerMemory, self).set_offset(button_num, offset)
30+ print("DEBUG: offset set to {}".format(
31+ self._model.get_button_offset(button_num)))
32+
33+ def press(self, channel):
34+ super(PhoneControllerMemory, self).press(channel)
35+ print("DEBUG: Pressing button - PWM set to {}".format(
36+ DEFAULT_PWM_PRESS+self._model.get_button_offset(channel)))

Subscribers

People subscribed via source and target branches