working version with calibration done

Fork of Eurobot2013 by Oskar Weigl

Committer:
xiaxia686
Date:
Wed Nov 14 15:48:20 2012 +0000
Revision:
3:8c78c15a92e3
Merged with Sonar;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xiaxia686 3:8c78c15a92e3 1 #include "system.h"
xiaxia686 3:8c78c15a92e3 2
xiaxia686 3:8c78c15a92e3 3 //Defining the externs
xiaxia686 3:8c78c15a92e3 4 DigitalOut OLED1(LED1);
xiaxia686 3:8c78c15a92e3 5 DigitalOut OLED2(LED2);
xiaxia686 3:8c78c15a92e3 6 DigitalOut OLED3(LED3);
xiaxia686 3:8c78c15a92e3 7 DigitalOut OLED4(LED4);
xiaxia686 3:8c78c15a92e3 8
xiaxia686 3:8c78c15a92e3 9 //nop style wait function
xiaxia686 3:8c78c15a92e3 10 void nopwait(int ms){
xiaxia686 3:8c78c15a92e3 11 while(ms--)
xiaxia686 3:8c78c15a92e3 12 for (volatile int i = 0; i < 24000; i++);
xiaxia686 3:8c78c15a92e3 13 }
xiaxia686 3:8c78c15a92e3 14
xiaxia686 3:8c78c15a92e3 15 float cpupercent; //defining the extern
xiaxia686 3:8c78c15a92e3 16 void measureCPUidle (void const* arg) {
xiaxia686 3:8c78c15a92e3 17
xiaxia686 3:8c78c15a92e3 18 Timer timer;
xiaxia686 3:8c78c15a92e3 19 cpupercent = 0; //defined in system.h
xiaxia686 3:8c78c15a92e3 20
xiaxia686 3:8c78c15a92e3 21 while(1) {
xiaxia686 3:8c78c15a92e3 22 timer.reset();
xiaxia686 3:8c78c15a92e3 23 timer.start();
xiaxia686 3:8c78c15a92e3 24 wait(1);
xiaxia686 3:8c78c15a92e3 25
xiaxia686 3:8c78c15a92e3 26 int thistime = timer.read_us()-1000000;
xiaxia686 3:8c78c15a92e3 27 cpupercent = thistime;
xiaxia686 3:8c78c15a92e3 28 }
xiaxia686 3:8c78c15a92e3 29 }