#include "procFrekvens.h"

#define PROC_COLOR 0x7
procFrekvens::procFrekvens(Timer *t, PPI *ppi, Log *log) {
	this->t = t;
	this->ppi = ppi;
	this->log = log;
	LogData ld("Process Frekvens startet");
	this->log->skriv(ld);
}

void procFrekvens::run() {
	int frekv, tmp = 0;
	int oldf = 0;	
	WWindow *win = WNewWindow(42, 21, 74, 23, 500, PROC_COLOR, " Frekvens: ");
	t->start(1);
	while (true) {
		frekv = this->t->read()-1;
		RTKDelay(10);
		tmp	= this->t->read()-1;
		if ( tmp < frekv ) {
			tmp = tmp + 65534;
		}
		WPutC( win, 0x0C );
		//Wprintf( win, "%d\n%d\n", frekv, tmp);

		tmp -= frekv;
		tmp *= 10;
		tmp /= 1000;
		/*if ( tmp != oldf ) {
			LogData ld( "Frekvens opdateret" );
			this->log->skriv(ld);
			oldf = tmp;
		}*/
		Wprintf( win, "%d kHz", tmp );
	}
}
