~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/win/include/vrpn_Analog_Radamec_SPI.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef VRPN_RADAMEC_SPI_H
 
2
#define VRPN_RADAMEC_SPI_H
 
3
 
 
4
#include "vrpn_Connection.h"
 
5
#include "vrpn_Analog.h"
 
6
 
 
7
class VRPN_API vrpn_Radamec_SPI: public vrpn_Serial_Analog
 
8
{
 
9
public:
 
10
        vrpn_Radamec_SPI (const char * name, vrpn_Connection * c,
 
11
                        const char * port, int baud = 38400);
 
12
 
 
13
        ~vrpn_Radamec_SPI () {};
 
14
 
 
15
        /// Called once through each main loop iteration to handle updates.
 
16
        virtual void mainloop ();
 
17
 
 
18
  protected:
 
19
        int _status;                //< Reset, Syncing, or Reading
 
20
        int _camera_id;             //< What is our camera ID, queried from device
 
21
        int _numchannels;           //< How many analog channels to open
 
22
 
 
23
        unsigned _expected_chars;           //< How many characters to expect in the report
 
24
        unsigned char _buffer[512]; //< Buffer of characters in report
 
25
        unsigned _bufcount;                 //< How many characters we have so far
 
26
 
 
27
        struct timeval timestamp;   //< Time of the last report from the device
 
28
 
 
29
        virtual int reset(void);                //< Set device back to starting config
 
30
        virtual int get_report(void);           //< Try to read a report from the device
 
31
 
 
32
        virtual void clear_values(void);        //< Clears all channels to 0
 
33
 
 
34
        /// Compute the CRC for the message or report starting at head with length len.
 
35
        unsigned char compute_crc(const unsigned char *head, int len);
 
36
 
 
37
        /// Convert a 24-bit value from a buffer into an unsigned integer value
 
38
        vrpn_uint32 convert_24bit_unsigned(const unsigned char *buf);
 
39
 
 
40
        /// Convert a 16-bit unsigned value from a buffer into an integer
 
41
        vrpn_int32  convert_16bit_unsigned(const unsigned char *buf);
 
42
 
 
43
        double  int_to_pan(vrpn_uint32 val);    //< Returns pan in degrees
 
44
        double  int_to_tilt(vrpn_uint32 val)    //< Returns tilt in degrees
 
45
                    { return int_to_pan(val); };
 
46
        double  int_to_zoom(vrpn_uint32 val);   //< Returns zoom in meters
 
47
        double  int_to_focus(vrpn_uint32 val);  //< Returns focal length in meters
 
48
        double  int_to_height(vrpn_uint32 val); //< Returns height in meters
 
49
        double  int_to_X(vrpn_uint32 mm, vrpn_uint32 frac);   //< Returns X location in meters
 
50
        double  int_to_Y(vrpn_uint32 mm, vrpn_uint32 frac)    //< Returns Y location in meters
 
51
                    { return int_to_X(mm, frac); };
 
52
        double  int_to_orientation(vrpn_uint32 val); //< Returns orientation in degrees
 
53
 
 
54
        /// Compute the CRC for the message, append it, and send message.
 
55
        /// Returns 0 on success, -1 on failure.
 
56
        int send_command(const unsigned char *cmd, int len);
 
57
 
 
58
        /// send report iff changed
 
59
        virtual void report_changes
 
60
                   (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
61
        /// send report whether or not changed
 
62
        virtual void report
 
63
                   (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
 
64
};
 
65
 
 
66
#endif