INT main(VOID) {
   HWND hwnd;
   HAB hab;
   HMQ hmq;
   QMSG qmsg;
   HWND hHlp;

   hmq = WinCreateMsgQueue(hab = WinInitialize(0), 0);
   hwnd = WinLoadDlg(HWND_DESKTOP,  // parent
                     NULLHANDLE,    // owner
                     dlgProc,       // dialog window proc
                     NULLHANDLE,    // module handle
                     ID_MAIN,      // dialog template ID
                     NULL);         // application data pointer

   if (hwnd) {
      hHlp = initHelp(hwnd);
      while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
         WinDispatchMsg(hab, &qmsg);
      endHelp(hwnd, hHlp);
   }

   WinDestroyWindow(hwnd);
   WinDestroyMsgQueue(hmq);
   WinTerminate(hab);
   return 0;
} /* end main */
#include "TinyTimber.h"
#include "GUI.h"
#include "PulseGene.h"
#include "joystick.h"
#include "init.h"
#include "Gate.h"
#include <avr/io.h>

//50% duty cycle, half time on and half time off.

GATE gate = initGATE(0,1,0);						//writepulseleft, writepulseright, pulseguard
PULSEGEN pulsegen1 = initPG(0,0,0,0, &gate, 0);		//freq, pos, old, saved, gate, whichpulse
PULSEGEN pulsegen2 = initPG(0,3,0,0, &gate, 1);
GUI g = initGUI(&pulsegen1, &pulsegen2, 1);			//pulse1, pulse2, pulseused
HELP help = initHelp(&g,0);
Joystick j = initJoy(&help, 0);

int main(void){
	
	init();
	INSTALL(&j, joystickPORTE, IRQ_PCINT0);			//Right, Left
	INSTALL(&j, joystickPORTB, IRQ_PCINT1);			//Up, Down, Press

	return TINYTIMBER(&g, update, 0);
}