Skip to content
Snippets Groups Projects
Commit 80e193a5 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Modified the example to interface with the ADC module.

parent 61a5f3e5
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,9 @@ TARGET_LINK_LIBRARIES(darwin_manager_test darwin_robot)
#TARGET_LINK_LIBRARIES(darwin_gpio_test darwin_robot)
# create an example application
#ADD_EXECUTABLE(darwin_adc_test darwin_adc_test.cpp)
ADD_EXECUTABLE(darwin_adc_test darwin_adc_test.cpp)
# link necessary libraries
#TARGET_LINK_LIBRARIES(darwin_adc_test darwin_robot)
TARGET_LINK_LIBRARIES(darwin_adc_test darwin_robot)
# create an example application
ADD_EXECUTABLE(darwin_imu_test darwin_imu_test.cpp)
......
#include "darwin_robot.h"
#include "darwin_adc.h"
#include "darwin_robot_exceptions.h"
#include <iostream>
std::string robot_device="A603LOBS";
//std::string robot_device="A4008atn";
#ifdef _SIM
std::string robot_device="/tmp/darwin_driver";
#else
std::string robot_device="/dev/ttyACM0";
#endif
int main(int argc, char *argv[])
{
int i=0;
try{
CDarwinRobot darwin("Darwin",robot_device,1000000,0x02);
std::cout << "found darwin controller" << std::endl;
darwin.adc_start();
for(i=0;i<5000;i++)
CDarwinADC adc("Darwin",robot_device,1000000,0x01);
adc.start();
for(i=0;i<50;i++)
{
std::cout << "Temperature: " << darwin.adc_get_temperature() << std::endl;
std::cout << "Channel1: " << darwin.adc_get_value(ADC_CH1) << std::endl;
std::cout << "Channel2: " << darwin.adc_get_value(ADC_CH2) << std::endl;
std::cout << "Channel3: " << darwin.adc_get_value(ADC_CH3) << std::endl;
std::cout << "Channel4: " << darwin.adc_get_value(ADC_CH4) << std::endl;
std::cout << "Channel5: " << darwin.adc_get_value(ADC_CH5) << std::endl;
std::cout << "Channel6: " << darwin.adc_get_value(ADC_CH6) << std::endl;
std::cout << "Channel7: " << darwin.adc_get_value(ADC_CH7) << std::endl;
std::cout << "Channel8: " << darwin.adc_get_value(ADC_CH8) << std::endl;
std::cout << "Channel9: " << darwin.adc_get_value(ADC_CH9) << std::endl;
std::cout << "Channel10: " << darwin.adc_get_value(ADC_CH10) << std::endl;
std::cout << "Channel12: " << darwin.adc_get_value(ADC_CH12) << std::endl;
std::cout << "Temperature: " << adc.get_temperature() << std::endl;
std::cout << "Channel1: " << adc.get_value(ADC_CH1) << std::endl;
std::cout << "Channel2: " << adc.get_value(ADC_CH2) << std::endl;
std::cout << "Channel3: " << adc.get_value(ADC_CH3) << std::endl;
std::cout << "Channel4: " << adc.get_value(ADC_CH4) << std::endl;
std::cout << "Channel5: " << adc.get_value(ADC_CH5) << std::endl;
std::cout << "Channel6: " << adc.get_value(ADC_CH6) << std::endl;
std::cout << "Channel7: " << adc.get_value(ADC_CH7) << std::endl;
std::cout << "Channel8: " << adc.get_value(ADC_CH8) << std::endl;
std::cout << "Channel9: " << adc.get_value(ADC_CH9) << std::endl;
std::cout << "Channel10: " << adc.get_value(ADC_CH10) << std::endl;
std::cout << "Channel12: " << adc.get_value(ADC_CH12) << std::endl;
usleep(100000);
}
darwin.adc_stop();
adc.stop();
}catch(CException &e){
std::cout << e.what() << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment