From 2e2689f868364e16972465abc22801aaeaf3d8ba Mon Sep 17 00:00:00 2001 From: andyh0913 Date: Fri, 22 Mar 2019 22:00:30 +0800 Subject: [PATCH] super bright check.cpp --- control_7688/check.cpp | 45 ++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/control_7688/check.cpp b/control_7688/check.cpp index aa0641e..2a4540a 100644 --- a/control_7688/check.cpp +++ b/control_7688/check.cpp @@ -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}; @@ -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 "); + 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; }