USB Host Shield 2.0
Loading...
Searching...
No Matches
AMBX.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Aran Vink. All rights reserved.
2
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9
10 Contact information
11 -------------------
12
13 Aran Vink
14 e-mail : aranvink@gmail.com
15 */
16
17#ifndef _ambxusb_h_
18#define _ambxusb_h_
19
20#include "Usb.h"
21#include "AMBXEnums.h"
22
23/* AMBX data taken from descriptors */
24#define AMBX_EP_MAXPKTSIZE 40 // max size for data via USB
25
26/* Names we give to the 3 AMBX but note only one is actually used (output) */
27#define AMBX_CONTROL_PIPE 0
28#define AMBX_OUTPUT_PIPE 1
29#define AMBX_INPUT_PIPE 2
30
31/* PID and VID of the different devices */
32#define AMBX_VID 0x0471 // Philips
33#define AMBX_PID 0x083F // AMBX Controller
34
35/* Endpoint addresses */
36#define AMBX_ENDPOINT_IN 0x81
37#define AMBX_ENDPOINT_OUT 0x02
38#define AMBX_ENDPOINT_PNP 0x83
39
40/* Output payload constants */
41#define AMBX_PREFIX_COMMAND 0xA1
42#define AMBX_SET_COLOR_COMMAND 0x03
43
44/* LEFT/RIGHT lights. Normally placed adjecent to your screen. */
45#define AMBX_LIGHT_LEFT 0x0B
46#define AMBX_LIGHT_RIGHT 0x1B
47
48/* Wallwasher lights. Normally placed behind your screen. */
49#define AMBX_LIGHT_WW_LEFT 0x2B
50#define AMBX_LIGHT_WW_CENTER 0x3B
51#define AMBX_LIGHT_WW_RIGHT 0x4B
52
53#define AMBX_LIGHT_COMMAND_BUFFER_SIZE 6
54
55
56#define AMBX_MAX_ENDPOINTS 3
57
63class AMBX : public USBDeviceConfig {
64public:
69 AMBX(USB *pUsb);
70
79 uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
89 uint8_t Poll();
90
95 virtual uint8_t GetAddress() {
96 return bAddress;
97 };
98
105 virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
106 return (vid == AMBX_VID && (pid == AMBX_PID));
107 };
120
126
131 void attachOnInit(void (*funcOnInit)(void)) {
132 pFuncOnInit = funcOnInit;
133 };
137
138protected:
145
146private:
150 void onInit();
151 void (*pFuncOnInit)(void); // Pointer to function called in onInit()
152
153 uint8_t writeBuf[AMBX_EP_MAXPKTSIZE]; // General purpose buffer for output data
154
155 /* Private commands */
156 void Light_Command(uint8_t *data, uint16_t nbytes);
157};
158
159#endif
#define AMBX_MAX_ENDPOINTS
Definition AMBX.h:56
#define AMBX_EP_MAXPKTSIZE
Definition AMBX.h:24
#define AMBX_VID
Definition AMBX.h:32
#define AMBX_PID
Definition AMBX.h:33
AmbxColorsEnum
Definition AMBXEnums.h:21
AmbxLightsEnum
Definition AMBXEnums.h:30
Definition AMBX.h:63
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
Definition AMBX.h:105
uint8_t Poll()
Definition AMBX.cpp:212
uint8_t Release()
Definition AMBX.cpp:205
EpInfo epInfo[AMBX_MAX_ENDPOINTS]
Definition AMBX.h:144
bool AMBXConnected
Definition AMBX.h:136
void attachOnInit(void(*funcOnInit)(void))
Definition AMBX.h:131
USB * pUsb
Definition AMBX.h:140
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition AMBX.cpp:37
uint8_t bAddress
Definition AMBX.h:142
void setAllLights(AmbxColorsEnum color)
Definition AMBX.cpp:237
void setLight(uint8_t ambx_light, uint8_t r, uint8_t g, uint8_t b)
Definition AMBX.cpp:223
virtual uint8_t GetAddress()
Definition AMBX.h:95
Definition UsbCore.h:220