CoffeePi
Coffee machine control for Raspberry Pi
stripe.h
Go to the documentation of this file.
1 /*
2  * stripe.h
3  *
4  * Created on: Sep 25, 2017
5  * Author: Philipp Hinz
6  */
7 
8 #ifndef STRIPE_H_
9 #define STRIPE_H_
10 
11 // i2c
12 #define I2C_ADDRESS_STRIPE 0x69
13 #define STRIPE_CMD_SETR 0x01
14 #define STRIPE_CMD_SETG 0x02
15 #define STRIPE_CMD_SETB 0x03
16 #define STRIPE_CMD_SETW 0x04
17 #define STRIPE_CMD_SETDIM 0x05
18 #define STRIPE_CMD_SET 0x06 // Bytes: DIM R G B W
19 #define STRIPE_CMD_SET2 0x07 // Bytes: DIM R G B
20 #define STRIPE_CMD_RESET 0x09
21 #define STRIPE_CMD_FADEOUT 0x0A // Bytes: TIMEH TIMEL
22 #define STRIPE_CMD_FADETO 0x0B // Bytes: R G B W TIMEH TIMEL
23 #define STRIPE_CMD_FADESTOP 0x0C
24 
25 // Color transient (fading) parameters
26 typedef enum {
30  TRANS_SLOW = 200
32 
33 struct stripe_color {
34  int red = 0;
35  int green = 0;
36  int blue = 0;
37 };
38 
39 void *stripeThread(void *threadid);
40 void *stripeTimerHandler(void *threadid);
41 void stripeInit(void);
42 int stripeCommand(int len, char* data);
43 void stripeUpdate(void);
44 void stripeUpdateDim(void);
45 void stripeSetRGB(int red, int green, int blue);
46 void stripeSetColor(stripe_color color);
48 void stripeSetDim(int dim);
49 void stripeSetWhite(int white);
50 void stripeOn(void);
51 void stripeOff(void);
52 void stripeGetRGB(int* red, int* green, int* blue);
53 void stripeGetDim(int* dim);
54 void stripeGetWhite(int* white);
55 void stripeEffectDisable(void);
56 void stripeEffectHeating(int percent);
58 
59 #endif /* STRIPE_H_ */
stripe_transient_t
Definition: stripe.h:26
Definition: stripe.h:28
void * stripeTimerHandler(void *threadid)
This is the handler for time based stripe effects.
Definition: stripe.cpp:30
void stripeSetWhite(int white)
Updates the white value of the stripe (4th channel)
Definition: stripe.cpp:198
void stripeGetDim(int *dim)
Reads the current stripe dimmer value.
Definition: stripe.cpp:236
void stripeGetWhite(int *white)
Reads the current stripe white value (4th channel)
Definition: stripe.cpp:244
void stripeEffectDisable(void)
Stops current running effects.
Definition: stripe.cpp:251
Definition: stripe.h:29
void stripeOn(void)
Turns the stripe on (Sets dimmer to 100%)
Definition: stripe.cpp:205
void * stripeThread(void *threadid)
Thread for the stripe control.
Definition: stripe.cpp:45
Definition: stripe.h:33
Definition: stripe.h:30
int red
Definition: stripe.h:34
int blue
Definition: stripe.h:36
void stripeUpdate(void)
Updates the color data and prepares the stripe command.
Definition: stripe.cpp:119
void stripeEffectPulse(stripe_color color)
Enables pulsing with a given color of the stripe.
Definition: stripe.cpp:276
void stripeInit(void)
Initializes i2c communication to stripe controller.
Definition: stripe.cpp:78
Definition: stripe.h:27
void stripeOff(void)
Turns the stripe on (Sets dimmer to 0%)
Definition: stripe.cpp:215
void stripeEffectHeating(int percent)
Sets the stripe to a correspondending color to the heating status.
Definition: stripe.cpp:259
int stripeCommand(int len, char *data)
Sends out command data to the stripe controller via i2c.
Definition: stripe.cpp:101
void stripeSetTransient(stripe_transient_t transient)
Updates the transient time for the stripe (fading)
Definition: stripe.cpp:182
int green
Definition: stripe.h:35
void stripeSetRGB(int red, int green, int blue)
Updates the color of the stripe.
Definition: stripe.cpp:163
void stripeGetRGB(int *red, int *green, int *blue)
Reads the current stripe color.
Definition: stripe.cpp:226
void stripeSetColor(stripe_color color)
Updates the color of the stripe.
Definition: stripe.cpp:174
void stripeUpdateDim(void)
Updates the dimmer value of the stripe.
Definition: stripe.cpp:147
void stripeSetDim(int dim)
Updates the dimmer value of the stripe.
Definition: stripe.cpp:190