diff options
Diffstat (limited to 'peripheral/libupm/examples/c++')
171 files changed, 0 insertions, 13951 deletions
diff --git a/peripheral/libupm/examples/c++/CMakeLists.txt b/peripheral/libupm/examples/c++/CMakeLists.txt deleted file mode 100644 index b227703..0000000 --- a/peripheral/libupm/examples/c++/CMakeLists.txt +++ /dev/null @@ -1,260 +0,0 @@ -# Extract module name from non-standard example name -macro(get_module_name example_name module_name) - string(LENGTH ${example_name} length) - string(FIND ${example_name} "-" index) - if (${index} GREATER 1) - string(SUBSTRING ${example_name} 0 ${index} substr) - set(${module_name} ${substr}) - elseif (${example_name} MATCHES "^grove") - set (${module_name} "grove") - elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401") - set (${module_name} "gas") - else() - set(${module_name} ${example_name}) - endif() -endmacro() - -# Set source file, include and linker settings for an example -# If example cannot be built, example_bin is cleared -macro(add_custom_example example_bin example_src example_module_list) - set(found_all_modules TRUE) - foreach (module ${example_module_list}) - if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}") - set(found_all_modules FALSE) - endif() - if (MODULE_LIST) - list(FIND MODULE_LIST ${module} index) - if (${index} EQUAL -1) - set(found_all_modules FALSE) - endif() - endif() - endforeach() - if (found_all_modules) - add_executable (${example_bin} ${example_src}) - target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT}) - foreach (module ${example_module_list}) - set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}") - include_directories (${module_dir}) - if (${module} STREQUAL "lcd") - set(module "i2clcd") - endif() - target_link_libraries (${example_bin} ${module}) - endforeach() - else() - MESSAGE(INFO " Ignored ${example_bin}") - set (example_bin "") - endif() -endmacro() - - -# Add specified example by name -# Note special case for grove based examples -macro(add_example example_name) - set(example_src "${example_name}.cxx") - set(example_bin "${example_name}-example") - get_module_name(${example_name} module_name) - set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}") - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}" - AND EXISTS ${module_dir} - AND IS_DIRECTORY ${module_dir}) - add_custom_example(${example_bin} ${example_src} ${module_name}) - if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove")) - set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}") - if (EXISTS ${grove_module_path}) - include_directories(${grove_module_path}) - target_link_libraries (${example_bin} ${example_name}) - endif() - endif() - else() - MESSAGE(INFO " Ignored ${example_bin}") - endif() -endmacro() - - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples) - -# Set the mraa include and link directories prior to adding examples -include_directories (${MRAA_INCLUDE_DIRS}) -link_directories (${MRAA_LIBDIR}) - -# If your sample source file matches the name of the module it tests, add it here -# Exceptions are as follows: -# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01) -# mq? will use module gas -# grove* will use module grove -add_example (hmc5883l) -add_example (groveled) -add_example (groverelay) -add_example (grovelight) -add_example (grovetemp) -add_example (grovebutton) -add_example (groverotary) -add_example (groveslide) -add_example (buzzer-sound) -add_example (nrf24l01-transmitter) -add_example (nrf24l01-receiver) -add_example (nrf24l01-broadcast) -add_example (hcsr04) -add_example (max44000) -add_example (mma7455) -add_example (st7735) -add_example (max31855) -add_example (bmpx8x) -add_example (stepmotor) -add_example (pulsensor) -add_example (mic) -add_example (mpu9150) -add_example (maxds3231m) -add_example (max31723) -add_example (max5487) -add_example (nrf8001-broadcast) -add_example (nrf8001-helloworld) -add_example (lpd8806) -add_example (mlx90614) -add_example (ecs1030) -add_example (mq2) -add_example (mq3) -add_example (mq4) -add_example (mq5) -add_example (mq6) -add_example (mq7) -add_example (mq8) -add_example (mq9) -add_example (tp401) -add_example (tcs3414cs) -add_example (th02) -add_example (ttp223) -add_example (lsm303) -add_example (joystick12) -add_example (lol) -add_example (tsl2561) -add_example (htu21d) -add_example (mpl3115a2) -add_example (ldt0028) -add_example (am2315) -add_example (itg3200) -add_example (enc03r) -add_example (adc121c021) -add_example (ds1307) -add_example (a110x) -add_example (gp2y0a) -add_example (grovemoisture) -add_example (groveehr) -add_example (ta12200) -add_example (grovelinefinder) -add_example (grovevdiv) -add_example (grovewater) -add_example (guvas12d) -add_example (mpr121) -add_example (ublox6) -add_example (yg1006) -add_example (wt5001) -add_example (ppd42ns) -add_example (mq303a) -add_example (grovespeaker) -add_example (rfr359f) -add_example (biss0001) -add_example (rotaryencoder) -add_example (adxl345) -add_example (rpr220) -add_example (rpr220-intr) -add_example (mma7660) -add_example (cjq4435) -add_example (adxl335) -add_example (hmtrp) -add_example (nunchuck) -add_example (otp538u) -add_example (grovecollision) -add_example (groveelectromagnet) -add_example (groveemg) -add_example (groveo2) -add_example (grovegsr) -add_example (ina132) -add_example (l298) -add_example (l298-stepper) -add_example (at42qt1070) -add_example (grovemd) -add_example (grovemd-stepper) -add_example (pca9685) -add_example (groveeldriver) -add_example (adafruitss) -add_example (adafruitms1438) -add_example (adafruitms1438-stepper) -add_example (hx711) -add_example (flex) -add_example (a110x-intr) -add_example (mhz16) -add_example (apds9002) -add_example (waterlevel) -add_example (tm1637) -add_example (zfm20) -add_example (zfm20-register) -add_example (uln200xa) -add_example (grovewfs) -add_example (isd1820) -add_example (sx6119) -add_example (si114x) -add_example (maxsonarez) -add_example (hm11) -add_example (ht9170) -add_example (h3lis331dl) -add_example (ad8232) -add_example (grovescam) -add_example (m24lr64e) -add_example (rgbringcoder) -add_example (hp20x) -add_example (pn532) -add_example (pn532-writeurl) -add_example (lsm9ds0) -add_example (loudness) -add_example (mg811) -add_example (wheelencoder) -add_example (sm130) -add_example (grovegprs) -add_example (lm35) -add_example (micsv89) -add_example (xbee) -add_example (urm37) -add_example (urm37-uart) -add_example (adxrs610) -add_example (bma220) -add_example (dfrph) -add_example (mcp9808) -add_example (groveultrasonic) -add_example (sx1276-lora) -add_example (sx1276-fsk) -add_example (ili9341) -if (OPENZWAVE_FOUND) - include_directories(${OPENZWAVE_INCLUDE_DIRS}) - add_example (ozw) -endif() -add_example (nlgpio16) -add_example (ads1x15) -if (MODBUS_FOUND) - include_directories(${MODBUS_INCLUDE_DIRS}) - add_example (t3311) - add_example (hwxpxx) -endif() -add_example (hdxxvxta) -add_example (rhusb) -add_example (apds9930) -add_example (kxcjk1013) -add_example (ssd1351) - -# These are special cases where you specify example binary, source file and module(s) -include_directories (${PROJECT_SOURCE_DIR}/src) -add_custom_example (groveled-multi-example groveled-multi.cxx grove) -add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd) -add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd) -add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd) -add_custom_example (es08a-example es08a.cxx servo) -add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd) -add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd) -add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd) -add_custom_example (sainsmartks-example sainsmartks.cxx lcd) -add_custom_example (eboled-example eboled.cxx lcd) -add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150) -add_custom_example (ak8975-example ak8975.cxx mpu9150) -add_custom_example (mpu9250-example mpu9250.cxx mpu9150) -add_custom_example (groveledbar-example groveledbar.cxx my9221) -add_custom_example (grovecircularled-example grovecircularled.cxx my9221) diff --git a/peripheral/libupm/examples/c++/a110x-intr.cxx b/peripheral/libupm/examples/c++/a110x-intr.cxx deleted file mode 100644 index 187c2ed..0000000 --- a/peripheral/libupm/examples/c++/a110x-intr.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "a110x.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -// Our pulse counter -volatile unsigned int counter = 0; - -// Our interrupt handler -void hallISR(void *arg) -{ - counter++; -} - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an A110X sensor on digital pin D2 - upm::A110X* hall = new upm::A110X(2); - - // This example uses a user-supplied interrupt handler to count - // pulses that occur when a magnetic field of the correct polarity - // is detected. This could be used to measure the rotations per - // minute (RPM) of a rotor for example. - - hall->installISR(hallISR, NULL); - - while (shouldRun) - { - cout << "Pulses detected: " << counter << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete hall; - return 0; -} diff --git a/peripheral/libupm/examples/c++/a110x.cxx b/peripheral/libupm/examples/c++/a110x.cxx deleted file mode 100644 index 30c355d..0000000 --- a/peripheral/libupm/examples/c++/a110x.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "a110x.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an A110X sensor on digital pin D2 - upm::A110X* hall = new upm::A110X(2); - - // check every second for the presence of a magnetic field (south - // polarity) - while (shouldRun) - { - bool val = hall->magnetDetected(); - if (val) - cout << "Magnet (south polarity) detected." << endl; - else - cout << "No magnet detected." << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete hall; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ad8232.cxx b/peripheral/libupm/examples/c++/ad8232.cxx deleted file mode 100644 index 5d03527..0000000 --- a/peripheral/libupm/examples/c++/ad8232.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "ad8232.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Ad8232 sensor on digital pins 10 (LO+), 11 (LO-) - // and an analog pin, 0 (OUTPUT) - upm::AD8232 *ad8232 = new upm::AD8232(10, 11, 0); - - // Output the raw numbers from the ADC, for plotting elsewhere. - // A return of 0 indicates a Lead Off (LO) condition. - // In theory, this data could be fed to software like Processing - // (https://www.processing.org/) to plot the data just like an - // EKG you would see in a hospital. - while (shouldRun) - { - cout << ad8232->value() << endl; - usleep(1000); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete ad8232; - return 0; -} diff --git a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx b/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx deleted file mode 100644 index 1bcf75b..0000000 --- a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "adafruitms1438.h" - -using namespace std; -using namespace upm; - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an Adafruit MS 1438 on I2C bus 0 - - upm::AdafruitMS1438 *ms = - new upm::AdafruitMS1438(ADAFRUITMS1438_I2C_BUS, - ADAFRUITMS1438_DEFAULT_I2C_ADDR); - - // Setup for use with a stepper motor connected to the M1 & M2 ports - - // set a PWM period of 50Hz - - // disable first, to be safe - ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12); - - // configure for a NEMA-17, 200 steps per revolution - ms->stepConfig(AdafruitMS1438::STEPMOTOR_M12, 200); - - // set speed at 10 RPM's - ms->setStepperSpeed(AdafruitMS1438::STEPMOTOR_M12, 10); - ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12, - AdafruitMS1438::DIR_CW); - - // enable - cout << "Enabling..." << endl; - ms->enableStepper(AdafruitMS1438::STEPMOTOR_M12); - - cout << "Rotating 1 full revolution at 10 RPM speed." << endl; - ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 200); - - cout << "Sleeping for 2 seconds..." << endl; - sleep(2); - cout << "Rotating 1/2 revolution in opposite direction at 10 RPM speed." - << endl; - - ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12, - AdafruitMS1438::DIR_CCW); - ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 100); - - cout << "Disabling..." << endl; - ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12); - - cout << "Exiting" << endl; - -//! [Interesting] - - delete ms; - return 0; -} diff --git a/peripheral/libupm/examples/c++/adafruitms1438.cxx b/peripheral/libupm/examples/c++/adafruitms1438.cxx deleted file mode 100644 index 8ca184c..0000000 --- a/peripheral/libupm/examples/c++/adafruitms1438.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "adafruitms1438.h" - -using namespace std; -using namespace upm; - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an Adafruit MS 1438 on I2C bus 0 - - upm::AdafruitMS1438 *ms = - new upm::AdafruitMS1438(ADAFRUITMS1438_I2C_BUS, - ADAFRUITMS1438_DEFAULT_I2C_ADDR); - - // Setup for use with a DC motor connected to the M3 port - - // set a PWM period of 50Hz - ms->setPWMPeriod(50); - - // disable first, to be safe - ms->disableMotor(AdafruitMS1438::MOTOR_M3); - - // set speed at 50% - ms->setMotorSpeed(AdafruitMS1438::MOTOR_M3, 50); - ms->setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CW); - - cout << "Spin M3 at half speed for 3 seconds, then reverse for 3 seconds." - << endl; - - ms->enableMotor(AdafruitMS1438::MOTOR_M3); - - sleep(3); - - cout << "Reversing M3" << endl; - ms->setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CCW); - - sleep(3); - - cout << "Stopping M3" << endl; - ms->disableMotor(AdafruitMS1438::MOTOR_M3); - - cout << "Exiting" << endl; - -//! [Interesting] - - delete ms; - return 0; -} diff --git a/peripheral/libupm/examples/c++/adafruitss.cxx b/peripheral/libupm/examples/c++/adafruitss.cxx deleted file mode 100644 index f2a7ebf..0000000 --- a/peripheral/libupm/examples/c++/adafruitss.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Stan Gifford <stan@gifford.id.au> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Description - * Demo program for Adafruit 16 channel servo shield/controller - * Physical setup for tests is a single servo attached to one channel. - * Note - when 3 or more GWS servos attached results unpredictable. - * Adafruit do recommend a Cap be installed on the board which should alleviate the issue. - * I (and Adafruit) are unable to give any Capacitor sizing data. - */ - -#include <iostream> -#include "adafruitss.h" -#include <unistd.h> - -using namespace std; - -int main() { - -int n; - -//! [Interesting] - upm::adafruitss* servos = new upm::adafruitss(6,0x40); - - for (;;) - { - cout << "Setting all to 0" << endl; - for (n = 0; n < 16; n++) - servos->servo(n, 1, 0); // GWS Mini Servo = Type 1. - usleep(1000000); // Wait 1 second - - cout << "Setting all to 45" << endl; - for (n = 0; n < 16; n++) - servos->servo(n, 1, 45); - usleep(1000000); // Wait 1 second - - cout << "Setting all to 90" << endl; - for (n = 0; n < 16; n++) - servos->servo(n, 1, 90); - usleep(1000000); // Wait 1 second - - cout << "Setting all to 135" << endl; - for (n = 0; n < 16; n++) - servos->servo(n, 1, 135); - usleep(1000000); // Wait 1 second - - cout << "Setting all to 180" << endl; - for (n = 0; n < 16; n++) - servos->servo(n, 1, 160); - usleep(2000000); // Wait 1 second - } -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/adc121c021.cxx b/peripheral/libupm/examples/c++/adc121c021.cxx deleted file mode 100644 index 18288ad..0000000 --- a/peripheral/libupm/examples/c++/adc121c021.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "adc121c021.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an ADC121C021 on I2C bus 0 - - upm::ADC121C021 *adc = new upm::ADC121C021(ADC121C021_I2C_BUS, - ADC121C021_DEFAULT_I2C_ADDR); - - // An analog sensor, such as a Grove light sensor, - // must be attached to the adc - // Prints the value and corresponding voltage every 50 milliseconds - while (shouldRun) - { - uint16_t val = adc->value(); - cout << "ADC value: " << val << " Volts = " - << adc->valueToVolts(val) << endl; - usleep(50000); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete adc; - return 0; -} diff --git a/peripheral/libupm/examples/c++/adis16448.cxx b/peripheral/libupm/examples/c++/adis16448.cxx deleted file mode 100644 index a1d4296..0000000 --- a/peripheral/libupm/examples/c++/adis16448.cxx +++ /dev/null @@ -1,66 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// The MIT License (MIT) -// -// Submit Date: 03/09/2015 -// Author: Juan Jose Chong <juanjchong@gmail.com> -// Copyright (c) 2015 Juan Jose Chong -// -////////////////////////////////////////////////////////////////////////////////////// -// adis16448.cxx -////////////////////////////////////////////////////////////////////////////////////// -// -// This example code runs on an Intel Edison and uses mraa to acquire data -// from an ADIS16448. This data is then scaled and printed onto the terminal. -// -// This software has been tested to connect to an ADIS16448 through a level shifter -// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through -// the level shifter and the ADIS16448 is also being powered by the Intel Edison. -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "adis16448.h" - -int -main(int argc, char **argv) -{ - while(true) - { - //! [Interesting] - upm::ADIS16448* imu = new upm::ADIS16448(0,3); //upm::ADIS16448(SPI,RST) - - //Read the specified register, scale it, and display it on the screen - std::cout << "XGYRO_OUT:" << imu->gyroScale(imu->regRead(XGYRO_OUT)) << std::endl; - std::cout << "YGYRO_OUT:" << imu->gyroScale(imu->regRead(YGYRO_OUT)) << std::endl; - std::cout << "ZGYRO_OUT:" << imu->gyroScale(imu->regRead(ZGYRO_OUT)) << std::endl; - std::cout << " " << std::endl; - std::cout << "XACCL_OUT:" << imu->accelScale(imu->regRead(XACCL_OUT)) << std::endl; - std::cout << "YACCL_OUT:" << imu->accelScale(imu->regRead(YACCL_OUT)) << std::endl; - std::cout << "ZACCL_OUT:" << imu->accelScale(imu->regRead(ZACCL_OUT)) << std::endl; - std::cout << " " << std::endl; - //! [Interesting] - sleep(1); - } - return (0); -} diff --git a/peripheral/libupm/examples/c++/ads1x15.cxx b/peripheral/libupm/examples/c++/ads1x15.cxx deleted file mode 100644 index 3c5da65..0000000 --- a/peripheral/libupm/examples/c++/ads1x15.cxx +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Author: Marc Graham <marc@m2ag.net> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "mraa.hpp" - -#include <iostream> -#include <unistd.h> -#include "ads1015.h" -#include "ads1115.h" - - - -int main() -{ - - using namespace std; - using namespace upm; - int command; - //Select the device you are testing here and adjust case 6 for the correct sample rates. - //upm::ADS1015 *ads = new upm::ADS1015(1); - upm::ADS1115 *ads = new upm::ADS1115(1, 0x49); - float inputVoltage; - int ans; - - do - { - - cout << endl; - cout << "1 - get Conversion \t" ; - cout << "2 - get last conversion" << endl; - cout << "3 - get Gain \t\t"; - cout << "4 - set Gain" << endl;; - cout << "5 - get Data Rate \t"; - cout << "6 - set Data Rate" << endl; - cout << "7 - Set Upper Threshold \t" ; - cout << "8 - Set Lower Threshold \t"; - cout << "9 - Display Thresholds \t"; - cout << "10 - Set Default Thresholds \t"; - cout << "11 - Set conversion ready" << endl; - cout << "12 - get Comp Que \t" ; - cout << "13 - set Comp Que" << endl; - cout << "14 - get Comp Pol \t"; - cout << "15 - set Comp Pol" << endl; - cout << "16 - get Comp mode \t"; - cout << "17 - set Comp mode " << endl; - cout << "18 - get Comp Latch\t"; - cout << "19 - set Comp Latch " << endl; - cout << "20 - get Continuous \t"; - cout << "21 - set Continuous \t" << endl; - cout << "-1 - exit" << endl; - cout << "Enter a command: "; - cin >> command; - - - switch(command) - { - case 2: - cout << ads->getLastSample() << endl; - break; - case 3: - cout << std::hex << ads->getGain() << endl; - break; - case 5: - cout << std::hex << ads->getSPS() << endl; - break; - case 4: - int gain; - ADS1015::ADSGAIN set_gain; - cout << "select one of the following:" << endl; - cout << "1 -> gain 2/3 \t 2 -> gain1 \t 3 -> gain 2" << endl; - cout << "4 -> gain 4 \t 5 -> gain 8 \t 6 -> gain 15" << endl; - cin >> gain; - switch(gain){ - case 1: - set_gain = ADS1X15::GAIN_TWOTHIRDS; - break; - case 2: - set_gain = ADS1X15::GAIN_ONE; - break; - case 3: - set_gain = ADS1X15::GAIN_TWO; - break; - case 4: - set_gain = ADS1X15::GAIN_FOUR; - break; - case 5: - set_gain = ADS1X15::GAIN_EIGHT; - break; - case 6: - set_gain = ADS1X15::GAIN_SIXTEEN; - break; - default: - set_gain = ADS1X15::GAIN_ONE; - } - ads->setGain(set_gain); - break; - case 6: - int rate; - /*ADS1015::ADSDATARATE set_rate; - cout << "select one of the following:" << endl; - cout << "1 -> SPS_120 \t 2 -> SPS_250 \t 3 -> SPS_490 \t 4 -> SPS_920" << endl; - cout << "5 -> SPS_1600 \t 6 -> SPS_2400 \t 7 -> SPS_3300" << endl; - cin >> rate; - switch(rate){ - case 1: - set_rate = ADS1015::SPS_128; - break; - case 2: - set_rate = ADS1015::SPS_250; - break; - case 3: - set_rate = ADS1015::SPS_490; - break; - case 4: - set_rate = ADS1015::SPS_920; - break; - case 5: - set_rate = ADS1015::SPS_1600; - break; - case 6: - set_rate = ADS1015::SPS_2400; - break; - case 7: - set_rate = ADS1015::SPS_3300; - break; - default: - set_rate = ADS1015::SPS_1600; - } */ - ADS1115::ADSDATARATE set_rate; - cout << "select one of the following:" << endl; - cout << "1 -> SPS_8 \t 2 -> SPS_16 \t 3 -> SPS_32 \t 4 -> SPS_64" << endl; - cout << "5 -> SPS_128 \t 6 -> SPS_250 \t 7 -> SPS_475 \t 8-> SPS_860" << endl; - cin >> rate; - switch(rate){ - case 1: - set_rate = ADS1115::SPS_8; - break; - case 2: - set_rate = ADS1115::SPS_16; - break; - case 3: - set_rate = ADS1115::SPS_32; - break; - case 4: - set_rate = ADS1115::SPS_64; - break; - case 5: - set_rate = ADS1115::SPS_128; - break; - case 6: - set_rate = ADS1115::SPS_250; - break; - case 7: - set_rate = ADS1115::SPS_475; - break; - case 8: - set_rate = ADS1115::SPS_860; - break; - default: - set_rate = ADS1115::SPS_128; - } - - ads->setSPS(set_rate); - break; - case 1: - int mode; - ADS1X15::ADSMUXMODE set_mode; - cout << "select one of the following:" << endl; - cout << "1 -> MUX_0_1 \t 2 -> MUX_0_3 \t 3 -> MUX_1_3 \t 4 -> MUX_2_3" << endl; - cout << "5 -> SINGLE_0 \t 6 -> SINGLE_1 \t 7 -> SINGLE_2 \t 8 -> SINGLE_3" << endl; - cin >> mode; - switch(mode){ - case 1: - set_mode = ADS1X15::DIFF_0_1; - break; - case 2: - set_mode = ADS1X15::DIFF_0_3; - break; - case 3: - set_mode = ADS1X15::DIFF_1_3; - break; - case 4: - set_mode = ADS1X15::DIFF_2_3; - break; - case 5: - set_mode = ADS1X15::SINGLE_0; - break; - case 6: - set_mode = ADS1X15::SINGLE_1; - break; - case 7: - set_mode = ADS1X15::SINGLE_2; - break; - case 8: - set_mode = ADS1X15::SINGLE_3; - break; - default: - set_mode = ADS1X15::DIFF_0_1; - break; - } - cout << ads->getSample(set_mode) << endl; - break; - case 7: - cout << " enter a float value: " ; - cin >> inputVoltage; - ads->setThresh(ADS1115::THRESH_HIGH, inputVoltage); - break; - case 8: - cout << " enter a float value: " ; - cin >> inputVoltage; - ads->setThresh(ADS1115::THRESH_LOW, inputVoltage); - break; - case 9: - cout << "Upper " << ads->getThresh(ADS1X15::THRESH_HIGH) << endl; - cout << "Lower " << ads->getThresh(ADS1X15::THRESH_LOW) << endl; - break; - case 10: - ads->setThresh(ADS1115::THRESH_DEFAULT); - break; - case 11: - ads->setThresh(ADS1015::CONVERSION_RDY); - break; - case 12: - cout << ads->getCompQue() << endl; - break; - case 13: - int que; - cout << "select one of the following:" << endl; - cout << "1 -> CQUE_1CONV \t 2 -> CQUE_2CONV \t 3 -> CQUE_3CONV \t 4 -> CQUE_NONE" << endl; - cin >> que; - switch(que){ - case 1: - ads->setCompQue(ADS1X15::CQUE_1CONV); - break; - case 2: - ads->setCompQue(ADS1X15::CQUE_2CONV); - break; - case 3: - ads->setCompQue(ADS1X15::CQUE_4CONV); - break; - case 4: - default: - ads->setCompQue(ADS1X15::CQUE_NONE); - break; - } - break; - case 14: - cout << ads->getCompPol() << endl; - break; - case 15: - cout << "select one of the following:" << endl; - cout << "1 -> active high \t 2 -> active low" << endl; - cin >> ans; - if(ans == 1) ads->setCompPol(true); - else ads->setCompPol(false); - break; - case 16: - cout << ads->getCompMode() << endl; - break; - case 17: - cout << "select one of the following:" << endl; - cout << "1 -> Window \t 2 -> Traditional (default)" << endl; - cin >> ans; - if(ans == 1) ads->setCompMode(true); - else ads->setCompMode(); - break; - case 18: - cout << ads->getCompLatch() << cout; - break; - case 19: - cout << "select one of the following:" << endl; - cout << "1 -> Latching \t 2 -> Non-latching (default)" << endl; - cin >> ans; - if(ans == 1) ads->setCompLatch(true); - else ads->setCompLatch(); - break; - case 20: - cout << ads->getContinuous() << cout; - break; - case 21: - cout << "select one of the following:" << endl; - cout << "1 -> Power Down (default) \t 2 -> Continuous" << endl; - cin >> ans; - if(ans == 1) ads->setContinuous(true); - else ads->setContinuous(); - break; - case -1: - break; - default: - - break; - } - - }while (command != -1 ); - - delete ads; - - return MRAA_SUCCESS; -} diff --git a/peripheral/libupm/examples/c++/adxl335.cxx b/peripheral/libupm/examples/c++/adxl335.cxx deleted file mode 100644 index 471695d..0000000 --- a/peripheral/libupm/examples/c++/adxl335.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "adxl335.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an ADXL335 accelerometer on analog pins A0, A1, and A2 - upm::ADXL335* accel = new upm::ADXL335(0, 1, 2); - - cout << "Please make sure the sensor is completely still. Sleeping for" - << " 2 seconds." << endl; - sleep(2); - cout << "Calibrating..." << endl; - - accel->calibrate(); - - while (shouldRun) - { - int x, y, z; - float aX, aY, aZ; - - accel->values(&x, &y, &z); - cout << "Raw Values: X: " << x << " Y: " << y << " Z: " << z << endl; - - accel->acceleration(&aX, &aY, &aZ); - cout << "Acceleration: X: " << aX << "g" << endl; - cout << "Acceleration: Y: " << aY << "g" << endl; - cout << "Acceleration: Z: " << aZ << "g" << endl; - cout << endl; - - usleep(200000); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete accel; - return 0; -} diff --git a/peripheral/libupm/examples/c++/adxl345.cxx b/peripheral/libupm/examples/c++/adxl345.cxx deleted file mode 100644 index a5bc2cc..0000000 --- a/peripheral/libupm/examples/c++/adxl345.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include "adxl345.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - int16_t *raw; - float *acc; - - // Note: Sensor only works at 3.3V on the Intel Edison with Arduino breakout - upm::Adxl345* accel = new upm::Adxl345(0); - - while(true){ - accel->update(); // Update the data - raw = accel->getRawValues(); // Read raw sensor data - acc = accel->getAcceleration(); // Read acceleration (g) - fprintf(stdout, "Current scale: 0x%2xg\n", accel->getScale()); - fprintf(stdout, "Raw: %6d %6d %6d\n", raw[0], raw[1], raw[2]); - fprintf(stdout, "AccX: %5.2f g\n", acc[0]); - fprintf(stdout, "AccY: %5.2f g\n", acc[1]); - fprintf(stdout, "AccZ: %5.2f g\n", acc[2]); - sleep(1); - } -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/adxrs610.cxx b/peripheral/libupm/examples/c++/adxrs610.cxx deleted file mode 100644 index 4ec53ef..0000000 --- a/peripheral/libupm/examples/c++/adxrs610.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "adxrs610.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and - // analog A1 (temp out) with an analog reference voltage of - // 5.0 - upm::ADXRS610 *sensor = new upm::ADXRS610(0, 1, 5.0); - - // set a deadband region around the zero point to report 0.0 (optional) - sensor->setDeadband(0.015); - - // Every tenth of a second, sample the ADXRS610 and output it's - // corresponding temperature and angular velocity - - while (shouldRun) - { - cout << "Vel (deg/s): " << sensor->getAngularVelocity() << endl; - cout << "Temp (C): " << sensor->getTemperature() << endl; - - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ak8975.cxx b/peripheral/libupm/examples/c++/ak8975.cxx deleted file mode 100644 index 1b95ead..0000000 --- a/peripheral/libupm/examples/c++/ak8975.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mpu9150.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - upm::AK8975 *sensor = new upm::AK8975(); - - sensor->init(); - - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getMagnetometer(&x, &y, &z); - cout << "Magnetometer: "; - cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl; - - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/am2315.cxx b/peripheral/libupm/examples/c++/am2315.cxx deleted file mode 100644 index 4b95e1c..0000000 --- a/peripheral/libupm/examples/c++/am2315.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: William Penner <william.penner@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "am2315.h" - -volatile int doWork = 0; - -upm::AM2315 *sensor = NULL; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) { - printf("\nCtrl-C received.\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - // Register signal handler - signal(SIGINT, sig_handler); - - //! [Interesting] - float humidity = 0.0; - float temperature = 0.0; - - sensor = new upm::AM2315(0, AM2315_I2C_ADDRESS); - - sensor->testSensor(); - - while (!doWork) { - humidity = sensor->getHumidity(); - temperature = sensor->getTemperature(); - - std::cout << "humidity value = " << - humidity << - ", temperature value = " << - temperature << std::endl; - usleep (500000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/apds9002.cxx b/peripheral/libupm/examples/c++/apds9002.cxx deleted file mode 100644 index 87b5070..0000000 --- a/peripheral/libupm/examples/c++/apds9002.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "apds9002.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Luminance sensor on analog pin A0 - upm::APDS9002* luminance = new upm::APDS9002(0); - - while (shouldRun) - { - int val = luminance->value(); - cout << "Luminance value is " << val << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete luminance; - return 0; -} diff --git a/peripheral/libupm/examples/c++/apds9930.cxx b/peripheral/libupm/examples/c++/apds9930.cxx deleted file mode 100644 index 8d461c9..0000000 --- a/peripheral/libupm/examples/c++/apds9930.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "apds9930.h" - -using namespace std; - -int shouldRun = true; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int -main() -{ - signal(SIGINT, sig_handler); - //! [Interesting] - // Instantiate a Digital Proximity and Ambient Light sensor on iio device 4 - upm::APDS9930* light_proximity = new upm::APDS9930(4); - - while (shouldRun) { - float lux = light_proximity->getAmbient(); - cout << "Luminance value is " << lux << endl; - float proximity = light_proximity->getProximity(); - cout << "Proximity value is " << proximity << endl; - sleep(1); - } - //! [Interesting] - - cout << "Exiting" << endl; - - delete light_proximity; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/at42qt1070.cxx b/peripheral/libupm/examples/c++/at42qt1070.cxx deleted file mode 100644 index c22a998..0000000 --- a/peripheral/libupm/examples/c++/at42qt1070.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "at42qt1070.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -void printButtons(upm::AT42QT1070 *touch) -{ - bool buttonPressed = false; - uint8_t buttons = touch->getButtons(); - - cout << "Buttons Pressed: "; - for (int i=0; i<7; i++) - { - if (buttons & (1 << i)) - { - cout << i << " "; - buttonPressed = true; - } - } - - if (!buttonPressed) - cout << "None"; - - cout << endl; - - if (touch->isCalibrating()) - cout << "Calibration is occurring." << endl; - - if (touch->isOverflowed()) - cout << "Overflow was detected." << endl; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an AT42QT1070 on I2C bus 0 - - upm::AT42QT1070 *touch = new upm::AT42QT1070(AT42QT1070_I2C_BUS, - AT42QT1070_DEFAULT_I2C_ADDR); - - while (shouldRun) - { - touch->updateState(); - printButtons(touch); - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete touch; - return 0; -} diff --git a/peripheral/libupm/examples/c++/biss0001.cxx b/peripheral/libupm/examples/c++/biss0001.cxx deleted file mode 100644 index 1574c2f..0000000 --- a/peripheral/libupm/examples/c++/biss0001.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "biss0001.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Motion sensor on GPIO pin D2 - upm::BISS0001* motion = new upm::BISS0001(2); - - while (shouldRun) - { - bool val = motion->value(); - - if (val) - cout << "Detecting moving object"; - else - cout << "No moving objects detected"; - - cout << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete motion; - return 0; -} diff --git a/peripheral/libupm/examples/c++/bma220.cxx b/peripheral/libupm/examples/c++/bma220.cxx deleted file mode 100644 index a41b81a..0000000 --- a/peripheral/libupm/examples/c++/bma220.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "bma220.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - // Instantiate an BMA220 using default parameters (bus 0, addr 0x0a) - upm::BMA220 *sensor = new upm::BMA220(); - - // Output data every half second until interrupted - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getAccelerometer(&x, &y, &z); - cout << "Accelerometer: "; - cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/bmpx8x.cxx b/peripheral/libupm/examples/c++/bmpx8x.cxx deleted file mode 100644 index 28e5be8..0000000 --- a/peripheral/libupm/examples/c++/bmpx8x.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "bmpx8x.h" -#include <signal.h> - -int doWork = 0; -upm::BMPX8X *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - uint32_t presure = 0; - float temperature = 0; - float altitude = 0; - uint32_t sealevel = 0; - - // Instantiate a BMPX8X sensor on I2C - sensor = new upm::BMPX8X(0, ADDR); - - // Print the pressure, altitude, sea level, and - // temperature values every 0.1 seconds - while (!doWork) { - presure = sensor->getPressure (); - temperature = sensor->getTemperature (); - altitude = sensor->getAltitude (); - sealevel = sensor->getSealevelPressure (); - - std::cout << "pressure value = " << - presure << - ", altitude value = " << - altitude << - ", sealevel value = " << - sealevel << - ", temperature = " << - temperature << std::endl; - usleep (100000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/buzzer-sound.cxx b/peripheral/libupm/examples/c++/buzzer-sound.cxx deleted file mode 100644 index 1d377ba..0000000 --- a/peripheral/libupm/examples/c++/buzzer-sound.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "buzzer.h" - - -int -main(int argc, char **argv) { - //! [Interesting] - int chord[] = { DO, RE, MI, FA, SOL, LA, SI, DO, SI }; - - // create Buzzer instance - upm::Buzzer* sound = new upm::Buzzer(5); - // print sensor name - std::cout << sound->name() << std::endl; - - // play sound (DO, RE, MI, etc...), pausing for 0.1 seconds between notes - for (int chord_ind = 0; chord_ind < 7; chord_ind++) { - // play each note for one second - std::cout << sound->playSound(chord[chord_ind], 1000000) << std::endl; - usleep(100000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sound; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/cjq4435.cxx b/peripheral/libupm/examples/c++/cjq4435.cxx deleted file mode 100644 index f9d84d4..0000000 --- a/peripheral/libupm/examples/c++/cjq4435.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "cjq4435.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3 - upm::CJQ4435* mosfet = new upm::CJQ4435(3); - - mosfet->setPeriodMS(10); - mosfet->enable(true); - - while (shouldRun) - { - // start with a duty cycle of 0.0 (off) and increment to 1.0 (on) - for (float i=0.0; i <= 1.0; i+=0.1) - { - mosfet->setDutyCycle(i); - usleep(100000); - } - sleep(1); - // Now take it back down - // start with a duty cycle of 1.0 (on) and decrement to 0.0 (off) - for (float i=1.0; i >= 0.0; i-=0.1) - { - mosfet->setDutyCycle(i); - usleep(100000); - } - sleep(1); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete mosfet; - return 0; -} diff --git a/peripheral/libupm/examples/c++/dfrph.cxx b/peripheral/libupm/examples/c++/dfrph.cxx deleted file mode 100644 index 601fdbf..0000000 --- a/peripheral/libupm/examples/c++/dfrph.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "dfrph.h" - -using namespace std; - -bool shouldRun = true; - -#define DFRPH_AREF 5.0 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a DFRPH sensor on analog pin A0, with an analog - // reference voltage of DFRPH_AREF - upm::DFRPH *sensor = new upm::DFRPH(0, DFRPH_AREF); - - - // After calibration, set the offset (based on calibration with a pH - // 7.0 buffer solution). See the UPM sensor documentation for - // calibrations instructions. - sensor->setOffset(0.065); - - // Every second, sample the pH and output it's corresponding - // analog voltage. - - while (shouldRun) - { - cout << "Detected volts: " << sensor->volts() << endl; - cout << "pH value: " << sensor->pH() << endl; - cout << endl; - - sleep(1); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ds1307.cxx b/peripheral/libupm/examples/c++/ds1307.cxx deleted file mode 100644 index 44a0b08..0000000 --- a/peripheral/libupm/examples/c++/ds1307.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "ds1307.h" - -using namespace std; - -void printTime(upm::DS1307 *rtc) -{ - cout << "The time is: " << - rtc->month << "/" << rtc->dayOfMonth << "/" << rtc->year << " " - << rtc->hours << ":" << rtc->minutes << ":" << rtc->seconds; - - if (rtc->amPmMode) - cout << (rtc->pm) ? " PM " : " AM "; - - cout << endl; - - cout << "Clock is in " << ((rtc->amPmMode) ? "AM/PM mode" : "24hr mode") - << endl; -} - -int -main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate a DS1037 on I2C bus 0 - upm::DS1307 *rtc = new upm::DS1307(0); - - // always do this first - cout << "Loading the current time... " << endl; - if (!rtc->loadTime()) - { - cerr << "rtc->loadTime() failed." << endl; - return 0; - } - - printTime(rtc); - - // set the year as an example - cout << "setting the year to 50" << endl; - rtc->year = 50; - - rtc->setTime(); - - // reload the time and print it - rtc->loadTime(); - printTime(rtc); - - //! [Interesting] - - delete rtc; - return 0; -} diff --git a/peripheral/libupm/examples/c++/eboled.cxx b/peripheral/libupm/examples/c++/eboled.cxx deleted file mode 100644 index c1c281c..0000000 --- a/peripheral/libupm/examples/c++/eboled.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <iostream> -#include "eboled.h" - -using namespace std; - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an Edison Block OLED using default values - upm::EBOLED *lcd = new upm::EBOLED(); - - lcd->clear(); - lcd->setCursor(10, 15); - lcd->write("Hello"); - lcd->setCursor(30, 15); - lcd->write("World!"); - lcd->refresh(); - - cout << "Sleeping for 5 seconds..." << endl; - sleep(5); - - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/ecs1030.cxx b/peripheral/libupm/examples/c++/ecs1030.cxx deleted file mode 100644 index 40a7dc5..0000000 --- a/peripheral/libupm/examples/c++/ecs1030.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdlib.h> -#include "ecs1030.h" - -int is_running = 0; -upm::ECS1030 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - sensor = new upm::ECS1030(0); - signal(SIGINT, sig_handler); - - while (!is_running) { - std::cout << "I = " << sensor->getCurrency_A () << ", Power = " << sensor->getPower_A () << std::endl; - std::cout << "I = " << sensor->getCurrency_B () << ", Power = " << sensor->getPower_B () << std::endl; - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/enc03r.cxx b/peripheral/libupm/examples/c++/enc03r.cxx deleted file mode 100644 index da0db9b..0000000 --- a/peripheral/libupm/examples/c++/enc03r.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "enc03r.h" - -using namespace std; - -bool shouldRun = true; - -// analog voltage, usually 3.3 or 5.0 -#define CALIBRATION_SAMPLES 1000 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a ENC03R on analog pin A0 - upm::ENC03R *gyro = new upm::ENC03R(0); - - // The first thing we need to do is calibrate the sensor. - cout << "Please place the sensor in a stable location, and do not" << endl; - cout << "move it while calibration takes place." << endl; - cout << "This may take a couple of minutes." << endl; - - gyro->calibrate(CALIBRATION_SAMPLES); - cout << "Calibration complete. Reference value: " - << gyro->calibrationValue() << endl; - - // Read the input and print both the raw value and the angular velocity, - // waiting 0.1 seconds between readings - while (shouldRun) - { - unsigned int val = gyro->value(); - double av = gyro->angularVelocity(val); - - cout << "Raw value: " << val << ", " - << "angular velocity: " << av << " deg/s" << endl; - - usleep(100000); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete gyro; - return 0; -} diff --git a/peripheral/libupm/examples/c++/es08a.cxx b/peripheral/libupm/examples/c++/es08a.cxx deleted file mode 100644 index 3f7e5c4..0000000 --- a/peripheral/libupm/examples/c++/es08a.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "es08a.h" -#include <signal.h> -#include <stdlib.h> - -int -main(int argc, char **argv) -{ - //! [Interesting] - upm::ES08A *servo = new upm::ES08A(5); - - // Sets the shaft to 180, then to 90, then to 0, - // then back to 90, and finally back to 180, - // pausing for a second in between each angle - servo->setAngle (180); - std::cout << "Set angle to 180" << std::endl; - sleep(1); - servo->setAngle (90); - std::cout << "Set angle to 90" << std::endl; - sleep(1); - servo->setAngle (0); - std::cout << "Set angle to 0" << std::endl; - sleep(1); - servo->setAngle (90); - std::cout << "Set angle to 90" << std::endl; - sleep(1); - servo->setAngle (180); - std::cout << "Set angle to 180" << std::endl; - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete servo; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/flex.cxx b/peripheral/libupm/examples/c++/flex.cxx deleted file mode 100644 index 5477338..0000000 --- a/peripheral/libupm/examples/c++/flex.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "flex.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with a Spectra Symbol flex sensor. - // We attached a 22K resistor to a breadboard, - // with 1 end attached to GND and the other connected to - // both the flex sensor and A0. - // The flex sensor was connected on 1 pin to the 22K resistor and A0 - // and on the other pin to 5V. - - // Instantiate a Flex sensor on analog pin A0 - upm::Flex *flex = new upm::Flex(0); - - while (shouldRun) - { - cout << "Flex value: " << flex->value() << endl; - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete flex; - return 0; -} diff --git a/peripheral/libupm/examples/c++/gp2y0a.cxx b/peripheral/libupm/examples/c++/gp2y0a.cxx deleted file mode 100644 index 0111b17..0000000 --- a/peripheral/libupm/examples/c++/gp2y0a.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "gp2y0a.h" - -using namespace std; - -bool shouldRun = true; - -// analog voltage, usually 3.3 or 5.0 -#define GP2Y0A_AREF 5.0 -#define SAMPLES_PER_QUERY 20 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Note, for the Grove 80cm version of this sensor, due to the way - // it is wired, you need to plug this into the A0 port, where it - // will use the available A1 pin for data. - - // Instantiate a GP2Y0A on analog pin A1 - upm::GP2Y0A *volts = new upm::GP2Y0A(1); - - // The higher the voltage (closer to AREF) the closer the object is. NOTE: - // the measured voltage will probably not exceed 3.3 volts. - // Every second, print the averaged voltage value (averaged over 20 samples). - while (shouldRun) - { - cout << "AREF: " << GP2Y0A_AREF - << ", Voltage value (higher means closer): " - << volts->value(GP2Y0A_AREF, SAMPLES_PER_QUERY) << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete volts; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovebutton.cxx b/peripheral/libupm/examples/c++/grovebutton.cxx deleted file mode 100644 index 7d2d69a..0000000 --- a/peripheral/libupm/examples/c++/grovebutton.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "grove.h" - -int -main(int argc, char **argv) -{ - // This example uses GPIO 0 -//! [Interesting] - - // Create the button object using GPIO pin 0 - upm::GroveButton* button = new upm::GroveButton(0); - - // Read the input and print, waiting one second between readings - while( 1 ) { - std::cout << button->name() << " value is " << button->value() << std::endl; - sleep(1); - } - - // Delete the button object - delete button; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovecircularled.cxx b/peripheral/libupm/examples/c++/grovecircularled.cxx deleted file mode 100644 index 066e017..0000000 --- a/peripheral/libupm/examples/c++/grovecircularled.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovecircularled.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a Grove Circular LED on D9 for data, D8 for clock - - upm::GroveCircularLED *circle = new upm::GroveCircularLED(9, 8); - - int level = 0; - while (shouldRun) - { - circle->setSpinner(level); - level = (level + 1) % 24; - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete circle; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovecollision.cxx b/peripheral/libupm/examples/c++/grovecollision.cxx deleted file mode 100644 index 2de7609..0000000 --- a/peripheral/libupm/examples/c++/grovecollision.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <iostream> -#include <unistd.h> -#include <signal.h> -#include "grovecollision.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the Grove Collision Sensor - // Instantiate a Grove Collision on digital pin D2 - upm::GroveCollision* collision = new upm::GroveCollision(2); - - bool collisionState = false; - cout << "No collision" << endl; - while (shouldRun) - { - if (collision->isColliding() && !collisionState) - { - cout << "Collision!" << endl; - collisionState = true; - } - else if (collisionState) - { - cout << "No collision" << endl; - collisionState = false; - } - } - -//! [Interesting] - cout << "Exiting" << endl; - - delete collision; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveehr.cxx b/peripheral/libupm/examples/c++/groveehr.cxx deleted file mode 100644 index b056a15..0000000 --- a/peripheral/libupm/examples/c++/groveehr.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "groveehr.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2 - upm::GroveEHR* heart = new upm::GroveEHR(2); - - // set the beat counter to 0, init the clock and start counting beats - heart->clearBeatCounter(); - heart->initClock(); - heart->startBeatCounter(); - - while (shouldRun) - { - // we grab these just for display purposes in this example - uint32_t millis = heart->getMillis(); - uint32_t beats = heart->beatCounter(); - - // heartRate() requires that at least 5 seconds pass before - // returning anything other than 0 - int hr = heart->heartRate(); - - // output milliseconds passed, beat count, and computed heart rate - cout << "Millis: " << millis << " Beats: " << beats; - cout << " Heart Rate: " << hr << endl; - - sleep(1); - } - - heart->stopBeatCounter(); -//! [Interesting] - - cout << "Exiting..." << endl; - - delete heart; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveeldriver.cxx b/peripheral/libupm/examples/c++/groveeldriver.cxx deleted file mode 100644 index 126eaaf..0000000 --- a/peripheral/libupm/examples/c++/groveeldriver.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <iostream> -#include <unistd.h> -#include <signal.h> -#include "groveeldriver.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the Grove El Driver Module - // Instantiate a Grove El Driver on digital pin D2 - upm::GroveElDriver* eldriver = new upm::GroveElDriver(2); - - bool lightState = true; - - while (shouldRun) - { - if (lightState) - eldriver->on(); - else - eldriver->off(); - lightState = !lightState; - sleep(1); - } - -//! [Interesting] - eldriver->off(); - cout << "Exiting" << endl; - - delete eldriver; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveelectromagnet.cxx b/peripheral/libupm/examples/c++/groveelectromagnet.cxx deleted file mode 100644 index 386f4de..0000000 --- a/peripheral/libupm/examples/c++/groveelectromagnet.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <iostream> -#include <time.h> -#include <signal.h> -#include "groveelectromagnet.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -float get_time() -{ - return ((float)(clock()))/CLOCKS_PER_SEC; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the Grove Electromagnetic Module - // Instantiate a Grove Electromagnet on digital pin D2 - upm::GroveElectromagnet* magnet = new upm::GroveElectromagnet(2); - cout << "Starting up magnet...." << endl; - magnet->off(); - - bool magnetState = false; - float time_passed = get_time(); - - // Turn magnet on and off every 5 seconds - while (shouldRun) - { - if ((get_time() - time_passed) > 5.0) - { - magnetState = !magnetState; - if (magnetState) - magnet->on(); - else - magnet->off(); - cout << "Turning magnet " << ((magnetState) ? "on" : "off") << endl; - time_passed = get_time(); - } - } - -//! [Interesting] - magnet->off(); - cout << "Exiting" << endl; - - delete magnet; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveemg.cxx b/peripheral/libupm/examples/c++/groveemg.cxx deleted file mode 100644 index d06295a..0000000 --- a/peripheral/libupm/examples/c++/groveemg.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "groveemg.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the GroveEMG Muscle Signal Reader Sensor Module - // Instantiate a GroveEMG on analog pin A0 - upm::GroveEMG *emg = new upm::GroveEMG(0); - cout << "Calibrating...." << endl; - emg->calibrate(); - - while (shouldRun) - { - cout << emg->value() << endl; - usleep(100000); - } - -//! [Interesting] - cout << "Exiting" << endl; - delete emg; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovegprs.cxx b/peripheral/libupm/examples/c++/grovegprs.cxx deleted file mode 100644 index bc0e3d9..0000000 --- a/peripheral/libupm/examples/c++/grovegprs.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdio.h> -#include "grovegprs.h" - -using namespace std; -using namespace upm; - -void printUsage(char *progname) -{ - cout << "Usage: " << progname << " [AT command]" << endl; - cout << endl; - - cout << "If an argument is supplied on the command line, that argument is" - << endl; - cout << "sent to the module and the response is printed out." << endl; - cout << endl; - cout << "If no argument is used, then the manufacturer and the current" - << endl; - cout << "saved profiles are queried and the results printed out." << endl; - cout << endl; - cout << endl; -} - -// simple helper function to send a command and wait for a response -void sendCommand(upm::GroveGPRS* sensor, string cmd) -{ - // commands need to be terminated with a carriage return - cmd += "\r"; - - sensor->writeDataStr(cmd); - - // wait up to 1 second - if (sensor->dataAvailable(1000)) - { - cout << "Returned: " << sensor->readDataStr(1024) << endl; - } - else - { - cerr << "Timed out waiting for response" << endl; - } -} - - -int main(int argc, char **argv) -{ -//! [Interesting] - - // Instantiate a GroveGPRS Module on UART 0 - upm::GroveGPRS* sensor = new upm::GroveGPRS(0); - - // Set the baud rate, 19200 baud is the default. - if (sensor->setBaudRate(19200) != mraa::SUCCESS) - { - cerr << "Failed to set tty baud rate" << endl; - return 1; - } - - printUsage(argv[0]); - - if (argc > 1) - { - cout << "Sending command line argument (" << argv[1] << ")..." << endl; - sendCommand(sensor, argv[1]); - } - else - { - // query the module manufacturer - cout << "Querying module manufacturer (AT+CGMI)..." << endl; - sendCommand(sensor, "AT+CGMI"); - - sleep(1); - - // query the saved profiles - cout << "Querying the saved profiles (AT&V)..." << endl; - sendCommand(sensor, "AT&V"); - - // A comprehensive list is available from the datasheet at: - // http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf - } - -//! [Interesting] - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovegsr.cxx b/peripheral/libupm/examples/c++/grovegsr.cxx deleted file mode 100644 index 549e775..0000000 --- a/peripheral/libupm/examples/c++/grovegsr.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovegsr.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the GroveGSR Galvanic Skin Response Sensor module. - - // Instantiate a GroveGSR on analog pin A0 - upm::GroveGSR *gsr = new upm::GroveGSR(0); - cout << "Calibrating...." << endl; - gsr->calibrate(); - - while (shouldRun) - { - cout << gsr->value() << endl; - usleep(500000); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete gsr; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveled-multi.cxx b/peripheral/libupm/examples/c++/groveled-multi.cxx deleted file mode 100644 index 16a6eba..0000000 --- a/peripheral/libupm/examples/c++/groveled-multi.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014-2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grove.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a grove LED on D2. Here we are controlling a Grove - // Multi-color flash LED. We just just need to turn it on - it will - // then cycle through various colors (red, green, blue, purple) on it's - // own until turned off. - upm::GroveLed* led = new upm::GroveLed(2); - - // start the light show - led->on(); - - // just sleep until interrupted - while (shouldRun) - sleep(1); - -//! [Interesting] - - led->off(); - cout << "Exiting..." << endl; - - delete led; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveled.cxx b/peripheral/libupm/examples/c++/groveled.cxx deleted file mode 100644 index 52d5e84..0000000 --- a/peripheral/libupm/examples/c++/groveled.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Contributions: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "grove.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - - // Create the Grove LED object using GPIO pin 2 - upm::GroveLed* led = new upm::GroveLed(2); - - // Print the name - std::cout << led->name() << std::endl; - - // Turn the LED on and off 10 times, pausing one second - // between transitions - for (int i=0; i < 10; i++) { - led->on(); - sleep(1); - led->off(); - sleep(1); - } - - // Delete the Grove LED object - delete led; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveledbar.cxx b/peripheral/libupm/examples/c++/groveledbar.cxx deleted file mode 100644 index d86110c..0000000 --- a/peripheral/libupm/examples/c++/groveledbar.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "groveledbar.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a GroveLEDBar, we use D8 for the data, and D9 for the - // clock. This was tested with a Grove LED bar. - upm::GroveLEDBar* bar = new upm::GroveLEDBar(8, 9); - - while (shouldRun) - { - // count up from green to red - for (int i=0; i<=10; i++) - { - bar->setBarLevel(i, true); - usleep(100000); - } - sleep(1); - - // count down from red to green - for (int i=0; i<=10; i++) - { - bar->setBarLevel(i, false); - usleep(100000); - } - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - // turn off the LED's - bar->setBarLevel(0); - - delete bar; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovelight.cxx b/peripheral/libupm/examples/c++/grovelight.cxx deleted file mode 100644 index 64760c9..0000000 --- a/peripheral/libupm/examples/c++/grovelight.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Contributions: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "grove.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - // Create the light sensor object using AIO pin 0 - upm::GroveLight* light = new upm::GroveLight(0); - - // Read the input and print both the raw value and a rough lux value, - // waiting one second between readings - while( 1 ) { - std::cout << light->name() << " raw value is " << light->raw_value() << - ", which is roughly " << light->value() << " lux" << std::endl; - sleep(1); - } - - // Delete the light sensor object - delete light; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovelinefinder.cxx b/peripheral/libupm/examples/c++/grovelinefinder.cxx deleted file mode 100644 index a8290c5..0000000 --- a/peripheral/libupm/examples/c++/grovelinefinder.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovelinefinder.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Line Finder sensor on digital pin D2 - upm::GroveLineFinder* finder = new upm::GroveLineFinder(2); - - // check every second for the presence of white detection - while (shouldRun) - { - bool val = finder->whiteDetected(); - if (val) - cout << "White detected." << endl; - else - cout << "Black detected." << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete finder; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovemd-stepper.cxx b/peripheral/libupm/examples/c++/grovemd-stepper.cxx deleted file mode 100644 index f65c5e4..0000000 --- a/peripheral/libupm/examples/c++/grovemd-stepper.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "grovemd.h" - -using namespace std; - -int main(int argc, char **argv) -{ - //! [Interesting] - // Instantiate an I2C Grove Motor Driver on I2C bus 0 - - upm::GroveMD *motors = new upm::GroveMD(GROVEMD_I2C_BUS, - GROVEMD_DEFAULT_I2C_ADDR); - - // This example demonstrates using the GroveMD to drive a stepper motor - - // configure it, for this example, we'll assume 200 steps per rev - motors->configStepper(200); - - // set for half a rotation - motors->setStepperSteps(100); - - // let it go - clockwise rotation, 10 RPM speed - motors->enableStepper(upm::GroveMD::STEP_DIR_CW, 10); - - sleep(3); - - // Now do it backwards... - motors->setStepperSteps(100); - motors->enableStepper(upm::GroveMD::STEP_DIR_CCW, 10); - - // now disable - motors->disableStepper(); - - //! [Interesting] - - cout << "Exiting..." << endl; - - delete motors; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovemd.cxx b/peripheral/libupm/examples/c++/grovemd.cxx deleted file mode 100644 index a5c1015..0000000 --- a/peripheral/libupm/examples/c++/grovemd.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "grovemd.h" - -using namespace std; - -int main(int argc, char **argv) -{ - //! [Interesting] - // Instantiate an I2C Grove Motor Driver on I2C bus 0 - - upm::GroveMD *motors = new upm::GroveMD(GROVEMD_I2C_BUS, - GROVEMD_DEFAULT_I2C_ADDR); - - // set direction to CW and set speed to 50% - cout << "Spin M1 and M2 at half speed for 3 seconds" << endl; - motors->setMotorDirections(upm::GroveMD::DIR_CW, upm::GroveMD::DIR_CW); - motors->setMotorSpeeds(127, 127); - - sleep(3); - // counter clockwise - cout << "Reversing M1 and M2 for 3 seconds" << endl; - motors->setMotorDirections(upm::GroveMD::DIR_CCW, upm::GroveMD::DIR_CCW); - sleep(3); - - //! [Interesting] - - cout << "Stopping motors" << endl; - motors->setMotorSpeeds(0, 0); - - cout << "Exiting..." << endl; - - delete motors; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovemoisture.cxx b/peripheral/libupm/examples/c++/grovemoisture.cxx deleted file mode 100644 index 1fee54c..0000000 --- a/peripheral/libupm/examples/c++/grovemoisture.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovemoisture.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Moisture sensor on analog pin A0 - upm::GroveMoisture* moisture = new upm::GroveMoisture(0); - - // Values (approximate): - // 0-300, sensor in air or dry soil - // 300-600, sensor in humid soil - // 600+, sensor in wet soil or submerged in water. - // Read the value every second and print the corresponding moisture level - while (shouldRun) - { - int val = moisture->value(); - cout << "Moisture value: " << val << ", "; - if (val >= 0 && val < 300) - cout << "dry"; - else if (val >= 300 && val < 600) - cout << "moist"; - else - cout << "wet"; - - cout << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete moisture; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveo2.cxx b/peripheral/libupm/examples/c++/groveo2.cxx deleted file mode 100644 index cc1b240..0000000 --- a/peripheral/libupm/examples/c++/groveo2.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "groveo2.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the O2 Oxygen Concentration Sensor Module - // Instantiate a GroveO2 on analog pin A0 - upm::GroveO2 *O2 = new upm::GroveO2(0); - while (shouldRun) - { - cout << "The output voltage is: " << O2->voltageValue() << "mV" << endl; - usleep(100000); - } - -//! [Interesting] - cout << "Exiting" << endl; - delete O2; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groverelay.cxx b/peripheral/libupm/examples/c++/groverelay.cxx deleted file mode 100644 index 4366dd6..0000000 --- a/peripheral/libupm/examples/c++/groverelay.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Author: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "grove.h" - -int -main(int argc, char **argv) -{ - // This example uses GPIO 0 -//! [Interesting] - - // Create the relay switch object using GPIO pin 0 - upm::GroveRelay* relay = new upm::GroveRelay(0); - - // Close and then open the relay switch 3 times, - // waiting one second each time. The LED on the relay switch - // will light up when the switch is on (closed). - // The switch will also make a noise between transitions. - for ( int i = 0; i < 3; i++ ) { - relay->on(); - if ( relay->isOn() ) - std::cout << relay->name() << " is on" << std::endl; - sleep(1); - relay->off(); - if ( relay->isOff() ) - std::cout << relay->name() << " is off" << std::endl; - sleep(1); - } - - // Delete the relay switch object - delete relay; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/groverotary.cxx b/peripheral/libupm/examples/c++/groverotary.cxx deleted file mode 100644 index 4139242..0000000 --- a/peripheral/libupm/examples/c++/groverotary.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <iomanip> -#include "grove.h" - -using namespace std; - -int main () -{ -//! [Interesting] - // Instantiate a rotary sensor on analog pin A0 - upm::GroveRotary* knob = new upm::GroveRotary(0); - - // Print sensor name to confirm it initialized properly - cout << knob->name() << endl; - - while(true) { - float abs_value = knob->abs_value(); // Absolute raw value - float abs_deg = knob->abs_deg(); // Absolute degrees - float abs_rad = knob->abs_rad(); // Absolute radians - float rel_value = knob->rel_value(); // Relative raw value - float rel_deg = knob->rel_deg(); // Relative degrees - float rel_rad = knob->rel_rad(); // Relative radians - - fprintf(stdout, "Absolute: %4d raw %5.2f deg = %3.2f rad Relative: %4d raw %5.2f deg %3.2f rad\n", - (int16_t)abs_value, abs_deg, abs_rad, (int16_t)rel_value, rel_deg, rel_rad); - - usleep(2500000); // Sleep for 2.5s - } -//! [Interesting] - delete knob; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovescam.cxx b/peripheral/libupm/examples/c++/grovescam.cxx deleted file mode 100644 index 6edd85d..0000000 --- a/peripheral/libupm/examples/c++/grovescam.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdio.h> -#include "grovescam.h" - -using namespace std; -using namespace upm; - -int main (int argc, char **argv) -{ -//! [Interesting] - - // Instantiate a Grove Serial Camera on UART 0 - upm::GROVESCAM* camera = new upm::GROVESCAM(0); - - // make sure port is initialized properly. 115200 baud is the default. - if (!camera->setupTty()) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - if (camera->init()) - cout << "Initialized..." << endl; - else - cout << "init() failed" << endl; - - if (camera->preCapture()) - cout << "preCapture succeeded..." << endl; - else - cout << "preCapture failed." << endl; - - if (camera->doCapture()) - cout << "doCapture succeeded..." << endl; - else - cout << "doCapture failed." << endl; - - cout << "Image size is " << camera->getImageSize() << " bytes" << endl; - - if (camera->getImageSize() > 0) - { - cout << "Storing image.jpg..." << endl; - if (camera->storeImage("image.jpg")) - cout << "storeImage succeeded..." << endl; - else - cout << "storeImage failed." << endl; - } -//! [Interesting] - - delete camera; - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveslide.cxx b/peripheral/libupm/examples/c++/groveslide.cxx deleted file mode 100644 index 42e975a..0000000 --- a/peripheral/libupm/examples/c++/groveslide.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include <unistd.h> -#include <iostream> -#include <iomanip> -#include "grove.h" - -using namespace std; - -int main () -{ -//! [Interesting] - upm::GroveSlide* slide = new upm::GroveSlide(0); // Instantiate new grove slide potentiometer on analog pin A0 - - cout << slide->name() << endl; - - while(true) { - float adc_value = slide->raw_value(); // Read raw value - float volts = slide->voltage_value(); // Read voltage, board reference set at 5.0V - fprintf(stdout, "%4d = %.2f V\n", (uint16_t)adc_value, volts); - - usleep(2500000); // Sleep for 2.5s - } -//! [Interesting] - delete slide; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovespeaker.cxx b/peripheral/libupm/examples/c++/grovespeaker.cxx deleted file mode 100644 index 97d6518..0000000 --- a/peripheral/libupm/examples/c++/grovespeaker.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovespeaker.h" - -using namespace std; - -int main () -{ -//! [Interesting] - // Instantiate a Grove Speaker on digital pin D2 - upm::GroveSpeaker* speaker = new upm::GroveSpeaker(2); - - // Play all 7 of the lowest notes - speaker->playAll(); - - // Play a medium C-sharp - speaker->playSound('c', true, "med"); -//! [Interesting] - - cout << "Exiting" << endl; - - delete speaker; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovetemp.cxx b/peripheral/libupm/examples/c++/grovetemp.cxx deleted file mode 100644 index 73de9c7..0000000 --- a/peripheral/libupm/examples/c++/grovetemp.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Contributions: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <iomanip> -#include "grove.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - - // Create the temperature sensor object using AIO pin 0 - upm::GroveTemp* temp = new upm::GroveTemp(0); - std::cout << temp->name() << std::endl; - - // Read the temperature ten times, printing both the Celsius and - // equivalent Fahrenheit temperature, waiting one second between readings - for (int i=0; i < 10; i++) { - int celsius = temp->value(); - int fahrenheit = (int) (celsius * 9.0/5.0 + 32.0); - printf("%d degrees Celsius, or %d degrees Fahrenheit\n", - celsius, fahrenheit); - sleep(1); - } - - // Delete the temperature sensor object - delete temp; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/groveultrasonic.cxx b/peripheral/libupm/examples/c++/groveultrasonic.cxx deleted file mode 100644 index e054c4c..0000000 --- a/peripheral/libupm/examples/c++/groveultrasonic.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Jun Kato <i@junkato.jp> - * Copyright (c) 2015 Jun Kato. - * - * Thanks to Seeed Studio for a working arduino sketch - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "groveultrasonic.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -upm::GroveUltraSonic *sonar = NULL; -bool running = true; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) { - running = false; - } -} - -int -main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - // upm::GroveUltraSonic *sonar = NULL; - sonar = new upm::GroveUltraSonic(2); - while(running) { - int width = sonar->getDistance(); - printf("Echo width = %d\n", width); - printf("Distance inches = %f.2\n\n", width/148.0); - sleep(3); - } -//! [Interesting] - printf("exiting application\n"); - delete sonar; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovevdiv.cxx b/peripheral/libupm/examples/c++/grovevdiv.cxx deleted file mode 100644 index 40be66c..0000000 --- a/peripheral/libupm/examples/c++/grovevdiv.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovevdiv.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Voltage Divider sensor on analog pin A0 - upm::GroveVDiv* vDiv = new upm::GroveVDiv(0); - - // collect data and output measured voltage according to the setting - // of the scaling switch (3 or 10) - while (shouldRun) - { - unsigned int val = vDiv->value(100); - float gain3val = vDiv->computedValue(3, val); - float gain10val = vDiv->computedValue(10, val); - cout << "ADC value: " << val << " Gain 3: " << gain3val - << "v Gain 10: " << gain10val << "v" << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete vDiv; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovewater.cxx b/peripheral/libupm/examples/c++/grovewater.cxx deleted file mode 100644 index 51bfacb..0000000 --- a/peripheral/libupm/examples/c++/grovewater.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovewater.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Water sensor on digital pin D2 - upm::GroveWater* water = new upm::GroveWater(2); - - while (shouldRun) - { - bool val = water->isWet(); - if (val) - cout << "Sensor is wet." << endl; - else - cout << "Sensor is dry." << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete water; - return 0; -} diff --git a/peripheral/libupm/examples/c++/grovewfs.cxx b/peripheral/libupm/examples/c++/grovewfs.cxx deleted file mode 100644 index ea819ae..0000000 --- a/peripheral/libupm/examples/c++/grovewfs.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "grovewfs.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Water Flow Sensor on digital pin D2 - upm::GroveWFS* flow = new upm::GroveWFS(2); - - // set the flow counter to 0 and start counting - flow->clearFlowCounter(); - flow->startFlowCounter(); - - while (shouldRun) - { - // we grab these (,illis and flowCount) just for display - // purposes in this example - uint32_t millis = flow->getMillis(); - uint32_t flowCount = flow->flowCounter(); - - float fr = flow->flowRate(); - - // output milliseconds passed, flow count, and computed flow rate - cout << "Millis: " << millis << " Flow Count: " << flowCount; - cout << " Flow Rate: " << fr << " LPM" << endl; - - // best to gather data for at least one second for reasonable - // results. - sleep(2); - } - - flow->stopFlowCounter(); -//! [Interesting] - - cout << "Exiting..." << endl; - - delete flow; - return 0; -} diff --git a/peripheral/libupm/examples/c++/guvas12d.cxx b/peripheral/libupm/examples/c++/guvas12d.cxx deleted file mode 100644 index 3351741..0000000 --- a/peripheral/libupm/examples/c++/guvas12d.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "guvas12d.h" - -using namespace std; - -bool shouldRun = true; - -// analog voltage, usually 3.3 or 5.0 -#define GUVAS12D_AREF 5.0 -#define SAMPLES_PER_QUERY 1024 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the Grove UV Sensor module. - // It has a sensing range from between 200-400nm. It's strongest - // response is around 320-360nm. - - // Instantiate a GUVAS12D on analog pin A0 - upm::GUVAS12D *volts = new upm::GUVAS12D(0); - - // The higher the voltage the more intense the UV radiation. - - while (shouldRun) - { - cout << "AREF: " << GUVAS12D_AREF - << ", Voltage value (higher means more UV): " - << volts->value(GUVAS12D_AREF, SAMPLES_PER_QUERY) << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete volts; - return 0; -} diff --git a/peripheral/libupm/examples/c++/h3lis331dl.cxx b/peripheral/libupm/examples/c++/h3lis331dl.cxx deleted file mode 100644 index d4a04ca..0000000 --- a/peripheral/libupm/examples/c++/h3lis331dl.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "h3lis331dl.h" - -using namespace std; -using namespace upm; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an H3LIS331DL on I2C bus 0 - - upm::H3LIS331DL *accel = new upm::H3LIS331DL(H3LIS331DL_I2C_BUS, - H3LIS331DL_DEFAULT_I2C_ADDR); - - // Initialize the device with default values - accel->init(); - - while (shouldRun) - { - int x, y, z; - float ax, ay, az; - - accel->update(); - - accel->getRawXYZ(&x, &y, &z); - accel->getAcceleration(&ax, &ay, &az); - - cout << "Raw: X = " << x << " Y = " << y << " Z = " << z << endl; - - cout << "Acceleration: AX = " << ax << " AY = " << ay << " AZ = " << az - << endl; - - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete accel; - return 0; -} diff --git a/peripheral/libupm/examples/c++/hcsr04.cxx b/peripheral/libupm/examples/c++/hcsr04.cxx deleted file mode 100644 index c0a2725..0000000 --- a/peripheral/libupm/examples/c++/hcsr04.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "hcsr04.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -upm::HCSR04 *sonar = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - sonar->m_doWork = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - sonar = new upm::HCSR04(5, 6); - signal(SIGINT, sig_handler); - - sleep(1); - - for(;;){ - std::cout << "get distance" << std::endl; - double distance = sonar->getDistance(CM); - std::cout << "distance " << distance << std::endl; - sleep(5); - } - - delete sonar; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/hdxxvxta.cxx b/peripheral/libupm/examples/c++/hdxxvxta.cxx deleted file mode 100644 index 2a555f3..0000000 --- a/peripheral/libupm/examples/c++/hdxxvxta.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "hdxxvxta.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - cout << "Initializing..." << endl; - - // Instantiate an HDXXVXTA instance, using A1 for humidity and A0 - // for temperature - upm::HDXXVXTA *sensor = new upm::HDXXVXTA(1, 0); - - // update and print available values every second - while (shouldRun) - { - // update our values from the sensor - sensor->update(); - - // we show both C and F for temperature - cout << "Temperature: " << sensor->getTemperature() - << " C / " << sensor->getTemperature(true) << " F" - << endl; - - cout << "Humidity: " << sensor->getHumidity() - << " %" << endl; - - cout << endl; - - sleep(1); - } - - cout << "Exiting..." << endl; - - delete sensor; - -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/hm11.cxx b/peripheral/libupm/examples/c++/hm11.cxx deleted file mode 100644 index e759804..0000000 --- a/peripheral/libupm/examples/c++/hm11.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdio.h> -#include "hm11.h" - -using namespace std; -using namespace upm; - -void printUsage(char *progname) -{ - cout << "Usage: " << progname << " [AT command]" << endl; - cout << endl; - - cout << "If an argument is supplied on the command line, that argument is" - << endl; - cout << "sent to the module and the response is printed out." << endl; - cout << endl; - cout << "If no argument is used, then the address and PIN of the module" - << endl; - cout << "are queried and the results printed out." << endl; - cout << endl; - cout << endl; -} - -// simple helper function to send a command and wait for a response -void sendCommand(upm::HM11* ble, char *cmd) -{ - char buffer[BUFSIZ]; - ble->writeData(cmd, strlen(cmd)); - - // wait up to 1 second - if (ble->dataAvailable(1000)) - { - memset(buffer, 0, BUFSIZ); - - ble->readData(buffer, BUFSIZ - 1); - cout << "Returned: " << buffer << endl; - } - else - { - cerr << "Timed out waiting for response" << endl; - } -} - - -int main (int argc, char **argv) -{ -//! [Interesting] - char buffer[BUFSIZ]; - // Instantiate a HM11 BLE Module on UART 0 - - upm::HM11* ble = new upm::HM11(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!ble->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - printUsage(argv[0]); - - if (argc > 1) - { - cout << "Sending command line argument (" << argv[1] << ")..." << endl; - sendCommand(ble, argv[1]); - } - else - { - // query the module address - char addr[] = "AT+ADDR?"; - cout << "Querying module address (" << addr << ")..." << endl; - sendCommand(ble, addr); - - sleep(1); - - // query the module address - char pin[] = "AT+PASS?"; - cout << "Querying module PIN (" << pin << ")..." << endl; - sendCommand(ble, pin); - - // Other potentially useful commands are: - // - // AT+VERS? - query module version - // AT+ROLE0 - set as slave - // AT+ROLE1 - set as master - // AT+CLEAR - clear all previous settings - // AT+RESET - restart the device - // - // A comprehensive list is available from the datasheet at: - // http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf - } - -//! [Interesting] - - delete ble; - return 0; -} diff --git a/peripheral/libupm/examples/c++/hmc5883l.cxx b/peripheral/libupm/examples/c++/hmc5883l.cxx deleted file mode 100644 index dec08ce..0000000 --- a/peripheral/libupm/examples/c++/hmc5883l.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Contributions: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include "hmc5883l.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate on I2C - upm::Hmc5883l* compass = new upm::Hmc5883l(0); - int16_t *pos; - - compass->set_declination(0.2749); // Set your declination from true north in radians - - // Print out the coordinates, heading, and direction every second - while(true){ - compass->update(); // Update the coordinates - pos = compass->coordinates(); - fprintf(stdout, "coor: %5d %5d %5d ", pos[0], pos[1], pos[2]); - fprintf(stdout, "heading: %5.2f direction: %3.2f\n", compass->heading(), compass->direction()); - sleep(1); - } -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/hmtrp.cxx b/peripheral/libupm/examples/c++/hmtrp.cxx deleted file mode 100644 index 3d58ba9..0000000 --- a/peripheral/libupm/examples/c++/hmtrp.cxx +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <string.h> -#include <iostream> -#include <signal.h> -#include "hmtrp.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -void printUsage() -{ - cout << "Usage:" << endl; - cout << "Pass a commandline argument (any argument) to this program" - << endl; - cout << "to query the radio configuration and output it. NOTE: the" - << endl; - cout << "radio must be in CONFIG mode for this to work." - << endl; - cout << endl; - cout << "Running this program without arguments will simply transmit" - << endl; - cout << "'Hello World!' every second, and output any data received from" - << endl; - cout << "another radio." - << endl; - cout << endl; -} - -const size_t bufferLength = 256; - -int main (int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a HMTRP radio device on uart 0 - - upm::HMTRP* radio = new upm::HMTRP(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!radio->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - printUsage(); - - // By default, this radio simply transmits data sent via writeData() - // and reads any available data via readData(). - - // It can be placed into a configuration mode by grounding the - // CONFIG pin on the module. When this is done, the various - // configuration query and config methods can be used. In this - // example, by default, we just read any data available fom the - // device, and periodically transmit "Hello World". - - // If any argument was specified on the command line, do a simple - // configuration query and output the results. The radio must be in - // CONFIG mode for this to work. - - if (argc > 1) - { - // config mode - uint32_t freq; - uint32_t dataRate; - uint16_t rxBandwidth; - uint8_t modulation; - uint8_t txPower; - uint32_t uartBaud; - - if (radio->getConfig(&freq, &dataRate, &rxBandwidth, &modulation, - &txPower, &uartBaud)) - { - cout << "Radio configuration:" << endl; - cout << "freq: " << freq << " dataRate: " << dataRate - << " rxBandwidth: " << rxBandwidth << "Khz" << endl; - - cout << "modulation: " << int(modulation) << "Khz txPower: " - << int(txPower) << " uartBaud: " << uartBaud << endl; - } - else - { - cerr << "getConfig() failed. Make sure the radio is in " - << "CONFIG mode." << endl; - } - } - else - { - // normal read/write mode - char radioBuffer[bufferLength]; - int counter = 0; - cout << "Running in normal read/write mode." << endl; - - while (shouldRun) - { - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (radio->dataAvailable()) - { - memset(radioBuffer, 0, bufferLength); - int rv = radio->readData(radioBuffer, bufferLength - 1); - - if (rv > 0) - cout << "Received: " << radioBuffer << endl; - - if (rv < 0) // some sort of read error occured - { - cerr << "Port read error." << endl; - break; - } - - continue; - } - - usleep(100000); // 100ms - counter++; - // every second, transmit "Hello World" - if (counter > 10) - { - static const char *hello = "Hello World!"; - cout << "Transmitting hello world..." << endl; - radio->writeData((char *)hello, strlen(hello) + 1); - counter = 0; - } - } - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete radio; - return 0; -} diff --git a/peripheral/libupm/examples/c++/hp20x.cxx b/peripheral/libupm/examples/c++/hp20x.cxx deleted file mode 100644 index 119a449..0000000 --- a/peripheral/libupm/examples/c++/hp20x.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "hp20x.h" - -using namespace std; -using namespace upm; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an HP20X on default I2C bus and address - - upm::HP20X *bar = new upm::HP20X(); - - // Initialize the device with default values - bar->init(); - - // Output data every second until interrupted - while (shouldRun) - { - printf("Temperature: %f Celcius\n", bar->getTemperature()); - printf("Pressure: %f Millibars\n", bar->getPressure()); - printf("Altitude: %f Meters\n", bar->getAltitude()); - - printf("\n"); - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete bar; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ht9170.cxx b/peripheral/libupm/examples/c++/ht9170.cxx deleted file mode 100644 index 1be72b6..0000000 --- a/peripheral/libupm/examples/c++/ht9170.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "ht9170.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main () -{ - signal(SIGINT, sig_handler); - //! [Interesting] - - // Instantiate a DTMF decoder - upm::HT9170* dtmf = new upm::HT9170(12, 11, 10, 9, 8); - - // Now we just spin in a loop, sleeping every 100ms, checking to see - // if a digit is available. If so, we decode and print the digit, - // and continue looping. - - while(shouldRun) - { - if (dtmf->digitReady()) - { - cout << "Got DTMF code: " << dtmf->decodeDigit() << endl; - // now spin until digitReady() goes false again - while (dtmf->digitReady()) - ; - } - - usleep(100000); - } - - //! [Interesting] - - cout << "Exiting..." << endl; - - delete dtmf; - return 0; -} diff --git a/peripheral/libupm/examples/c++/htu21d.cxx b/peripheral/libupm/examples/c++/htu21d.cxx deleted file mode 100644 index 63d6fdf..0000000 --- a/peripheral/libupm/examples/c++/htu21d.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: William Penner <william.penner@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "htu21d.h" - -volatile int doWork = 0; - -upm::HTU21D *sensor = NULL; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) { - printf("\nCtrl-C received.\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - // Register signal handler - signal(SIGINT, sig_handler); - - //! [Interesting] - float humidity = 0.0; - float temperature = 0.0; - float compRH = 0.0; - - sensor = new upm::HTU21D(0, HTU21D_I2C_ADDRESS); - - sensor->testSensor(); - - while (!doWork) { - compRH = sensor->getCompRH(true); - humidity = sensor->getHumidity(false); - temperature = sensor->getTemperature(false); - - std::cout << "humidity value = " << - humidity << - ", temperature value = " << - temperature << - ", compensated RH value = " << - compRH << std::endl; - usleep (500000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/hwxpxx.cxx b/peripheral/libupm/examples/c++/hwxpxx.cxx deleted file mode 100644 index 1cfdf54..0000000 --- a/peripheral/libupm/examples/c++/hwxpxx.cxx +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "hwxpxx.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - string defaultDev = "/dev/ttyUSB0"; - - // if an argument was specified, use it as the device instead - if (argc > 1) - defaultDev = string(argv[1]); - - cout << "Using device " << defaultDev << endl; - cout << "Initializing..." << endl; - - // Instantiate an HWXPXX instance, using MODBUS slave address 3, and - // default comm parameters (19200, 8, N, 2) - upm::HWXPXX *sensor = new upm::HWXPXX(defaultDev, 3); - - // output the Slave ID (manufacturer, model, serno) - cout << "Slave ID: " << sensor->getSlaveID() << endl; - - // stored temperature and humidity offsets - cout << "Temperature Offset: " << sensor->getTemperatureOffset() - << endl; - cout << "Humidity Offset: " << sensor->getHumidityOffset() - << endl; - - cout << endl; - - // update and print available values every second - while (shouldRun) - { - // update our values from the sensor - sensor->update(); - - // we show both C and F for temperature - cout << "Temperature: " << sensor->getTemperature() - << " C / " << sensor->getTemperature(true) << " F" - << endl; - - cout << "Humidity: " << sensor->getHumidity() - << " %" << endl; - - cout << "Slider: " << sensor->getSlider() << " %" << endl; - - cout << "Override Switch Status: " << sensor->getOverrideSwitchStatus() - << endl; - - cout << endl; - - sleep(1); - } - - cout << "Exiting..." << endl; - - delete sensor; - -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/hx711.cxx b/peripheral/libupm/examples/c++/hx711.cxx deleted file mode 100644 index 531734b..0000000 --- a/peripheral/libupm/examples/c++/hx711.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -* -* Author: Rafael da Mata Neri <rafael.neri@gmail.com> -* Copyright (c) 2015 Intel Corporation. -* -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of -* this software and associated documentation files (the "Software"), to deal in -* the Software without restriction, including without limitation the rights to -* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -* the Software, and to permit persons to whom the Software is furnished to do so, -* subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <unistd.h> -#include <iostream> -#include <signal.h> - -//! [Interesting] -#include "hx711.h" - -int -main(int argc, char **argv) -{ - upm::HX711 *scale = new upm::HX711(3, 2); - - // 2837: value obtained via calibration - scale->setScale(2837); - scale->tare(); - std::cout << scale->getUnits() << std::endl; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/ili9341.cxx b/peripheral/libupm/examples/c++/ili9341.cxx deleted file mode 100644 index 8fe397a..0000000 --- a/peripheral/libupm/examples/c++/ili9341.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Author: Shawn Hymel - * Copyright (c) 2016 SparkFun Electronics - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> - -#include "ili9341.h" - -int main(int argc, char **argv) { -//! [Interesting] - - // Pins (Edison) - // CS_LCD GP44 (MRAA 31) - // CS_SD GP43 (MRAA 38) unused - // DC GP12 (MRAA 20) - // RESEST GP13 (MRAA 14) - upm::ILI9341 * lcd = new upm::ILI9341(31, 38, 20, 14); - - // Fill the screen with a solid color - lcd->fillScreen(lcd->color565(0, 40, 16)); - - // Draw some shapes - lcd->drawFastVLine(10, 10, 100, ILI9341_RED); - lcd->drawFastHLine(20, 10, 50, ILI9341_CYAN); - lcd->drawLine(160, 30, 200, 60, ILI9341_GREEN); - lcd->fillRect(20, 30, 75, 60, ILI9341_ORANGE); - lcd->drawCircle(70, 50, 20, ILI9341_PURPLE); - lcd->fillCircle(120, 50, 20, ILI9341_PURPLE); - lcd->drawTriangle(50, 100, 10, 140, 90, 140, ILI9341_YELLOW); - lcd->fillTriangle(150, 100, 110, 140, 190, 140, ILI9341_YELLOW); - lcd->drawRoundRect(20, 150, 50, 30, 10, ILI9341_RED); - lcd->drawRoundRect(130, 150, 50, 30, 10, ILI9341_RED); - lcd->fillRoundRect(75, 150, 50, 30, 10, ILI9341_RED); - - // Write some text - lcd->setCursor(0, 200); - lcd->setTextColor(ILI9341_LIGHTGREY); - lcd->setTextWrap(true); - lcd->setTextSize(1); - lcd->print("Text 1\n"); - lcd->setTextSize(2); - lcd->print("Text 2\n"); - lcd->setTextSize(3); - lcd->print("Text 3\n"); - lcd->setTextSize(4); - lcd->print("Text 4\n"); - - // Test screen rotation - for(int r = 0; r < 4; r++) { - lcd->setRotation(r); - lcd->fillRect(0, 0, 5, 5, ILI9341_WHITE); - sleep(1); - } - - // Invert colors, wait, then revert back - lcd->invertDisplay(true); - sleep(2); - lcd->invertDisplay(false); - - // Don't forget to free up that memory! - delete lcd; -//! [Interesting] - return 0; -}
\ No newline at end of file diff --git a/peripheral/libupm/examples/c++/ina132.cxx b/peripheral/libupm/examples/c++/ina132.cxx deleted file mode 100644 index 0c78630..0000000 --- a/peripheral/libupm/examples/c++/ina132.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "ina132.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the INA132 Differential Amplifier Sensor module. - - // Instantiate an INA132 on analog pin A0 - upm::INA132 *amplifier = new upm::INA132(0); - - while (shouldRun) - { - cout << amplifier->value() << endl; - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete amplifier; - return 0; -} diff --git a/peripheral/libupm/examples/c++/isd1820.cxx b/peripheral/libupm/examples/c++/isd1820.cxx deleted file mode 100644 index 3246808..0000000 --- a/peripheral/libupm/examples/c++/isd1820.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "isd1820.h" - -using namespace std; - -int main (int argc, char **argv) -{ -//! [Interesting] - // Instantiate a ISD1820 on digital pins 2 (play) and 3 (record) - // This example was tested on the Grove Recorder. - - upm::ISD1820* recorder = new upm::ISD1820(2, 3); - - // if an argument was specified (any argument), go into record mode, - // else playback a previously recorded sample - - cout << "Supply any argument to the command line to record." << endl; - cout << "Running this example without arguments will play back any " << endl; - cout << "previously recorded sound." << endl; - cout << "There is approximately 10 seconds of recording time." << endl; - - cout << endl; - - bool doRecord = false; - - if (argc > 1) - doRecord = true; - - // depending on what was selected, do it, and sleep for 15 seconds - - if (doRecord) - recorder->record(true); - else - recorder->play(true); - - // There are about 10 seconds of recording/playback time, so we will - // sleep for a little extra time. - cout << "Sleeping for 15 seconds..." << endl; - sleep(15); - - // now, turn off whatever we were doing. - - if (doRecord) - recorder->record(false); - else - recorder->play(false); - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete recorder; - return 0; -} diff --git a/peripheral/libupm/examples/c++/itg3200.cxx b/peripheral/libupm/examples/c++/itg3200.cxx deleted file mode 100644 index a1bf8af..0000000 --- a/peripheral/libupm/examples/c++/itg3200.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include "itg3200.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - int16_t *rot; - float *ang; - - // Note: Sensor not supported on Intel Edison with Arduino breakout - upm::Itg3200* gyro = new upm::Itg3200(0); - - while(true){ - gyro->update(); // Update the data - rot = gyro->getRawValues(); // Read raw sensor data - ang = gyro->getRotation(); // Read rotational speed (deg/sec) - fprintf(stdout, "Raw: %6d %6d %6d\n", rot[0], rot[1], rot[2]); - fprintf(stdout, "AngX: %5.2f\n", ang[0]); - fprintf(stdout, "AngY: %5.2f\n", ang[1]); - fprintf(stdout, "AngZ: %5.2f\n", ang[2]); - fprintf(stdout, "Temp: %5.2f Raw: %6d\n", gyro->getTemperature(), gyro->getRawTemp()); - sleep(1); - } -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx b/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx deleted file mode 100644 index ca2f155..0000000 --- a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "jhd1313m1.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - // 0x62 RGB_ADDRESS, 0x3E LCD_ADDRESS - upm::Jhd1313m1 *lcd = new upm::Jhd1313m1(0, 0x3E, 0x62); - lcd->setCursor(0,0); - lcd->write("Hello World"); - lcd->setCursor(1,2); - lcd->write("Hello World"); - - printf("Sleeping for 5 seconds\n"); - sleep(5); - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/joystick12.cxx b/peripheral/libupm/examples/c++/joystick12.cxx deleted file mode 100644 index 408ca2a..0000000 --- a/peripheral/libupm/examples/c++/joystick12.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Alexander Komarov <alexander.komarov@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "joystick12.h" -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -upm::Joystick12 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - // Instantiate a joystick on analog pins A0 and A1 - sensor = new upm::Joystick12(0,1); - signal(SIGINT, sig_handler); - - // Print the X and Y input values every second - while (!is_running) { - float x = sensor->getXInput(); - float y = sensor->getYInput(); - std::cout << "Driving X:" << x << ": and Y:" << y << std::endl; - sleep(1); - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/kxcjk1013.cxx b/peripheral/libupm/examples/c++/kxcjk1013.cxx deleted file mode 100644 index 3732dbd..0000000 --- a/peripheral/libupm/examples/c++/kxcjk1013.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "kxcjk1013.h" - -using namespace std; - -int shouldRun = true; -upm::KXCJK1013* accelerometer; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -void -data_callback(char* data) -{ - float x, y, z; - accelerometer->extract3Axis(data, &x, &y, &z); - printf("%.1f %.1f %.1f\n", x, y, z); - // usleep(100); -} - -int -main() -{ - signal(SIGINT, sig_handler); - //! [Interesting] - // Instantiate a KXCJK1013 Accelerometer Sensor on iio device 0 - accelerometer = new upm::KXCJK1013(0); - accelerometer->setScale(0.019163); - accelerometer->setSamplingFrequency(25.0); - accelerometer->enable3AxisChannel(); - accelerometer->installISR(data_callback, NULL); - accelerometer->enableBuffer(16); - - while (shouldRun) { - sleep(1); - } - accelerometer->disableBuffer(); - - //! [Interesting] - cout << "Exiting" << endl; - - delete accelerometer; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/l298-stepper.cxx b/peripheral/libupm/examples/c++/l298-stepper.cxx deleted file mode 100644 index 8fe2b91..0000000 --- a/peripheral/libupm/examples/c++/l298-stepper.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "l298.h" - -using namespace std; - -int main () -{ - //! [Interesting] - - // Instantiate a Stepper motor on a L298 Dual H-Bridge. - - // This was tested with the NEMA-17 12V, 350mA, with 200 steps per rev. - upm::L298* l298 = new upm::L298(200, 3, 4, 7, 8, 9); - - l298->setSpeed(10); // 10 RPMs - l298->setDirection(upm::L298::DIR_CW); - l298->enable(true); - cout << "Rotating 1 full revolution at 10 RPM speed." << endl; - // move 200 steps, a full rev - l298->stepperSteps(200); - cout << "Sleeping for 2 seconds..." << endl; - sleep(2); - cout << "Rotating 1/2 revolution in opposite direction at 10 RPM speed." - << endl; - l298->setDirection(upm::L298::DIR_CCW); - l298->stepperSteps(100); - // release - l298->enable(false); - - //! [Interesting] - - cout << "Exiting..." << endl; - - delete l298; - return 0; -} diff --git a/peripheral/libupm/examples/c++/l298.cxx b/peripheral/libupm/examples/c++/l298.cxx deleted file mode 100644 index 8e360b2..0000000 --- a/peripheral/libupm/examples/c++/l298.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "l298.h" - -using namespace std; - -int main () -{ - //! [Interesting] - - // Instantiate one of the 2 possible DC motors on a L298 Dual - // H-Bridge. For controlling a stepper motor, see the l298-stepper - // example. - upm::L298* l298 = new upm::L298(3, 4, 7); - - cout << "Starting motor at 50% for 3 seconds..." << endl; - l298->setSpeed(50); - l298->setDirection(upm::L298::DIR_CW); - l298->enable(true); - - sleep(3); - - cout << "Reversing direction..." << endl; - l298->setDirection(upm::L298::DIR_NONE); // fast stop - l298->setDirection(upm::L298::DIR_CCW); - sleep(3); - - l298->setSpeed(0); - l298->enable(false); - - //! [Interesting] - - cout << "Exiting..." << endl; - - delete l298; - return 0; -} diff --git a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx b/peripheral/libupm/examples/c++/lcm1602-i2c.cxx deleted file mode 100644 index f405f96..0000000 --- a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: Thomas Ingleby <thomas.c.ingleby@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "lcm1602.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - upm::Lcm1602* lcd = new upm::Lcm1602(0, 0x27); - lcd->setCursor(0,0); - lcd->write("Hello World"); -//! [Interesting] - sleep(3); - lcd->setCursor(1,2); - lcd->write("Hello World"); - sleep(3); - lcd->setCursor(2,4); - lcd->write("Hello World"); - sleep(3); - lcd->setCursor(3,6); - lcd->write("Hello World"); - sleep(3); - delete lcd; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx b/peripheral/libupm/examples/c++/lcm1602-parallel.cxx deleted file mode 100644 index 642c6af..0000000 --- a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: Sergey Kiselev <sergey.kiselev@intel.com> - * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 - 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <lcm1602.h> - -int -main(int argc, char **argv) -{ -//! [Interesting] - // LCD connection: - // LCD RS pin to digital pin 8 - // LCD Enable pin to digital pin 13 - // LCD D4 pin to digital pin 2 - // LCD D5 pin to digital pin 3 - // LCD D6 pin to digital pin 4 - // LCD D7 pin to digital pin 5 - // LCD R/W pin to ground - // 10K trimmer potentiometer: - // ends to +5V and ground - // wiper to LCD VO pin (pin 3) - upm::Lcm1602 *lcd = new upm::Lcm1602(8, 13, 2, 3, 4, 5, 20, 2); - lcd->setCursor(0,0); - lcd->write("Hello World"); - lcd->setCursor(1,2); - lcd->write("Hello World"); - - printf("Sleeping for 5 seconds\n"); - sleep(5); - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/ldt0028.cxx b/peripheral/libupm/examples/c++/ldt0028.cxx deleted file mode 100644 index 8d9c8b7..0000000 --- a/peripheral/libupm/examples/c++/ldt0028.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Author: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <iomanip> -#include <cmath> -#include "ldt0028.h" - -int -main(int argc, char **argv) -{ -//! [Interesting] - const int NUMBER_OF_SECONDS = 10; - const int MICROSECONDS_PER_SECOND = 1000000; - const int SAMPLES_PER_SECOND = 50; - const int THRESHOLD = 100; - - // Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0 - upm::LDT0028* sensor = new upm::LDT0028(0); - - // Read the signal every 20 milliseconds for 10 seconds - std::cout << "For the next " << NUMBER_OF_SECONDS << " seconds, " - << SAMPLES_PER_SECOND << " samples will be taken every second." - << std::endl << std::endl; - uint16_t* buffer = new uint16_t[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND]; - for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) { - buffer[i] = (uint16_t) sensor->getSample(); - usleep(MICROSECONDS_PER_SECOND / SAMPLES_PER_SECOND); - } - - // Print the number of times the reading was greater than the threshold - int count = 0; - for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) { - if (buffer[i] > THRESHOLD) { - count++; - } - } - std::cout << sensor->name() << " exceeded the threshold value of " << - THRESHOLD << " a total of " << count << " times," << std::endl - << "out of a total of " << NUMBER_OF_SECONDS*SAMPLES_PER_SECOND - << " readings." << std::endl << std::endl; - - // Print a graphical representation of the average value sampled - // each second for the past 10 seconds, using a scale factor of 15 - std::cout << "Now printing a graphical representation of the average reading " - << std::endl << "each second for the last " - << NUMBER_OF_SECONDS << " seconds." << std::endl; - const int SCALE_FACTOR = 15; - for (int i=0; i < NUMBER_OF_SECONDS; i++) { - long sum = 0; - for (int j=0; j < SAMPLES_PER_SECOND; j++) { - sum += buffer[i*SAMPLES_PER_SECOND + j]; - } - double average = (double) sum / (double) SAMPLES_PER_SECOND; - int stars_to_print = (int) round(average / SCALE_FACTOR); - std::cout << "(" << std::setw(4) << (int) round(average) << ") | "; - for (int j=0; j<stars_to_print; j++) { - std::cout << "*"; - } - std::cout << std::endl; - } - - // Delete the sensor object - delete sensor; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/lm35.cxx b/peripheral/libupm/examples/c++/lm35.cxx deleted file mode 100644 index 8930940..0000000 --- a/peripheral/libupm/examples/c++/lm35.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "lm35.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a LM35 on analog pin A0, with a default analog - // reference voltage of 5.0 - upm::LM35 *sensor = new upm::LM35(0); - - // Every half second, sample the sensor and output the temperature - - while (shouldRun) - { - cout << "Temperature: " << sensor->getTemperature() << " C" << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/lol.cxx b/peripheral/libupm/examples/c++/lol.cxx deleted file mode 100644 index 9f2943d..0000000 --- a/peripheral/libupm/examples/c++/lol.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Alexander Komarov <alexander.komarov@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "lol.h" -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -upm::LoL *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - sensor = new upm::LoL(); - signal(SIGINT, sig_handler); - - unsigned char *buffer; - //buffer = sensor->getFramebuffer(); - int x = 0, y = 0; - while (!is_running) { - sensor->setPixel(x, y, !(sensor->getPixel(x, y))); - if (++x == 13) { x = 0; y++; } - if (y == 9) y = 0; - usleep(10000); - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/loudness.cxx b/peripheral/libupm/examples/c++/loudness.cxx deleted file mode 100644 index 44e62b0..0000000 --- a/peripheral/libupm/examples/c++/loudness.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "loudness.h" - -using namespace std; - -bool shouldRun = true; - -#define LOUDNESS_AREF 5.0 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a Loudness sensor on analog pin A0, with an analog - // reference voltage of LOUDNESS_AREF - upm::Loudness *loud = new upm::Loudness(0, LOUDNESS_AREF); - - // Every tenth of a second, sample the loudness and output it's - // corresponding analog voltage. - - while (shouldRun) - { - cout << "Detected loudness (volts): " << loud->loudness() << endl; - - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete loud; - return 0; -} diff --git a/peripheral/libupm/examples/c++/lpd8806.cxx b/peripheral/libupm/examples/c++/lpd8806.cxx deleted file mode 100644 index 8828f07..0000000 --- a/peripheral/libupm/examples/c++/lpd8806.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "lpd8806.h" -#include <signal.h> - -void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait); - -int doWork = 0; -upm::LPD8806 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - sensor = new upm::LPD8806(10, 7); - usleep (1000000); - - sensor->show (); - - while (!doWork) { - // Back-and-forth lights - scanner(127, 0, 0, 30); // red, slow - scanner(0, 0, 127, 15); // blue, fast - usleep (1000000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} - -void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait) { - int i, j, pos, dir; - - pos = 0; - dir = 1; - - for(i=0; i < ((sensor->getStripLength() - 1) * 8); i++) { - // Draw 5 pixels centered on pos. setPixelColor() will clip - // any pixels off the ends of the strip, no worries there. - // we'll make the colors dimmer at the edges for a nice pulse - // look - sensor->setPixelColor(pos - 2, r/4, g/4, b/4); - sensor->setPixelColor(pos - 1, r/2, g/2, b/2); - sensor->setPixelColor(pos, r, g, b); - sensor->setPixelColor(pos + 1, r/2, g/2, b/2); - sensor->setPixelColor(pos + 2, r/4, g/4, b/4); - - sensor->show(); - usleep (wait * 1000); - // If we wanted to be sneaky we could erase just the tail end - // pixel, but it's much easier just to erase the whole thing - // and draw a new one next time. - for(j=-2; j<= 2; j++) { - sensor->setPixelColor(pos+j, 0,0,0); - } - // Bounce off ends of strip - pos += dir; - if(pos < 0) { - pos = 1; - dir = -dir; - } else if (pos >= sensor->getStripLength()) { - pos = sensor->getStripLength() - 2; - dir = -dir; - } - } -} diff --git a/peripheral/libupm/examples/c++/lsm303.cxx b/peripheral/libupm/examples/c++/lsm303.cxx deleted file mode 100644 index f75fd5b..0000000 --- a/peripheral/libupm/examples/c++/lsm303.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <iostream> - -//! [Interesting] -#include "lsm303.h" - -int -main(int argc, char **argv) -{ - // Instantiate LSM303 compass on I2C - upm::LSM303 *sensor = new upm::LSM303(0); - - // Get the coordinate data - sensor->getCoordinates(); - int16_t* coor = sensor->getRawCoorData(); // in XYZ order. - // The sensor returns XZY, but the driver compensates and makes it XYZ - - // Print out the X, Y, and Z coordinate data using two different methods - std::cout << "coor: rX " << (int)coor[0] - << " - rY " << (int)coor[1] - << " - rZ " << (int)coor[2] - << std::endl; - std::cout << "coor: gX " << sensor->getCoorX() - << " - gY " << sensor->getCoorY() - << " - gZ " << sensor->getCoorZ() - << std::endl; - - // Get and print out the heading - std::cout << "heading: " - << sensor->getHeading() - << std::endl; - - // Get the acceleration - sensor->getAcceleration(); - int16_t* accel = sensor->getRawAccelData(); - // Print out the X, Y, and Z acceleration data using two different methods - std::cout << "acc: rX " << (int)accel[0] - << " - rY " << (int)accel[1] - << " - Z " << (int)accel[2] - << std::endl; - std::cout << "acc: gX " << sensor->getAccelX() - << " - gY " << sensor->getAccelY() - << " - gZ " << sensor->getAccelZ() - << std::endl; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/lsm9ds0.cxx b/peripheral/libupm/examples/c++/lsm9ds0.cxx deleted file mode 100644 index 66644a0..0000000 --- a/peripheral/libupm/examples/c++/lsm9ds0.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "lsm9ds0.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - // Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b, - // xm addr 1d) - upm::LSM9DS0 *sensor = new upm::LSM9DS0(); - - sensor->init(); - - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getAccelerometer(&x, &y, &z); - cout << "Accelerometer: "; - cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl; - - sensor->getGyroscope(&x, &y, &z); - cout << "Gryoscope: "; - cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl; - - sensor->getMagnetometer(&x, &y, &z); - cout << "Magnetometer: "; - cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl; - - cout << "Temperature: " << sensor->getTemperature() << endl; - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/m24lr64e.cxx b/peripheral/libupm/examples/c++/m24lr64e.cxx deleted file mode 100644 index 6c3aae0..0000000 --- a/peripheral/libupm/examples/c++/m24lr64e.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "m24lr64e.h" - -using namespace std; -using namespace upm; - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an M24LR64E on I2C bus 0 - - upm::M24LR64E *nfcTag = new upm::M24LR64E(M24LR64E_I2C_BUS); - - // This example accesses the device in the 'user' (default) mode, - // reads the last byte of data in the EEPROM, inverts it, writes - // it back, and then re-reads it. - - // Read the last byte of the EEPROM area - - int addr = M24LR64E::EEPROM_I2C_LENGTH - 1; - printf("Address: %d\n", addr); - uint8_t byte = nfcTag->readByte(addr); - printf("Read byte: %02x\n", byte); - - // Now change it to it's opposite and write it - byte = ~byte; - nfcTag->writeByte(addr, byte); - printf("Wrote inverted byte: %02x\n", byte); - - // Now read it back. - byte = nfcTag->readByte(addr); - printf("Read byte: %02x\n", byte); - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete nfcTag; - return 0; -} diff --git a/peripheral/libupm/examples/c++/max31723.cxx b/peripheral/libupm/examples/c++/max31723.cxx deleted file mode 100644 index 96082af..0000000 --- a/peripheral/libupm/examples/c++/max31723.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "max31723.h" -#include <signal.h> - -int doWork = 0; -upm::MAX31723 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - sensor = new upm::MAX31723(7); - usleep (1000000); - - while (!doWork) { - std::cout << "Temperature " << sensor->getTemperature() << std::endl; - usleep (1000000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/max31855.cxx b/peripheral/libupm/examples/c++/max31855.cxx deleted file mode 100644 index 2390d93..0000000 --- a/peripheral/libupm/examples/c++/max31855.cxx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Author: Brendan Le Foll <brendan.le.foll@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -//! [Interesting] -#include "max31855.h" - -int -main(int argc, char **argv) -{ - upm::MAX31855 *temp = new upm::MAX31855(0, 8); - - std::cout << temp->getTemp() << std::endl; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/max44000.cxx b/peripheral/libupm/examples/c++/max44000.cxx deleted file mode 100644 index 404f544..0000000 --- a/peripheral/libupm/examples/c++/max44000.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "max44000.h" - -int -main(int argc, char **argv) -{ - //! [Interesting] - upm::MAX44000 *sensor = new upm::MAX44000(0, ADDR); - std::cout << "proximity value = " << sensor->getAmbient () << std::endl; - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/max5487.cxx b/peripheral/libupm/examples/c++/max5487.cxx deleted file mode 100644 index 661be05..0000000 --- a/peripheral/libupm/examples/c++/max5487.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "max5487.h" -#include <signal.h> - -upm::MAX5487 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - sensor = new upm::MAX5487(7); - - // Power LED UP - for (int i = 0; i < 255; i++) { - sensor->setWiperA(i); - usleep (5000); - } - - // Power LED DOWN - for (int i = 0; i < 255; i++) { - sensor->setWiperA(255 - i); - usleep (5000); - } - - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/maxds3231m.cxx b/peripheral/libupm/examples/c++/maxds3231m.cxx deleted file mode 100644 index e5a6fc1..0000000 --- a/peripheral/libupm/examples/c++/maxds3231m.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "maxds3231m.h" -#include <signal.h> - -int doWork = 0; -upm::MAXDS3231M *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - upm::Time3231 t; - sensor = new upm::MAXDS3231M(0, ADDR); - - t.second = 1; - t.minute = 3; - t.hour = 3; - t.day = 3; - t.month = 3; - t.year = 3; - t.weekDay = 3; - sensor->setDate (t); // Note, second should be set to 1. - - usleep (500000); - - while (!doWork) { - if (sensor->getDate (t)) { - std::cout << (int)t.hour << ":" << (int)t.minute << ":" << (int)t.second << std::endl; - } - std::cout << "Temperature " << sensor->getTemperature() << std::endl; - usleep (1000000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/maxsonarez.cxx b/peripheral/libupm/examples/c++/maxsonarez.cxx deleted file mode 100644 index 3c3d300..0000000 --- a/peripheral/libupm/examples/c++/maxsonarez.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "maxsonarez.h" - -using namespace std; - -bool shouldRun = true; - -#define MAXSONAREZ_AREF 5.0 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a MaxSonarEZ on analog pin A1, with an analog - // reference voltage of MAXSONAREZ_AREF - upm::MAXSONAREZ *sonar = new upm::MAXSONAREZ(1, MAXSONAREZ_AREF); - - // Every second, sample the sonar and output the distance to an - // object in inches. - - // With the EZ3 version, the minimum and maximum ranges seemed to be - // between 6 and 33 inches - - while (shouldRun) - { - cout << "AREF: " << MAXSONAREZ_AREF - << ", distance in inches: " << sonar->inches() << endl; - - sleep(1); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sonar; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mcp9808.cxx b/peripheral/libupm/examples/c++/mcp9808.cxx deleted file mode 100644 index ba4e5e4..0000000 --- a/peripheral/libupm/examples/c++/mcp9808.cxx +++ /dev/null @@ -1,163 +0,0 @@ -#include <iostream> -#include <unistd.h> -#include "mcp9808.h" - -#include "mraa.hpp" - -int main() -{ - using namespace std; - -//! [Interesting] - int command; - upm::MCP9808 *temp = new upm::MCP9808(6); - - do - { - cout << endl; - cout << "1 - read temp \t" ; - cout << "2 - sleep mode \t"; - cout << "3 - wake up" << endl; - cout << "4 - set mode to " << (temp->isCelsius() == true ? "Fahrenheit" : "Celcius") << endl; - cout << "5 - show status bits" << endl; - cout << "6 - Set Tcrit \t" ; - cout << "7 - Set Tupper \t" ; - cout << "8 - Set Tlower " << endl; - cout << "9 - Display monitor temps " << endl; - cout << "10 - Enable alert default\t"; - cout << "11 - Enable alert interrupt" << endl; - cout << "12 - Clear interrupt \t" ; - cout << "13 - Clear alert mode" << endl; - cout << "14 - Get Hysteresis\t"; - cout << "15 - Set Hysteresis" << endl; - cout << "16 - Get Resolution\t"; - cout << "17 - Set Resolution" << endl; - cout << "18 - Get Manufacturer ID"<< endl; - cout << "19 - Get Device ID" << endl; - cout << "-1 - exit" << endl; - cout << "Enter a command: "; - cin >> command; - - switch(command) - { - float t; - case 1: - std::cout << "Temp: " << temp->getTemp() << "° " << (temp->isCelsius()? "Celsius" : "Fahrenheit")<< std::endl; - break; - case 2: - cout << "shutdown sensor (sleep mode)" << endl; - temp->shutDown(); - break; - case 3: - cout << "wake up sensor" << endl; - temp->shutDown(false); - break; - case 4: - cout << "set mode to " << (temp->isCelsius() ? "Fahrenheit" : "Celcius") << endl; - temp->setMode(!temp->isCelsius()); - break; - case 5: - cout << "Tcrit = " << temp->isTcrit(); - cout << " Tupper = " << temp->isTupper(); - cout << " Tlower = " << temp->isTlower(); - break; - case 6: - cout << "enter a value"; - cin >> t; - temp->setMonitorReg(temp->CRIT_TEMP, t); - break; - case 7: - cout << "enter a value"; - cin >> t; - temp->setMonitorReg(temp->UPPER_TEMP, t); - break; - case 8: - cout << "enter a value"; - cin >> t; - temp->setMonitorReg(temp->LOWER_TEMP, t); - break; - case 9: - cout << "tcrit = " << temp->getMonitorReg(temp->CRIT_TEMP) << endl; - cout << "tupper = " << temp->getMonitorReg(temp->UPPER_TEMP) << endl; - cout << "tlower = " << temp->getMonitorReg(temp->LOWER_TEMP) << endl; - break; - case 10: - cout << "set alert mode default" ; - temp->setAlertMode(temp->ALERTCTRL); - break; - case 11: - cout << "set alert mode interrupt"; - temp->setAlertMode(temp->ALERTMODE | temp->ALERTCTRL ); - break; - case 12: - temp->clearInterrupt(); - break; - case 13: - cout << "Clear alerts" << endl; - temp->clearAlertMode(); - break; - case 14: - cout << "Hysteresis: " << temp->getHysteresis() << endl; - break; - case 15: - int u; - cout << "enter 1 to 4"; - cin >> u ; - switch(u) - { - case 1: - temp->setHysteresis(temp->HYST_0); - break; - case 2: - temp->setHysteresis(temp->HYST_1_5); - break; - case 3: - temp->setHysteresis(temp->HYST_3_0); - break; - case 4: - default: - temp->setHysteresis(temp->HYST_6_0); - break; - } - break; - case 16: - cout << "Resolution: " << temp->getResolution() << endl; - break; - case 17: - int v; - cout << "enter 1 to 4"; - cin >> v ; - switch(v) - { - case 1: - temp->setResolution(temp->RES_LOW); - break; - case 2: - temp->setResolution(temp->RES_MEDIUM); - break; - case 3: - temp->setResolution(temp->RES_HIGH); - break; - case 4: - default: - temp->setResolution(temp->RES_PRECISION); - break; - } - break; - case 18: - cout << "Manufacturer ID: " << std::hex << temp->getManufacturer() << endl; - break; - case 19: - cout << "Get device ID: " << std::hex << temp->getDevicedId() << endl; - break; - case -1: - break; - default: - cout << endl << "That option is not available. Try again" << endl; - break; - } - - }while (command != -1 ); -//! [Interesting] - return MRAA_SUCCESS; -} diff --git a/peripheral/libupm/examples/c++/mg811.cxx b/peripheral/libupm/examples/c++/mg811.cxx deleted file mode 100644 index b17423c..0000000 --- a/peripheral/libupm/examples/c++/mg811.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mg811.h" - -using namespace std; - -bool shouldRun = true; - -#define MG811_AREF 5.0 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate an MG811 on analog pin A0, and digital pin D2 with an - // analog reference voltage of MG811_AREF (5.0) - upm::MG811 *sensor = new upm::MG811(0, 2, MG811_AREF); - - // Every tenth of a second, sample the sensor and output it's - // detected CO2 concentration in parts per million (ppm) - - while (shouldRun) - { - cout << "CO2 concentration in PPM: " << sensor->ppm() << endl; - - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mhz16.cxx b/peripheral/libupm/examples/c++/mhz16.cxx deleted file mode 100644 index 542dc5f..0000000 --- a/peripheral/libupm/examples/c++/mhz16.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mhz16.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main (int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a MHZ16 serial CO2 sensor on uart 0. - // This example was tested on the Grove CO2 sensor module. - - upm::MHZ16* co2 = new upm::MHZ16(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!co2->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - cout << "Make sure that the sensor has had at least 3 minutes to warm up" - << endl; - cout << "or you will not get valid results." << endl; - cout << "The temperature reported is not the ambient temperature, " << endl; - cout << "but rather the temperature of the sensor elements." << endl; - - sleep(1); - - while (shouldRun) - { - if(!co2->getData()){ - cerr << "Failed to retrieve data" << endl; - continue; - } - - cout << "CO2 concentration: " << co2->getGas() << " PPM, " - << "Temperature (in C): " << co2->getTemperature() <<endl; - - sleep(2); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete co2; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mic.cxx b/peripheral/libupm/examples/c++/mic.cxx deleted file mode 100644 index 8773d71..0000000 --- a/peripheral/libupm/examples/c++/mic.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mic.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -uint16_t buffer [128]; -upm::Microphone *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - // Attach microphone to analog port A0 - sensor = new upm::Microphone(0); - signal(SIGINT, sig_handler); - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of the averages - while (!is_running) { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx); - if (thresh) { - // do something .... - } - } - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/micsv89.cxx b/peripheral/libupm/examples/c++/micsv89.cxx deleted file mode 100644 index cf1530b..0000000 --- a/peripheral/libupm/examples/c++/micsv89.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Marc Graham <marc@m2ag.net> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <iostream> -#include <unistd.h> -#include <signal.h> -#include "micsv89.h" - -/* - * An example for using the MICSV89 sensor library. - * The MICSV89 comes in 4 variants, PWM and I2c - * in 3.3 volts and 5 volts. This library only implements - * the I2c version of the device. - * - * Device output is not valid until a warm up of 15 minutes - * of operation. - * - * Additional linker flags: -lupm-micsv89 - */ - -using namespace std; - -volatile int running = 1; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) { - cout << "Exiting program." << endl; - running = 0; - } -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - upm::MICSV89 *sensor = new upm::MICSV89(6); - - while(running) - { - sensor->update(); - while(!sensor->valid()); - cout << "co2: " << sensor->co2equ() << endl; - cout << "short: " << sensor->vocshort() << endl; - cout << "tvoc: " << sensor->tvoc() << endl; - cout << "resistor: " << sensor->resistor() << endl; - cout << "****************************" << endl; - sleep(5); - } - - delete sensor; -//! [Interesting] - - return MRAA_SUCCESS; -} diff --git a/peripheral/libupm/examples/c++/mlx90614.cxx b/peripheral/libupm/examples/c++/mlx90614.cxx deleted file mode 100644 index dbd00f4..0000000 --- a/peripheral/libupm/examples/c++/mlx90614.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mlx90614.h" -#include <signal.h> - -int doWork = 0; -upm::MLX90614 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - sensor = new upm::MLX90614(0, DEVICE_ADDR); - - while (!doWork) { - std::cout << "Object Temperature (" << sensor->readObjectTempC() << ") Ambient Temperature (" << sensor->readAmbientTempC() << ")" << std::endl; - usleep (1000000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mma7455.cxx b/peripheral/libupm/examples/c++/mma7455.cxx deleted file mode 100644 index 052919f..0000000 --- a/peripheral/libupm/examples/c++/mma7455.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mma7455.h" -#include <signal.h> -#include <pthread.h> - -int doWork = 0; -upm::MMA7455 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - sensor = new upm::MMA7455(0, ADDR); - - short x, y, z; - while (!doWork) { - sensor->readData(&x, &y, &z); - std::cout << "Accelerometer X(" << x << ") Y(" << y << ") Z(" << z << ")" << std::endl; - usleep (100000); - } - - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mma7660.cxx b/peripheral/libupm/examples/c++/mma7660.cxx deleted file mode 100644 index c426db5..0000000 --- a/peripheral/libupm/examples/c++/mma7660.cxx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "mma7660.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an MMA7660 on I2C bus 0 - - upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS, - MMA7660_DEFAULT_I2C_ADDR); - - // place device in standby mode so we can write registers - accel->setModeStandby(); - - // enable 64 samples per second - accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64); - - // place device into active mode - accel->setModeActive(); - - while (shouldRun) - { - int x, y, z; - - accel->getRawValues(&x, &y, &z); - cout << "Raw values: x = " << x - << " y = " << y - << " z = " << z - << endl; - - float ax, ay, az; - - accel->getAcceleration(&ax, &ay, &az); - cout << "Acceleration: x = " << ax - << "g y = " << ay - << "g z = " << az - << "g" << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete accel; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mpl3115a2.cxx b/peripheral/libupm/examples/c++/mpl3115a2.cxx deleted file mode 100644 index f9499d1..0000000 --- a/peripheral/libupm/examples/c++/mpl3115a2.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Author: William Penner <william.penner@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "mpl3115a2.h" - -volatile int doWork = 0; - -upm::MPL3115A2 *sensor = NULL; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) { - printf("\nCtrl-C received.\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - // Register signal handler - signal(SIGINT, sig_handler); - - //! [Interesting] - float pressure = 0.0; - float temperature = 0.0; - float altitude = 0.0; - float sealevel = 0.0; - - sensor = new upm::MPL3115A2(0, MPL3115A2_I2C_ADDRESS); - - sensor->testSensor(); - - while (!doWork) { - temperature = sensor->getTemperature(true); - pressure = sensor->getPressure(false); - altitude = sensor->getAltitude(); - sealevel = sensor->getSealevelPressure(); - - std::cout << "pressure value = " << - pressure << - ", altitude value = " << - altitude << - ", sealevel value = " << - sealevel << - ", temperature = " << - temperature << std::endl; - usleep (500000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mpr121.cxx b/peripheral/libupm/examples/c++/mpr121.cxx deleted file mode 100644 index 7998965..0000000 --- a/peripheral/libupm/examples/c++/mpr121.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "mpr121.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -void printButtons(upm::MPR121 *touch) -{ - bool buttonPressed = false; - - cout << "Buttons Pressed: "; - for (int i=0; i<12; i++) - { - if (touch->m_buttonStates & (1 << i)) - { - cout << i << " "; - buttonPressed = true; - } - } - - if (!buttonPressed) - cout << "None"; - - if (touch->m_overCurrentFault) - cout << "Over Current Fault detected!" << endl; - - cout << endl; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an MPR121 on I2C bus 0 - - upm::MPR121 *touch = new upm::MPR121(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR); - - // init according to AN3944 defaults - touch->configAN3944(); - - while (shouldRun) - { - touch->readButtons(); - printButtons(touch); - sleep(1); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete touch; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mpu60x0.cxx b/peripheral/libupm/examples/c++/mpu60x0.cxx deleted file mode 100644 index d90a017..0000000 --- a/peripheral/libupm/examples/c++/mpu60x0.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mpu9150.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - upm::MPU60X0 *sensor = new upm::MPU60X0(); - - sensor->init(); - - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getAccelerometer(&x, &y, &z); - cout << "Accelerometer: "; - cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl; - - sensor->getGyroscope(&x, &y, &z); - cout << "Gryoscope: "; - cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl; - - cout << "Temperature: " << sensor->getTemperature() << endl; - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mpu9150.cxx b/peripheral/libupm/examples/c++/mpu9150.cxx deleted file mode 100644 index d6f5da5..0000000 --- a/peripheral/libupm/examples/c++/mpu9150.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mpu9150.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - upm::MPU9150 *sensor = new upm::MPU9150(); - - sensor->init(); - - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getAccelerometer(&x, &y, &z); - cout << "Accelerometer: "; - cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl; - - sensor->getGyroscope(&x, &y, &z); - cout << "Gryoscope: "; - cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl; - - sensor->getMagnetometer(&x, &y, &z); - cout << "Magnetometer: "; - cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl; - - cout << "Temperature: " << sensor->getTemperature() << endl; - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mpu9250.cxx b/peripheral/libupm/examples/c++/mpu9250.cxx deleted file mode 100644 index fd093f9..0000000 --- a/peripheral/libupm/examples/c++/mpu9250.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mpu9250.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - upm::MPU9250 *sensor = new upm::MPU9250(); - - sensor->init(); - - while (shouldRun) - { - sensor->update(); - - float x, y, z; - - sensor->getAccelerometer(&x, &y, &z); - cout << "Accelerometer: "; - cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl; - - sensor->getGyroscope(&x, &y, &z); - cout << "Gryoscope: "; - cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl; - - sensor->getMagnetometer(&x, &y, &z); - cout << "Magnetometer: "; - cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl; - - cout << "Temperature: " << sensor->getTemperature() << endl; - cout << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/mq2.cxx b/peripheral/libupm/examples/c++/mq2.cxx deleted file mode 100644 index f3bd9ca..0000000 --- a/peripheral/libupm/examples/c++/mq2.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq2.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -uint16_t buffer [128]; -upm::MQ2 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - // Attach gas sensor to A0 - sensor = new upm::MQ2(0); - signal(SIGINT, sig_handler); - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 milliseconds; - // find the average of 128 samples; and - // print a running graph of the averages using a resolution of 5 - while (!is_running) { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq3.cxx b/peripheral/libupm/examples/c++/mq3.cxx deleted file mode 100644 index 9fd3cce..0000000 --- a/peripheral/libupm/examples/c++/mq3.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq3.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -uint16_t buffer [128]; -upm::MQ3 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - // Attach gas sensor to A0 - sensor = new upm::MQ3(0); - signal(SIGINT, sig_handler); - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 milliseconds; - // find the average of 128 samples; and - // print a running graph of the averages using a resolution of 5 - while (!is_running) { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq303a.cxx b/peripheral/libupm/examples/c++/mq303a.cxx deleted file mode 100644 index 4557de0..0000000 --- a/peripheral/libupm/examples/c++/mq303a.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "mq303a.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an mq303a sensor on analog pin A0 - - // This device uses a heater powered from an analog I/O pin. - // If using A0 as the data pin, then you need to use A1, as the heater - // pin (if using a grove mq303a). For A1, we can use the D15 gpio, - // setup as an output, and drive it low to power the heater. - - upm::MQ303A *mq303a = new upm::MQ303A(0, 15); - - cout << "Enabling heater and waiting 2 minutes for warmup." << endl; - mq303a->heaterEnable(true); - sleep(120); - - cout << "This sensor may need to warm until the value drops below about 450." - << endl; - - // Print the detected alcohol value every second - while (shouldRun) - { - int val = mq303a->value(); - - cout << "Alcohol detected (higher means stronger alcohol): " - << val << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - mq303a->heaterEnable(false); - - delete mq303a; - return 0; -} diff --git a/peripheral/libupm/examples/c++/mq4.cxx b/peripheral/libupm/examples/c++/mq4.cxx deleted file mode 100644 index 686970b..0000000 --- a/peripheral/libupm/examples/c++/mq4.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq4.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -bool shouldRun = true; - -using namespace std; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - { - shouldRun = false; - } -} - -//! [Interesting] -int main(int argc, char **argv) -{ - // Attach gas sensor to Analog A0 - upm::MQ4 *sensor = new upm::MQ4(0); - signal(SIGINT, sig_handler); - - uint16_t buffer [128]; - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asteriskss as averages - while (shouldRun) - { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - cout << "Exiting" << endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq5.cxx b/peripheral/libupm/examples/c++/mq5.cxx deleted file mode 100644 index 541bb26..0000000 --- a/peripheral/libupm/examples/c++/mq5.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq5.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -uint16_t buffer [128]; -upm::MQ5 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - sensor = new upm::MQ5(0); - signal(SIGINT, sig_handler); - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - while (!is_running) { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 7); - if (thresh) { - // do something .... - } - } - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq6.cxx b/peripheral/libupm/examples/c++/mq6.cxx deleted file mode 100644 index 0a73af1..0000000 --- a/peripheral/libupm/examples/c++/mq6.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq6.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -bool shouldRun = true; - -using namespace std; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - { - shouldRun = false; - } -} - -//! [Interesting] -int main(int argc, char **argv) -{ - // Attach gas sensor to Analog A0 - upm::MQ6 *sensor = new upm::MQ6(0); - signal(SIGINT, sig_handler); - - uint16_t buffer [128]; - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asteriskss as averages - while (shouldRun) - { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - cout << "Exiting" << endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq7.cxx b/peripheral/libupm/examples/c++/mq7.cxx deleted file mode 100644 index a6279f1..0000000 --- a/peripheral/libupm/examples/c++/mq7.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq7.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -bool shouldRun = true; - -using namespace std; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - { - shouldRun = false; - } -} - -//! [Interesting] -int main(int argc, char **argv) -{ - // Attach gas sensor to Analog A0 - upm::MQ7 *sensor = new upm::MQ7(0); - signal(SIGINT, sig_handler); - - uint16_t buffer [128]; - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asteriskss as averages - while (shouldRun) - { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - cout << "Exiting" << endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq8.cxx b/peripheral/libupm/examples/c++/mq8.cxx deleted file mode 100644 index eae583f..0000000 --- a/peripheral/libupm/examples/c++/mq8.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq8.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -bool shouldRun = true; - -using namespace std; - -void -sig_handler(int signo) -{ - if (signo == SIGINT) - { - shouldRun = false; - } -} - -//! [Interesting] -int main(int argc, char **argv) -{ - // Attach gas sensor to Analog A0 - upm::MQ8 *sensor = new upm::MQ8(0); - signal(SIGINT, sig_handler); - - uint16_t buffer [128]; - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - // Infinite loop, ends when script is cancelled - // Repeatedly, take a sample every 2 microseconds; - // find the average of 128 samples; and - // print a running graph of asteriskss as averages - while (shouldRun) - { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - cout << "Exiting" << endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/mq9.cxx b/peripheral/libupm/examples/c++/mq9.cxx deleted file mode 100644 index b62dad3..0000000 --- a/peripheral/libupm/examples/c++/mq9.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "mq9.h" -#include <signal.h> -#include <stdlib.h> -#include <sys/time.h> - -int is_running = 0; -uint16_t buffer [128]; -upm::MQ9 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - is_running = 1; - } -} - -//! [Interesting] -int -main(int argc, char **argv) -{ - sensor = new upm::MQ9(0); - signal(SIGINT, sig_handler); - - thresholdContext ctx; - ctx.averageReading = 0; - ctx.runningAverage = 0; - ctx.averagedOver = 2; - - while (!is_running) { - int len = sensor->getSampledWindow (2, 128, buffer); - if (len) { - int thresh = sensor->findThreshold (&ctx, 30, buffer, len); - sensor->printGraph(&ctx, 5); - if (thresh) { - // do something .... - } - } - } - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/nlgpio16.cxx b/peripheral/libupm/examples/c++/nlgpio16.cxx deleted file mode 100644 index 44c901e..0000000 --- a/peripheral/libupm/examples/c++/nlgpio16.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdio.h> -#include "nlgpio16.h" - -using namespace std; -using namespace upm; - -int main(int argc, char **argv) -{ - // Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0) - upm::NLGPIO16* sensor = new upm::NLGPIO16(); - - // get the Version - cout << "Device Version: " << sensor->getVersion() << endl; - // read the gpio at pin 3 - cout << "GPIO 3 Value: " << sensor->gpioRead(3) << endl; - // read the analog voltage at pin 5 - cout << "Analog 5 Voltage: " << sensor->analogReadVolts(5) << endl; - // set the gpio at pin 14 to HIGH - sensor->gpioSet(14); - - delete sensor; - return 0; -} - -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx b/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx deleted file mode 100644 index f4a1d21..0000000 --- a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <string.h> -#include <unistd.h> -#include <iostream> -#include "nrf24l01.h" -#include <signal.h> -#include <stdio.h> -#include <vector> - -int running = 0; -upm::NRF24L01 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - running = 1; - } -} - -void nrf_handler () { -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - - sensor = new upm::NRF24L01(7, 8); - sensor->setBeaconingMode (); - - std::vector<std::string> msgs; - - msgs.push_back ("Hello World 1!!!"); - msgs.push_back ("Hello World 2!!!"); - msgs.push_back ("Hello World 3!!!"); - msgs.push_back ("Hello World 4!!!"); - msgs.push_back ("Hello World 5!!!"); - - signal(SIGINT, sig_handler); - - while (!running) { - for (std::vector<std::string>::iterator item = msgs.begin(); item != msgs.end(); ++item) { - std::cout << "BROADCASTING " << (*item).c_str() << std::endl; - - for (int i = 0; i < 3; i++) { - sensor->sendBeaconingMsg ((uint8_t*) (*item).c_str()); - usleep (1000000); - } - } - } - - std::cout << "exiting application" << std::endl; - - msgs.clear(); - delete sensor; - - //! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx b/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx deleted file mode 100644 index 344cb0c..0000000 --- a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <string.h> -#include <unistd.h> -#include <iostream> -#include "nrf24l01.h" -#include <signal.h> - -int running = 0; -upm::NRF24L01 *comm = NULL; - -uint8_t local_address[5] = {0x01, 0x01, 0x01, 0x01, 0x01}; -uint8_t broadcast_address[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - running = 1; - } -} - -//! [Interesting] -void nrf_handler () { - std::cout << "Reciever :: " << *((uint32_t *)&(comm->m_rxBuffer[0])) << std::endl; -} - -int -main(int argc, char **argv) -{ - - comm = new upm::NRF24L01(7, 8); - comm->setSourceAddress ((uint8_t *) local_address); - comm->setDestinationAddress ((uint8_t *) broadcast_address); - comm->setPayload (MAX_BUFFER); - comm->configure (); - comm->setSpeedRate (upm::NRF_250KBPS); - comm->setChannel (99); - comm->setDataReceivedHandler (nrf_handler); - - signal(SIGINT, sig_handler); - - while (!running) { - comm->pollListener (); - } - - std::cout << "exiting application" << std::endl; - - delete comm; - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx b/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx deleted file mode 100644 index 5d9f7cc..0000000 --- a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <string.h> -#include <unistd.h> -#include <iostream> -#include "nrf24l01.h" -#include <signal.h> - -int running = 0; -upm::NRF24L01 *comm = NULL; - -uint8_t destAddress[5] = {0x01, 0x01, 0x01, 0x01, 0x01}; -uint8_t srcAddress[5] = {0x01, 0x01, 0x01, 0x01, 0x02}; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - running = 1; - } -} - -void nrf_handler () { -} - -int -main(int argc, char **argv) -{ -//! [Interesting] - uint32_t dummyData = 0; - comm = new upm::NRF24L01(7, 8); - comm->setSourceAddress ((uint8_t *) srcAddress); - comm->setDestinationAddress ((uint8_t *) destAddress); - comm->setPayload (MAX_BUFFER); - comm->setChannel (99); - comm->configure (); - comm->setDataReceivedHandler (nrf_handler); - - signal(SIGINT, sig_handler); - - while (!running) { - memcpy (comm->m_txBuffer, &dummyData, sizeof (dummyData)); - comm->send (); - std::cout << "devi2 :: sending data ...." << dummyData << std::endl; - usleep (3000000); - dummyData += 3000; - } - - std::cout << "exiting application" << std::endl; - - delete comm; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx b/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx deleted file mode 100644 index 534e32b..0000000 --- a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "nrf8001.h" -#include "nrf8001-broadcast.h" -#include <lib_aci.h> -#include <aci_setup.h> -#include <signal.h> - -#ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT - static services_pipe_type_mapping_t - services_pipe_type_mapping[NUMBER_OF_PIPES] = SERVICES_PIPE_TYPE_MAPPING_CONTENT; -#else - #define NUMBER_OF_PIPES 0 - static services_pipe_type_mapping_t * services_pipe_type_mapping = NULL; -#endif - -/** - * Store the setup for the nRF8001 in the flash of the AVR to save on RAM - */ -static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] = SETUP_MESSAGES_CONTENT; - -/** - * aci_struct that will contain - * total initial credits - * current credit - * current state of the aci (setup/standby/active/sleep) - * open remote pipe pending - * close remote pipe pending - * Current pipe available bitmap - * Current pipe closed bitmap - * Current connection interval, slave latency and link supervision timeout - * Current State of the the GATT client (Service Discovery) - * Status of the bond (R) Peer address - */ -static struct aci_state_t aci_state; - -/** - * Temporary buffers for sending ACI commands - */ -static hal_aci_evt_t aci_data; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - } -} - -void -init_aci_setup () { - /** - * Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 - */ - if (NULL != services_pipe_type_mapping) { - aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0]; - } else { - aci_state.aci_setup_info.services_pipe_type_mapping = NULL; - } - - aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES; - aci_state.aci_setup_info.setup_msgs = setup_msgs; - aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES; -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - - init_aci_setup (); - init_local_interfaces (&aci_state, 10, 8, 4); - - while (1) { - static bool setup_required = false; - if (lib_aci_event_get (&aci_state, &aci_data)) { - aci_evt_t * aci_evt; - aci_evt = &aci_data.evt; - - switch(aci_evt->evt_opcode) { - /** - As soon as you reset the nRF8001 you will get an ACI Device Started Event - */ - case ACI_EVT_DEVICE_STARTED: { - aci_state.data_credit_available = aci_evt->params.device_started.credit_available; - switch(aci_evt->params.device_started.device_mode) { - case ACI_DEVICE_SETUP: - /** - When the device is in the setup mode - */ - printf ("Evt Device Started: Setup\n"); - setup_required = true; - break; - - case ACI_DEVICE_STANDBY: - printf ("Evt Device Started: Standby\n"); - lib_aci_broadcast(10/* in seconds */, 0x0100 /* advertising interval 100ms */); - printf ("Broadcasting started\n"); - break; - } - } - break; //ACI Device Started Event - - case ACI_EVT_CMD_RSP: - if (ACI_STATUS_SUCCESS != aci_evt->params.cmd_rsp.cmd_status) { - printf ("ACI_EVT_CMD_RSP\n"); - while (1); - } - break; - - case ACI_EVT_CONNECTED: - printf ("ACI_EVT_CONNECTED\n"); - break; - - case ACI_EVT_PIPE_STATUS: - printf ("ACI_EVT_PIPE_STATUS\n"); - break; - - case ACI_EVT_DISCONNECTED: - if (ACI_STATUS_ERROR_ADVT_TIMEOUT == aci_evt->params.disconnected.aci_status) { - printf ("Broadcasting timed out\n"); - } else { - printf ("Evt Disconnected. Link Loss\n"); - } - break; - - case ACI_EVT_DATA_RECEIVED: - printf ("ACI_EVT_DATA_RECEIVED\n"); - break; - - case ACI_EVT_HW_ERROR: - printf ("ACI_EVT_HW_ERROR\n"); - break; - } - } - - if (setup_required) { - if (SETUP_SUCCESS == do_aci_setup(&aci_state)) { - setup_required = false; - } - } - usleep (100); - } - - close_local_interfaces (&aci_state); - - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.h b/peripheral/libupm/examples/c++/nrf8001-broadcast.h deleted file mode 100644 index b6f8cb5..0000000 --- a/peripheral/libupm/examples/c++/nrf8001-broadcast.h +++ /dev/null @@ -1,93 +0,0 @@ -#include "hal_platform.h" -#include "aci.h" - -#pragma once - -#define PIPE_GAP_DEVICE_NAME_SET 1 - -#define NUMBER_OF_PIPES 1 - -#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ - {ACI_STORE_LOCAL, ACI_SET}, \ -} - -#define GAP_PPCP_MAX_CONN_INT 0xffff /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ -#define GAP_PPCP_MIN_CONN_INT 0xffff /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific maximum*/ -#define GAP_PPCP_SLAVE_LATENCY 0 -#define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ - -#define NB_SETUP_MESSAGES 13 -#define SETUP_MESSAGES_CONTENT {\ - {0x00,\ - {\ - 0x07,0x06,0x00,0x00,0x03,0x02,0x41,0xd7,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x10,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x90,0x00,0x64,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x10,0x38,0x02,0xff,0x02,0x58,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x05,0x06,0x10,0x54,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ - 0x02,0x28,0x03,0x01,0x0e,0x03,0x00,0x00,0x2a,0x04,0x14,0x0b,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x1c,0x05,0x00,0x03,0x2a,0x00,0x01,0x62,0x63,0x61,0x73,0x74,0x63,0x73,0x65,0x6d,0x69,\ - 0x2e,0x04,0x04,0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x38,0x00,0x01,0x2a,0x06,0x04,0x03,0x02,0x00,0x05,0x2a,0x01,0x01,0x00,0x00,0x04,0x04,\ - 0x05,0x05,0x00,0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x54,0x06,0x04,0x09,0x08,0x00,0x07,0x2a,0x04,0x01,0xff,0xff,0xff,0xff,0x00,0x00,0xff,\ - 0xff,0x04,0x04,0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,\ - },\ - },\ - {0x00,\ - {\ - 0x04,0x06,0x20,0x70,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x0d,0x06,0x40,0x00,0x2a,0x00,0x01,0x00,0x80,0x04,0x00,0x03,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x06,0x06,0x60,0x00,0x00,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x06,0x06,0xf0,0x00,0x03,0x4c,0xf2,\ - },\ - },\ -} diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx b/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx deleted file mode 100644 index 5866a0f..0000000 --- a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "nrf8001.h" -#include "nrf8001-helloworld.h" -#include <lib_aci.h> -#include <aci_setup.h> -#include <signal.h> -#include "uart_over_ble.h" - -/* - * You can use the nRF UART app in the Apple iOS app store and Google Play for Android 4.3 for Samsung Galaxy S4 - * with this helloworld application - */ - -#ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT - static services_pipe_type_mapping_t - services_pipe_type_mapping[NUMBER_OF_PIPES] = SERVICES_PIPE_TYPE_MAPPING_CONTENT; -#else - #define NUMBER_OF_PIPES 0 - static services_pipe_type_mapping_t * services_pipe_type_mapping = NULL; -#endif - -/** - * Store the setup for the nRF8001 in the flash of the AVR to save on RAM - */ -static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] = SETUP_MESSAGES_CONTENT; - -/** - * aci_struct that will contain - * total initial credits - * current credit - * current state of the aci (setup/standby/active/sleep) - * open remote pipe pending - * close remote pipe pending - * Current pipe available bitmap - * Current pipe closed bitmap - * Current connection interval, slave latency and link supervision timeout - * Current State of the the GATT client (Service Discovery) - * Status of the bond (R) Peer address - */ -static struct aci_state_t aci_state; - -/** - * Temporary buffers for sending ACI commands - */ -static hal_aci_evt_t aci_data; - -/* -Timing change state variable -*/ -static bool timing_change_done = false; - -/* -Used to test the UART TX characteristic notification -*/ -static uart_over_ble_t uart_over_ble; -static uint8_t uart_buffer[20]; -static uint8_t uart_buffer_len = 0; -static uint8_t dummychar = 0; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - } -} - -void -init_aci_setup () { - /** - * Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 - */ - if (NULL != services_pipe_type_mapping) { - aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0]; - } else { - aci_state.aci_setup_info.services_pipe_type_mapping = NULL; - } - - aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES; - aci_state.aci_setup_info.setup_msgs = setup_msgs; - aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES; -} - -void -uart_over_ble_init (void) { - uart_over_ble.uart_rts_local = true; -} - -bool -uart_tx (uint8_t *buffer, uint8_t buffer_len) { - bool status = false; - - if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX) && - (aci_state.data_credit_available >= 1)) { - status = lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, buffer, buffer_len); - if (status) { - aci_state.data_credit_available--; - } - } - - return status; -} - -bool -uart_process_control_point_rx(uint8_t *byte, uint8_t length) { - bool status = false; - aci_ll_conn_params_t *conn_params; - - if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_TX) ) { - switch (*byte) { - /* - Queues a ACI Disconnect to the nRF8001 when this packet is received. - May cause some of the UART packets being sent to be dropped - */ - case UART_OVER_BLE_DISCONNECT: - /* - Parameters: - None - */ - lib_aci_disconnect(&aci_state, ACI_REASON_TERMINATE); - status = true; - break; - - /* - Queues an ACI Change Timing to the nRF8001 - */ - case UART_OVER_BLE_LINK_TIMING_REQ: - /* - Parameters: - Connection interval min: 2 bytes - Connection interval max: 2 bytes - Slave latency: 2 bytes - Timeout: 2 bytes - Same format as Peripheral Preferred Connection Parameters (See nRFgo studio -> nRF8001 Configuration -> GAP Settings - Refer to the ACI Change Timing Request in the nRF8001 Product Specifications - */ - conn_params = (aci_ll_conn_params_t *)(byte+1); - lib_aci_change_timing( conn_params->min_conn_interval, - conn_params->max_conn_interval, - conn_params->slave_latency, - conn_params->timeout_mult); - status = true; - break; - - /* - Clears the RTS of the UART over BLE - */ - case UART_OVER_BLE_TRANSMIT_STOP: - /* - Parameters: - None - */ - uart_over_ble.uart_rts_local = false; - status = true; - break; - - - /* - Set the RTS of the UART over BLE - */ - case UART_OVER_BLE_TRANSMIT_OK: - /* - Parameters: - None - */ - uart_over_ble.uart_rts_local = true; - status = true; - break; - } - } - - return status; -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - - init_aci_setup (); - init_local_interfaces (&aci_state, 10, 8, 4); - - while (1) { - static bool setup_required = false; - - // We enter the if statement only when there is a ACI event available to be processed - if (lib_aci_event_get(&aci_state, &aci_data)) { - aci_evt_t * aci_evt; - aci_evt = &aci_data.evt; - switch(aci_evt->evt_opcode) { - /** - As soon as you reset the nRF8001 you will get an ACI Device Started Event - */ - case ACI_EVT_DEVICE_STARTED: { - aci_state.data_credit_total = aci_evt->params.device_started.credit_available; - switch(aci_evt->params.device_started.device_mode) { - case ACI_DEVICE_SETUP: - /** - When the device is in the setup mode - */ - printf ("Evt Device Started: Setup \n"); - setup_required = true; - break; - - case ACI_DEVICE_STANDBY: - printf ("Evt Device Started: Standby \n"); - // Looking for an iPhone by sending radio advertisements - // When an iPhone connects to us we will get an ACI_EVT_CONNECTED event from the nRF8001 - if (aci_evt->params.device_started.hw_error) { - usleep (20000); //Handle the HW error event correctly. - } else { - lib_aci_connect(0/* in seconds : 0 means forever */, 0x0050 /* advertising interval 50ms*/); - printf ("Advertising started \n"); - } - break; - } - } - break; // ACI Device Started Event - - case ACI_EVT_CMD_RSP: - //If an ACI command response event comes with an error -> stop - if (ACI_STATUS_SUCCESS != aci_evt->params.cmd_rsp.cmd_status) { - //ACI ReadDynamicData and ACI WriteDynamicData will have status codes of - //TRANSACTION_CONTINUE and TRANSACTION_COMPLETE - //all other ACI commands will have status code of ACI_STATUS_SCUCCESS for a successful command - printf ("ACI_EVT_CMD_RSP \n"); - } - if (ACI_CMD_GET_DEVICE_VERSION == aci_evt->params.cmd_rsp.cmd_opcode) { - //Store the version and configuration information of the nRF8001 in the Hardware Revision String Characteristic - lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET, - (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version), sizeof(aci_evt_cmd_rsp_params_get_device_version_t)); - } - break; - - case ACI_EVT_CONNECTED: - printf ("ACI_EVT_CONNECTED"); - uart_over_ble_init (); - timing_change_done = false; - aci_state.data_credit_available = aci_state.data_credit_total; - - /* - Get the device version of the nRF8001 and store it in the Hardware Revision String - */ - lib_aci_device_version(); - break; - - case ACI_EVT_PIPE_STATUS: - printf ("ACI_EVT_PIPE_STATUS \n"); - if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX) && (false == timing_change_done)) { - lib_aci_change_timing_GAP_PPCP(); // change the timing on the link as specified in the nRFgo studio -> nRF8001 conf. -> GAP. - // Used to increase or decrease bandwidth - timing_change_done = true; - - char hello[]="Hello World, works"; - uart_tx((uint8_t *)&hello[0], strlen(hello)); - } - break; - - case ACI_EVT_TIMING: - printf ("Evt link connection interval changed \n"); - lib_aci_set_local_data(&aci_state, - PIPE_UART_OVER_BTLE_UART_LINK_TIMING_CURRENT_SET, - (uint8_t *)&(aci_evt->params.timing.conn_rf_interval), /* Byte aligned */ - PIPE_UART_OVER_BTLE_UART_LINK_TIMING_CURRENT_SET_MAX_SIZE); - break; - - case ACI_EVT_DISCONNECTED: - printf ("ACI_EVT_DISCONNECTED \n"); - lib_aci_connect(0/* in seconds : 0 means forever */, 0x0050 /* advertising interval 50ms*/); - printf ("Advertising started \n"); - break; - - case ACI_EVT_DATA_RECEIVED: - if (PIPE_UART_OVER_BTLE_UART_RX_RX == aci_evt->params.data_received.rx_data.pipe_number) { - for(int i=0; i<aci_evt->len - 2; i++) { - uart_buffer[i] = aci_evt->params.data_received.rx_data.aci_data[i]; - } - - uart_buffer_len = aci_evt->len - 2; - if (lib_aci_is_pipe_available(&aci_state, PIPE_UART_OVER_BTLE_UART_TX_TX)) { - } - } - - if (PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_RX == aci_evt->params.data_received.rx_data.pipe_number) { - //Subtract for Opcode and Pipe number - uart_process_control_point_rx(&aci_evt->params.data_received.rx_data.aci_data[0], aci_evt->len - 2); - } - - printf ("Incomming data - %s\n", uart_buffer); - break; - - case ACI_EVT_DATA_CREDIT: - printf ("ACI_EVT_DATA_CREDIT \n"); - aci_state.data_credit_available = aci_state.data_credit_available + aci_evt->params.data_credit.credit; - break; - - case ACI_EVT_PIPE_ERROR: - printf ("ACI_EVT_PIPE_ERROR \n"); - //Increment the credit available as the data packet was not sent. - //The pipe error also represents the Attribute protocol Error Response sent from the peer and that should not be counted - //for the credit. - if (ACI_STATUS_ERROR_PEER_ATT_ERROR != aci_evt->params.pipe_error.error_code) { - aci_state.data_credit_available++; - } - break; - - case ACI_EVT_HW_ERROR: - printf ("ACI_EVT_HW_ERROR \n"); - lib_aci_connect(0/* in seconds, 0 means forever */, 0x0050 /* advertising interval 50ms*/); - printf ("Advertising started \n"); - break; - - } - } - - /* setup_required is set to true when the device starts up and enters setup mode. - * It indicates that do_aci_setup() should be called. The flag should be cleared if - * do_aci_setup() returns ACI_STATUS_TRANSACTION_COMPLETE. - */ - if(setup_required) { - if (SETUP_SUCCESS == do_aci_setup(&aci_state)) { - setup_required = false; - } - } - - usleep (100); - } - - close_local_interfaces (&aci_state); - - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.h b/peripheral/libupm/examples/c++/nrf8001-helloworld.h deleted file mode 100644 index ec566b5..0000000 --- a/peripheral/libupm/examples/c++/nrf8001-helloworld.h +++ /dev/null @@ -1,254 +0,0 @@ -#include "hal_platform.h" -#include "aci.h" - -#pragma once - -#define SETUP_ID 0 -#define SETUP_FORMAT 2 /** nRF8001 Cx */ -#define ACI_DYNAMIC_DATA_SIZE 263 - -/* Service: GATT - Characteristic: Service Changed - Pipe: TX_ACK */ -#define PIPE_GATT_SERVICE_CHANGED_TX_ACK 1 -#define PIPE_GATT_SERVICE_CHANGED_TX_ACK_MAX_SIZE 4 - -/* Service: Device Information - Characteristic: Hardware Revision String - Pipe: SET */ -#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET 2 -#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET_MAX_SIZE 9 - -/* Service: Device Information - Characteristic: Manufacturer Name String - Pipe: SET */ -#define PIPE_DEVICE_INFORMATION_MANUFACTURER_NAME_STRING_SET 3 -#define PIPE_DEVICE_INFORMATION_MANUFACTURER_NAME_STRING_SET_MAX_SIZE 20 - -/* Service: Device Information - Characteristic: Model Number String - Pipe: SET */ -#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET 4 -#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE 8 - -/* Service: Device Information - Characteristic: Firmware Revision String - Pipe: SET */ -#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET 5 -#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET_MAX_SIZE 4 - -/* Service: Device Information - Characteristic: PNP_ID - Pipe: SET */ -#define PIPE_DEVICE_INFORMATION_PNP_ID_SET 6 -#define PIPE_DEVICE_INFORMATION_PNP_ID_SET_MAX_SIZE 7 - -/* Service: UART over BTLE - Characteristic: UART RX - Pipe: RX */ -#define PIPE_UART_OVER_BTLE_UART_RX_RX 7 -#define PIPE_UART_OVER_BTLE_UART_RX_RX_MAX_SIZE 20 - -/* Service: UART over BTLE - Characteristic: UART TX - Pipe: TX */ -#define PIPE_UART_OVER_BTLE_UART_TX_TX 8 -#define PIPE_UART_OVER_BTLE_UART_TX_TX_MAX_SIZE 20 - -/* Service: UART over BTLE - Characteristic: UART Control Point - Pipe: TX */ -#define PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_TX 9 -#define PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_TX_MAX_SIZE 9 - -/* Service: UART over BTLE - Characteristic: UART Control Point - Pipe: RX */ -#define PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_RX 10 -#define PIPE_UART_OVER_BTLE_UART_CONTROL_POINT_RX_MAX_SIZE 9 - -/* Service: UART over BTLE - Characteristic: UART Link Timing Current - Pipe: SET */ -#define PIPE_UART_OVER_BTLE_UART_LINK_TIMING_CURRENT_SET 11 -#define PIPE_UART_OVER_BTLE_UART_LINK_TIMING_CURRENT_SET_MAX_SIZE 6 - - -#define NUMBER_OF_PIPES 11 - -#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ - {ACI_STORE_LOCAL, ACI_TX_ACK}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ - {ACI_STORE_LOCAL, ACI_RX}, \ - {ACI_STORE_LOCAL, ACI_TX}, \ - {ACI_STORE_LOCAL, ACI_TX}, \ - {ACI_STORE_LOCAL, ACI_RX}, \ - {ACI_STORE_LOCAL, ACI_SET}, \ -} - -#define GAP_PPCP_MAX_CONN_INT 0x12 /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ -#define GAP_PPCP_MIN_CONN_INT 0xa /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ -#define GAP_PPCP_SLAVE_LATENCY 0 -#define GAP_PPCP_CONN_TIMEOUT 0xa /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ - -#define NB_SETUP_MESSAGES 30 -#define SETUP_MESSAGES_CONTENT {\ - {0x00,\ - {\ - 0x07,0x06,0x00,0x00,0x02,0x02,0x41,0xfe,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x0b,0x01,0x01,0x00,0x00,0x06,0x00,0x00,\ - 0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1e,0x06,0x10,0x1c,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x14,0x03,0x90,0x01,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ - 0x02,0x28,0x03,0x01,0x02,0x03,0x00,0x00,0x2a,0x04,0x04,0x14,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x1c,0x05,0x00,0x03,0x2a,0x00,0x01,0x48,0x65,0x6c,0x6c,0x6f,0x63,0x73,0x65,0x6d,0x69,\ - 0x2e,0x63,0x6f,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x38,0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,0x00,0x01,0x2a,0x06,0x04,0x03,0x02,\ - 0x00,0x05,0x2a,0x01,0x01,0x80,0x00,0x04,0x04,0x05,0x05,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x54,0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,0x06,0x04,0x09,0x08,0x00,0x07,0x2a,\ - 0x04,0x01,0x0a,0x00,0x12,0x00,0x00,0x00,0x0a,0x00,0x04,0x04,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x70,0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,0x04,0x04,0x05,0x05,0x00,0x09,0x28,\ - 0x03,0x01,0x22,0x0a,0x00,0x05,0x2a,0x26,0x04,0x05,0x04,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0x8c,0x0a,0x2a,0x05,0x01,0x00,0x00,0x00,0x00,0x46,0x14,0x03,0x02,0x00,0x0b,0x29,0x02,\ - 0x01,0x00,0x00,0x04,0x04,0x02,0x02,0x00,0x0c,0x28,0x00,0x01,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0xa8,0x0a,0x18,0x04,0x04,0x05,0x05,0x00,0x0d,0x28,0x03,0x01,0x02,0x0e,0x00,0x27,0x2a,\ - 0x04,0x04,0x09,0x01,0x00,0x0e,0x2a,0x27,0x01,0x0a,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x05,0x05,0x00,0x0f,0x28,0x03,0x01,0x02,\ - 0x10,0x00,0x29,0x2a,0x04,0x04,0x14,0x02,0x00,0x10,0x2a,0x29,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0xe0,0x01,0x30,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x05,0x05,0x00,0x11,0x28,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x20,0xfc,0x03,0x01,0x02,0x12,0x00,0x24,0x2a,0x04,0x04,0x08,0x02,0x00,0x12,0x2a,0x24,0x01,\ - 0x31,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x05,0x05,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0x18,0x00,0x13,0x28,0x03,0x01,0x02,0x14,0x00,0x26,0x2a,0x04,0x04,0x04,0x02,0x00,0x14,\ - 0x2a,0x26,0x01,0x33,0x34,0x00,0x00,0x04,0x04,0x05,0x05,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0x34,0x15,0x28,0x03,0x01,0x02,0x16,0x00,0x50,0x2a,0x06,0x04,0x08,0x07,0x00,0x16,0x2a,\ - 0x50,0x01,0x02,0x00,0x00,0xaa,0xaa,0xcc,0xcc,0x04,0x04,0x10,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0x50,0x10,0x00,0x17,0x28,0x00,0x01,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,0x93,0xf3,\ - 0xa3,0xb5,0x01,0x00,0x40,0x6e,0x04,0x04,0x13,0x13,0x00,0x18,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0x6c,0x28,0x03,0x01,0x04,0x19,0x00,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,0x93,0xf3,\ - 0xa3,0xb5,0x02,0x00,0x40,0x6e,0x44,0x10,0x14,0x00,0x00,0x19,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0x88,0x00,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x13,0x13,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0xa4,0x1a,0x28,0x03,0x01,0x10,0x1b,0x00,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,0x93,\ - 0xf3,0xa3,0xb5,0x03,0x00,0x40,0x6e,0x14,0x00,0x14,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0xc0,0x1b,0x00,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x14,0x03,0x02,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0xdc,0x00,0x1c,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,0x1d,0x28,0x03,0x01,\ - 0x14,0x1e,0x00,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,0x93,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x21,0xf8,0xf3,0xa3,0xb5,0x04,0x00,0x40,0x6e,0x54,0x10,0x09,0x00,0x00,0x1e,0x00,0x04,0x02,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x14,0x03,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x22,0x14,0x02,0x00,0x1f,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x13,0x13,0x00,0x20,0x28,0x03,\ - 0x01,0x02,0x21,0x00,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,\ - },\ - },\ - {0x00,\ - {\ - 0x1b,0x06,0x22,0x30,0x93,0xf3,0xa3,0xb5,0x05,0x00,0x40,0x6e,0x06,0x04,0x07,0x06,0x00,0x21,0x00,0x05,\ - 0x02,0xff,0xff,0xff,0xff,0xff,0xff,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x40,0x00,0x2a,0x05,0x01,0x00,0x04,0x04,0x00,0x0a,0x00,0x0b,0x2a,0x27,0x01,0x00,0x80,0x04,\ - 0x00,0x0e,0x00,0x00,0x2a,0x29,0x01,0x00,0x80,0x04,0x00,0x10,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x40,0x1c,0x00,0x00,0x2a,0x24,0x01,0x00,0x80,0x04,0x00,0x12,0x00,0x00,0x2a,0x26,0x01,0x00,\ - 0x80,0x04,0x00,0x14,0x00,0x00,0x2a,0x50,0x01,0x00,0x80,0x04,\ - },\ - },\ - {0x00,\ - {\ - 0x1f,0x06,0x40,0x38,0x00,0x16,0x00,0x00,0x00,0x02,0x02,0x00,0x08,0x04,0x00,0x19,0x00,0x00,0x00,0x03,\ - 0x02,0x00,0x02,0x04,0x00,0x1b,0x00,0x1c,0x00,0x04,0x02,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x13,0x06,0x40,0x54,0x0a,0x04,0x00,0x1e,0x00,0x1f,0x00,0x05,0x02,0x00,0x80,0x04,0x00,0x21,0x00,0x00,\ - },\ - },\ - {0x00,\ - {\ - 0x13,0x06,0x50,0x00,0x9e,0xca,0xdc,0x24,0x0e,0xe5,0xa9,0xe0,0x93,0xf3,0xa3,0xb5,0x00,0x00,0x40,0x6e,\ - },\ - },\ - {0x00,\ - {\ - 0x06,0x06,0xf0,0x00,0x02,0xb2,0xd1,\ - },\ - },\ -} diff --git a/peripheral/libupm/examples/c++/nunchuck.cxx b/peripheral/libupm/examples/c++/nunchuck.cxx deleted file mode 100644 index 4b9d617..0000000 --- a/peripheral/libupm/examples/c++/nunchuck.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "nunchuck.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a nunchuck controller bus 0 - upm::NUNCHUCK *nunchuck = new upm::NUNCHUCK(0); - - // always do this first - cout << "Initializing... " << endl; - if (!nunchuck->init()) - { - cerr << "nunchuck->init() failed." << endl; - return 0; - } - - while (shouldRun) - { - nunchuck->update(); - - cout << "stickX: " << nunchuck->stickX - << ", stickY: " << nunchuck->stickY << endl; - cout << "accelX: " << nunchuck->accelX - << ", accelY: " << nunchuck->accelY - << ", accelZ: " << nunchuck->accelZ << endl; - - cout << "button C: " - << ((nunchuck->buttonC) ? "pressed" : "not pressed") << endl; - cout << "button Z: " - << ((nunchuck->buttonZ) ? "pressed" : "not pressed") << endl; - cout << endl; - - usleep(100000); - } - //! [Interesting] - - delete nunchuck; - return 0; -} diff --git a/peripheral/libupm/examples/c++/otp538u.cxx b/peripheral/libupm/examples/c++/otp538u.cxx deleted file mode 100644 index ea6e3b3..0000000 --- a/peripheral/libupm/examples/c++/otp538u.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <iomanip> -#include <signal.h> -#include "otp538u.h" - -using namespace std; - -bool shouldRun = true; - -// analog voltage, usually 3.3 or 5.0 -#define OTP538U_AREF 5.0 - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a OTP538U on analog pins A0 and A1 - // A0 is used for the Ambient Temperature and A1 is used for the - // Object temperature. - upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF); - - // Output ambient and object temperatures - while (shouldRun) - { - cout << "Ambient temp: " << std::fixed << setprecision(2) - << temps->ambientTemperature() - << " C, Object temp: " << temps->objectTemperature() - << " C" << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete temps; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ozw.cxx b/peripheral/libupm/examples/c++/ozw.cxx deleted file mode 100644 index 40c30f4..0000000 --- a/peripheral/libupm/examples/c++/ozw.cxx +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> - -#include "ozw.h" - -using namespace std; - -int main(int argc, char **argv) -{ -//! [Interesting] - - string defaultDev = "/dev/ttyACM0"; - - // if an argument was specified, use it as the device instead - if (argc > 1) - defaultDev = string(argv[1]); - - // Instantiate an OZW instance - upm::OZW *sensor = new upm::OZW(); - - // The first thing to do is create options, then lock them when done. - sensor->optionsCreate(); - sensor->optionsLock(); - - // Next, initialize it. - cout << "Initializing, this may take awhile depending on your ZWave network" - << endl; - - if (!sensor->init(defaultDev)) - { - cerr << "Init failed." << endl; - return 0; - } - cout << "Initialization complete" << endl; - - cout << "Dumping nodes..." << endl; - - sensor->dumpNodes(); - - // The following is example output of dumpNodes: - // - // Dumping nodes... - // Node 1: Z-Stick Gen5 - // Node 2: Smart Switch 6 - // Index: 0, Type: bool, Label: Switch, Value: False - // Index: 2, Type: float, Label: Energy, Value: 1.190 kWh - // Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh - // Index: 4, Type: int32, Label: Interval, Value: 1521 seconds - // Index: 5, Type: float, Label: Power, Value: 0.000 W - // Index: 6, Type: float, Label: Voltage, Value: 121.256 V - // Index: 7, Type: float, Label: Current, Value: 0.000 A - // Index: 8, Type: bool, Label: Exporting, Value: False - // Index: 45, Type: list, Label: Day, Value: Friday - // Index: 46, Type: byte, Label: Hour, Value: 5 - // Index: 47, Type: byte, Label: Minute, Value: 53 - // Node 3: Multi Sensor - // Index: 0, Type: bool, Label: Sensor, Value: True - // Index: 1, Type: float, Label: Temperature, Value: 72.8 F - // Index: 2, Type: float, Label: Luminance, Value: 4 lux - // Index: 3, Type: float, Label: Relative Humidity, Value: 22 % - // Index: 17, Type: byte, Label: Battery Level, Value: 98 % - // Node 5: Minimote - // Node 6: Smart Energy Switch - // Index: 0, Type: bool, Label: Switch, Value: False - // Index: 2, Type: float, Label: Power, Value: 0.000 W - // Index: 3, Type: float, Label: Energy, Value: 1.609 kWh - // Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh - // Index: 5, Type: int32, Label: Interval, Value: 1521 seconds - // Index: 6, Type: float, Label: Power, Value: 0.000 W - // Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W - // Index: 8, Type: int32, Label: Interval, Value: 1521 seconds - // Index: 9, Type: bool, Label: Exporting, Value: False - // Node 7: Smart Energy Switch - // Index: 0, Type: bool, Label: Switch, Value: False - // Index: 2, Type: float, Label: Power, Value: 0.000 W - // Index: 3, Type: float, Label: Energy, Value: 0.000 kWh - // Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh - // Index: 5, Type: int32, Label: Interval, Value: 1521 seconds - // Index: 6, Type: float, Label: Power, Value: 0.000 W - // Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W - // Index: 8, Type: int32, Label: Interval, Value: 1521 seconds - // Index: 9, Type: bool, Label: Exporting, Value: False - // - // So, with the above in mind: - // - // 1. Query the temperature on node 3 and print it out (as a - // string), along with the units of measure: - // - // cout << "Temperature: " << sensor->getValueAsString(3, 1) - // << " " << sensor->getValueUnits(3, 1) << endl; - // - // 2. query the same temperature as a float: - // - // float temperature = sensor->getValueAsFloat(3, 1); - // - // 3. Turn on the light plugged into the switch on Node 7, wait 5 - // seconds, then turn it back off again: - // - // cout << "Turning ON node 7" << endl; - // sensor->setValueAsBool(7, 0, true); - // - // cout << "Sleeping for 5 seconds" << endl; - // sleep(5); - // - // cout << "Turning OFF node 7" << endl; - // sensor->setValueAsBool(7, 0, false); - - -//! [Interesting] - - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/pca9685.cxx b/peripheral/libupm/examples/c++/pca9685.cxx deleted file mode 100644 index 0806e40..0000000 --- a/peripheral/libupm/examples/c++/pca9685.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "pca9685.h" - -using namespace std; - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an PCA9685 on I2C bus 0 - - upm::PCA9685 *leds = new upm::PCA9685(PCA9685_I2C_BUS, - PCA9685_DEFAULT_I2C_ADDR); - - // put device to sleep - leds->setModeSleep(true); - - // setup a period of 50Hz - leds->setPrescaleFromHz(50); - - // wake device up - leds->setModeSleep(false); - - // Setup a 50% duty cycle -- on time at 0, off time at 2048 (4096 / 2) - // Set for all channels - - leds->ledOnTime(PCA9685_ALL_LED, 0); - leds->ledOffTime(PCA9685_ALL_LED, 2048); - - // but, turn channel 3 full off and channel 4 full on - - cout << "Turning channel 3 off, and channel 4 on." << endl; - cout << "All other channels will be PWM'd at a 50% duty cycle." << endl; - - leds->ledFullOff(3, true); - leds->ledFullOn(4, true); - - // now, just sleep for 5 seconds, reset channels 3 and 4, and exit. - cout << "Sleeping for 5 seconds..." << endl; - - sleep(5); - - cout << "Exiting..." << endl; - - // clear the bits we set earlier - leds->ledFullOff(3, false); - leds->ledFullOn(4, false); - -//! [Interesting] - - delete leds; - return 0; -} diff --git a/peripheral/libupm/examples/c++/pn532-writeurl.cxx b/peripheral/libupm/examples/c++/pn532-writeurl.cxx deleted file mode 100644 index f7fc956..0000000 --- a/peripheral/libupm/examples/c++/pn532-writeurl.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "pn532.h" - -using namespace std; - -// the URL we want to add as an NDEF record -// NOTE: this cannot exceed 34 characters. -static char url[] = "iotdk.intel.com"; - - -int main(int argc, char **argv) -{ -//! [Interesting] - // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the - // IRQ, and gpio 2 for the reset pin. - - upm::PN532 *nfc = new upm::PN532(3, 2); - - if (!nfc->init()) - cerr << "init() failed" << endl; - - uint32_t vers = nfc->getFirmwareVersion(); - - if (vers) - printf("Got firmware version: 0x%08x\n", vers); - else - { - printf("Could not identify PN532\n"); - return 1; - } - - // Now scan and identify any cards that come in range (1 for now) - - // Retry forever - nfc->setPassiveActivationRetries(0xff); - - nfc->SAMConfig(); - - uint8_t uidSize; - uint8_t uid[7]; - - bool foundCard = false; - while (!foundCard) - { - memset(uid, 0, 7); - if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A, - uid, &uidSize, 2000)) - { - // found a card - printf("Found a card: UID len %d\n", uidSize); - printf("UID: "); - for (int i = 0; i < uidSize; i++) - printf("%02x ", uid[i]); - printf("\n"); - printf("SAK: 0x%02x\n", nfc->getSAK()); - printf("ATQA: 0x%04x\n\n", nfc->getATQA()); - foundCard = true; - } - else - { - printf("Waiting for a card...\n"); - } - } - - if (uidSize != 7) - { - printf("This example will only write an NDEF URI to preformatted\n"); - printf("Mifare Ultralight or NTAG2XX tags\n"); - - return 1; - } - - // 48 bytes is maximum data area on ultralight cards, so we use that - // as the maximum datasize here. Obviously if you have a bigger - // card, you can write more data. - if (!nfc->ntag2xx_WriteNDEFURI(nfc->NDEF_URIPREFIX_HTTP, url, 48)) - { - // failure - printf("Failed to write NDEF record tag.\n"); - return 1; - } - - printf("Success, URL record written to tag.\n"); - - -//! [Interesting] - - delete nfc; - return 0; -} diff --git a/peripheral/libupm/examples/c++/pn532.cxx b/peripheral/libupm/examples/c++/pn532.cxx deleted file mode 100644 index d1b7ba0..0000000 --- a/peripheral/libupm/examples/c++/pn532.cxx +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> -#include "pn532.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the - // IRQ, and gpio 2 for the reset pin. - - upm::PN532 *nfc = new upm::PN532(3, 2); - - if (!nfc->init()) - cerr << "init() failed" << endl; - - uint32_t vers = nfc->getFirmwareVersion(); - - if (vers) - printf("Got firmware version: 0x%08x\n", vers); - else - { - printf("Could not identify PN532\n"); - return 1; - } - - // Now scan and identify any cards that come in range (1 for now) - - // Retry forever - nfc->setPassiveActivationRetries(0xff); - - nfc->SAMConfig(); - - uint8_t uidSize; - uint8_t uid[7]; - - while (shouldRun) - { - memset(uid, 0, 7); - if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A, - uid, &uidSize, 2000)) - { - // found a card - printf("Found a card: UID len %d\n", uidSize); - printf("UID: "); - for (int i = 0; i < uidSize; i++) - printf("%02x ", uid[i]); - printf("\n"); - printf("SAK: 0x%02x\n", nfc->getSAK()); - printf("ATQA: 0x%04x\n\n", nfc->getATQA()); - sleep(1); - } - else - { - printf("Waiting for a card...\n"); - } - } - - -//! [Interesting] - - delete nfc; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ppd42ns.cxx b/peripheral/libupm/examples/c++/ppd42ns.cxx deleted file mode 100644 index 38a64e5..0000000 --- a/peripheral/libupm/examples/c++/ppd42ns.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Author: Zion Orent <zorent@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "ppd42ns.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a dust sensor on GPIO pin D8 - upm::PPD42NS* dust = new upm::PPD42NS(8); - upm::dustData data; - cout << "This program will give readings every 30 seconds until you stop it" << endl; - while (shouldRun) - { - data = dust->getData(); - cout << "Low pulse occupancy: " << data.lowPulseOccupancy << endl; - cout << "Ratio: " << data.ratio << endl; - cout << "Concentration: " << data.concentration << endl; - } -//! [Interesting] - - cout << "Exiting" << endl; - - delete dust; - return 0; -} diff --git a/peripheral/libupm/examples/c++/pulsensor.cxx b/peripheral/libupm/examples/c++/pulsensor.cxx deleted file mode 100644 index dcb9cba..0000000 --- a/peripheral/libupm/examples/c++/pulsensor.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <string.h> -#include <unistd.h> -#include "pulsensor.h" -#include <signal.h> - -using namespace upm; - -int doWork = 0; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -void -handler (clbk_data data) { - printf ("callback data (%d)\n", data); -} - -int -main(int argc, char **argv) -{ -//! [Interesting] - Pulsensor *sensor = new Pulsensor(handler); - - sensor->start_sampler(); - while (!doWork) { - usleep (5); - } - sensor->stop_sampler(); -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/rfr359f.cxx b/peripheral/libupm/examples/c++/rfr359f.cxx deleted file mode 100644 index b7a8c21..0000000 --- a/peripheral/libupm/examples/c++/rfr359f.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "rfr359f.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate an RFR359F digital pin D2 - // This was tested on the Grove IR Distance Interrupter - - upm::RFR359F* dInterruptor = new upm::RFR359F(2); - - // The range appears to be about 4 inches, depending on adjustment - while (shouldRun) - { - if (dInterruptor->objectDetected()) - cout << "Object detected" << endl; - else - cout << "Area is clear" << endl; - - usleep(100000); // 100ms - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete dInterruptor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/rgbringcoder.cxx b/peripheral/libupm/examples/c++/rgbringcoder.cxx deleted file mode 100644 index 52644cd..0000000 --- a/peripheral/libupm/examples/c++/rgbringcoder.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "rgbringcoder.h" -#include <signal.h> - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - - //! [Interesting] - - // There are a lot of pins to hook up. These pins are valid for the - // Edison board, but may need to be adjusted for other platforms. - - // In order: - // enable - 4 - // latch - 10 - // clear - 11 - // clock - 2 - // data - 9 - // switch - 7 - - // red pwm - 3 - // green pwm - 5 - // blue pwm - 6 - - // encA - 12 - // encB - 13 - - upm::RGBRingCoder *ringCoder = - new upm::RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3, 5, 6); - - uint16_t spin = 0x0001; - bool oldState = false; - int oldPos = 0; - - // Lets go green - ringCoder->setRGBLED(0.99, 0.01, 0.99); - - while (shouldRun) - { - // you spin me round... - if (spin == 0) - spin = 0x0001; - - ringCoder->setRingLEDS(spin); - spin <<= 1; - - // check button state - bool bstate = ringCoder->getButtonState(); - if (bstate != oldState) - { - cout << "Button state changed from " << oldState << " to " - << bstate << endl; - oldState = bstate; - } - - // check encoder position - int epos = ringCoder->getEncoderPosition(); - if (epos != oldPos) - { - cout << "Encoder position changed from " << oldPos << " to " - << epos << endl; - oldPos = epos; - } - - usleep(100000); - } - - //! [Interesting] - - delete ringCoder; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/rhusb.cxx b/peripheral/libupm/examples/c++/rhusb.cxx deleted file mode 100644 index 20f12ed..0000000 --- a/peripheral/libupm/examples/c++/rhusb.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "rhusb.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - string defaultDev = "/dev/ttyUSB0"; - - // if an argument was specified, use it as the device instead - if (argc > 1) - defaultDev = string(argv[1]); - - cout << "Using device " << defaultDev << endl; - cout << "Initializing..." << endl; - - // Instantiate an RHUSB instance on defaultDev - upm::RHUSB sensor(defaultDev); - - // output the firmware ID - cout << "Firmware ID: " << sensor.getFirmwareID() << endl; - cout << endl; - - // update and print available values every second - while (shouldRun) - { - // update our values from the sensor - sensor.update(); - - // we show both C and F for temperature - cout << "Temperature: " << sensor.getTemperature() - << " C / " << sensor.getTemperature(true) << " F" - << endl; - - cout << "Humidity: " << sensor.getHumidity() - << " %" << endl; - - cout << endl; - - sleep(1); - } - - - cout << "Exiting..." << endl; - -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/rotaryencoder.cxx b/peripheral/libupm/examples/c++/rotaryencoder.cxx deleted file mode 100644 index f6c505e..0000000 --- a/peripheral/libupm/examples/c++/rotaryencoder.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "rotaryencoder.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Grove Rotary Encoder, using signal pins D2 and D3 - upm::RotaryEncoder* rotaryencoder = new upm::RotaryEncoder(2, 3); - - while (shouldRun) - { - cout << "Position: " << rotaryencoder->position() << endl; - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete rotaryencoder; - return 0; -} diff --git a/peripheral/libupm/examples/c++/rpr220-intr.cxx b/peripheral/libupm/examples/c++/rpr220-intr.cxx deleted file mode 100644 index 05a8381..0000000 --- a/peripheral/libupm/examples/c++/rpr220-intr.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "rpr220.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -volatile unsigned int counter = 0; - -// Our interrupt handler -void rprISR(void *arg) -{ - counter++; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // This example uses an interrupt handler to increment a counter - - // Instantiate an RPR220 digital pin D2 - // This was tested on the Grove IR Reflective Sensor - - upm::RPR220* rpr220 = new upm::RPR220(2); - - // Here, we setup our Interupt Service Routine (ISR) to count - // 'black' pulses detected. - - rpr220->installISR(rprISR, NULL); - - while (shouldRun) - { - cout << "Counter: " << counter << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete rpr220; - return 0; -} diff --git a/peripheral/libupm/examples/c++/rpr220.cxx b/peripheral/libupm/examples/c++/rpr220.cxx deleted file mode 100644 index c9bdf1d..0000000 --- a/peripheral/libupm/examples/c++/rpr220.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "rpr220.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // This example uses a simple method to determine current status - - // Instantiate an RPR220 digital pin D2 - // This was tested on the Grove IR Reflective Sensor - - upm::RPR220* rpr220 = new upm::RPR220(2); - - while (shouldRun) - { - if (rpr220->blackDetected()) - cout << "Black detected" << endl; - else - cout << "Black NOT detected" << endl; - - usleep(100000); // 100ms - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete rpr220; - return 0; -} diff --git a/peripheral/libupm/examples/c++/sainsmartks.cxx b/peripheral/libupm/examples/c++/sainsmartks.cxx deleted file mode 100644 index 19c8704..0000000 --- a/peripheral/libupm/examples/c++/sainsmartks.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <signal.h> -#include <iostream> - -#include "sainsmartks.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // use default pins - upm::SAINSMARTKS* lcd = new upm::SAINSMARTKS(); - lcd->setCursor(0,0); - lcd->write("Sainsmart KS"); - lcd->setCursor(1,2); - lcd->write("Hello World"); - - // output current key value every second. - while (shouldRun) - { - cout << "Button value: " << lcd->getRawKeyValue() << endl; - sleep(1); - } - -//! [Interesting] - - delete lcd; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/si114x.cxx b/peripheral/libupm/examples/c++/si114x.cxx deleted file mode 100644 index 4c069c9..0000000 --- a/peripheral/libupm/examples/c++/si114x.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "si114x.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a SI114x UV Sensor on I2C bus 0 - upm::SI114X* uvi = new upm::SI114X(0); - - // First initialize it - uvi->initialize(); - - cout << "UV Index Scale:" << endl; - cout << "---------------" << endl; - cout << "11+ Extreme" << endl; - cout << "8-10 Very High" << endl; - cout << "6-7 High" << endl; - cout << "3-5 Moderate" << endl; - cout << "0-2 Low" << endl; - cout << endl; - - // update every second and print the currently measured UV Index - while (shouldRun) - { - // update current value(s) - uvi->update(); - - // print detected value - cout << "UV Index: " << uvi->getUVIndex() << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete uvi; - return 0; -} diff --git a/peripheral/libupm/examples/c++/sm130.cxx b/peripheral/libupm/examples/c++/sm130.cxx deleted file mode 100644 index 3d1e3bd..0000000 --- a/peripheral/libupm/examples/c++/sm130.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <string> -#include <signal.h> -#include <stdio.h> -#include "sm130.h" - -using namespace std; -using namespace upm; - -int main (int argc, char **argv) -{ -//! [Interesting] - - // Instantiate a UART based SM130 RFID Module using defaults - upm::SM130* sensor = new upm::SM130(); - - // set the baud rate. 19200 baud is the default. - if (sensor->setBaudRate(19200)) - { - cerr << "Failed to set baud rate" << endl; - return 1; - } - - cout << "Resetting..." << endl; - sensor->reset(); - - cout << "Firmware revision: " << sensor->getFirmwareVersion() << endl; - - cout << "Waiting up to 5 seconds for a tag..." << endl; - - if (sensor->waitForTag(5000)) - { - cout << "Found tag, UID: " - << sensor->string2HexString(sensor->getUID()) << endl; - cout << "Tag Type: " << sensor->tag2String(sensor->getTagType()) - << endl; - } - else - { - // error - cout << "waitForTag failed: " << sensor->getLastErrorString() << endl; - } - -//! [Interesting] - - cout << "Exiting" << endl; - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/ssd1306-oled.cxx b/peripheral/libupm/examples/c++/ssd1306-oled.cxx deleted file mode 100644 index 07421e3..0000000 --- a/peripheral/libupm/examples/c++/ssd1306-oled.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Author Marc Graham <marc@m2ag.net> - * Copyright (c) 2015 Intel Corporation. - * - * Adapted from ssd1308 library. - * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "ssd1306.h" - -#define DEVICE_ADDRESS 0x3C -#define BUS_NUMBER 0x6 - -static uint8_t intel_logo[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224, - 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60, - 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, - 30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, - 224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, - 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, - 195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, - 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, - 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, - 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, - 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, - 135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, - 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, - 224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255, - 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, - 255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, - 231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, - 0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7, - 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, - 7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, - 7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, - 31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224, - 224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, - 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252, - 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, - 127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, - 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3, - 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 - }; - -int -main(int argc, char **argv) -{ -//! [Interesting] - upm::SSD1306 *lcd = new upm::SSD1306(BUS_NUMBER, DEVICE_ADDRESS); - - lcd->clear(); - lcd->stopscroll(); - lcd->draw(intel_logo, 1024); - - sleep(3); - - lcd->clear(); - lcd->setCursor(2, 0); - lcd->write("Hello"); - lcd->setCursor(3,0); - lcd->write("World"); - - sleep(3); - - lcd->invert(true); - - sleep(3); - - lcd->dim(true); - - sleep(3); - - lcd->dim(false); - - sleep(3); - - lcd->invert(false); - lcd->startscrollright(0x00, 0x0F); - - sleep(5); - - lcd->stopscroll(); - lcd->startscrollleft(0x00, 0x0F); - - sleep(5); - - lcd->stopscroll(); - lcd->startscrolldiagleft(0x00,0x0F); - - sleep(5); - - lcd->stopscroll(); - lcd->startscrolldiagright(0x00,0x0F); - - sleep(5); - - lcd->stopscroll(); - - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/ssd1308-oled.cxx b/peripheral/libupm/examples/c++/ssd1308-oled.cxx deleted file mode 100644 index f54169e..0000000 --- a/peripheral/libupm/examples/c++/ssd1308-oled.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "ssd1308.h" - -#define DEVICE_ADDRESS 0x3C -#define BUS_NUMBER 0x0 - -static uint8_t intel_logo[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224, - 224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60, - 62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, - 30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, - 224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, - 128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, - 195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, - 159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, - 0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, - 128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, - 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, - 255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, - 15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, - 135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, - 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, - 224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255, - 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, - 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, - 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, - 255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, - 231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, - 0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7, - 7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, - 7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, - 7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, - 31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224, - 224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, - 224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252, - 254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, - 127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, - 63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3, - 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 }; - -int -main(int argc, char **argv) -{ -//! [Interesting] - upm::SSD1308 *lcd = new upm::SSD1308(BUS_NUMBER, DEVICE_ADDRESS); - - lcd->clear(); - lcd->draw(intel_logo, 1024); - - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/ssd1327-oled.cxx b/peripheral/libupm/examples/c++/ssd1327-oled.cxx deleted file mode 100644 index 73323ec..0000000 --- a/peripheral/libupm/examples/c++/ssd1327-oled.cxx +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "ssd1327.h" - -#define DEVICE_ADDRESS 0x3C -#define BUS_NUMBER 0x0 - -static uint8_t SeeedLogo[] ={ -0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, -0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0, -0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, -0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, -0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0, -0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, -0x07, 0x80, 0x03, 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1, -0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, -0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE1, 0xE0, 0x07, 0x0F, -0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -0xF8, 0x70, 0x1C, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x0F, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, -0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xDF, 0xE1, 0x9F, 0xEC, 0x7E, -0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, 0xE1, 0xB9, 0xEC, 0xE7, 0xE0, 0x61, 0xD8, 0x66, -0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, 0x7C, 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86, -0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83, -0xC3, 0x61, 0x18, 0x46, 0x03, 0x86, 0x18, 0x66, 0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7, -0xF9, 0xFE, 0x1F, 0xE6, 0x3F, 0x9F, 0xEC, 0xFE, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6, -0x3F, 0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, -0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xF3, 0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00, -0x00, 0x00, 0x7D, 0x9E, 0x68, 0x20, 0xB2, 0xC8, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E, -0x6F, 0x20, 0xB2, 0xF9, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB, -0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, 0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00, -0xF8, 0x00, 0x00, 0x40, 0x40, 0x02, 0x00, 0x00, 0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40, -0x60, 0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, 0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9, 0x2C, -0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, 0x40, 0x62, 0xF9, 0x2C, 0x80, 0x8C, 0xD2, 0x40, -0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, 0x80, 0x84, 0xD2, 0x40, 0x8B, 0x2D, 0x92, 0x48, -0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, 0x8D, 0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - - -int -main(int argc, char **argv) -{ -//! [Interesting] - upm::SSD1327 *lcd = new upm::SSD1327(BUS_NUMBER, 0x3C); - - // If you don't set the display to be white, the seeed logo will appear jagged - lcd->setGrayLevel(12); - lcd->draw(SeeedLogo, 96 * 96 / 8); - - // Simple print hello world - for (uint8_t i = 0; i < 12; i++) - { - lcd->setCursor(i, 0); - lcd->setGrayLevel(i); - lcd->write("Hello World"); - } - - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/ssd1351.cxx b/peripheral/libupm/examples/c++/ssd1351.cxx deleted file mode 100644 index c0de509..0000000 --- a/peripheral/libupm/examples/c++/ssd1351.cxx +++ /dev/null @@ -1,61 +0,0 @@ -#include "mraa.hpp" -#include <iostream> -#include <unistd.h> - -#include "ssd1351.h" - -#define BLACK 0x0000 -#define WHITE 0xFFFF -#define INTEL_BLUE 0x0BF8 - -int main(int argc, char **argv) -{ - // Define colors (16-bit RGB on 5/6/5 bits) - int colors[] = {0x0000, 0x000F, 0x03E0, 0x03EF, - 0x7800, 0x780F, 0x7BE0, 0xC618, - 0x7BEF, 0x001F, 0x07E0, 0x07FF, - 0xF800, 0xF81F, 0xFFE0, 0xFFFF}; -//! [Interesting] - // Initialize display with pins - // oc = 0, dc = 1, r = 2, si = 11, cl = 13 - upm::SSD1351* display = new upm::SSD1351(0, 1, 2); - - // Test lines pixel by pixel - for(int i = 0; i < SSD1351HEIGHT; i++) { - for(int j = 0; j < SSD1351WIDTH; j++) { - display->drawPixel(i, j, colors[i/8]); - } - } - display->refresh(); - sleep(5); - - // Test rectangles - for(int i = 0; i < SSD1351HEIGHT/32; i++) { - for (int j = 0; j < SSD1351WIDTH/32; j++) { - display->fillRect(i * 32, j * 32, 32, 32, colors[i * 4 + j]); - } - } - display->refresh(); - sleep(5); - - // Test circles - display->fillScreen(0x2104); - for(int i = 0; i < SSD1351HEIGHT/32; i++) { - for (int j = 0; j < SSD1351WIDTH/32; j++) { - display->drawCircle(i * 32 + 15, j * 32 + 15, 15, colors[i * 4 + j]); - } - } - display->refresh(); - sleep(5); - - // Test Text - display->fillScreen(INTEL_BLUE); - display->setTextColor(WHITE, INTEL_BLUE); - display->setTextSize(4); - display->setCursor(7, 30); - display->print("Intel"); - display->setCursor(5, 70); - display->print("IoTDK"); - display->refresh(); -//! [Interesting] -} diff --git a/peripheral/libupm/examples/c++/st7735.cxx b/peripheral/libupm/examples/c++/st7735.cxx deleted file mode 100644 index 2c14d49..0000000 --- a/peripheral/libupm/examples/c++/st7735.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <string.h> -#include <unistd.h> -#include <iostream> -#include "st7735.h" -#include <signal.h> - -int -main(int argc, char **argv) -{ -//! [Interesting] - upm::ST7735 * lcd = new upm::ST7735(7, 4, 9, 8); - lcd->fillScreen (ST7735_RED); - lcd->refresh (); - - lcd->fillScreen (ST7735_CYAN); - lcd->refresh (); - - lcd->fillScreen (ST7735_BLACK); - lcd->refresh (); - - lcd->drawLine(10, 10, 10, 100, ST7735_MAGENTA); - lcd->drawLine(20, 20, 10, 100, ST7735_YELLOW); - lcd->drawLine(30, 30, 50, 100, ST7735_WHITE); - lcd->refresh (); - - lcd->drawPixel (20, 20, ST7735_GREEN); - lcd->refresh (); - - lcd->drawTriangle (50, 50, 80, 80, 60, 90, ST7735_GREEN); - lcd->refresh (); - - lcd->drawCircle (100, 110, 10, ST7735_BLUE); - lcd->refresh (); - - - lcd->setTextWrap(0x0); - - lcd->setCursor(0, 30); - lcd->setTextColor(ST7735_RED, ST7735_RED); - lcd->setTextSize(1); - lcd->print("Hello World!"); - - lcd->setCursor(10, 50); - lcd->setTextColor(ST7735_RED, ST7735_YELLOW); - lcd->setTextSize(2); - lcd->print("BIG"); - - lcd->refresh (); - - std::cout << "exiting application" << std::endl; - - delete lcd; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/stepmotor.cxx b/peripheral/libupm/examples/c++/stepmotor.cxx deleted file mode 100644 index 9357d5d..0000000 --- a/peripheral/libupm/examples/c++/stepmotor.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Authors: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "stepmotor.h" - -using namespace std; - -int doWork = 1; -upm::StepMotor *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 0; - } -} - -int -main(int argc, char **argv) -{ -//! [Interesting] - sensor = new upm::StepMotor(2, 3); - - while (doWork) { - cout << "1 Revolution forward and back at 60 rpm" << endl; - sensor->setSpeed(60); - sensor->stepForward(200); - usleep(1000000); - sensor->stepBackward(200); - usleep(1000000); - - cout << "1 Revolution forward and back at 150 rpm" << endl; - sensor->setSpeed(150); - sensor->stepForward(200); - usleep(1000000); - sensor->stepBackward(200); - usleep(1000000); - - cout << "1 Revolution forward and back at 300 rpm" << endl; - sensor->setSpeed(300); - sensor->stepForward(200); - usleep (1000000); - sensor->stepBackward(200); - usleep (1000000); - } - - delete sensor; -//! [Interesting] - return 0; -} diff --git a/peripheral/libupm/examples/c++/sx1276-fsk.cxx b/peripheral/libupm/examples/c++/sx1276-fsk.cxx deleted file mode 100644 index f63d1bf..0000000 --- a/peripheral/libupm/examples/c++/sx1276-fsk.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <stdlib.h> -#include <iostream> -#include <signal.h> -#include "sx1276.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - - cout << "Specify an argument to go into receive mode. Default is transmit" - << endl; - - bool rx = false; - if (argc > 1) - rx = true; - - // Instantiate an SX1276 using default parameters - upm::SX1276 *sensor = new upm::SX1276(); - - // 915Mhz - sensor->setChannel(915000000); - - // FSK configuration (rx and tx must be configured the same): - // Tx output power = 14 dBm - // FSK freq deviation = 25000 Hz - // FSK bandwidth = 50000 bps - // FSK AFC bandwidth = 83333 Hz - // FSK datarate = 50000 bps - // FSK preamble len = 5 - // FSK fixed length payload = false - // FSK CRC check = true - // FSK (rx) continuous Rx mode = false - - sensor->setTxConfig(sensor->MODEM_FSK, 14, 25000, 0, - 50000, 0, 5, false, true, false, 0, false); - - sensor->setRxConfig(sensor->MODEM_FSK, 50000, 50000, - 0, 83333, 5, 0, false, 0, true, - false, 0, false, true); - - int count = 0; - int buflen = 64; - char buffer[buflen]; - - while (shouldRun) - { - if (!rx) - { - snprintf(buffer, buflen, "Ping %d", count++); - cout << "Sending..." << std::string(buffer) << endl; - sensor->sendStr(string(buffer), 3000); - - sensor->setSleep(); - sleep(1); - } - else - { - // receiving - cout << "Attempting to receive..." << endl; - int rv; - if (rv = sensor->setRx(3000)) - { - cout << "setRx returned " << rv << endl; - } - else - { - cout << "Received Buffer: " << sensor->getRxBufferStr() << endl; - } - - // go back to sleep when done - sensor->setSleep(); - usleep(250000); - } - - - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/sx1276-lora.cxx b/peripheral/libupm/examples/c++/sx1276-lora.cxx deleted file mode 100644 index 7c45597..0000000 --- a/peripheral/libupm/examples/c++/sx1276-lora.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <stdlib.h> -#include <iostream> -#include <signal.h> -#include "sx1276.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); -//! [Interesting] - cout << "Specify an argument to go into receive mode. Default is transmit" - << endl; - - bool rx = false; - if (argc > 1) - rx = true; - - // Instantiate an SX1276 using default parameters - upm::SX1276 *sensor = new upm::SX1276(); - - // 915Mhz - sensor->setChannel(915000000); - - // LORA configuration (rx and tx must be configured the same): - // Tx output power = 14 dBm - // LORA bandwidth = 125000 (can also be 250K and 500K) - // LORA spreading factor = 7 - // LORA coding rate = 1 (4/5) - // LORA preamble len = 8 - // LORA symbol timeout = 5 - // LORA fixed payload = false - // LORA IQ inversion = false - // LORA (rx) continuous Rx mode = true - - sensor->setTxConfig(sensor->MODEM_LORA, 14, 0, 125000, - 7, 1, 8, false, true, false, 0, false); - - sensor->setRxConfig(sensor->MODEM_LORA, 125000, 7, - 1, 0, 8, 5, false, 0, true, false, 0, false, true); - - int count = 0; - int buflen = 64; - char buffer[buflen]; - - while (shouldRun) - { - if (!rx) - { - snprintf(buffer, buflen, "Ping %d", count++); - cout << "Sending..." << std::string(buffer) << endl; - sensor->sendStr(string(buffer), 3000); - sensor->setSleep(); - sleep(1); - } - else - { - // receiving - cout << "Attempting to receive..." << endl; - int rv; - if (rv = sensor->setRx(3000)) - { - cout << "setRx returned " << rv << endl; - } - else - { - cout << "Received Buffer: " << sensor->getRxBufferStr() << endl; - } - - // go back to sleep when done - sensor->setSleep(); - usleep(5000); - } - - - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/sx6119.cxx b/peripheral/libupm/examples/c++/sx6119.cxx deleted file mode 100644 index 2608387..0000000 --- a/peripheral/libupm/examples/c++/sx6119.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "sx6119.h" - -using namespace std; - -int main (int argc, char **argv) -{ -//! [Interesting] - // Instantiate a SX6119 on digital pins 2 (power) and 3 (seek) - // This example was tested on the Grove FM Receiver. - - upm::SX6119* radio = new upm::SX6119(2, 3); - - // if an argument was specified (any argument), seek to the next - // station, else just toggle the power. - - - cout << "Supply any argument to the command line to seek to the" << endl; - cout << "next station." << endl; - cout << "Running the example without an argument will toggle the" <<endl; - cout << "power on or off." << endl; - - cout << endl; - - bool doSeek = false; - - if (argc > 1) - doSeek = true; - - // depending on what was selected, do it - - if (doSeek) - radio->seek(); - else - radio->togglePower(); - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete radio; - return 0; -} diff --git a/peripheral/libupm/examples/c++/t3311.cxx b/peripheral/libupm/examples/c++/t3311.cxx deleted file mode 100644 index 1859dc6..0000000 --- a/peripheral/libupm/examples/c++/t3311.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> - -#include "t3311.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - string defaultDev = "/dev/ttyUSB0"; - - // if an argument was specified, use it as the device instead - if (argc > 1) - defaultDev = string(argv[1]); - - cout << "Initializing..." << endl; - - // Instantiate an T3311 instance, using MODBUS slave address 1, and - // default comm parameters (9600, 8, N, 2) - upm::T3311 *sensor = new upm::T3311(defaultDev, 1); - - // output the serial number and firmware revision - cout << "Serial Number: " << sensor->getSerialNumber() << endl; - cout << "Firmware Revision: " << sensor->getFirmwareMajor() - << "." << sensor->getFirmwareMinor() << endl; - cout << endl; - - // update and print available values every second - while (shouldRun) - { - // update our values from the sensor - sensor->update(); - - // we show both C and F for temperature - cout << "Temperature: " << sensor->getTemperature() - << " C / " << sensor->getTemperature(true) << " F" - << endl; - - cout << "Humidity: " << sensor->getHumidity() - << " %" << endl; - - // this value depends on the sensor configuration -- by default - // it is the dew point temperature - cout << "Computed Value: " << sensor->getComputedValue() << endl; - - // with FW revisions > 2.44, extended computed data is available - if (sensor->extendedDataAvailable()) - { - cout << "Dew Point Temperature: " << sensor->getDewPointTemperature() - << " C / " << sensor->getDewPointTemperature(true) << " F" - << endl; - - cout << "Absolute Humidity: " << sensor->getAbsoluteHumidity() - << " g/m3" << endl; - - cout << "Specific Humidity: " << sensor->getSpecificHumidity() - << " g/kg" << endl; - - cout << "Mixing Ratio: " << sensor->getMixingRatio() - << " g/kg" << endl; - - cout << "Specific Enthalpy: " << sensor->getSpecificEnthalpy() - << " kJ/kg" << endl; - } - - cout << endl; - - sleep(1); - } - - cout << "Exiting..." << endl; - - delete sensor; - -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/ta12200.cxx b/peripheral/libupm/examples/c++/ta12200.cxx deleted file mode 100644 index 5f949a1..0000000 --- a/peripheral/libupm/examples/c++/ta12200.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "ta12200.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a TA12-200 sensor on analog pin A0 - upm::TA12200* electricity = new upm::TA12200(0); - - while (shouldRun) - { - unsigned int maxVal = electricity->highestValue(); - float current = electricity->milliAmps(maxVal); - - cout << "Max ADC Value: " << maxVal << ", current: " << current - << "mA" << endl; - usleep(100000); - } - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete electricity; - return 0; -} diff --git a/peripheral/libupm/examples/c++/tcs3414cs.cxx b/peripheral/libupm/examples/c++/tcs3414cs.cxx deleted file mode 100644 index 5e6376e..0000000 --- a/peripheral/libupm/examples/c++/tcs3414cs.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "tcs3414cs.h" -#include <signal.h> - -int doWork = 0; -upm::TCS3414CS *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - upm::tcs3414sc_rgb_t rgb; - - // Instantiate the color sensor on I2C - sensor = new upm::TCS3414CS (); - - // Print out the r, g, b, and clr value every 0.5 seconds - while (!doWork) { - sensor->readRGB (&rgb); - std::cout << (int)rgb.r << ", " << (int)rgb.g << ", " << (int)rgb.b << ", " << rgb.clr << std::endl; - usleep (500000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/th02.cxx b/peripheral/libupm/examples/c++/th02.cxx deleted file mode 100644 index cce0367..0000000 --- a/peripheral/libupm/examples/c++/th02.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "th02.h" -#include <signal.h> - -int doWork = 0; -upm::TH02 *sensor = NULL; - -void -sig_handler(int signo) -{ - printf("got signal\n"); - if (signo == SIGINT) { - printf("exiting application\n"); - doWork = 1; - } -} - -int -main(int argc, char **argv) -{ - //! [Interesting] - float temperature = 0.0; - float humidity = 0.0; - sensor = new upm::TH02 (); - - while (!doWork) { - temperature = sensor->getTemperature (); - humidity = sensor->getHumidity (); - std::cout << "Temperature = " << temperature << ", Humidity = " << humidity << std::endl; - usleep (500000); - } - //! [Interesting] - - std::cout << "exiting application" << std::endl; - - delete sensor; - - return 0; -} diff --git a/peripheral/libupm/examples/c++/tm1637.cxx b/peripheral/libupm/examples/c++/tm1637.cxx deleted file mode 100644 index 235ae50..0000000 --- a/peripheral/libupm/examples/c++/tm1637.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "tm1637.h" -#include <signal.h> -#include <unistd.h> -#include <sstream> -#include <time.h> - -using namespace std; -using namespace upm; - -bool run = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - run = false; -} - -int -main(int argc, char** argv) -{ - //! [Interesting] - bool point = true; - int timezone = -7; // Your UTC offset - time_t rawtime; - struct tm * gmt; - char myTime[5]; - - fprintf(stdout, "TM1637 Display Example\n"); - signal(SIGINT, sig_handler); - - TM1637 myDisplay = TM1637(0, 1); // TM1637 on pins 0 (clk) and 1 (dio) - myDisplay.write(0x39, 0x09, 0x09); // Start a box using 7-segment encoding - myDisplay.writeAt(3, ']'); // Finish box using writeAt function - sleep(3); // Wait 3 seconds - - while(run) - { - time(&rawtime); // Update raw time - gmt = gmtime(&rawtime); // Get current time - - int hour = (gmt) ? gmt->tm_hour : 0; - int min = (gmt) ? gmt->tm_min : 0; - // Format and store the time in 24 hour format - snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min); - - myDisplay.write(myTime); // Write to display as string - myDisplay.setColon(point ^= true); // Toggle the dots on the display - sleep(1); // Only update once every second - } - - //! [Interesting] - return 0; -} - - diff --git a/peripheral/libupm/examples/c++/tp401.cxx b/peripheral/libupm/examples/c++/tp401.cxx deleted file mode 100644 index 255d3f0..0000000 --- a/peripheral/libupm/examples/c++/tp401.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include <unistd.h> -#include <iostream> -#include "tp401.h" - -using namespace std; - -//! [Interesting] -// Give a qualitative meaning to the value from the sensor -std::string -airQuality(uint16_t value) -{ - if(value < 50) return "Fresh Air"; - if(value < 200) return "Normal Indoor Air"; - if(value < 400) return "Low Pollution"; - if(value < 600) return "High Pollution - Action Recommended"; - return "Very High Pollution - Take Action Immediately"; -} - -int main () -{ - upm::TP401* airSensor = new upm::TP401(0); // Instantiate new grove air quality sensor on analog pin A0 - - cout << airSensor->name() << endl; - - fprintf(stdout, "Heating sensor for 3 minutes...\n"); - // wait 3 minutes for sensor to warm up - for(int i = 0; i < 3; i++) { - if(i) { - fprintf(stdout, "Please wait, %d minute(s) passed..\n", i); - } - sleep(60); - } - fprintf(stdout, "Sensor ready!\n"); - - while(true) { - uint16_t value = airSensor->getSample(); // Read raw value - float ppm = airSensor->getPPM(); // Read CO ppm (can vary slightly from previous read) - fprintf(stdout, "raw: %4d ppm: %5.2f %s\n", value, ppm, airQuality(value).c_str()); - usleep(2500000); // Sleep for 2.5s - } - - delete airSensor; - return 0; -} -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/tsl2561.cxx b/peripheral/libupm/examples/c++/tsl2561.cxx deleted file mode 100644 index 14ddb8a..0000000 --- a/peripheral/libupm/examples/c++/tsl2561.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: Nandkishor Sonar <Nandkishor.Sonar@intel.com> - * Copyright (c) 2014 Intel Corporation. - * - * LIGHT-TO-DIGITAL CONVERTER [TAOS-TSL2561] - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include <unistd.h> -#include "tsl2561.h" - -int main (int argc, char **argv) -{ - mraa_result_t error = MRAA_SUCCESS; - upm::TSL2561 *sensor = NULL; - int loopCount = 100; - -//! [Interesting] - if (argc < 2) { - printf("Provide loop count \n"); - } else { - loopCount = atoi(argv[1]); - } - sensor = new upm::TSL2561(); - - for(int i=0; i< loopCount; i++){ - fprintf(stdout, "Lux = %d\n", sensor->getLux()); - } - -//! [Interesting] - - delete(sensor); - - return (0); -} diff --git a/peripheral/libupm/examples/c++/ttp223.cxx b/peripheral/libupm/examples/c++/ttp223.cxx deleted file mode 100644 index 1d15585..0000000 --- a/peripheral/libupm/examples/c++/ttp223.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: Sarah Knepper <sarah.knepper@intel.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "ttp223.h" - -int -main(int argc, char **argv) -{ - // This example uses GPIO 0 -//! [Interesting] - - // Create the TTP223 touch sensor object using GPIO pin 0 - upm::TTP223* touch = new upm::TTP223(0); - - // Check whether or not a finger is near the touch sensor and - // print accordingly, waiting one second between readings - while( 1 ) { - if ( touch->isPressed() ) { - std::cout << touch->name() << " is pressed" << std::endl; - } else { - std::cout << touch->name() << " is not pressed" << std::endl; - } - sleep(1); - } - - // Delete the touch sensor object - delete touch; -//! [Interesting] - - return 0; -} diff --git a/peripheral/libupm/examples/c++/ublox6.cxx b/peripheral/libupm/examples/c++/ublox6.cxx deleted file mode 100644 index a0cd5f2..0000000 --- a/peripheral/libupm/examples/c++/ublox6.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "ublox6.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -const size_t bufferLength = 256; - -int main (int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Ublox6 GPS device on uart 0. - upm::Ublox6* nmea = new upm::Ublox6(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!nmea->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - // Collect and output NMEA data. There are various libraries out on - // the Internet, such as tinyGPS or tinyGPS++ that can handle - // decoding NMEA data and presenting it in a more easily accessible - // format. This example will just check for, and read raw NMEA data - // from the device and output it on stdout. - - // This device also supports numerous configuration options, which - // you can set with writeData(). Please refer to the Ublox-6 data - // sheet for further information on the formats of the data sent and - // received, and the various operating modes available. - - char nmeaBuffer[bufferLength]; - while (shouldRun) - { - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (nmea->dataAvailable()) - { - int rv = nmea->readData(nmeaBuffer, bufferLength); - - if (rv > 0) - write(1, nmeaBuffer, rv); - - if (rv < 0) // some sort of read error occured - { - cerr << "Port read error." << endl; - break; - } - - continue; - } - - usleep(100000); // 100ms - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete nmea; - return 0; -} diff --git a/peripheral/libupm/examples/c++/uln200xa.cxx b/peripheral/libupm/examples/c++/uln200xa.cxx deleted file mode 100644 index 53a6958..0000000 --- a/peripheral/libupm/examples/c++/uln200xa.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include "uln200xa.h" - -using namespace std; - -int main () -{ - //! [Interesting] - - // Instantiate a Stepper motor on a ULN200XA Dual H-Bridge. - - // This was tested with the Grove Gear Stepper Motor with Driver - - // Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and - // I4 is pin D11 - upm::ULN200XA* uln200xa = new upm::ULN200XA(4096, 8, 9, 10, 11); - - uln200xa->setSpeed(5); - uln200xa->setDirection(upm::ULN200XA::DIR_CW); - cout << "Rotating 1 revolution clockwise." << endl; - uln200xa->stepperSteps(4096); - cout << "Sleeping for 2 seconds..." << endl; - sleep(2); - cout << "Rotating 1/2 revolution counter clockwise." << endl; - uln200xa->setDirection(upm::ULN200XA::DIR_CCW); - uln200xa->stepperSteps(2048); - - // turn off the power - uln200xa->release(); - - //! [Interesting] - cout << "Exiting..." << endl; - - delete uln200xa; - return 0; -} - diff --git a/peripheral/libupm/examples/c++/urm37-uart.cxx b/peripheral/libupm/examples/c++/urm37-uart.cxx deleted file mode 100644 index 7a94a1f..0000000 --- a/peripheral/libupm/examples/c++/urm37-uart.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "urm37.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a URM37 sensor on UART 0, with the reset pin on D2 - upm::URM37 *sensor = new upm::URM37(0, 2); - - // Every half a second, sample the URM37 and output the measured - // distance in cm, and temperature in degrees C - - while (shouldRun) - { - cout << "Detected distance (cm): " << sensor->getDistance() << endl; - cout << "Temperature (C): " << sensor->getTemperature() << endl; - - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/urm37.cxx b/peripheral/libupm/examples/c++/urm37.cxx deleted file mode 100644 index 820b2a1..0000000 --- a/peripheral/libupm/examples/c++/urm37.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "urm37.h" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - - // Instantiate a URM37 sensor on analog pin A0, reset pin on D2, - // trigger pin on D3 with an analog reference voltage of 5.0 - upm::URM37 *sensor = new upm::URM37(0, 2, 3, 5.0); - - // Every half a second, sample the URM37 and output the measured - // distance in cm. - - while (shouldRun) - { - cout << "Detected distance (cm): " << sensor->getDistance() << endl; - usleep(500000); - } - -//! [Interesting] - - cout << "Exiting" << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/waterlevel.cxx b/peripheral/libupm/examples/c++/waterlevel.cxx deleted file mode 100644 index d3a069f..0000000 --- a/peripheral/libupm/examples/c++/waterlevel.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Author: Zion Orent <zorent@ics.com> -* Copyright (c) 2015 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include <iostream> -#include <unistd.h> -#include <signal.h> -#include "waterlevel.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -int main(int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // The was tested with the Water Level Sensor - // Instantiate a Water Level Sensor on digital pin D2 - upm::WaterLevel* waterlevel = new upm::WaterLevel(2); - - while (shouldRun) - { - if (waterlevel->isSubmerged()) - cout << "Sensor is submerged in liquid" << endl; - else - cout << "Liquid is below water level sensor" << endl; - sleep(1); - } - -//! [Interesting] - cout << "Exiting" << endl; - - delete waterlevel; - return 0; -} diff --git a/peripheral/libupm/examples/c++/wheelencoder.cxx b/peripheral/libupm/examples/c++/wheelencoder.cxx deleted file mode 100644 index 08a7825..0000000 --- a/peripheral/libupm/examples/c++/wheelencoder.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "wheelencoder.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main() -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a DFRobot Wheel Encoder on digital pin D2 - upm::WheelEncoder* sensor = new upm::WheelEncoder(2); - - // set the counter to 0 and start counting - sensor->clearCounter(); - sensor->startCounter(); - - while (shouldRun) - { - // output milliseconds passed and current sensor count - cout << "Millis: " << sensor->getMillis() << " Count: " - << sensor->counter() << endl; - - sleep(1); - } - - sensor->stopCounter(); -//! [Interesting] - - cout << "Exiting..." << endl; - - delete sensor; - return 0; -} diff --git a/peripheral/libupm/examples/c++/wt5001.cxx b/peripheral/libupm/examples/c++/wt5001.cxx deleted file mode 100644 index 317e877..0000000 --- a/peripheral/libupm/examples/c++/wt5001.cxx +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "wt5001.h" - -using namespace std; - -void printUsage(char *progname) -{ - cout << "Usage:" << progname << " <command>" << endl; - cout << "Commands:" << endl; - cout << "0 - stop playing" << endl; - cout << "1 - start playing track 1" << endl; - cout << "2 - pause/un-pause playback" << endl; - cout << "3 - next track" << endl; - cout << "4 - previous track" << endl; -} - -int main (int argc, char **argv) -{ -//! [Interesting] - // Instantiate a WT5001 serial MP3 player on uart 0. - // This example was tested on the Grove Serial MP3 module. - - upm::WT5001* mp3 = new upm::WT5001(0); - - int cmd = -1; - if (argc > 1) - cmd = atoi(argv[1]); - - // make sure port is initialized properly. 9600 baud is the default. - if (!mp3->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - switch (cmd) - { - case 0: - mp3->stop(); - break; - - case 1: - mp3->play(upm::WT5001::SD, 1); - break; - - case 2: - mp3->pause(); - break; - - case 3: - mp3->next(); - break; - - case 4: - mp3->previous(); - break; - - default: - // nothing, just output usage, and info below - printUsage(argv[0]); - break; - } - - // Example: set the date - // mp3->setDate(2015, 1, 1); - - // Example: set the time - // mp3->setTime(12, 30, 30); - - // print out some information - uint8_t vol = 0; - if (mp3->getVolume(&vol)) - cout << "The current volume is: " << int(vol) << endl; - - uint8_t ps = 0; - if (mp3->getPlayState(&ps)) - cout << "The current play state is: " << int(ps) << endl; - - uint16_t numf = 0; - if (mp3->getNumFiles(upm::WT5001::SD, &numf)) - cout << "The number of files on the SD card is: " << int(numf) << endl; - - uint16_t curf = 0; - if (mp3->getCurrentFile(&curf)) - cout << "The current file is: " << int(curf) << endl; - - uint16_t year = 0; - uint8_t month = 0, day = 0; - if (mp3->getDate(&year, &month, &day)) - cout << "The device date is: " << int(month) << "/" << int(day) - << "/" << int(year) << endl; - - uint8_t hour = 0, minute = 0, second = 0; - if (mp3->getTime(&hour, &minute, &second)) - cout << "The device time is: " << int(hour) << ":" << int(minute) - << ":" << int(second) << endl; - -//! [Interesting] - - cout << "Exiting..." << endl; - - delete mp3; - return 0; -} diff --git a/peripheral/libupm/examples/c++/xbee.cxx b/peripheral/libupm/examples/c++/xbee.cxx deleted file mode 100644 index 834d8bc..0000000 --- a/peripheral/libupm/examples/c++/xbee.cxx +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include <stdio.h> -#include "xbee.h" - -using namespace std; -using namespace upm; - -void printUsage(char *progname) -{ - cout << "Usage: " << progname << " [AT command]" << endl; - cout << endl; - - cout << "If an argument is supplied on the command line, that argument is" - << endl; - cout << "sent to the module and the response is printed out." << endl; - cout << endl; - cout << "If no argument is used, then the firmware revision, serial number" - << endl; - cout << "and the current IP address (if set) are queried." << endl; - cout << endl; - cout << endl; -} - -//! [Interesting] - -// simple helper function to send a command and wait for a response -void sendCommand(upm::XBee* sensor, string cmd) -{ - // commands need to be terminated with a carriage return - cmd += "\r"; - - sensor->writeDataStr(cmd); - - string resp; - while (sensor->dataAvailable(2000)) - { - resp += sensor->readDataStr(1024); - } - - if (resp.empty()) - { - cerr << "Timed out waiting for response" << endl; - return; - } - - resp = sensor->stringCR2LF(resp); - cout << "Returned (" << resp.size() << " bytes): " << endl; - cout << resp << endl; -} - -int main(int argc, char **argv) -{ - - // Instantiate a XBee Module on UART 0 - upm::XBee* sensor = new upm::XBee(0); - - // Set the baud rate, 9600 baud is the default. - if (sensor->setBaudRate(9600)) - { - cerr << "Failed to set tty baud rate" << endl; - return 1; - } - - printUsage(argv[0]); - - if (argc > 1) - { - // enable command mode - sensor->commandMode(); - cout << "Sending command line argument (" << argv[1] << ")..." << endl; - sendCommand(sensor, argv[1]); - } - else - { - // enable command mode - sensor->commandMode(); - // query the verbose firmware revision - cout << "Querying verbose firmware revision (ATVL)..." << endl; - sendCommand(sensor, "ATVL"); - // query the number - cout << "Querying Serial Number High (ATSH)..." << endl; - sendCommand(sensor, "ATSH"); - cout << "Querying Serial Number Low (ATSL)..." << endl; - sendCommand(sensor, "ATSL"); - - cout << "Querying address, if set (ATMY)..." << endl; - sendCommand(sensor, "ATMY"); - - // For the XBee WiFi S6B - // A comprehensive list of commands and command modes is - // available from the datasheet at: - // ftp1.digi.com/support/documentation/90002180_L.pdf - - // For the XBee S1 - // A comprehensive list of commands and command modes is - // available from the datasheet at: - // http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf - - // For the XBee WiFi module: - // An example using AT commands to connect to an AP, with a - // private Key using WPA2: - - // Connect to AP with SSID 'mySSID': - // ATIDmySSID - - // Provide the private key 'secret': - // ATPKsecret - - // Use WPA2 encryption - // ATEE2 - - } - - - delete sensor; - return 0; -} - -//! [Interesting] diff --git a/peripheral/libupm/examples/c++/yg1006.cxx b/peripheral/libupm/examples/c++/yg1006.cxx deleted file mode 100644 index 07dbfb5..0000000 --- a/peripheral/libupm/examples/c++/yg1006.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "yg1006.h" - -using namespace std; - -int shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - - -int main () -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a yg1006 flame sensor on digital pin D2 - upm::YG1006* flame = new upm::YG1006(2); - - // check every second for the presence of a flame - while (shouldRun) - { - bool val = flame->flameDetected(); - if (val) - cout << "Flame detected." << endl; - else - cout << "No flame detected." << endl; - - sleep(1); - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete flame; - return 0; -} diff --git a/peripheral/libupm/examples/c++/zfm20-register.cxx b/peripheral/libupm/examples/c++/zfm20-register.cxx deleted file mode 100644 index fb1292c..0000000 --- a/peripheral/libupm/examples/c++/zfm20-register.cxx +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "zfm20.h" - -using namespace std; -using namespace upm; - -int main (int argc, char **argv) -{ -//! [Interesting] - // Instantiate a ZFM20 Fingerprint reader on UART 0 - - upm::ZFM20* fp = new upm::ZFM20(0); - - // make sure port is initialized properly. 57600 baud is the default. - if (!fp->setupTty(B57600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - // This example demonstrates registering a fingerprint on the zfm20 - // module. The procedure is as follows: - // - // 1. get an image, store it in characteristics buffer 1 - // 2. get another image, store it in characteristics buffer 2 - // 3. store the image, assuming the two fingerprints match - - // first, we need to register our address and password - - fp->setPassword(ZFM20_DEFAULT_PASSWORD); - fp->setAddress(ZFM20_DEFAULT_ADDRESS); - - // now verify the password. If this fails, any other commands - // will be ignored, so we just bail. - if (fp->verifyPassword()) - { - cout << "Password verified." << endl; - } - else - { - cerr << "Password verification failed." << endl; - return 1; - } - - cout << endl; - - uint8_t rv; - // get the first image - - cout << "Place a finger on the sensor." << endl; - while (fp->generateImage() != ZFM20::ERR_OK) - ; - - // in theory, we have an image - cout << "Image captured, converting..." << endl; - - if ((rv = fp->image2Tz(1)) != ZFM20::ERR_OK) - { - cerr << "Image conversion failed with error code " << int(rv) <<endl; - return 1; - } - - cout << "Image conversion succeeded, remove finger." << endl; - sleep(1); - - while (fp->generateImage() != ZFM20::ERR_NO_FINGER) - ; - - cout << endl; - cout << "Now place the same finger on the sensor." << endl; - - while (fp->generateImage() != ZFM20::ERR_OK) - ; - - cout << "Image captured, converting..." << endl; - - // save this one in slot 2 - if ((rv = fp->image2Tz(2)) != ZFM20::ERR_OK) - { - cerr << "Image conversion failed with error code " << int(rv) <<endl; - return 1; - } - - cout << "Image conversion succeeded, remove finger." << endl; - cout << endl; - - cout << "Storing fingerprint at id 1" << endl; - - // create the model - if ((rv = fp->createModel()) != ZFM20::ERR_OK) - { - if (rv == ZFM20::ERR_FP_ENROLLMISMATCH) - cerr << "Fingerprints did not match." << endl; - else - cerr << "createModel failed with error code " << int(rv) <<endl; - - return 1; - } - - // now store it, we hard code the id (second arg) to 1 here - if ((rv = fp->storeModel(1, 1)) != ZFM20::ERR_OK) - { - cerr << "storeModel failed with error code " << int(rv) <<endl; - return 1; - } - - cout << endl; - cout << "Fingerprint stored at id 1." << endl; - -//! [Interesting] - - delete fp; - return 0; -} diff --git a/peripheral/libupm/examples/c++/zfm20.cxx b/peripheral/libupm/examples/c++/zfm20.cxx deleted file mode 100644 index a7323b0..0000000 --- a/peripheral/libupm/examples/c++/zfm20.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Author: Jon Trulson <jtrulson@ics.com> - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <unistd.h> -#include <iostream> -#include <signal.h> -#include "zfm20.h" - -using namespace std; -using namespace upm; - -int main (int argc, char **argv) -{ -//! [Interesting] - // Instantiate a ZFM20 Fingerprint reader on UART 0 - - upm::ZFM20* fp = new upm::ZFM20(0); - - // make sure port is initialized properly. 57600 baud is the default. - if (!fp->setupTty(B57600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - // first, set the default password and address - fp->setPassword(ZFM20_DEFAULT_PASSWORD); - fp->setAddress(ZFM20_DEFAULT_ADDRESS); - - // now verify the password. If this fails, any other commands - // will be ignored, so we just bail. - if (fp->verifyPassword()) - { - cout << "Password verified." << endl; - } - else - { - cerr << "Password verification failed." << endl; - return 1; - } - - // how many valid stored templates (fingerprints) do we have? - cout << "Total stored templates: " << fp->getNumTemplates() << endl; - cout << endl; - - // now spin waiting for a fingerprint to successfully image - cout << "Waiting for finger print..." << endl; - - while (fp->generateImage() == ZFM20::ERR_NO_FINGER) - ; - - // in theory, we have an image - cout << "Image captured, converting..." << endl; - - uint8_t rv; - if ((rv = fp->image2Tz(1)) != ZFM20::ERR_OK) - { - cerr << "Image conversion failed with error code " << int(rv) <<endl; - return 1; - } - - cout << "Image conversion succeeded." << endl; - cout << "Searching database..." << endl; - - uint16_t id = 0; - uint16_t score = 0; - - // we search for a print matching slot 1, where we shored our last - // converted fingerprint - if ((rv = fp->search(1, &id, &score)) != ZFM20::ERR_OK) - { - if (rv == ZFM20::ERR_FP_NOTFOUND) - { - cout << "Finger Print not found" << endl; - return 0; - } - else - { - cerr << "Search failed with error code " << int(rv) <<endl; - return 1; - } - } - - cout << "Fingerprint found!" << endl; - cout << "ID: " << int(id) << ", Score: " << int(score) << endl; - -//! [Interesting] - - delete fp; - return 0; -} |