ir.cpp
Go to the documentation of this file.
00001 #include "phidgets_api/ir.h"
00002 
00003 namespace phidgets {
00004 
00005 IR::IR():
00006   Phidget(),
00007   ir_handle_(0)
00008 {
00009   // create the handle
00010   CPhidgetIR_create(&ir_handle_);
00011 
00012   // pass handle to base class
00013   Phidget::init((CPhidgetHandle)ir_handle_);
00014 
00015   // register base class callbacks
00016   Phidget::registerHandlers();
00017   
00018   // register ir data callback
00019         CPhidgetIR_set_OnCode_Handler(ir_handle_, CodeHandler, this);
00020 }
00021 
00022 
00023 int IR::CodeHandler(CPhidgetIRHandle ir, void *userptr, unsigned char *data, int dataLength, int bitCount, int repeat)
00024 {
00025   ((IR*)userptr)->codeHandler(data, dataLength, bitCount, repeat);
00026   return 0;
00027 }
00028 
00029 void IR::codeHandler(unsigned char *data, int dataLength, int bitCount, int repeat)
00030 {
00031         int i;
00032         printf("DataLength: %d, Bit Count: %d, Repeat: %d\n", dataLength, bitCount, repeat);
00033         printf("Code: ");
00034         for(i = 0; i < dataLength; i++)
00035         {
00036                 printf("%02x", data[i]); 
00037         }
00038         printf("\n");
00039 }
00040 
00041 } // namespace phidgets


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Sat Dec 28 2013 17:19:27