Removed non standard functions togglePin, toggleLED,isButtonPressed, and waitForButtonPress. And updated all examples that used these, to use other functions. Note togglePin was used internally in shiftOut. Also note, that some of these functions were replaced by the code that was inside the non standard function e.g inside togglePin. In the longer term these internal maple function calls need to be replaced by high level Arduino API calls like digitalRead and digitalWrite where applicable
This commit is contained in:
parent
7bc0e0f015
commit
5dcfa4f1b0
|
@ -143,6 +143,8 @@ uint32 digitalRead(uint8 pin);
|
|||
* @see pinMode()
|
||||
*/
|
||||
uint16 analogRead(uint8 pin);
|
||||
#if FALSE
|
||||
// Roger Clark. Deprecated these functions as they are not part of the standard Arduino API
|
||||
|
||||
/**
|
||||
* Toggles the digital value at the given pin.
|
||||
|
@ -202,7 +204,7 @@ uint8 isButtonPressed(uint8 pin=BOARD_BUTTON_PIN,
|
|||
* @see pinMode()
|
||||
*/
|
||||
uint8 waitForButtonPress(uint32 timeout_millis=0);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Shift out a byte of data, one bit at a time.
|
||||
*
|
||||
|
|
|
@ -54,6 +54,8 @@ void digitalWrite(uint8 pin, uint8 val) {
|
|||
gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, val);
|
||||
}
|
||||
|
||||
#if FALSE
|
||||
// Roger Clark. Deprecated these functions as they are not part of the standard Arduino API
|
||||
void togglePin(uint8 pin) {
|
||||
if (pin >= BOARD_NR_GPIO_PINS) {
|
||||
return;
|
||||
|
@ -92,3 +94,4 @@ uint8 waitForButtonPress(uint32 timeout) {
|
|||
} while (!isButtonPressed());
|
||||
return true;
|
||||
}
|
||||
#endif
|
|
@ -31,7 +31,7 @@ void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value) {
|
|||
for (int i = 0; i < 8; i++) {
|
||||
int bit = bitOrder == LSBFIRST ? i : (7 - i);
|
||||
digitalWrite(dataPin, (value >> bit) & 0x1);
|
||||
togglePin(clockPin);
|
||||
togglePin(clockPin);
|
||||
gpio_toggle_bit(PIN_MAP[clockPin].gpio_device, PIN_MAP[clockPin].gpio_bit);// togglePin(clockPin);
|
||||
gpio_toggle_bit(PIN_MAP[clockPin].gpio_device, PIN_MAP[clockPin].gpio_bit);// togglePin(clockPin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,9 +311,9 @@ void LiquidCrystal::pulseEnable(void) {
|
|||
// the following threads:
|
||||
// http://forums.leaflabs.com/topic.php?id=640
|
||||
// http://forums.leaflabs.com/topic.php?id=512
|
||||
togglePin(_enable_pin);
|
||||
gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin);
|
||||
delayMicroseconds(1);
|
||||
togglePin(_enable_pin);
|
||||
gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin);
|
||||
|
||||
// Commands needs > 37us to settle.
|
||||
delayMicroseconds(42);
|
||||
|
|
|
@ -14,6 +14,6 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
toggleLED(); // Turn the LED from off to on, or on to off
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(1000); // Wait for 1 second (1000 milliseconds)
|
||||
}
|
||||
|
|
|
@ -32,6 +32,6 @@ void loop() {
|
|||
previousMillis = millis();
|
||||
|
||||
// If the LED is off, turn it on, and vice-versa:
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,22 @@ void setup() {
|
|||
pinMode(BOARD_BUTTON_PIN, INPUT);
|
||||
}
|
||||
|
||||
#define BUTTON_DEBOUNCE_DELAY 1
|
||||
uint8 isButtonPressed(uint8 pin=BOARD_BUTTON_PIN,
|
||||
uint32 pressedLevel=BOARD_BUTTON_PRESSED_LEVEL) {
|
||||
if (digitalRead(pin) == pressedLevel) {
|
||||
delay(BUTTON_DEBOUNCE_DELAY);
|
||||
while (digitalRead(pin) == pressedLevel)
|
||||
;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Check if the button is pressed.
|
||||
if (isButtonPressed()) {
|
||||
// If so, turn the LED from on to off, or from off to on:
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop () {
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100);
|
||||
|
||||
while (Serial.available()) {
|
||||
|
@ -490,7 +490,7 @@ void cmd_sequential_gpio_writes(void) {
|
|||
|
||||
pinMode(i, OUTPUT);
|
||||
do {
|
||||
togglePin(i);
|
||||
gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit);
|
||||
} while (!Serial.available());
|
||||
|
||||
digitalWrite(i, LOW);
|
||||
|
@ -513,7 +513,7 @@ void cmd_gpio_toggling(void) {
|
|||
for (uint32 i = 0; i < BOARD_NR_GPIO_PINS; i++) {
|
||||
if (boardUsesPin(i))
|
||||
continue;
|
||||
togglePin(i);
|
||||
gpio_toggle_bit(PIN_MAP[i].gpio_device, PIN_MAP[i].gpio_bit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100);
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
|
||||
for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) {
|
||||
if (boardUsesPin(i))
|
||||
|
|
|
@ -12,6 +12,6 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
toggleLED(); // Turn the LED from off to on, or on to off
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(1000); // Wait for 1 second (1000 milliseconds)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Blink LED & count Demo");
|
||||
|
|
|
@ -20,7 +20,7 @@ void setup()
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ void setup()
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Integer Input - Floating Output");
|
||||
|
|
|
@ -40,7 +40,7 @@ void setup(void)
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void loop(void)
|
|||
sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1);
|
||||
Serial.println(buf);
|
||||
}
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ void setup()
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Prime Number Generator");
|
||||
|
|
|
@ -20,7 +20,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Prime Number Generator V2");
|
||||
|
|
|
@ -20,7 +20,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Prime Number Generator V2");
|
||||
|
|
|
@ -17,7 +17,7 @@ void setup()
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Print Binary Format");
|
||||
|
|
|
@ -19,7 +19,7 @@ void setup() // run once, when the sketch starts
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Print Float Format");
|
||||
|
|
|
@ -18,7 +18,7 @@ void setup() // run once, when the sketch starts
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Print HEX Format");
|
||||
|
|
|
@ -15,7 +15,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("Serial Read Until Example:");
|
||||
|
|
Binary file not shown.
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
Serial.println("ASCII Table ~ Character Map");
|
||||
|
|
|
@ -21,7 +21,7 @@ void setup() {
|
|||
// wait for serial monitor to be connected.
|
||||
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
|
||||
{
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
delay(100); // fast blink
|
||||
}
|
||||
li1 = strtol (szNumbers,&pEnd,10); // BASE 10
|
||||
|
|
|
@ -44,7 +44,7 @@ void loop() {
|
|||
// if the sensor reading is greater than the threshold:
|
||||
if (sensorReading >= threshold) {
|
||||
// toggle the built-in LED
|
||||
toggleLED();
|
||||
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off
|
||||
// send the string "Knock!" back to the computer, followed by newline
|
||||
Serial.println("Knock!");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue