diff options
Diffstat (limited to 'peripheral/libupm/examples/c++/ds1808lc.cxx')
-rw-r--r-- | peripheral/libupm/examples/c++/ds1808lc.cxx | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/peripheral/libupm/examples/c++/ds1808lc.cxx b/peripheral/libupm/examples/c++/ds1808lc.cxx deleted file mode 100644 index 33e655e..0000000 --- a/peripheral/libupm/examples/c++/ds1808lc.cxx +++ /dev/null @@ -1,51 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <iostream> -#include <string> -#include "ds1808lc.hpp" - -#define EDISON_I2C_BUS 1 // Edison I2C-1 -#define DS1808_GPIO_PWR 15 // Edison GP165 - -void printState(upm::ILightController *lightController) -{ - if (lightController->isPowered()) - { - std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl; - } - else - { - std::cout << "Light is not powered." << std::endl; - } -} - -int main( int argc, char **argv ) -{ - int status = 0; - upm::ILightController* lightController; - - try { - lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS); - std::cout << "Existing state: "; printState(lightController); - if (argc == 2) - { - std::string arg = argv[1]; - int brightness = ::atoi(argv[1]); - if (brightness > 0) { - lightController->setPowerOn(); - lightController->setBrightness(brightness); - } else - lightController->setPowerOff(); - } - std::cout << "Now: ";printState(lightController); - } catch (std::exception& e) { - std::cout << "Error: " << e.what() << std::endl; - status = 1; - } - - delete lightController; - return status; -} - - |