ledbar/arduino/controlled/controlled.ino
2012-06-30 19:24:16 +02:00

34 lines
870 B
C++

#include "../ledbar.h"
class Ledbar lb[NUM_TLCS];
int c[cpinsets][CH];
int wait = 10;
void setup()
{
Serial.begin(38400);
int i = 0, led = 0;
for (i = 0; i < NUM_TLCS; i++)
lb[i].begin(B1100000 | i << 1);
for (led = 0; led < cpinsets; led++) {
for (i = 0; i < CH; i++) {
c[led][i] = cmax[led][i] / 2;
lb[cpin[led][i] >> 4].setPinMode(cpin[led][i] & 0xf, LPM_PWM);
}
}
}
void loop()
{
int led, i;
for (led = 0; led < cpinsets; led++) {
for (i = 0; i < CH; i++) {
while (!Serial.available());
unsigned long s = (unsigned char) Serial.read();
// Serial.print(cpin[led][i], DEC); Serial.print("="); Serial.print(s, DEC); Serial.print("/"); Serial.print(cmax[led][i], DEC); Serial.print(" ");
lb[cpin[led][i] >> 4].setPinPWM(cpin[led][i] & 0xf, s * cmax[led][i] / 256);
}
}
// Serial.println();
}