Example #1
0
void infoTemplate(char *information)
{
    int centerX = ROW_LENGTH/2;
    int centerY = COL_HEIGHT/2;

    //Clear previous information
    LCDSetRect(0, centerY - 9, ROW_LENGTH-1, 2*9, FILL, WHITE);
    //Information
    LCDPutStr(information, centerX - strlen(information)/2*8, centerY - 8, LARGE, WHITE, RED);
    delay(200);
}
Example #2
0
void basicTemplate(char *screenTitle, char *information, char *prevScreen, char *nextScreen)
{
    LCDClear(WHITE);
    // Header
    //// Screen Title
    ////// Top Bar
    LCDSetRect(0, 0, COL_HEIGHT-1, 25, FILL, RED);

    ////// Screen Title - Centered over the Top Bar
    int centerX = COL_HEIGHT/2;
    int centerY = 25/4;
    LCDPutStr(screenTitle, centerX - strlen(screenTitle)/2*8+2, centerY, LARGE, WHITE, RED);

    //Information
    centerX = ROW_LENGTH/2;
    centerY = COL_HEIGHT/2;
    LCDPutStr(information, centerX - strlen(information)/2*8, centerY - 8, LARGE, WHITE, RED);


    // Footer
    //// Navigation Bar
    ////// Bottom Bar
    LCDSetRect(0, COL_HEIGHT-20-1, ROW_LENGTH-1, 20, FILL, RED);

    //////// Previous Screen String
    centerX = ROW_LENGTH/4;
    centerY = COL_HEIGHT - (20 - 20/4);
    LCDPutStr(prevScreen, centerX - strlen(prevScreen)/2*8+2, centerY, MEDIUM, WHITE, RED);

    //////// Divider
    LCDSetRect(ROW_LENGTH/2 - 5, COL_HEIGHT-20-1, 10, 20, FILL, BLACK);

    //////// Next Screen String
    centerX = ROW_LENGTH/4 + ROW_LENGTH/2;
    centerY = COL_HEIGHT - (20 - 20/4);
    LCDPutStr(nextScreen, centerX - strlen(nextScreen)/2*8+2, centerY, MEDIUM, WHITE, RED);

    //delay(500);
}
// ----------------------------------------------------------
int main()
{
	AT91PS_PIO    p_pPioB  = AT91C_BASE_PIOB;
	AT91PS_PMC    p_pPMC   = AT91C_BASE_PMC;
	AT91PS_SYS    p_pSys   = AT91C_BASE_SYS;
	char		msg[100];
	Color_t		bckgColor=LCD_COLOR_RED;
	int			h, m, s;
	int value;
	float position=2;
	float change=4;

	// Initializations
	AT91F_LowLevel_Init();

	InitLCD();
	LCD_ClearScreen( bckgColor );
	//Backlight(0);

	//enable the clock of the PIO
	p_pPMC->PMC_PCER = 1 << AT91C_ID_PIOB;

	p_pPioB->PIO_ODR    = 0xffffffff;   // All as input
	p_pSys->PIOB_PPUDR  = 0xffffffff;   // Disable Pull-up resistor

	p_pPioB->PIO_OER = SPKR_BIT;	// Enable SPKR output

	p_pSys->PIOA_PPUDR  = 0xffffffff;   // Disable Pull-up resistor

#define	BIT_SW1 0x01000000
#define	BIT_SW2 0x02000000

	// BUTTON SW1
	p_pPioB->PIO_ODR |= BIT_SW1; //ure in Input
	p_pPioB->PIO_PER |= BIT_SW1; //Enable PB24

	h = m = 0;
	s = 1;

	AT91F_Finalize_Init();

	// Other actions executed once...
	//LCD_WriteString("The time is:", FONT_DESCRIPTOR, 10, 10, LCD_COLOR_BLACK, bckgColor);
	 /*
	tone( 1000,500);	
	tone( 2000,500);	
	tone( 3000,500);	
	tone( 4000,500);	
	*/
	
/*
	while(1)
	{
		p_pPioB->PIO_SODR = SPKR_BIT;

		Delay(5000000/2000);		//a stupid way to created 1S delay

		p_pPioB->PIO_CODR = SPKR_BIT;

		Delay(5000000/2000);		//a stupid way to created 1S delay
	}
*/
   
	// And the main loop follows ...
	while ( true )
	{
		/*ADC_GetChannel( AN_TRIMMER, &value );
		Delay(5000000);		//a stupid way to created 1S delay
		tone(value,150);
		// Clock algorithm
		s = s + 1;
		if (s==20) {
			s = 1;
			
		}

		// Printing the clock on the screen
		sprintf(msg, "%02d:%02d:%02d", h, m, s);
		*/
		//LCD_WriteString(msg, FONT_DESCRIPTOR, 30, 50, LCD_COLOR_BLACK, bckgColor);
		Delay(100);
		if(!((p_pPioB->PIO_PDSR) & BIT_SW1))
	    	if(position>=90 && position<=110){
				position=0;
				change=change+1;
			}
			LCDSetRect(65, 0, 85, 130, 1, LCD_COLOR_WHITE);
			LCDSetRect(65, 90, 85, 110, 0, LCD_COLOR_BLACK);
			LCD_WriteString("*", FONT_DESCRIPTOR, 72, ((int)position)%110, LCD_COLOR_BLACK, bckgColor);
			position=position+change;
		if(position>110){
		  return 0;
		}
		
	}
	return -1;	//Error, the execution mustn't get here!
}
int main (void) {

  SPIDDR=(1<<SDA)|(1<<CLK)|(1<<CS)|(1<<RESET); //Port-Direction Setup


  //Init Uart and send OK
  UCR = (1<<RXEN)|(1<<TXEN);
  UBRR=(F_CPU / (BAUD_RATE * 16L) - 1);
  loop_until_bit_is_set(USR, UDRE);
  UDR = 'O';
  loop_until_bit_is_set(USR, UDRE);
  UDR = 'K';


  CS0
  SDA0
  CLK1

  RESET1
  RESET0
  RESET1

  CLK1
  SDA1
  CLK1

  waitms(10);

  //Software Reset
  sendCMD(0x01);

  //Sleep Out
  sendCMD(0x11);

  //Booster ON
  sendCMD(0x03);

  waitms(10);

  //Display On
  sendCMD(0x29);

  //Normal display mode
  sendCMD(0x13);

  //Display inversion on
  sendCMD(0x21);

  //Data order
  sendCMD(0xBA);

  //Memory data access control
  sendCMD(0x36);

  sendData(8);   //rgb + MirrorX
 //sendData(8|64);   //rgb + MirrorX
 // sendData(8|128);   //rgb + MirrorY

#ifdef MODE565
  sendCMD(0x3A);
  sendData(5);   //16-Bit per Pixel
#else
  sendCMD(0x3A);
  sendData(3);   //12-Bit per Pixel (default)
#endif


  //Set Constrast
  sendCMD(0x25);
  sendData(55);


LCDClearScreen();

 LCDSetRect(50,0,100,50,1,ORANGE);
 unsigned char i=30;
 
 while (i>5){
 LCDSetCircle(100,100,i,BLACK);
 i = i-5;
 }
 
 LCDPutChar('A', 20, 20, SMALL, RED, BLUE);
 LCDPutChar('N', 20, 26, SMALL, RED, BLUE);
 LCDPutChar('D', 20, 32, 0, RED, BLUE);
 LCDPutChar('-', 20, 38, SMALL, RED, BLUE);
 LCDPutChar('T', 20, 42, SMALL, RED, BLUE);
 LCDPutChar('E', 20, 48, 0, RED, BLUE);
 LCDPutChar('C', 20, 54, SMALL, RED, BLUE);
 LCDPutChar('H', 20, 60, SMALL, RED, BLUE);
 LCDPutChar('.', 20, 66, 0, RED, BLUE);
 LCDPutChar('P', 20, 72, SMALL, RED, BLUE);
 LCDPutChar('L', 20, 78, 0, RED, BLUE);
 //LCDPutChar("Hello World!", 20, 20, SMALL, WHITE, BLACK);
 
 LCDSetLine(30,120,70,90,GREEN);
 LCDSetLine(70,90,30,70,GREEN);
 LCDSetLine(30,70,30,120,GREEN);
}