François Gautrais há 9 anos atrás
pai
commit
2ed48b8c06
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      recv.c

+ 6 - 1
recv.c

@@ -20,6 +20,7 @@ int main()
 	bus_t bus;
 	pthread_t thread;
 	FILE* file = NULL;
+	struct timeval tv;
 	setup_io();
 	bus_init_recv(&bus, PIN_DATA, PIN_CLK, PIN_ACK);
 	init_read_pin(PIN_DATA, PIN_CLK, PIN_ACK);
@@ -27,10 +28,14 @@ int main()
 	while(1)
 	{
 		uint32_t c;
+		double w;
 		char buffer[16];
 		bus_read(&bus, &c, 4);
+		
+		gettimeofday(&tv, NULL);
 		printf("%ld' s  %ld ms %'d us \n", c/1000000, c%1000000/1000, c%1000);
-
+		w=3600.0/(((double)c)/1000000.0);
+		printf("%ld : %.2lf W %.2lf\n\n", tv.tv_sec, w, w/220);
 	}