-
Notifications
You must be signed in to change notification settings - Fork 9
/
MissileLauncher.h
105 lines (87 loc) · 2.15 KB
/
MissileLauncher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* @mainpage Missile Launcher Arduino Library
*
* An Arduino library that allows you to control a USB MissileLauncher.
*
* http://hardwarefun.com/projects/missile-launcher
*
* @note Requires v2.0 of USB Host Shield Library available at https://github.com/felis/USB_Host_Shield_2.0
* @author Sudar <http://sudarmuthu.com> <http://hardwarefun.com>
* @version 0.1
*/
/*
* Copyright 2011 Sudar Muthu (http://sudarmuthu.com)
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer or coffee in return - Sudar
* ----------------------------------------------------------------------------
*/
#include <Usb.h>
#ifndef MissileLauncher_H
#define MissileLauncher_H
/**
* Enum to hold the different possible actions
*/
enum MissileLauncherActions {
DOWN = 1, /*!< down */
UP = 2, /*!< up */
LEFT = 4, /*!< left */
RIGHT = 8, /*!< right */
FIRE = 16, /*!< fire */
STOP = 32 /*!< Stop */
};
/**
* The core MissileLauncher class
*
* @todo: Make the movement related methods inline
*/
class MissileLauncher : public USB {
public:
/**
* Default constructor
*/
MissileLauncher();
/**
* Rotate upwards
*/
void moveUp();
/**
* Rotate downwards
*/
void moveDown();
/**
* Rotate Left
*/
void moveLeft();
/**
* Rotate Right
*/
void moveRight();
/**
* Fire the Missiles.
*
* Should call the stop method or any other movement methods to stop firing
*/
void fire();
/**
* Stop the device
*/
void stop();
private:
/**
* Send proper signal to the USB device based on command requested
*/
void issueCommand(MissileLauncherActions);
// variables
uint8_t addr;
uint8_t endPoint;
uint8_t bmReqType;
uint8_t bRequest;
uint8_t wValLo;
uint8_t wValHi;
uint16_t wInd;
uint16_t total;
};
#endif