Skip to content

Commit 748657e

Browse files
Improve pin stub so servo code doesn't explode.
See #76
1 parent 1a83bbd commit 748657e

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/microbithal_js.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,9 @@ int microbit_hal_pin_set_analog_period_us(int pin, int period) {
113113
mp_js_hal_audio_period_us(period);
114114
return 0;
115115
}
116-
117-
/*
118-
// Calling setAnalogPeriodUs requires the pin to be in analog-out mode. So
119-
// test for this mode by first calling getAnalogPeriodUs, and if it fails then
120-
// attempt to configure the pin in analog-out mode by calling setAnalogValue.
121-
if ((ErrorCode)pin_obj[pin]->getAnalogPeriodUs() == DEVICE_NOT_SUPPORTED) {
122-
if (pin_obj[pin]->setAnalogValue(0) != DEVICE_OK) {
123-
return -1;
124-
}
125-
}
126-
127-
// Set the analog period.
128-
if (pin_obj[pin]->setAnalogPeriodUs(period) == DEVICE_OK) {
129-
return 0;
130-
} else {
131-
return -1;
132-
}
133-
*/
134-
return -1;
116+
// We don't support other pins yet but more practical to claim success as
117+
// this allows programs using servos to otherwise function.
118+
return 0;
135119
}
136120

137121
int microbit_hal_pin_get_analog_period_us(int pin) {

0 commit comments

Comments
 (0)