Permalink
Browse files

computing frame delays in main project

  • Loading branch information...
1 parent d5cb82d commit 175e8a3e795f356a9d3edcf02ee1fd4aaf2065a0 @x37v committed Sep 8, 2012
Showing with 19 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +2 −1 capture.c
  3. +16 −0 led_driver.cpp
View
@@ -9,3 +9,4 @@ other/
*.lai
*.la
*.a
+*.swp
View
@@ -785,7 +785,8 @@ long_options [] = {
int main (int argc, char ** argv) {
dev_name = "/dev/video0";
- output_name = "/dev/ttyUSB000";
+ //output_name = "/dev/ttyUSB000";
+ output_name = "/dev/ttyACM0";
//printf("%ld\n", sizeof(struct v4l2_buffer));
View
@@ -6,16 +6,19 @@
#include <string.h>
#include <unistd.h>
#include <cstdlib>
+#include <sys/time.h>
using std::cout;
using std::endl;
+#define COMPUTE_FRAME_DELAY
namespace {
std::ofstream serial;
unsigned int num_leds;
unsigned int num_leds_div_8;
uint8_t * led = NULL;
+ struct timeval time_last;
}
uint8_t reverse_bits(uint8_t b) {
@@ -42,6 +45,7 @@ void write_latch(std::ofstream& out, unsigned int num_leds) {
void draw(std::ofstream& out) {
uint8_t packet[64];
int packet_byte = 0;
+ struct timeval time_now;
//we are writing for 7 panels at once
for (unsigned int i = 0; i < (num_leds / 8); i++) {
@@ -75,6 +79,16 @@ void draw(std::ofstream& out) {
}
*/
}
+
+#ifdef COMPUTE_FRAME_DELAY
+ memcpy(&time_last, &time_now, sizeof(struct timeval));
+ gettimeofday(&time_now, NULL);
+ if (time_now.tv_usec > time_last.tv_usec) {
+ cout << (time_now.tv_sec - time_last.tv_sec - 1) * 1000000 + (time_now.tv_usec + 1000000 - time_last.tv_usec) << endl;
+ } else {
+ cout << (time_now.tv_sec - time_last.tv_sec) * 1000000 + (time_now.tv_usec - time_last.tv_usec) << endl;
+ }
+#endif
}
int led_open_output(char * device_path, unsigned int led_count) {
@@ -90,6 +104,8 @@ int led_open_output(char * device_path, unsigned int led_count) {
return 0;
}
+ gettimeofday(&time_last, NULL);
+
return 1;
}

0 comments on commit 175e8a3

Please sign in to comment.