Skip to content

Commit 4fae4db

Browse files
committed
moved debug_mode reference
1 parent 717fc7c commit 4fae4db

8 files changed

Lines changed: 8 additions & 24 deletions

File tree

src/adafruit_circuitplayground/express.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def __init__(self):
4747
"touch": [False] * 7,
4848
"shake": False,
4949
}
50-
self.__debug_mode = False
51-
self.pixels = Pixel(self.__state, self.__debug_mode)
50+
self.pixels = Pixel(self.__state)
5251

5352
@property
5453
def acceleration(self):
@@ -114,7 +113,7 @@ def light(self):
114113
return self.__state["light"]
115114

116115
def __show(self):
117-
if self.__debug_mode:
116+
if utils.debug_mode:
118117
common.debugger_communication_client.debug_send_to_simulator(
119118
self.__state, CONSTANTS.CPX
120119
)

src/adafruit_circuitplayground/pixel.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212

1313

1414
class Pixel:
15-
def __init__(self, state, debug_mode=False):
15+
def __init__(self, state):
1616
self.__state = state
1717
self.auto_write = True
18-
self.__debug_mode = debug_mode
1918
self.telemetry_state = False
2019

2120
def show(self):
2221
# Send the state to the extension so that React re-renders the Webview
2322
# or send the state to the debugger (within this library)
24-
if self.__debug_mode:
23+
if utils.debug_mode:
2524
common.debugger_communication_client.debug_send_to_simulator(
2625
self.__state, CONSTANTS.CPX
2726
)
@@ -32,9 +31,6 @@ def __show_if_auto_write(self):
3231
if self.auto_write:
3332
self.show()
3433

35-
def __set_debug_mode(self, debug_mode):
36-
self.__debug_mode = debug_mode
37-
3834
def __getitem__(self, index):
3935
if type(index) is not slice:
4036
if not self.__valid_index(index):

src/adafruit_circuitplayground/test/test_pixel.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ def setup_method(self):
1616
}
1717
)
1818

19-
@pytest.mark.parametrize("debug_mode", [True, False])
20-
def test_set_debug_mode(self, debug_mode):
21-
self.pixel._Pixel__set_debug_mode(debug_mode)
22-
assert debug_mode == self.pixel._Pixel__debug_mode
23-
2419
def test_get_item_out_of_bounds(self):
2520
with pytest.raises(IndexError):
2621
p = self.pixel[3]

src/common/debugger_communication_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
def debug_send_to_simulator(state, active_device):
2828
global previous_state
2929
if state != previous_state:
30+
print("here!")
3031
previous_state = copy.deepcopy(state)
3132

3233
updated_state = utils.update_state_with_device_name(state, active_device)

src/common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
previous_state = {}
1111

1212
abs_path_to_user_file = ""
13-
13+
debug_mode=False
1414

1515
def update_state_with_device_name(state, device_name):
1616
updated_state = dict(state)

src/debug_user_code.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252

5353
# Init API variables
5454
utils.abs_path_to_user_file = abs_path_to_code_file
55-
cpx._Express__debug_mode = True
56-
cpx.pixels._Pixel__set_debug_mode(True)
57-
mb._MicrobitModel__set_debug_mode(True)
55+
utils.debug_mode = True
5856

5957
# Execute the user's code file
6058
with open(abs_path_to_code_file, encoding="utf8") as user_code_file:

src/micropython/microbit/__model/display.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def __init__(self):
2121

2222
self.__current_pid = None
2323
self.__lock = threading.Lock()
24-
self.__debug_mode = False
2524

2625
def scroll(self, value, delay=150, wait=True, loop=False, monospace=False):
2726
"""
@@ -352,7 +351,7 @@ def __create_scroll_image(images):
352351
def __update_client(self):
353352
sendable_json = {"leds": self.__get_array()}
354353

355-
if self.__debug_mode:
354+
if common.utils.debug_mode:
356355
common.debugger_communication_client.debug_send_to_simulator(
357356
sendable_json, CONSTANTS.MICROBIT
358357
)

src/micropython/microbit/__model/microbit_model.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,4 @@ def __update_gesture(self, new_state):
9898
new_gesture = new_state.get(CONSTANTS.EXPECTED_INPUT_GESTURE)
9999
self.accelerometer._Accelerometer__update_gesture(new_gesture)
100100

101-
def __set_debug_mode(self, mode):
102-
self.display._Display__debug_mode = mode
103-
104-
105101
__mb = MicrobitModel()

0 commit comments

Comments
 (0)