From 500f851991ed89b65dd6cbecd5ca31748431c83d Mon Sep 17 00:00:00 2001 From: James Devine Date: Sat, 9 Jan 2016 18:46:52 +0000 Subject: [PATCH] microbit: whitespace corrections Corrected additional whitespace on some lines of source/MicroBitPin.cpp --- source/MicroBitPin.cpp | 86 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/source/MicroBitPin.cpp b/source/MicroBitPin.cpp index 857590e..9785845 100644 --- a/source/MicroBitPin.cpp +++ b/source/MicroBitPin.cpp @@ -2,29 +2,29 @@ #include "MicroBitPin.h" /** - * Constructor. + * Constructor. * Create a Button representation with the given ID. * @param id the ID of the new Pin object. * @param name the pin name for this MicroBitPin instance to represent * @param capability the capability of this pin, can it only be digital? can it only be analog? can it be both? - * + * * Example: - * @code + * @code * MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_BOTH); * @endcode */ -MicroBitPin::MicroBitPin(int id, PinName name, PinCapability capability) -{ - //set mandatory attributes +MicroBitPin::MicroBitPin(int id, PinName name, PinCapability capability) +{ + //set mandatory attributes this->id = id; this->name = name; this->capability = capability; - + // Power up in a disconnected, low power state. // If we're unused, this is how it will stay... this->status = 0x00; this->pin = NULL; - + } /** @@ -45,16 +45,16 @@ void MicroBitPin::disconnect() NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Disabled; // forcibly disable the ADC - BUG in mbed.... delete ((AnalogIn *)pin); } - + if (status & IO_STATUS_ANALOG_OUT) { if(((DynamicPwm *)pin)->getPinName() == name) - ((DynamicPwm *)pin)->release(); - } + ((DynamicPwm *)pin)->release(); + } if (status & IO_STATUS_TOUCH_IN) delete ((MicroBitButton *)pin); - + this->pin = NULL; this->status = status & IO_STATUS_EVENTBUS_ENABLED; //retain event bus status } @@ -62,9 +62,9 @@ void MicroBitPin::disconnect() /** * Configures this IO pin as a digital output (if necessary) and sets the pin to 'value'. * @param value 0 (LO) or 1 (HI) - * + * * Example: - * @code + * @code * MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_BOTH); * P0.setDigitalValue(1); // P0 is now HI * @return MICROBIT_OK on success, MICROBIT_INVALID_PARAMETER if value is out of range, or MICROBIT_NOT_SUPPORTED @@ -80,14 +80,14 @@ int MicroBitPin::setDigitalValue(int value) // Ensure we have a valid value. if (value < 0 || value > 1) return MICROBIT_INVALID_PARAMETER; - + // Move into a Digital input state if necessary. if (!(status & IO_STATUS_DIGITAL_OUT)){ - disconnect(); + disconnect(); pin = new DigitalOut(name); status |= IO_STATUS_DIGITAL_OUT; } - + // Write the value. ((DigitalOut *)pin)->write(value); @@ -97,9 +97,9 @@ int MicroBitPin::setDigitalValue(int value) /** * Configures this IO pin as a digital input (if necessary) and tests its current value. * @return 1 if this input is high, 0 if input is LO, or MICROBIT_NOT_SUPPORTED if the given pin does not have analog capability. - * + * * Example: - * @code + * @code * MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_BOTH); * P0.getDigitalValue(); // P0 is either 0 or 1; * @endcode @@ -109,14 +109,14 @@ int MicroBitPin::getDigitalValue() //check if this pin has a digital mode... if(!(PIN_CAPABILITY_DIGITAL & capability)) return MICROBIT_NOT_SUPPORTED; - + // Move into a Digital input state if necessary. if (!(status & IO_STATUS_DIGITAL_IN)){ - disconnect(); - pin = new DigitalIn(name,PullDown); + disconnect(); + pin = new DigitalIn(name,PullDown); status |= IO_STATUS_DIGITAL_IN; } - + return ((DigitalIn *)pin)->read(); } @@ -131,20 +131,20 @@ int MicroBitPin::setAnalogValue(int value) //check if this pin has an analogue mode... if(!(PIN_CAPABILITY_ANALOG & capability)) return MICROBIT_NOT_SUPPORTED; - + //sanitise the brightness level if(value < 0 || value > MICROBIT_PIN_MAX_OUTPUT) return MICROBIT_INVALID_PARAMETER; - + float level = (float)value / float(MICROBIT_PIN_MAX_OUTPUT); - + // Move into an analogue input state if necessary, if we are no longer the focus of a DynamicPWM instance, allocate ourselves again! if (!(status & IO_STATUS_ANALOG_OUT) || !(((DynamicPwm *)pin)->getPinName() == name)){ - disconnect(); + disconnect(); pin = (void *)DynamicPwm::allocate(name); status |= IO_STATUS_ANALOG_OUT; } - + //perform a write with an extra check! :) if(((DynamicPwm *)pin)->getPinName() == name) ((DynamicPwm *)pin)->write(level); @@ -156,9 +156,9 @@ int MicroBitPin::setAnalogValue(int value) /** * Configures this IO pin as an analogue input (if necessary and possible). * @return the current analogue level on the pin, in the range 0 - 1024, or MICROBIT_NOT_SUPPORTED if the given pin does not have analog capability. - * + * * Example: - * @code + * @code * MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_BOTH); * P0.getAnalogValue(); // P0 is a value in the range of 0 - 1024 * @endcode @@ -168,14 +168,14 @@ int MicroBitPin::getAnalogValue() //check if this pin has an analogue mode... if(!(PIN_CAPABILITY_ANALOG & capability)) return MICROBIT_NOT_SUPPORTED; - + // Move into an analogue input state if necessary. if (!(status & IO_STATUS_ANALOG_IN)){ - disconnect(); + disconnect(); pin = new AnalogIn(name); status |= IO_STATUS_ANALOG_IN; } - + //perform a read! return ((AnalogIn *)pin)->read_u16(); } @@ -219,14 +219,14 @@ int MicroBitPin::isAnalog() /** * Configures this IO pin as a makey makey style touch sensor (if necessary) and tests its current debounced state. * @return 1 if pin is touched, 0 if not, or MICROBIT_NOT_SUPPORTED if this pin does not support touch capability. - * + * * Example: - * @code + * @code * MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ALL); * if(P0.isTouched()) * { * uBit.display.clear(); - * } + * } * @endcode */ int MicroBitPin::isTouched() @@ -234,14 +234,14 @@ int MicroBitPin::isTouched() //check if this pin has a touch mode... if(!(PIN_CAPABILITY_TOUCH & capability)) return MICROBIT_NOT_SUPPORTED; - + // Move into a touch input state if necessary. if (!(status & IO_STATUS_TOUCH_IN)){ - disconnect(); - pin = new MicroBitButton(id, name); + disconnect(); + pin = new MicroBitButton(id, name); status |= IO_STATUS_TOUCH_IN; } - + return ((MicroBitButton *)pin)->isPressed(); } @@ -249,7 +249,7 @@ int MicroBitPin::isTouched() * Configures the PWM period of the analog output to the given value. * * @param period The new period for the analog output in microseconds. - * @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the + * @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the * given pin is not configured as an analog output. */ int MicroBitPin::setAnalogPeriodUs(int period) @@ -265,9 +265,9 @@ int MicroBitPin::setAnalogPeriodUs(int period) * Configures the PWM period of the analog output to the given value. * * @param period The new period for the analog output in microseconds. - * @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the + * @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the * given pin is not configured as an analog output. - */ + */ int MicroBitPin::setAnalogPeriod(int period) { return setAnalogPeriodUs(period*1000);