full support for setPull

This commit is contained in:
Peli de Halleux
2016-06-03 23:15:51 -07:00
parent e2ce49d94b
commit e6ca366d20
8 changed files with 72 additions and 46 deletions

View File

@ -223,12 +223,13 @@ declare const enum DAL {
MICROBIT_ACCELEROMETER_REST_TOLERANCE = 200,
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 1000,
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 400,
MICROBIT_ACCELEROMETER_3G_TOLERANCE = 3072,
MICROBIT_ACCELEROMETER_6G_TOLERANCE = 6144,
MICROBIT_ACCELEROMETER_8G_TOLERANCE = 8192,
MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 10,
MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 5,
MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10,
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h
MICROBIT_BUTTON_EVT_DOWN = 1,

View File

@ -278,6 +278,16 @@ declare namespace led {
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
}
declare enum PinPullMode {
//% block="down"
PullDown = 0,
//% block="up"
PullUp = 1,
//% block="none"
PullNone = 2,
}
declare namespace pins {
}

View File

@ -36,6 +36,15 @@ enum class PulseValue {
Low = MICROBIT_PIN_EVT_PULSE_LO
};
enum class PinPullMode {
//% block="down"
PullDown = 0,
//% block="up"
PullUp = 1,
//% block="none"
PullNone = 2
};
MicroBitPin *getPin(int id) {
switch (id) {
case MICROBIT_ID_IO_P0: return &uBit.io.P0;
@ -134,17 +143,6 @@ namespace pins {
PINOP(setAnalogPeriodUs(micros));
}
/**
* Configures the pull of this pin.
* @param name pin to set the pull mode on
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
*/
//% help=pins/digital-set-pull weight=21 blockGap=8
//% blockId=device_set_pull block="digital set pull|pin %pin|to %pull"
void setPull(DigitalPin name, PinMode pull) {
PINOP(setPull(pull));
}
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
@ -225,6 +223,22 @@ namespace pins {
}
}
/**
* Configures the pull of this pin.
* @param name pin to set the pull mode on
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
*/
//% help=pins/digital-set-pull weight=3
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
void setPull(DigitalPin name, PinPullMode pull) {
PinMode m = pull == PinPullMode::PullDown
? PinMode::PullDown
: pull == PinPullMode::PullUp ? PinMode::PullUp
: PinMode::PullNone;
PINOP(setPull(m));
}
/**
* Create a new zero-initialized buffer.
* @param size number of bytes in the buffer

View File

@ -1,9 +1,3 @@
enum PinMode {
PullDown,
PullUp,
PullNone
}
/**
* Control currents in Pins for analog/digital signals, servos, i2c, ...
*/

View File

@ -487,15 +487,6 @@ declare namespace pins {
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
function analogSetPeriod(name: AnalogPin, micros: number): void;
/**
* Configures the pull of this pin.
* @param name pin to set the pull mode on
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
*/
//% help=pins/digital-set-pull weight=21 blockGap=8
//% blockId=device_set_pull block="digital set pull|pin %pin|to %pull" shim=pins::setPull
function setPull(name: DigitalPin, pull: PinMode): void;
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
@ -544,6 +535,15 @@ declare namespace pins {
//% help=pins/analog-pitch weight=14 async shim=pins::analogPitch
function analogPitch(frequency: number, ms: number): void;
/**
* Configures the pull of this pin.
* @param name pin to set the pull mode on
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
*/
//% help=pins/digital-set-pull weight=3
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
function setPull(name: DigitalPin, pull: PinPullMode): void;
/**
* Create a new zero-initialized buffer.
* @param size number of bytes in the buffer