/********************************************************************* * dimmer example for Versa1.0 * Connect dimmer board to Versa1's VNH2 port. *********************************************************************/ #define BOARD Versa1 #include #include #include t_delay mainDelay; //----------- Setup ---------------- void setup(void) { fruitInit(); dimmerInit(); // init dimmer module delayStart(mainDelay, 20000); // init the mainDelay to 20 ms //----------- Switch setup ---------------- switchInit(); // init switch module switchSelect(0,K1); // assign connector K1 to switch channel 0 switchSelect(1,K2); switchSelect(2,K3); switchSelect(3,K4); } // ---------- Main loop ------------ void loop() { fraiseService();// listen to Fraise events dimmerService(); // dimmer management routine switchService(); // switch management routine if(delayFinished(mainDelay)) // when mainDelay triggers : { delayStart(mainDelay, 20000); // re-init mainDelay //dimmerPrintDebug(); // switchSend(); } } // ---------- Interrupts ------------ void highInterrupts() { dimmerHighInterrupt(); } void lowInterrupts() { dimmerLowInterrupt(); } // ---------- Receiving ------------ void fraiseReceive() // receive raw bytes { unsigned char c=fraiseGetChar(); if(c==40) dimmerReceive(); // if first byte is 40, then call dimmer receive function. }