servo: Added new module servo

Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
This commit is contained in:
Kiveisha Yevgeniy
2014-06-03 16:23:26 +00:00
parent 5b8922f7bf
commit 356b1dd43c
10 changed files with 316 additions and 0 deletions

View File

@ -8,6 +8,7 @@ add_executable (led-bar led-bar.cxx)
add_executable (seg-lcd 4digitdisplay.cxx)
add_executable (nrf_transmitter nrf_transmitter.cxx)
add_executable (nrf_receiver nrf_receiver.cxx)
add_executable (es08a es08a.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@ -16,6 +17,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/buzzer)
include_directories (${PROJECT_SOURCE_DIR}/src/ledbar)
include_directories (${PROJECT_SOURCE_DIR}/src/4digitdisplay)
include_directories (${PROJECT_SOURCE_DIR}/src/nrf24l01)
include_directories (${PROJECT_SOURCE_DIR}/src/servo)
target_link_libraries (compass hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled grove ${CMAKE_THREAD_LIBS_INIT})
@ -27,3 +29,4 @@ target_link_libraries (led-bar ledbar ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (seg-lcd 4digitdisplay ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf_transmitter nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (nrf_receiver nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (es08a servo ${CMAKE_THREAD_LIBS_INIT})

68
examples/es08a.cxx Normal file
View File

@ -0,0 +1,68 @@
/*
* 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 running = 0;
void
sig_handler(int signo)
{
printf("got signal\n");
if (signo == SIGINT) {
printf("exiting application\n");
running = 1;
}
}
int
main(int argc, char **argv)
{
upm::ES08A *servo = new upm::ES08A(5);
signal(SIGINT, sig_handler);
int clock = 0;
while (!running) {
for (int i = 0; i < 18; i++) {
servo->setAngle (clock);
clock += 10;
}
for (int i = 0; i < 18; i++) {
servo->setAngle (clock);
clock -= 10;
}
}
std::cout << "exiting application" << std::endl;
delete servo;
return 0;
}