From 5046bc8bf23e83fcdadd6b0d027c4b30ea27b59e Mon Sep 17 00:00:00 2001 From: riban Date: Mon, 15 Oct 2018 09:13:30 +0100 Subject: [PATCH] Fixes name conflict in examples with ESP32 GPIO. Further coding style fixes (all more cuddly now). --- examples/GPIO/Blink/Blink.ino | 12 +++++------- examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino | 6 ++---- examples/GPIO/Input/Input.ino | 12 +++++------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/examples/GPIO/Blink/Blink.ino b/examples/GPIO/Blink/Blink.ino index d7bc594a..fb42d9bd 100644 --- a/examples/GPIO/Blink/Blink.ino +++ b/examples/GPIO/Blink/Blink.ino @@ -12,10 +12,9 @@ #define OUTPUT_PIN 0 USB Usb; // Create an UHS2 interface object -UHS2_GPIO GPIO(&Usb); // Create a GPIO object +UHS2_GPIO Gpio(&Usb); // Create a GPIO object -void setup() -{ +void setup() { Serial.begin( 115200 ); #if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection @@ -28,12 +27,11 @@ void setup() delay( 200 ); } -void loop() -{ +void loop() { // Get the current output value, toggle then wait half a second - int nValue = GPIO.digitalReadOutput(OUTPUT_PIN); + int nValue = Gpio.digitalReadOutput(OUTPUT_PIN); nValue = (nValue ? 0 : 1); - GPIO.digitalWrite(OUTPUT_PIN, nValue); + Gpio.digitalWrite(OUTPUT_PIN, nValue); Serial.print(nValue ? "+" : "."); // Debug to show what the output should be doing delay(500); } diff --git a/examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino b/examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino index 119b4780..88c81f98 100644 --- a/examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino +++ b/examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino @@ -12,8 +12,7 @@ USB Usb; -void setup() -{ +void setup() { Serial.begin( 115200 ); #if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection @@ -26,8 +25,7 @@ void setup() delay( 200 ); } -void loop() -{ +void loop() { // Get the current output value, toggle then wait half a second uint8_t nGPO = Usb.gpioRdOutput(); uint8_t nValue = ((nGPO & 0x01) == 0x01) ? 0 : 1; diff --git a/examples/GPIO/Input/Input.ino b/examples/GPIO/Input/Input.ino index 7306df93..d46e1ade 100644 --- a/examples/GPIO/Input/Input.ino +++ b/examples/GPIO/Input/Input.ino @@ -12,10 +12,9 @@ #define OUTPUT_PIN 0 USB Usb; // Create an UHS2 interface object -UHS2_GPIO GPIO(&Usb); // Create a GPIO object +UHS2_GPIO Gpio(&Usb); // Create a GPIO object -void setup() -{ +void setup() { Serial.begin( 115200 ); #if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection @@ -28,11 +27,10 @@ void setup() delay( 200 ); } -void loop() -{ +void loop() { // Get the value of input, set value of output - int nValue = GPIO.digitalRead(INPUT_PIN); + int nValue = Gpio.digitalRead(INPUT_PIN); nValue = (nValue ? LOW : HIGH); - GPIO.digitalWrite(OUTPUT_PIN, nValue); + Gpio.digitalWrite(OUTPUT_PIN, nValue); }