8 inline static int readPin()
12 static uint64_t nanos()
15 timespec_get(&now, TIME_UTC);
16 return ((uint64_t)now.tv_sec) * 1000000000 + ((uint64_t)now.tv_nsec);
19 static void lines(const uint16_t line[chips*12]);
21 static void getDelay(uint64_t *delay, uint64_t *last);
23 extern void display(bool *go, const uint16_t lester[3][degreesIn][chips * 12], bool *swap)
27 tlc59711_init("/dev/spidev0.1");
28 uint64_t delay = 0, last = 0;
29 bool went_back = true;
33 for (int deg = 0; deg < degreesIn; deg++)
34 { // go thorugh degrees
35 while (last + ((delay)*deg) > nanos())
36 { // sleep between lines
38 went_back = true; // we can now wait for the next edge
39 if (!readPin() && went_back) // we are still in the loop but we need to exit
41 } // sleep between lines
43 lines(lester[p][deg]);
47 ; // wait till it goes low if we exited the loop early
48 getDelay(&delay, &last);
49 went_back = false; //make shure we trigger on the rising edge
50 printf("%llu\n", delay);
58 static void getDelay(uint64_t *delay, uint64_t *last)
62 *delay = (*last - tmp) / degreesIn;
64 static void lines(const uint16_t line[chips*12])
66 uint8_t data[chips*28];
68 for (int i = 0; i < chips; i++){
69 for(int b = 0; b < 12;b++)
70 tmp[11 - b] = line[i];
72 tlc59711_create(tmp, data + (28 * i));
74 transfer(data, NULL, chips * 28);