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 uint16_t pwmbuffer[chips][12];
21 static void lines(uint16_t data[chips][12]);
23 static void getDelay(uint64_t *delay, uint64_t *last);
25 extern void display(bool *go, const uint16_t lester[3][degreesIn][chips * 12], bool *swap)
29 tlc59711_init("/dev/spidev0.1");
30 uint64_t delay = 0, last = 0;
31 bool went_back = true;
35 for (int deg = 0; deg < degreesIn; deg++)
36 { // go thorugh degrees
37 while (last + ((delay)*deg) > nanos())
38 { // sleep between lines
40 went_back = true; // we can now wait for the next edge
41 if (!readPin() && went_back) // we are still in the loop but we need to exit
43 } // sleep between lines
44 for (uint8_t i = 0; i < chips * 12; i++)
46 pwmbuffer[i / 12][11 - (i % 12)] = lester[p][deg][i];
52 ; // wait till it goes low if we exited the loop early
53 getDelay(&delay, &last);
54 went_back = false; //make shure we trigger on the rising edge
55 printf("%llu\n", delay);
63 static void getDelay(uint64_t *delay, uint64_t *last)
67 *delay = (*last - tmp) / degreesIn;
69 static void lines(uint16_t line[chips][12])
71 uint8_t *data = (uint8_t *)malloc(chips * 28);
72 for (int i = 0; i < chips; i++)
73 tlc59711_create(line[i], data + (28 * i));
74 transfer(data, NULL, chips * 28);