|
@@ -31,7 +31,7 @@ void *stripeTimerHandler(void *threadid) {
|
|
|
if (currentColor.red == effectColor.red
|
|
|
&& currentColor.green == effectColor.green
|
|
|
&& currentColor.blue == effectColor.blue) {
|
|
|
- stripeSetRGB(0,0,0);
|
|
|
+ stripeSetRGB(0, 0, 0);
|
|
|
} else {
|
|
|
stripeSetColor(effectColor);
|
|
|
}
|
|
@@ -61,9 +61,11 @@ void *stripeThread(void *threadid) {
|
|
|
logger(V_NONE, LOG_ERRORC, "Simulating %d%% percent heating\n", tmp);
|
|
|
sleep(1);
|
|
|
if (inc) {
|
|
|
- if (++tmp >= 100) inc = 0;
|
|
|
+ if (++tmp >= 100)
|
|
|
+ inc = 0;
|
|
|
} else {
|
|
|
- if (--tmp <= 0) inc = 1;
|
|
|
+ if (--tmp <= 0)
|
|
|
+ inc = 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -77,11 +79,11 @@ void stripeInit() {
|
|
|
i2cfd = wiringPiI2CSetup(I2C_ADDRESS_STRIPE);
|
|
|
if (i2cfd < 0) {
|
|
|
logger_error("Could not initialize i2c with device ID 0x%.2x (%s)\n",
|
|
|
- I2C_ADDRESS_STRIPE, strerror(errno));
|
|
|
+ I2C_ADDRESS_STRIPE, strerror(errno));
|
|
|
pthread_exit(NULL);
|
|
|
}
|
|
|
logger(V_STRIPE, "Initialized i2c device on address 0x%.2x\n",
|
|
|
- I2C_ADDRESS_STRIPE);
|
|
|
+ I2C_ADDRESS_STRIPE);
|
|
|
currentColor.red = 0;
|
|
|
currentColor.green = 0;
|
|
|
currentColor.blue = 0;
|
|
@@ -94,17 +96,19 @@ void stripeInit() {
|
|
|
* Sends out command data to the stripe controller via i2c
|
|
|
* @param len Length of the data array
|
|
|
* @param *data Pointer to data array
|
|
|
+ * @return Number of failed bytes, 0 if successful
|
|
|
*/
|
|
|
int stripeCommand(int len, char* data) {
|
|
|
int ret = 0;
|
|
|
int i = 0;
|
|
|
pthread_mutex_lock(&mutex);
|
|
|
for (i = 0; i < len; i++) {
|
|
|
- ret += wiringPiI2CWriteReg8(i2cfd, i, data[i]);
|
|
|
+ ret -= wiringPiI2CWriteReg8(i2cfd, i, data[i]);
|
|
|
}
|
|
|
logger(V_STRIPE, "Wrote %d bytes to i2c device\n", len);
|
|
|
if (ret)
|
|
|
- logger(V_NONE, LOG_WARN, "Failed to write %d of %d bytes on i2c device\n", ret, len);
|
|
|
+ logger(V_NONE, LOG_WARN,
|
|
|
+ "Failed to write %d of %d bytes on i2c device\n", ret, len);
|
|
|
pthread_mutex_unlock(&mutex);
|
|
|
return ret;
|
|
|
}
|
|
@@ -255,13 +259,14 @@ void stripeEffectDisable(void) {
|
|
|
void stripeEffectHeating(int percent) {
|
|
|
long red, blue;
|
|
|
|
|
|
- if (percent > 100) percent = 100;
|
|
|
+ if (percent > 100)
|
|
|
+ percent = 100;
|
|
|
|
|
|
red = percent * 255;
|
|
|
- blue = (100-percent) * 255;
|
|
|
+ blue = (100 - percent) * 255;
|
|
|
|
|
|
stripeSetTransient(TRANS_FAST);
|
|
|
- stripeSetRGB(red/100,0,blue/100);
|
|
|
+ stripeSetRGB(red / 100, 0, blue / 100);
|
|
|
}
|
|
|
|
|
|
/**
|