-
Notifications
You must be signed in to change notification settings - Fork 0
/
desklamp.h
122 lines (106 loc) · 3.13 KB
/
desklamp.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* @file desklamp.h
* @author J. Mintenbeck
* @date 2013/11/09
* @version 1.0
* @brief Desklamp API
*
*/
#ifndef __DESKLAMP_H
#define __DESKLAMP_H
/** CPU Clock */
#ifndef F_CPU
#define F_CPU 12000000UL
#endif
/**
* @name Port definitions
* @{
*/
#define DESKLAMP_LED_DDR DDRA
#define DESKLAMP_LED_PORT PORTA
#define DESKLAMP_PIN_LED1 PA7
#define DESKLAMP_PIN_LED2 PA6
#define DESKLAMP_PIN_LED3 PA5
#define DESKLAMP_PIN_DP_EXT PA3
#define DESKLAMP_PIN_DM_EXT PA2
/** @} */
#define LOWBYTE(var) (((uchar *)&(var))[0])
#define HIGHBYTE(var) (((uchar *)&(var))[1])
/**
* @name Desklamp Commands
* @{
*/
#define DESKLAMP_CMD_SET_LED 1
#define DESKLAMP_CMD_SET_COLORMODE 5
#define DESKLAMP_CMD_SET_ADAPTER 11
#define DESKLAMP_CMD_SET_RGB 3
#define DESKLAMP_CMD_SET_STROBE 4
#define DESKLAMP_CMD_SET_DIMMER 2
#define DESKLAMP_CMD_SET_SERIAL 10
#define DESKLAMP_CMD_GET_RGB 7
#define DESKLAMP_CMD_GET_COLORMODE 8
#define DESKLAMP_CMD_IS_ADAPTER 12
#define DESKLAMP_CMD_GET_DIMMER 6
#define DESKLAMP_CMD_GET_EXTUSB 9
/** @} */
/**
* @name Desklamp states
* @{
*/
#define DESKLAMP_STATE_IDLE 0
#define DESKLAMP_STATE_BUSY 1
#define DESKLAMP_STATE_RX_DATA 2 // received Data
#define DESKLAMP_STATE_TX_DATA 3 // transmit Data
/** @} */
/**
* @name Colormodes
* @{
*/
#define DESKLAMP_COLORMODE_RGB 0
#define DESKLAMP_COLORMODE_MONO 1
/** @} */
/** OPTIONS */
#define COLORMODE DESKLAMP_COLORMODE_MONO
#define USBADAPTER 1
#define STROBE 1
enum {OFF, ON}; // Values for OFF = 0 , ON = 1
enum {DISABLE, ENABLE}; // Values for DISABLE = 0 , ENABLE = 1
/** Typdef for the desklamp structure */
typedef struct {
uint8_t state;
uint8_t colormode; /** colormode: RGB or Single Color */
uint8_t r; /** red */
uint8_t g; /** green */
uint8_t b; /** blue */
uint8_t dimmer; /** dimmer */
uint8_t strobe; /** strobe value */
uint8_t blackout;
uint8_t usb_ext; /** ext USB check */
uint32_t serial;
uint8_t isAdapter;
}desklamp_t;
void desklamp_init(void);
void desklamp_config_channel(uint8_t channel, uint8_t state);
void desklamp_init_pwm(void);
void desklamp_update_pwm(void);
void desklamp_set_led(uint8_t led, uint8_t onoff);
void desklamp_set_led_intensity(uint8_t led, uint8_t intensity);
void desklamp_set_rgb(uint8_t r, uint8_t g, uint8_t b);
void desklamp_set_dimmer(uint8_t dimmer);
void desklamp_set_colormode(uint8_t colormode);
void desklamp_set_adapter(uint8_t isAdapter);
void desklamp_set_serial(uint32_t serial);
void desklamp_set_strobe(uint8_t strobe);
void desklamp_set_blackout(uint8_t blackout);
void desklamp_set_state(uint8_t state);
uint8_t desklamp_get_state(void);
uint8_t desklamp_get_colormode(void);
uint8_t desklamp_is_adapter(void);
uint32_t desklamp_get_serial(void);
uint8_t desklamp_get_rgb(char c);
uint8_t desklamp_get_dimmer(void);
uint16_t desklamp_get_hsv(char c);
uint8_t desklamp_get_strobe(void);
uint8_t desklamp_chk_extusb(void);
#endif /* __DESKLAMP_H */
/* --------------------------------- End Of File ------------------------------ */