Skip to content

Commit

Permalink
super bright check.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
andyh0913 committed Mar 22, 2019
1 parent 542ba69 commit 2e2689f
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions control_7688/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mraa::Spi spi(SPI_PORT);
#endif

bool light[16];
bool wslight = true;

unsigned int num_ws = 5;
unsigned int num_led[] = {88,96,60,36,36};
Expand Down Expand Up @@ -56,28 +57,15 @@ int main() {
pca.setPWM(conf.pins[i], 0, (light[i] ? 4095 : 0));
#endif
}
printf("> ");
if(!(~scanf("%d", &id))) break;
if(id == -1) {
for(int i = 0; i < 16; ++i) {
light[i] = true;
}
} else if(id == -2) {
for(int i = 0; i < 16; ++i) {
light[i] = false;
}
} else {
id %= 16;
light[id] = !light[id];
}
if (id == -1){

if (wslight){
for(unsigned int i=0;i<num_ws;i++){
spi.writeByte( (uint8_t)(63) ); // start byte
spi.writeByte( (uint8_t)(62) ); // start byte
spi.writeByte( (uint8_t)(i) ); // i-th gif
for (unsigned int j=0;j<num_led[i];j++){
spi.writeByte( (uint8_t)(6) );
spi.writeByte( (uint8_t)(6) );
spi.writeByte( (uint8_t)(6) );
spi.writeByte( (uint8_t)(60) );
spi.writeByte( (uint8_t)(60) );
spi.writeByte( (uint8_t)(60) );
}
}
}
Expand All @@ -92,6 +80,25 @@ int main() {
}
}
}

printf("> ");
if(!(~scanf("%d", &id))) break;
if(id == -1) {
wslight = true;
for(int i = 0; i < 16; ++i) {
light[i] = true;
}
} else if(id == -2) {
wslight = false;
for(int i = 0; i < 16; ++i) {
light[i] = false;
}
} else {
wslight = false;
id %= 16;
light[id] = !light[id];
}

}
return 0;
}

0 comments on commit 2e2689f

Please sign in to comment.