diff --git a/examples/c++/AioA0.cpp b/examples/c++/AioA0.cpp index dfa3a4d..86883ad 100644 --- a/examples/c++/AioA0.cpp +++ b/examples/c++/AioA0.cpp @@ -33,9 +33,6 @@ main() mraa::Aio* a0; a0 = new mraa::Aio(0); - if (a0 == NULL) { - return MRAA_ERROR_UNSPECIFIED; - } for (;;) { adc_value = a0->read(); diff --git a/examples/c++/Blink-IO.cpp b/examples/c++/Blink-IO.cpp index d362f37..b7dbca8 100644 --- a/examples/c++/Blink-IO.cpp +++ b/examples/c++/Blink-IO.cpp @@ -56,12 +56,10 @@ main(int argc, char** argv) //! [Interesting] mraa::Gpio* gpio = new mraa::Gpio(iopin); - if (gpio == NULL) { - return mraa::ERROR_UNSPECIFIED; - } mraa::Result response = gpio->dir(mraa::DIR_OUT); if (response != mraa::SUCCESS) { mraa::printError(response); + delete gpio; return 1; } diff --git a/examples/c++/Isr-pin6.cpp b/examples/c++/Isr-pin6.cpp index 19c37fa..bb37ca6 100644 --- a/examples/c++/Isr-pin6.cpp +++ b/examples/c++/Isr-pin6.cpp @@ -53,5 +53,6 @@ main() sleep(1); } + delete x; return EXIT_SUCCESS; } diff --git a/examples/c++/Pwm3-cycle.cpp b/examples/c++/Pwm3-cycle.cpp index 76f2328..86e0175 100644 --- a/examples/c++/Pwm3-cycle.cpp +++ b/examples/c++/Pwm3-cycle.cpp @@ -46,9 +46,6 @@ main() mraa::Pwm* pwm; pwm = new mraa::Pwm(3); - if (pwm == NULL) { - return MRAA_ERROR_UNSPECIFIED; - } fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n"); pwm->enable(true); diff --git a/examples/c++/UartOW.cpp b/examples/c++/UartOW.cpp index 91c94e7..3d1a3e9 100644 --- a/examples/c++/UartOW.cpp +++ b/examples/c++/UartOW.cpp @@ -27,8 +27,6 @@ //! [Interesting] #include "uart_ow.hpp" -using namespace std; - int main(int argc, char** argv) { @@ -38,21 +36,23 @@ main(int argc, char** argv) mraa::Result rv; if ((rv = uart->reset()) == mraa::SUCCESS) { - cout << "Reset succeeded, device(s) detected!" << endl; + std::cout << "Reset succeeded, device(s) detected!" << std::endl; } else { - cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl; + std::cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << std::endl; + delete uart; return 1; } - cout << "Looking for devices..." << endl; + std::cout << "Looking for devices..." << std::endl; ; uint8_t count = 0; // start the search from scratch - string id = uart->search(true); + std::string id = uart->search(true); if (id.empty()) { - cout << "No devices detected." << endl; + std::cout << "No devices detected." << std::endl; + delete uart; return 1; } @@ -73,7 +73,7 @@ main(int argc, char** argv) id = uart->search(false); } - cout << "Exiting..." << endl; + std::cout << "Exiting..." << std::endl; delete uart; diff --git a/examples/java/GpioMmapped.java b/examples/java/GpioMmapped.java index c780a4e..ab85419 100644 --- a/examples/java/GpioMmapped.java +++ b/examples/java/GpioMmapped.java @@ -44,6 +44,7 @@ public class GpioMmapped { String version = mraa.getVersion(); System.out.println("hello mraa"); System.out.println(String.format("Version: %s", version)); + System.out.println(String.format("Platform: %s", board)); Gpio gpio = new Gpio(1); diff --git a/examples/java/I2cCompass.java b/examples/java/I2cCompass.java index 6bcebdb..93b75d9 100644 --- a/examples/java/I2cCompass.java +++ b/examples/java/I2cCompass.java @@ -117,9 +117,9 @@ public class I2cCompass { i2c.address(HMC5883L_I2C_ADDR); i2c.read(rx_tx_buf); - x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG]; - z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG]; - y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG]; + x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_X_LSB_REG] & 0xFF); + z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Z_LSB_REG] & 0xFF); + y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Y_LSB_REG] & 0xFF); direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);