ir.cpp
Go to the documentation of this file.
1 #include "phidgets_api/ir.h"
2 
3 namespace phidgets {
4 
6  Phidget(),
7  ir_handle_(0)
8 {
9  // create the handle
10  CPhidgetIR_create(&ir_handle_);
11 
12  // pass handle to base class
13  Phidget::init((CPhidgetHandle)ir_handle_);
14 
15  // register base class callbacks
17 
18  // register ir data callback
19  CPhidgetIR_set_OnCode_Handler(ir_handle_, CodeHandler, this);
20 }
21 
22 
23 int IR::CodeHandler(CPhidgetIRHandle /* ir */, void *userptr, unsigned char *data, int dataLength, int bitCount, int repeat)
24 {
25  ((IR*)userptr)->codeHandler(data, dataLength, bitCount, repeat);
26  return 0;
27 }
28 
29 void IR::codeHandler(unsigned char *data, int dataLength, int bitCount, int repeat)
30 {
31  int i;
32  printf("DataLength: %d, Bit Count: %d, Repeat: %d\n", dataLength, bitCount, repeat);
33  printf("Code: ");
34  for(i = 0; i < dataLength; i++)
35  {
36  printf("%02x", data[i]);
37  }
38  printf("\n");
39 }
40 
41 } // namespace phidgets
virtual void codeHandler(unsigned char *data, int dataLength, int bitCount, int repeat)
Definition: ir.cpp:29
virtual void registerHandlers()
Definition: phidget.cpp:16
Definition: ir.h:8
static int CodeHandler(CPhidgetIRHandle ir, void *userPtr, unsigned char *data, int dataLength, int bitCount, int repeat)
Definition: ir.cpp:23
IR()
Definition: ir.cpp:5
void init(CPhidgetHandle handle)
Definition: phidget.cpp:23
CPhidgetIRHandle ir_handle_
Definition: ir.h:16


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Tue May 7 2019 03:19:24