/*
 * stripe.h
 *
 *  Created on: Sep 25, 2017
 *      Author: Philipp Hinz
 */

#ifndef STRIPE_H_
#define STRIPE_H_

// i2c
#define I2C_ADDRESS_STRIPE	0x69
#define STRIPE_CMD_SETR		0x01
#define STRIPE_CMD_SETG		0x02
#define STRIPE_CMD_SETB		0x03
#define STRIPE_CMD_SETW		0x04
#define STRIPE_CMD_SETDIM	0x05
#define STRIPE_CMD_SET		0x06	// Bytes: DIM R G B W
#define STRIPE_CMD_SET2		0x07	// Bytes: DIM R G B
#define STRIPE_CMD_RESET	0x09
#define STRIPE_CMD_FADEOUT	0x0A	// Bytes: TIMEH TIMEL
#define STRIPE_CMD_FADETO	0x0B	// Bytes: R G B W TIMEH TIMEL
#define STRIPE_CMD_FADESTOP	0x0C

// Color transient (fading) parameters
typedef enum {
	TRANS_DIRECT = 0,
	TRANS_FAST = 6,
	TRANS_MEDIUM = 35,
	TRANS_SLOW = 100
} stripe_transient_t;

struct stripe_color {
	int red = 0;
	int green = 0;
	int blue = 0;
};

void *stripeThread(void *threadid);
void *stripeTimerHandler(void *threadid);
void stripeInit(void);
int stripeCommand(int len, char* data);
void stripeUpdate(void);
void stripeUpdateDim(void);
void stripeFadeOut(void);
void stripeSetRGB(int red, int green, int blue);
void stripeSetColor(stripe_color color);
void stripeSetTransient(stripe_transient_t transient);
void stripeSetDim(int dim);
void stripeSetWhite(int white);
void stripeOn(void);
void stripeOff(void);
void stripeGetRGB(int* red, int* green, int* blue);
void stripeGetDim(int* dim);
void stripeGetWhite(int* white);
void stripeEffectDisable(void);
void stripeEffectHeating(int percent);
void stripeEffectPulse(stripe_color color);

#endif /* STRIPE_H_ */
