#include "procLED.h"

#define PROC_COLOR 0x7

procLED::procLED(RTKMailbox *mb, LEDPort *leds, Log *log) {
	this->log = log;
	this->mb = mb;
	this->leds = leds;
	LogData ld("Process LED startet");
	this->log->skriv(ld);
}

void procLED::run() {
	WWindow *win = WNewWindow(5, 15, 36, 17, 500, PROC_COLOR, " LEDs: ");
	char com;
	while (true) {
		WPutC( win, 0x0C );
		Wprintf( win, "Leds: ");
		for ( int i=0; i<=7; i++)
			Wprintf( win, "%d", leds->on(i) );

		RTKGet( *(this->mb), &com );
		if ( com == 'a' ) {
			leds->setall(~leds->status());
		}
		else {			
			com = com-'0';
			leds->toggle(com);
		}

	}
}