/********************************************************************* * Function: void TouchLoadCalibration(void) * * PreCondition: EEPROMInit() must be called before * * Input: none * * Output: none * * Side Effects: none * * Overview: loads calibration parameters from EEPROM * * Note: none * ********************************************************************/ void TouchLoadCalibration(void){ #if ((GRAPHICS_PICTAIL_VERSION == 2) || (GRAPHICS_PICTAIL_VERSION == 250)) _calXMin = EEPROMReadWord(ADDRESS_XMIN); _calXMax = EEPROMReadWord(ADDRESS_XMAX); _calYMin = EEPROMReadWord(ADDRESS_YMIN); _calYMax = EEPROMReadWord(ADDRESS_YMAX); #else _calXMin = SST25ReadWord(ADDRESS_XMIN); _calXMax = SST25ReadWord(ADDRESS_XMAX); _calYMin = SST25ReadWord(ADDRESS_YMIN); _calYMax = SST25ReadWord(ADDRESS_YMAX); #endif }
int main(void) { GOL_MSG msg; // GOL message structure to interact with GOL Nop(); #if defined(PIC24FJ256DA210_DEV_BOARD) _ANSG8 = 0; /* S1 */ _ANSE9 = 0; /* S2 */ _ANSB5 = 0; /* S3 */ #else ///////////////////////////////////////////////////////////////////////////// // ADC Explorer 16 Development Board Errata (work around 2) // RB15 should be output ///////////////////////////////////////////////////////////////////////////// #ifndef MULTI_MEDIA_BOARD_DM00123 LATBbits.LATB15 = 0; TRISBbits.TRISB15 = 0; #endif #endif ///////////////////////////////////////////////////////////////////////////// #if defined(__dsPIC33F__) || defined(__PIC24H__) // Configure Oscillator to operate the device at 40Mhz // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2 // Fosc= 8M*40(2*2)=80Mhz for 8M input clock PLLFBD = 38; // M=40 CLKDIVbits.PLLPOST = 0; // N1=2 CLKDIVbits.PLLPRE = 0; // N2=2 OSCTUN = 0; // Tune FRC oscillator, if FRC is used // Disable Watch Dog Timer RCONbits.SWDTEN = 0; // Clock switching to incorporate PLL __builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary // Oscillator with PLL (NOSC=0b011) __builtin_write_OSCCONL(0x01); // Start clock switching while(OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur // Wait for PLL to lock while(OSCCONbits.LOCK != 1) { }; // Set PMD0 pin functionality to digital AD1PCFGL = AD1PCFGL | 0x1000; #elif defined(__PIC32MX__) INTEnableSystemMultiVectoredInt(); SYSTEMConfigPerformance(GetSystemClock()); #ifdef MULTI_MEDIA_BOARD_DM00123 CPLDInitialize(); CPLDSetGraphicsConfiguration(GRAPHICS_HW_CONFIG); CPLDSetSPIFlashConfiguration(SPI_FLASH_CHANNEL); #endif // #ifdef MULTI_MEDIA_BOARD_DM00123 #endif // #if defined(__dsPIC33F__) || defined(__PIC24H__) GOLInit(); // initialize graphics library & // create default style scheme for GOL #if defined (GFX_PICTAIL_V1) || defined (GFX_PICTAIL_V2) EEPROMInit(); // initialize Exp.16 EEPROM SPI BeepInit(); #else #if defined (USE_SST25VF016) SST25Init(); // initialize GFX3 SST25 flash SPI #endif #endif TouchInit(); // initialize touch screen HardwareButtonInit(); // Initialize the hardware buttons // create default style scheme for GOL TickInit(); // initialize tick counter (for random number generation) // create default style scheme for GOL #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__) // If S3 button on Explorer 16 board is pressed calibrate touch screen TRISAbits.TRISA9 = 1; if(PORTAbits.RA9 == 0) { TRISAbits.TRISA9 = 0; TouchCalibration(); TouchStoreCalibration(); } TRISAbits.TRISA9 = 0; #else /** * Force a touchscreen calibration by pressing the switch * Explorer 16 + GFX PICTail - S3 (8 bit PMP) * Explorer 16 + GFX PICTail - S5 (16 bit PMP) * Starter Kit + GFX PICTail - S0 (8 bit PMP) * Multimedia Expansion Board - Fire Button * DA210 Developement Board - S1 * NOTE: Starter Kit + GFX PICTail will switches are shared * with the 16 bit PMP data bus. **/ if(GetHWButtonTouchCal() == HW_BUTTON_PRESS) { TouchCalibration(); TouchStoreCalibration(); } #endif // If it's a new board (EEPROM_VERSION byte is not programed) calibrate touch screen #if defined (GFX_PICTAIL_V1) || defined (GFX_PICTAIL_V2) if(GRAPHICS_LIBRARY_VERSION != EEPROMReadWord(ADDRESS_VERSION)) { TouchCalibration(); TouchStoreCalibration(); } #else #if defined (USE_SST25VF016) if(GRAPHICS_LIBRARY_VERSION != SST25ReadWord(ADDRESS_VERSION)) { TouchCalibration(); TouchStoreCalibration(); } #elif defined (USE_SST39LF400) WORD tempArray[12], tempWord = 0x1234; SST39LF400Init(tempArray); tempWord = SST39LF400ReadWord(ADDRESS_VERSION); SST39LF400DeInit(tempArray); if(GRAPHICS_LIBRARY_VERSION != tempWord) { TouchCalibration(); TouchStoreCalibration(); } #endif #endif // Load touch screen calibration parameters from memory TouchLoadCalibration(); GDDDemoCreateFirstScreen(); while(1) { if(GOLDraw()) // Draw GOL object { TouchGetMsg(&msg); // Get message from touch screen #if (NUM_GDD_SCREENS > 1) // GDD Readme: // The following line of code allows a GDD user to touch the touchscreen // to cycle through different static screens for viewing. This is useful as a // quick way to view how each screen looks on the physical target hardware. // This line of code should eventually be commented out for actual development. // Also note that widget/object names can be found in GDD_Screens.h if(msg.uiEvent == EVENT_RELEASE) GDDDemoNextScreen(); #endif GOLMsg(&msg); // Process message } }//end while }