Пример #1
0
void InitApp(void)
{
    /* Setup analog functionality and port direction */

    // enable multi-vector interrupts
    INTEnableSystemMultiVectoredInt();

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // STEP 2. configure Timer 1 using internal clock, 1:256 prescale

    OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, T1_TICK);

    // set up the timer interrupt with a priority of 2
    ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
    
    /* Zero to DELAY_COUNTER for Delay procedure. */
    StartTimer();

    /* Initialize peripherals */

    DisplayBacklightConfig();

//#if defined WANT_GOL_INIT
    GOLInit();
//#endif

//    TouchInit(NULL,NULL,NULL,NULL);

    DisplayBacklightOn();

    SPIFlashInit();
    
// initialize the components for Resistive Touch Screen
//#if defined WANT_TOUCH_INIT
//    TouchInit(NULL,NULL,NULL,NULL);
//#endif
//    SDCARDInit();
//    MP3Init();

    /* PORT Init                                                            */
    /* PORTD 0-3 bits inputs.                                               */
    /* PORTA 0-1 bits outputs.                                              */

    /* TODO Must be disable the JTAG port, that we are to appropriate using */
    /* RA0, and RA1 ports.  */

    DDPCONbits.JTAGEN = 0;  /* JTAG debug disabled */
    /* TODO D port output now !!!! */
    TRISDbits.TRISD14 = TRISDbits.TRISD15 = 0;
        /* Port D 14, 15, pins pull up resistor enabled */
//    CNPUEbits.CNPUE20 = CNPUEbits.CNPUE21 = 1;
    TRISAbits.TRISA0 = TRISAbits.TRISA1 = 0;

}
Пример #2
0
int main( void )
{
    GOL_MSG msg;                                    // GOL message structure to interact with GOL

    RGBMapColorPins();

    TRISBbits.TRISB1 = 0; // Debug
    LATBbits.LATB1   = 0;

    #ifdef USE_FRC
        OSCCON = 0x1102;    // Enable secondary oscillator, use FRC oscillator
        CLKDIV = 0x0000;    // FRC post-scaler (1:1), USB postscaler (1:1), CPU postscaler (1:1)
    #else
        #ifdef GO_SLOW
            OSCCON = 0x3302;    // Enable secondary oscillator, use HS oscillator
            CLKDIV = 0x0080;    // (not needed - FRC post-scaler (1:1)), USB postscaler (4:1), CPU postscaler (1:1)
        #else
            OSCCON = 0x3302;    // Enable secondary oscillator, use HS oscillator
            CLKDIV = 0x0000;    // (not needed - FRC post-scaler (1:1)), USB postscaler (1:1), CPU postscaler (1:1)
        #endif
    #endif
    RCON = 0;

    // Initialize USB Embedded Host
    USBInitialize( 0 );

    // Initialize the RTCC
    RTCCInit();

    // Initialize the graphics library
    GOLInit();

    // Initialize the touch pads.
    CTMUInit();

    // Initialize the reference timer.
    TickInit();


    while (1)
    {
        if (GOLDraw())                          // Draw the screen
        {
            TouchSenseButtonsMsg( &msg );       // Get a raw touchpad message
            if ((msg.uiEvent != EVENT_INVALID) && ((tick - displayChangeTime) > MESSAGE_DEAD_TIME))
            {
                TranslateTouchpad( &msg );      // Translate the raw message
                GOLMsg( &msg );                 // Process the message
            }
        }
    }
}
Пример #3
0
/************************************************************************
 Main																
 ************************************************************************/
int main( void )
{
	GOL_MSG msg;                                // Instance of GOL message structure 
												// to interact with Graphics Object layer
	    
	// Configure the Device Clock
	// Configure FRC to operate the device at 40MIPS
	// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
	// Fosc= 7.37M*43/(2*2)=79.2275Mhz for 40MIPS input clock
	PLLFBD = 41;								// M=43
	CLKDIVbits.PLLPOST = 0;						// N1=2
	CLKDIVbits.PLLPRE = 0;						// N2=2
	OSCTUN = 0;									// Tune FRC oscillator, if FRC is used
	RCONbits.SWDTEN = 0;						// Disable Watch Dog Timer

	// Clock switch to incorporate PLL
	__builtin_write_OSCCONH(0x01);				// Initiate Clock Switch to
												// FRC with PLL (NOSC=0b001)
	__builtin_write_OSCCONL(0x01);				// Start clock switching
	while(OSCCONbits.COSC != 0b001);			// Wait for Clock switch to occur
	while(OSCCONbits.LOCK!=1);					// Wait for PLL to lock
	
	// Starter Kit initialization delay
	Delay(2000);
	
	// Initialize Speaker and Switches
	PIC24HSKInit();
       		
    // Initialize the OLED module and Microchip Graphics Library
    GOLInit();     	
	picture = &introDevice;

    while (1)
    {
        if (GOLDraw())                          // Draw the screen
        {
            AccelerometerMsg(&msg); 	      	// Get the raw accelerometer message
            if ((msg.uiEvent != EVENT_INVALID) && ((tick - displayChangeTime) > MESSAGE_DEAD_TIME))
            {
                TranslateAccelerometer(&msg);   // Translate the raw accelerometer message
                GOLMsg(&msg);                   // Process the message through to Graphics Object layer 
            }
        }
    }
}
Пример #4
0
/////////////////////////////////////////////////////////////////////////////
// Function: InitializeBoard()
// Input: none
// Output: none
// Overview: Initializes the hardware components including the PIC device
//           used.
/////////////////////////////////////////////////////////////////////////////
void InitializeBoard(void)
{    
     CLKDIVbits.RCDIV = 0;
     CLKDIVbits.DOZE = 0;
     CLKDIVbits.PLLEN = 1;
     CLKDIVbits.CPDIV = 0;
     OSCCONbits.COSC = 0b001;
     
     ANSA = 0x0000;
     ANSB = 0x0000;
     ANSC = 0x0010;		// RC4 as touch screen X+
     ANSD = 0x0000;
     ANSE = 0x0200;		// RE9 used as Y+
     ANSF = 0x0000;
     ANSG = 0x0000;
	
	LED_TRIS = 0;
	
    // Initialize graphics library and create default style scheme for GOL
    GOLInit();
	_DPTEST = 0b00;
	
	i2cInit();
	SPI1CON1 = 0b0000000100111110;
    SPI1STAT = 0x8000;
    
    RFIF = 0;
    if( RF_INT_PIN == 0 )
    {
        RFIF = 1;
    }

    //The following are PIC device specific settings for the SPI channel
    //used. 
    //Set IOs directions for SST25 SPI
        SST25_CS_LAT = 1;
        Nop();
        SST25_CS_TRIS = 0;

        SST25_SCK_TRIS = 0;
        Nop();
        SST25_SDO_TRIS = 0;
        Nop();
        SST25_SDI_TRIS = 1;

		//radio pins
		_RP11R = 8; // assign RP11 for SCK1
     	_RP2R = 7; // assign RP2 for SDO1
     	_SDI1R = 36; // assign RP36 for SDI1
     	_INT1R = 37;
    // set the peripheral pin select for the PSI channel used
        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS
    	#if (SST25_SPI_CHANNEL == 1)
    	    RPOR3bits.RP6R = 8;                 // assign RP6 for SCK1
    	    RPOR9bits.RP18R = 7;                 // assign RP18 for SDO1
    	    RPINR20bits.SDI1R = 32;              // assign RP18 for SDI1
        #elif (SST25_SPI_CHANNEL == 2)
            _RP6R = 11;                // assign RP11 for SCK2
    	    _RP18R = 10;                // assign RP2 for SDO2
    	    _SDI2R = 32;              // assign RP36 for SDI2
    	#endif
		

     	
        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS
	
	//radio
	PHY_CS_TRIS = 0;
    Nop();
    PHY_CS = 1;
    Nop();
    PHY_RESETn_TRIS = 0;
    PHY_RESETn = 1;
    RF_INT_TRIS = 1;
    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;
    SPI_SDO = 0;        
    SPI_SCK = 0; 
    PHY_WAKE_TRIS = 0;
    PHY_WAKE = 1;
    
	LED = 1;
	TRISAbits.TRISA1 = 0;
	Nop();
	PORTAbits.RA1 = 1;
	
	// initialize the Flash Memory driver
    FlashInit(&SPI_Init_Data);
    LED = 0;
    // initialize the timer that manages the tick counter
    TickInit(); 
                     
    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, TOUCH_INIT_VALUES);
    LED = 0;
}    
Пример #5
0
/*****************************************
 *int main (void)
 *****************************************/
int main (void)
{
    InitializeHardware();
    HardwareButtonInit();
    InitAllLEDs();
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH     
	GFX_DRIVER_AutoUpdPart();		// Turn on widget auto update, partial update for less flashing
#endif
    
    InitTick();
	GOLInit();

    SetColor(WHITE);
    ClearDevice();

	// Set proper display rotation
#if(DISP_ORIENTATION == 90)
    GFX_DRIVER_InitRotmode(ROTATE_90);
#else
#error "This PICTail display orientation must be 90."
#endif
       
	// make sure that the correct hex file is loaded
    CheckExternalFlashHex();

	// Create cursor in GFX_CURSOR_LAYER with Alpha Color = 0xA
	GFX_DRIVER_CreateLayer( GFX_CURSOR_LAYER, GFX_LAYER_TRANS_EN | 0xA, GetX(), GetY(), GetX() + 31, GetY() + 31 );
	GFX_DRIVER_ActivateLayer( GFX_CURSOR_LAYER );
	PutImage(0, 0, (void *)&mouse_cursor_icon_270, IMAGE_NORMAL); 
	GFX_DRIVER_ActivateLayer( GFX_MAIN_LAYER );
	
	// Start demo screen 
	demoScreens = DEMO_INTRO_SCREEN_CREATE;
	
    while(1)
	{
        GOLDraw();
#ifndef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
	#if defined( ONE_CYCLE_DRAWING	) 
		// The screen drawing starts and completes during one while(1) cycle loop in main().
		// This Demo is one cycle drawing application.
        if ( GFX_DRIVER_IsUpdateRequested() || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }
	#else
		// This way can be used when drawing may take few or more cycles of while(1) loop in main().
		// See "tick.c" file for details.
        if ( g_UpdateNow || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	        g_UpdateNow = 0;
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }	
	#endif
#endif		 
	}	

    return (-1);
}
Пример #6
0
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
}
Пример #7
0
/////////////////////////////////////////////////////////////////////////////
// Function: InitializeBoard()
// Input: none
// Output: none
// Overview: Initializes the hardware components including the PIC device
//           used.
/////////////////////////////////////////////////////////////////////////////
void InitializeBoard(void)
{
        /////////////////////////////////////////////////////////////////////////////
        // ADC Explorer 16 Development Board Errata (work around 2)
        // RB15 should be output
        /////////////////////////////////////////////////////////////////////////////
            LATBbits.LATB15 = 0;
            TRISBbits.TRISB15 = 0;

    #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;

        #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
            AD1PCFGLbits.PCFG6 = 1;
            AD1PCFGLbits.PCFG7 = 1;
            AD1PCFGLbits.PCFG8 = 1;
        #endif
        
    #elif defined(__PIC32MX__)
        INTEnableSystemMultiVectoredInt();
        SYSTEMConfigPerformance(GetSystemClock());
    #endif // #if defined(__dsPIC33F__) || defined(__PIC24H__)
    

    #if defined (EXPLORER_16)
/************************************************************************
* For Explorer 16 RD12 is connected to EEPROM chip select.
* To prevent a conflict between this EEPROM and SST25 flash
* the chip select of the EEPROM SPI should be pulled up.
************************************************************************/
        // Set IOs directions for EEPROM SPI
        MCHP25LC256_CS_LAT = 1;			    // set initial CS value to 1 (not asserted)
    	MCHP25LC256_CS_TRIS = 0;			// set CS pin to output
	#endif // #if defined (EXPLORER_16)


     //The following are PIC device specific settings for the SPI channel
     //used. 
    
     //Set IOs directions for SST25 SPI   
        SST25_CS_LAT = 1;
        SST25_CS_TRIS = 0;
 
       #ifndef __PIC32MX__
            SST25_SCK_TRIS = 0;
            SST25_SDO_TRIS = 0;
            SST25_SDI_TRIS = 1;
            #if defined(__PIC24FJ256GB210__)
            	SST25_SDI_ANS = 0;
    	    #endif
       #endif
    // set the peripheral pin select for the PSI channel used
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
        AD1PCFGL = 0xFFFF;
        RPOR9bits.RP18R = 11;                   // assign RP18 for SCK2
        RPOR8bits.RP16R = 10;                   // assign RP16 for SDO2
        RPINR22bits.SDI2R = 17;                 // assign RP17 for SDI2	
    #elif defined(__PIC24FJ256GB110__) || defined(__PIC24FJ256GA110__) || defined (__PIC24FJ256GB210__)
        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS
        RPOR10bits.RP21R = 11;                  // assign RP21 for SCK2
        RPOR9bits.RP19R = 10;                   // assign RP19 for SDO2
        RPINR22bits.SDI2R = 26;                 // assign RP26 for SDI2
        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS
    #elif defined(__PIC24FJ256DA210__)

        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS

    	#if (SST25_SPI_CHANNEL == 1)
    	    RPOR1bits.RP2R = 8;                 // assign RP2 for SCK1
    	    RPOR0bits.RP1R = 7;                 // assign RP1 for SDO1
    	    RPINR20bits.SDI1R = 0;              // assign RP0 for SDI1
        #elif (SST25_SPI_CHANNEL == 2)
            RPOR1bits.RP2R = 11;                // assign RP2 for SCK2
    	    RPOR0bits.RP1R = 10;                // assign RP1 for SDO2
    	    RPINR22bits.SDI2R = 0;              // assign RP0 for SDI2
    	#endif

        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS

    #endif

    /////////////////////////////////////////////////////////////////////////////
    //                  DRIVER SPECIFIC INITIALIZATION DATA
    /////////////////////////////////////////////////////////////////////////////

	GOLInit();                      // Initialize graphics library and create default style scheme for GOL

    // initialize GFX3 SST25 flash SPI
    SST25Init((void*) &SPI_Init_Data);                    
   
    TickInit();                     	

	
#if defined(SPI_CHANNEL_1_ENABLE) && defined(__PIC32MX__)          //SPI1 shares pins with the PMP CS. Not recommended for use
    SPI1TouchInit();

/****
 * AR1020 Touch Screen Controller
 *
 * Because the AR1020 needs to use the SPI channel to retrieve data and 
 * SPI channel 1 shares the PMP CS pin, this combination is not supported.
 * The user will receive a compile time error to avoid run time errors 
 * with this combination.
 ****/
#ifdef USE_TOUCHSCREEN_AR1020
#error "The combination of AR1020 touch screen controller and SPI 1 channel is not supported.  Please use SPI channel 2 with the AR1020 controller, or resistive touch."
#endif

#else	
    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, TOUCH_INIT_VALUES);  
#endif	

    HardwareButtonInit();           	// Initialize the hardware buttons

}   
Пример #8
0
/*********************************************************************
 * Function:       void CreateSchemes(void) 
 *
 * PreCondition:    None
 *
 * Input:           None
 *                  
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Create the styles used by the various screens
 *					Since the creation process involves calls
 *					to malloc/free vai the GOL we suspend all
 *					other tasks from executing because the standard
 *					malloc/free are not re-entrant
 *
 * Note:            
 ********************************************************************/
void CreateSchemes(void)
{
	vTaskSuspendAll();
	
	// Initialize the GOL
	GOLInit();
//	ANSAbits.ANSA7 = 1;  //because GOLInit reinitialise PRESS2  analog input back to digital


	if(green_sch != NULL) free(green_sch);
	green_sch = GOLCreateScheme();
	green_sch->Color0 = GREEN;
	green_sch->Color1 = GREEN;
	green_sch->ColorDisabled = GREEN;
	green_sch->CommonBkColor = GREEN;
	green_sch->EmbossDkColor = GREEN;
	green_sch->EmbossLtColor = GREEN;
	green_sch->TextColor0 = BLACK;
	green_sch->TextColor1 = BLACK;
	green_sch->pFont = (void*)&arial_narrow_0_0_0_14;
	
	
	if(basicscheme != NULL) free(basicscheme);
	basicscheme = GOLCreateScheme();
	basicscheme->Color0 = 11542;
	basicscheme->Color1 = 64969;
	basicscheme->ColorDisabled = 55070;
	basicscheme->CommonBkColor = 59196;
	basicscheme->EmbossDkColor = 6172;
	basicscheme->EmbossLtColor = 44765;
	basicscheme->TextColor0 = 64520;
	basicscheme->TextColor1 = 31;
	basicscheme->pFont = (void*)&arial_narrow_0_0_0_14;

	if(topbar != NULL) free(topbar);
	topbar = GOLCreateScheme();
	topbar->Color0 = BLUE_DARK;
	topbar->Color1 = BLUE_DARK;
	topbar->ColorDisabled = GRAY;
	topbar->TextColorDisabled = GRAY_LIGHT;
	topbar->CommonBkColor = BLUE_DARK;
	topbar->EmbossDkColor = BLUE_DARK;
	topbar->EmbossLtColor = BLUE_DARK;
	topbar->TextColor0 = WHITE;
	topbar->TextColor1 = WHITE;
//	topbar->pFont = (void*)&arial_narrow_0_0_0_14;
	topbar->pFont = (void*)&Arial_Narrow_26;
	
//	if(basicbig != NULL) free(basicbig);
//	basicbig = GOLCreateScheme();
//	basicbig->Color0 = 19583;
//	basicbig->Color1 = 64969;
//	basicbig->ColorDisabled = 55070;
//	basicbig->CommonBkColor = 59196;
//	basicbig->EmbossDkColor = 6172;
//	basicbig->EmbossLtColor = 44765;
//	basicbig->TextColor0 = 64520;
//	basicbig->TextColor1 = 31;
//	basicbig->pFont = (void*)&arial_narrow_0_0_0_20;
	
	if(defscheme != NULL) free(defscheme);
	defscheme = GOLCreateScheme();
	defscheme->Color0 = WHITE;
	defscheme->Color1 = GRAY_LIGHT;
	defscheme->ColorDisabled = 55070;
	defscheme->CommonBkColor = BLUE_LIGHT;
	defscheme->EmbossDkColor = BLUE_DARK;
	defscheme->EmbossLtColor = BLUE_DARK;
	defscheme->TextColor0 = BLACK;
	defscheme->TextColor1 = BLACK;//WHITE;
	defscheme->pFont = (void*)&Arial_Narrow_26;
	
	if(botbar != NULL) free(botbar);
	botbar = GOLCreateScheme();
	botbar->Color0 = BLUE_DARK;
	botbar->Color1 = BLUE_LIGHT;
	botbar->ColorDisabled = 55070;
	botbar->CommonBkColor = BLUE_LIGHT;
	botbar->EmbossDkColor = WHITE;
	botbar->EmbossLtColor = WHITE;
	botbar->TextColor0 = WHITE;
	botbar->TextColor1 = WHITE;
	botbar->pFont = (void*)&Arial_Narrow_Bold_18;
	
#if 0	
	// create the display schemes
	btnSchemeSmall = GOLCreateScheme();
	btnSchemeSmall->EmbossDkColor = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->EmbossLtColor = RGB565CONVERT(0xA9, 0xDB, 0xEF);
	btnSchemeSmall->TextColor0 = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->TextColor1 = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->TextColorDisabled = RGB565CONVERT(0xFF, 0xFF, 0xFF);
	btnSchemeSmall->Color0 = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->Color1 = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->ColorDisabled = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->CommonBkColor = RGB565CONVERT(0x1E, 0x00, 0xE5);
	btnSchemeSmall->pFont = (void*) &GOLSmallFont;
	
	btnSchemeMedium = GOLCreateScheme();
	memcpy(btnSchemeMedium, btnSchemeSmall, sizeof(GOL_SCHEME));
	btnSchemeMedium->pFont = (void*) &GOLMediumFont;
	
	blueScheme = GOLCreateScheme();
	blueScheme->TextColor0 = BLACK;
	blueScheme->TextColor1 = BLACK;
	blueScheme->TextColorDisabled = BLACK;
	
	greenScheme = GOLCreateScheme();
	greenScheme->Color0 = RGB565CONVERT(0x23, 0x9E, 0x0A);
	greenScheme->Color1 = BRIGHTGREEN;
	greenScheme->ColorDisabled = RGB565CONVERT(0x23, 0x9E, 0x0A);
	greenScheme->EmbossDkColor = DARKGREEN;
	greenScheme->EmbossLtColor = PALEGREEN;
	greenScheme->TextColor0 = RGB565CONVERT(0xFF, 0xFF, 0xFF);
	greenScheme->TextColor1 = BLACK;
	greenScheme->TextColorDisabled = RGB565CONVERT(0xDF, 0xAC, 0x83);

	redScheme = GOLCreateScheme();
	redScheme->Color0 = RGB565CONVERT(0xCC, 0x00, 0x00);
	redScheme->Color1 = BRIGHTRED;
	redScheme->EmbossDkColor = RED4;
	redScheme->EmbossLtColor = FIREBRICK1;
	redScheme->TextColor0 = RGB565CONVERT(0xC8, 0xD5, 0x85);
	redScheme->TextColor1 = BLACK;

	whiteScheme = GOLCreateScheme();
	whiteScheme->EmbossDkColor = RGB565CONVERT(0x40, 0x40, 0x40);
	whiteScheme->EmbossLtColor = RGB565CONVERT(0xE0, 0xE0, 0xE0);
	whiteScheme->TextColor0 = RGB565CONVERT(0x00, 0x00, 0x00);
	whiteScheme->TextColor1 = RGB565CONVERT(0x00, 0x00, 0x00);
	whiteScheme->TextColorDisabled = RGB565CONVERT(0x00, 0x00, 0x00);
	whiteScheme->Color0 = RGB565CONVERT(0xA0, 0xA0, 0xA0);
	whiteScheme->Color1 = RGB565CONVERT(0xA0, 0xA0, 0xA0);
	whiteScheme->ColorDisabled = RGB565CONVERT(0xFF, 0xFF, 0xFF);
	whiteScheme->CommonBkColor = RGB565CONVERT(0xFF, 0xFF, 0xFF);
	whiteScheme->pFont = (void*) &GOLFontDefault;
	   
#endif
	blackScheme = GOLCreateScheme();
	memcpy(blackScheme, botbar, sizeof(GOL_SCHEME));
	blackScheme->Color0 = BLACK;
	blackScheme->CommonBkColor = BLACK;
	blackScheme->TextColor0 = RGB565CONVERT(0xFF, 0xFF, 0xFF);
	blackScheme->TextColor1 = BLACK;
//	blackScheme->pFont = (void*) &GOLMediumFont;

	ConfirmShemes();
	AlarmShemes();
	BolusShemes();
	PrimeShemes();
	RunShemes();
	PwrdownShemes();
	
	xTaskResumeAll();
}