123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include "lpd8806.h"
- #include <signal.h>
-
- void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait);
-
- int doWork = 0;
- upm::LPD8806 *sensor = NULL;
-
- void
- sig_handler(int signo)
- {
- printf("got signal\n");
- if (signo == SIGINT) {
- printf("exiting application\n");
- doWork = 1;
- }
- }
-
- int
- main(int argc, char **argv)
- {
-
- sensor = new upm::LPD8806(10, 7);
- usleep (1000000);
-
- sensor->show ();
-
- while (!doWork) {
-
- scanner(127, 0, 0, 30);
- scanner(0, 0, 127, 15);
- usleep (1000000);
- }
-
-
- std::cout << "exiting application" << std::endl;
-
- delete sensor;
-
- return 0;
- }
-
- void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait) {
- int i, j, pos, dir;
-
- pos = 0;
- dir = 1;
-
- for(i=0; i < ((sensor->getStripLength() - 1) * 8); i++) {
-
-
-
-
- sensor->setPixelColor(pos - 2, r/4, g/4, b/4);
- sensor->setPixelColor(pos - 1, r/2, g/2, b/2);
- sensor->setPixelColor(pos, r, g, b);
- sensor->setPixelColor(pos + 1, r/2, g/2, b/2);
- sensor->setPixelColor(pos + 2, r/4, g/4, b/4);
-
- sensor->show();
- usleep (wait * 1000);
-
-
-
- for(j=-2; j<= 2; j++) {
- sensor->setPixelColor(pos+j, 0,0,0);
- }
-
- pos += dir;
- if(pos < 0) {
- pos = 1;
- dir = -dir;
- } else if (pos >= sensor->getStripLength()) {
- pos = sensor->getStripLength() - 2;
- dir = -dir;
- }
- }
- }
|