// ---------------------------------------------------- // TEST application for // Cruise Control application for Panther Electro-Steer // // -- TEST2 -- read the ElectroSteer switches // // Copyright 2005,2006, Mike Noel, All Rights Reserved // ---------------------------------------------------- #include #include #include #include // ********************* Definitions ********************* // digital i/o port definitions. // 0 - output - reflex uses to drive buzzer... // 1 - output - drive ES relay to go port // 2 - output - drive ES relay to go starboard // 3 - input - read ES switch labeled DN // 4 - input - read ES switch labeled UP // 5 - output - enable Horizontal Daventech compass // 6 - output - enable Vertical Daventech compass // 7 - input - read configuration switch labeled 4 // 8 - input - read configuration switch labeled 3 // 9 - input - read configuration switch labeled 2 // 10- input - read configuration switch labeled 1 #define PORTDIO 1 #define STARDIO 2 #define DnButton 3 #define UpButton 4 #define EnaHC 5 #define EnaVC 6 #define Config4 7 #define Config3 8 #define Config2 9 #define Config1 10 // ********************* Test Routine ******************** void main () { int i=0, sup=0, sdown=0, s=0, olds=0; // initialize the digital input ports aDig_Config(UpButton, ADIG_INPUT); aDig_Config(DnButton, ADIG_INPUT); // Print sign on message aPrint_String("Test 2, read ElectroSteer switches\n"); aCore_Sleep(2000); // Loop for 15 seconds (150 tenths) reading switches and noting changes for (i=0; i<150; i++) { sup = aDig_ReadInt(UpButton); sdown = aDig_ReadInt(DnButton); s = (sup * 10) + sdown; if (s != olds) { aPrint_IntDec(i); aPrint_String(" "); aPrint_IntDec(sup); aPrint_String(" "); aPrint_IntDec(sdown); aPrint_String("\n"); aCore_Sleep(1000); olds = s; } else aCore_Sleep(1000); } // Print sign off message aPrint_String("Test 2 finished\n"); aCore_Sleep(1000); }