return ((uint64_t)now.tv_sec) * 1000000000 + ((uint64_t)now.tv_nsec);
}
-static uint16_t pwmbuffer[chips][12];
-
-static void lines(uint16_t data[chips][12]);
+static void lines(const uint16_t line[chips*12]);
static void getDelay(uint64_t *delay, uint64_t *last);
if (!readPin() && went_back) // we are still in the loop but we need to exit
goto end;
} // sleep between lines
- for (uint8_t i = 0; i < chips * 12; i++)
- {
- pwmbuffer[(chips - 1) - (i / 12)][11 - (i % 12)] = lester[p][deg][i];
- }
- lines(pwmbuffer);
+
+ lines(lester[p][deg]);
}
end:
while (readPin())
getDelay(&delay, &last);
went_back = false; //make shure we trigger on the rising edge
printf("%llu\n", delay);
- if(p == 2)
- p = 0;
- else
- p++;
+ if (p == 2)
+ p = 0;
+ else
+ p++;
*swap = true;
}
}
*last = nanos();
*delay = (*last - tmp) / degreesIn;
}
-static void lines(uint16_t line[chips][12])
+static void lines(const uint16_t line[chips*12])
{
- uint8_t *data = (uint8_t *)malloc(chips * 28);
- for (int i = 0; i < chips; i++)
- tlc59711_create(line[i], data + (28 * i));
+ uint8_t data[chips*28];
+ uint16_t tmp[12];
+ for (int i = 0; i < chips; i++){
+ for(int b = 0; b < 12;b++)
+ tmp[11 - b] = line[(i*12)+b];
+
+ tlc59711_create(tmp, data + (28 * i));
+ }
transfer(data, NULL, chips * 28);
}