Exemple #1
0
void main(){

  Lcd_Init();                        // Initialize Lcd

  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,6,txt3);                 // Write text in first row

  Lcd_Out(2,6,txt4);                 // Write text in second row
  Delay_ms(2000);
  Lcd_Cmd(_LCD_CLEAR);               // Clear display

  Lcd_Out(1,1,txt1);                 // Write text in first row
  Lcd_Out(2,5,txt2);                 // Write text in second row

  Delay_ms(2000);

  // Moving text
  for(i=0; i<4; i++) {               // Move text to the right 4 times
    Lcd_Cmd(_LCD_SHIFT_RIGHT);
    Move_Delay();
  }

  while(1) {                         // Endless loop
    for(i=0; i<8; i++) {             // Move text to the left 7 times
      Lcd_Cmd(_LCD_SHIFT_LEFT);
      Move_Delay();
    }

    for(i=0; i<8; i++) {             // Move text to the right 7 times
      Lcd_Cmd(_LCD_SHIFT_RIGHT);
      Move_Delay();
    }
  }
}
/*
obs: a emissao do registrador ADCON1 nos programas, acarreta o nao acionamento adequado do PORTA e consequentemente provoca o mal funcionamento do programa.
O pino RA4 do PIC eh dreno aberto, isto implica que devemos conectar resitor de pull-up quando formos trabalhar este pino como I/O de uso geral.
O PORTE tambem possui a funcao de conversores analogicos ou  digitais tambem. Devemos configurar o ADCON1 para trabalharmos o PORTE como IO de uso geral.
*/
char configureLcd4Bits2x16(){
  trise = 0; // pinos D como saida
  ADCON1 = 0x06; // Todos os pinos A/D como I/O uso geral
    Lcd_Init();
    //Lcd8_Config(&PORTE,&PORTD,2,1,0,7,6,5,4,3,2,1,0);
    return 0;
}
Exemple #3
0
void Lcd_TFT_Init(void)
{
	Lcd_Init();
	Lcd_PowerEnable(0, 1);
	Lcd_EnvidOnOff(1);		//turn on vedio
	Lcd_ClearScr( (0x00<<11) | (0x00<<5) | (0x00) );  
}
Exemple #4
0
int main(void) {
  Thread *shelltp = NULL;

  halInit();
  chSysInit();


  palSetPadMode(GPIOA,9,PAL_MODE_STM32_ALTERNATE_PUSHPULL);
  palSetPadMode(GPIOA,10,PAL_MODE_INPUT);
  sdStart(&SD1, NULL);

  shellInit();

  palSetPadMode(GPIOA,8,PAL_MODE_OUTPUT_PUSHPULL);
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  Lcd_Init();
  Lcd_Clear();
  Lcd_Example();

  while (TRUE) {
    if (!shelltp){
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);}
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);
      shelltp = NULL;
    }
    chThdSleepMilliseconds(500);
  }
}
Exemple #5
0
void init()
{
 TRISB = 0x08; // Set CAN input and output
 TRISD=0X00; //PORT D OUTPUT FOR LCD
 PIE3=0X01;
 Lcd_Init(&PORTD);
 CANCON = 0X80; // request to enter CAN configuration mode REQOP = 100
 while (CANSTAT!=0X80); //Wait to enter CAN configuration mode OPMODE = 100
 BRGCON1 = 0X03; // set SJW and BRP, SJW = 1TQ, BRP = 01H
 BRGCON2 = 0X90; // set Phase_Seg1 = 3TQ and Prog_Seg = 1TQ
 BRGCON3 = 0X42; // set Phase_Seg2 = 3TQ / / Set send mail 0 symbols and data
 RXB0SIDH = 0XFF; // set the receive buffer identifier 0
 RXB0SIDL = 0XFB;   //srr=1, EXID=1
 RXB0EIDH=0XFF;    //HIGH EXTENDED IDENTIFIER SET AS 1
 RXB0EIDL=0XFF;    //LOW EXTENDED IDENTIFIER SET AS 1
 RXB0CON = 0X40; // just to receive valid MSG DEPENDING of EXTENDED identifier, FILHIT0 = 0 means RXB0 uses filter0
                        //NOT USING FILTERS
 RXB0DLC = 0X08; // set the length of data area for receive buffer 0=8BYTES
 RXB0D0 = 0X00; // initialize data from receive buffer 0 data zone
 RXB0D1 = 0X00;
 RXB0D2 = 0X00;
 RXB0D3 = 0X00;
 RXB0D4 = 0X00;
 RXB0D5 = 0X00;
 RXB0D6 = 0X00;
 RXB0D7 = 0X00;
 RXM0SIDH = 0X00;   //FILTER DISABLED
 RXM0SIDL = 0X00;
 RXM0EIDH= 0X00;  //EXTENDED MASK DISABLED
 RXM0EIDL= 0X00;
 CIOCON = 0X00;
 CANCON = 0X00; // enable CAN enter normal operating mode
 while (CANSTAT!= 0) ;   //WAIT FOR NORMAL MODE TO ESTABLISH
 }
void main()
{
int i;



trisb=0;
portb=0;
     Lcd_Init();                        // Initialize LCD

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1)       // Endless loop
{
if (UART1_Data_Ready())    // If data is received,
{
 for(i=0;i<100;i++)
 {
 uart_rd[i]= UART1_Read();
}
for(i=0;i<100;i++)
{
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,1,uart_rd[i]);
  delay_ms(10000);
}
}
}
}
void main(){
ADCON1 = 0b00001110;             // HABILITA CANAL AN0 E AN1
TRISA.RA0 = 1;
Lcd_Init ();                     // START LCD
Lcd_Cmd(_Lcd_Clear);             // CLEAR LCD
Lcd_Cmd(_LCD_CURSOR_OFF);        // TURN OFF LCD CURSOR
ADC_Init();
while(1){
adc_rd = ADC_Read(0);                        // GET ADC VALUE FROM 1ST CHANNEL
EEPROM_Write(0x08, adc_rd);       //ESCREVE "adc_rd" NA POSICAO 0x08 DA EEPROM
IntToStr(adc_rd, adcprint);                            // CONVERSION TO STRING
Lcd_out(1,1,"COUNTS..: ");
Lcd_Out_Cp(adcprint);                     // PRINTS ADC STEPS IN LCD FIRST ROW
if (diff != adc_rd){
BarSegmentNum = adc_rd /(1023 / 16);
                                    // CALCULATE NUMBERS OF BAR GRAPH SEGMENTS
Lcd_out(2,1,"                ");    // CLEARS LCD SECOND ROW
for (i = 0; i < BarSegmentNum; i++){
                               // LOOP TO PRINT EACH BAR SEGMENT IN SECOND ROW
CustomChar(2, i+1);}}           // PRINT CUSTOM CHARACTER FOR BARGRAPH SEGMENT
Delay_ms(750);                                        // STABILIZE LCD DISPLAY
diff = adc_rd;
// LCD SHOWS EEPROM VALUE
ADCeer = EEPROM_Read(0x08);                     // LE A POSICAO 0x08 DA EEPROM
ShortToStr (ADCeer, ADCeerSTR);
//Lcd_Cmd(_LCD_CLEAR);                                  // LIMPA A TELA DO LCD
Lcd_Out(2, 1, ADCeerSTR);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);                                    // LIMPA A TELA DO LCD
}                                                                 // END WHILE
}                                                                  // END MAIN
void Lcd_Config() {
  Lcd_Init();
  LcdCommandWr(0x06);	                     // Set Entry mode, increment move
  LcdCommandWr(0x10);	                     // Display and cursor shift
  LcdCommandWr(0x0E);	                     // Switch display and cursor on
  LcdCommandWr(0x01);	                     // Clear the LCD and jump to zero
}
void main() {
     unsigned char write = 'A';
     unsigned char read;
     
     char buffer[10];
     
     TWI_Init(100000);
     Lcd_Init();
     
     Write24C64_Byte(DEV24C64_ADDR, 0x00, write);
     read = Read24C64_Byte(DEV24C64_ADDR, 0x00);
     
     IntToHex(read, buffer);
     Lcd_Out(1, 1, buffer);
     
     while (1);
     
     if( write == read ) {
         Lcd_Out(1, 1, "Successfully written");
     } else {
         Lcd_Out(1, 1, "Data writing failed");
     }
     

     while (1) {

     }
}
Exemple #10
0
////////////////////////////////////////////////////////////
//                    MAIN
////////////////////////////////////////////////////////////
void main(void) {
    // Configura el Oscilador interno a 8Mhz
     OSCCONbits.IRCF = 0b111;

     
     // InitAllLEDs
    PORTA = 0x00;
    TRISAbits.TRISA0 = 1; // 1 input	
    TRISAbits.TRISA1 = 1; // 1 input
    TRISAbits.TRISA2 = 1; // 1 input	
    TRISAbits.TRISA3 = 1; // 1 input	// FOR ADC
    TRISAbits.TRISA4 = 1; // 1 input
    TRISAbits.TRISA5 = 1; // 1 input	// ICSP VPP
    TRISAbits.TRISA6 = 1; // 1 input	// OSCILATOR
    TRISAbits.TRISA7 = 1; // 1 input	// OSCILATOR

    PORTB = 0x00;
    //TRISB = 0x00; // 0x00 all as output
	TRISBbits.TRISB0 = 0; // 0 output	
    TRISBbits.TRISB1 = 0; // 0 output	
    TRISBbits.TRISB2 = 0; // 0 output 	// FOR LCD_D4
    TRISBbits.TRISB3 = 0; // 0 output	// FOR LCD_D5
    TRISBbits.TRISB4 = 0; // 0 output	// FOR LCD_D6
    TRISBbits.TRISB5 = 0; // 0 output	// FOR LCD_D7
    TRISBbits.TRISB6 = 0; // 0 output	// PGD (1 is value on POR) & LCD_RS
    TRISBbits.TRISB7 = 0; // 0 output	// PGC (1 is value on POR) & LCD_E
    //PORTB = 0x00;
    
    initADC();
	Lcd_Init();

	//CMCON = 0x07;

    while(1) {
        // INIT ADC CONVERSION
        initADCConversion();
        while(isADCConversionReady() == 0) {
            ;
        }
        int result = getADC10bitResult(); // result = 0-1023


        float minValue = 0.0;
        float maxValue = 5.0;
        float unitValue = (maxValue-minValue)/1024; // 5.0 / 1024

        // Si el voltaje alcanza el máximo valor (Vref+) currentValue=5 y si se queda en el mínimo valor (Vref-) currentValue=0.
        float currentValue = result * unitValue;

        //setBCDsText(ftoa(currentValue, (int *) 0));
		//setBCDCharacterNumber(integ);


		Lcd_Clear();
	    Lcd_Set_Cursor(1,1);
	    Lcd_Write_String(ftoa(currentValue, (int *) 0));
    }

 }
Exemple #11
0
void LCD_init(void){
	Lcd_Init();
	Lcd_Clear();
	Lcd_Set_XY(0,0);
	Lcd_Write_String(0,0,"Rw_ECG");
	Lcd_Write_String(0,1,"Hello! Your   heart rate is: ");
	Lcd_Write_String(0,4,"---");
}
Exemple #12
0
void inicializar(){
    ANSEL = 0;
    ANSELH = 0;
    Keypad_Init();                           // Initialize Keypad
    Lcd_Init();                              // Initialize Lcd
    Lcd_Cmd(_LCD_CLEAR);                      // Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF);                 // Cursor off
}
//相关初始化
void Init_sth(void)
{
	Lcd_Init();
  __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE);
	HAL_GPIO_WritePin(GPIOA,GPIO_PIN_0,GPIO_PIN_SET);
	Lcd_Clear(GREEN);
	showimage_farsight(gImage_logo);
	Gui_DrawFont_GBK16(28,40,BLUE,GREEN,(uint8_t *)"Touch ID");
}
Exemple #14
0
/***************************************************************************//**
 * @brief First set the RCC clock, then initial the LCD, display characters.
 ******************************************************************************/
void GPIO_LCD1602(void)
{
    Lcd_Init();                         /* initial       */
    lcd_clear();                        /* clean the LCD */
    Delay(1000);
    set_cursor(0,0);                    /* set cursor    */
    lcd_print ("     welcome !  ");     /* display       */
    set_cursor(0, 1);
    lcd_print (" www.coocox.org ");
}
Exemple #15
0
int Main()
{
	Lcd_Init() ; ;
	while(1)
	{	
		
		Paint_Bmp(pic) ;
	} 
	return 0;	
}
void main() {            // FUNCAO PRINCIPAL: MAIN
ADCON1 = 0x07;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
   TRISA = 0b00000000;            PORTA = 0b00000000;
   TRISB = 0b00000110;         // PORTB = 0b00000000;
   TRISC = 0b00000000;            PORTC = 0b00000000;
// ESTADOS INICIAIS DOS ACESSORIOS
BUZZER = 1;
// MENSAGEM INICIAL NO LCD
Lcd_Init();                                 // INICIA O LCD
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Cmd(_LCD_CURSOR_OFF);                   // DESLIGA O CURSOR
Lcd_Out(1, 1, msg_2); 
Lcd_Out(2, 1, msg_1);
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
while (1) {
if (!INT2) {
BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(50);
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA DUAS VEZES CURTAS
// EEPROM_Write(unsigned short address, unsigned short data);
EEPROM_Write(0x08, 'K');               //ESCREVE "K" NA POSICAO 0x08 DA EEPROM
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_3);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
} else if (!INT1) {
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA UMA VEZ CURTA
// EEPROM_Read(unsigned short address);
INFO = EEPROM_Read(0x08);                   // LE A POSICAO 0x08 DA EEPROM
ShortToStr (INFO, INFO_s);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_4);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1,1,INFO_s);   
Lcd_Out_Cp(" = DECIMAL");      
Lcd_Cmd(_LCD_SECOND_ROW);
Lcd_Chr_Cp(0+INFO);    
Lcd_Out_Cp(" =  CHARACTER");   
Delay_ms(2500);
Lcd_Cmd(_LCD_CLEAR);}                       // LIMPA A TELA DO LCD
else {
Lcd_Out(1, 1, msg_5);                       
Lcd_Out(2, 1, msg_6);
}                                                                  // FIM ELSE
 }                                                               // FIM  WHILE
  }                                                                // FIM MAIN
Exemple #17
0
void main() {
 Lcd_Init();
 Config_ptos();
 Config_adc();
 Config_UART1();
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1, 1, "9CM11-Termometro");
 delay_ms(2000);
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Cmd(_LCD_CURSOR_OFF);
 while(1){
  Proceso();
 }
}
Exemple #18
0
void main() {
    Lcd_Init();
    Foto_ADC_Init();
    Config_ptos();
    Lcd_Cmd(_LCD_CLEAR);               // Clear display
    Lcd_Out(1, 1, "9CM11-Volmetro");
    delay_ms(2000);
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Cmd(_LCD_CURSOR_OFF);
    while(1){
        Proceso();
        Proceso2();
    }
}
void main() {
     /*
       Lcd_Init() to initialize the library
     */
     Lcd_Init();
     
     /*
       In order to print a string on a specific
       row, colum, use the following function.
       
       first number is the line number.
       second number is the column number.
     */
     Lcd_Out(1, 1, "Jontropati.com");
     
     Delay_ms(1000);      // delay- 1 sec
     
     
     /*
       THis function append some new string from
       previous string position
     */
     Lcd_Out_CP(" !!!");

     Delay_ms(1000);    // delay 1 sec
     
     /*
       Clear the LCD display
     */
     Lcd_Cmd(_LCD_CLEAR);
     

     /*
       Below funciton, prints a charecter
       on specific line, column
     */
     Lcd_Chr(1, 1, 'A');
     
     Delay_ms(1000);
     
     /*
       This function appends a new charecter
       from previous position.
     */
     Lcd_Chr_CP('B');

     while (1) {

     }
}
void main()
{
  char txt[7];
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);                 // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off

  TRISB = 0b00010000;
  INTCON.GIE = 1;                      //Global Interrupt Enable
  INTCON.RBIF = 0;                     //Clear PORTB On-Change Interrupt Flag
  INTCON.RBIE = 1;                     //Enable PORTB On-Change Interrupt

  Lcd_Out(1,1,"Developed By");
  Lcd_Out(2,1,"CELAB");

  Delay_ms(3000);
  Lcd_Cmd(_LCD_CLEAR);

  T1CON = 0x10;                        //Initializing Timer Module

   while(1)
  {
    TMR1H = 0;                  //Sets the Initial Value of Timer
    TMR1L = 0;                  //Sets the Initial Value of Timer

    PORTB.F0 = 1;               //TRIGGER HIGH
    Delay_us(10);               //10uS Delay
    PORTB.F0 = 0;               //TRIGGER LOW

    while(!PORTB.F4);           //Waiting for Echo
    T1CON.F0 = 1;               //Timer Starts
    while(PORTB.F4);            //Waiting for Echo goes LOW
    T1CON.F0 = 0;               //Timer Stops

    a = (TMR1L | (TMR1H<<8));   //Reads Timer Value
    a = a/58.82;                //Converts Time to Distance
    a = a + 1;                  //Distance Calibration\
    if(a>=2 && a<=400)          //Check whether the result is valid or not
    {
      IntToStr(a,txt);
      Ltrim(txt);
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Out(1,1,"Distance = ");
      Lcd_Out(1,12,txt);
      Lcd_Out(1,15,"cm");
    }
    Delay_ms(400);
  }
}
void main()
{
        int i,j,k,l;
        int count=0;
        char c;
        ENTER=1;
        EXIT=1;
  TRISD = 0xFF; // PORTD as input
 Lcd_Init(); // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR); // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
  Lcd_Out(1,1,"WELCOME:");//Write text'Hello World' in first row
  c=toChar(count);
   Lcd_chr(2,1,c);
 while(1)
{
 if(ENTER == 1)
 {
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,"WELCOME");
   count++;
     if(count == 999)
     count=0;
     Delay(500);
 }
  if(EXIT == 1)
  {
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,"THANKS");
   count--;
if(count == -1)
count=0;
Delay(500);
}
    i=count;
    j=i%10;
    k=i/10;
    l=i/100;
    k=k-l*10;
    c=toChar(j);
    Lcd_chr(2,3,c);
    c=toChar(k);
    Lcd_chr(2,2,c);
    c=toChar(l);
    Lcd_chr(2,1,c);
    }
    }
Exemple #22
0
void PWR_Lcd_Tft_16Bit_240320_On(void)
{
    int i,j,k;
    Lcd_Port_Init();
    //Lcd_Lpc3600Enable(); // Enable LPC3600
    Lcd_Init(MODE_TFT_16BIT_240320);
    Glib_Init(MODE_TFT_16BIT_240320);
    Lcd_EnvidOnOff(1);

    Glib_ClearScr(0, MODE_TFT_16BIT_240320);
    Glib_Rectangle(0,0,239,319,0x07e0);
    Glib_FilledRectangle(0,0,20,20,65535);
    Glib_Rectangle(220,300,239,319,65535);
    Glib_Line(0,0,239,319,0x1f);
    Glib_Line(239,0,0,319,0xf800);
    Uart_Printf("TFT 64K color mode test 2!\n");
}
Exemple #23
0
// Digital Compass
int main(void)
{
    uint8_t Res;
    int16_t Com_Data[3];
    uint16_t x0, y0;
    unsigned long angle = 0;
    double radian;
    
    /* Setup the microcontroller system. Initialize the Embedded Flash Interface,  
     initialize the PLL and update the SystemFrequency variable. */
    xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    xSysCtlDelay(10000);

    delay_init(72);
    Lcd_Init();
    HMC5883L_Init();
    HMC5883L_Cfg(MODE_SIG | GAIN_1090 | SAMPLE_8 | DATA_RATE_15);
    
    Lcd_Clear(GRAY0);
    //
    Gui_Circle(64, 80, 50, BLUE);
    Gui_DrawFont_GBK16(64,14,BLUE,GRAY0,"N"); 
    Gui_DrawFont_GBK16(64,132,BLUE,GRAY0,"S"); 
    Gui_DrawFont_GBK16(5,80,BLUE,GRAY0,"W"); 
    Gui_DrawFont_GBK16(116,80,BLUE,GRAY0,"E"); 
    while(1){
        Res = HMC5883L_DataGet(&Com_Data[0], &Com_Data[1], &Com_Data[2]);
        if(Res) break;
        angle = (unsigned long) (atan2((double)Com_Data[0],(double)Com_Data[1])*(180/3.14159265)+180);
        //angle = rand()%360;
    	radian = angle * 3.1415926 / 180;
        
        if(angle <= 180){
            x0 = 64 + (int16_t)(40 * sin(radian));
            y0 = 80 - (int16_t)(40 * cos(radian));
        } else {
            x0 = 64 + (int16_t)(40 * sin(radian));
            y0 = 80 - (int16_t)(40 * cos(radian));
        }
        Gui_DrawLine(64, 80, x0, y0, BLUE);   
        delay_ms(500);
        Gui_DrawLine(64, 80, x0, y0, GRAY0); 
    }
    return 0;
}
/*
 Initializes all globals and sets default bits in registers.
*/
void initialize(){
  C1ON_bit         = 0;     // Disable comparators
  C2ON_bit         = 0;
  ANSEL            = 0x04;  // Configure AN2 pin as analog
  ANSELH           = 0;     // Configure other AN pins as digital I/O

  // Initialize timer 0 to interrupt every 10ms
  OPTION_REG       = 0x86;
  TMR0             = 100;
  INTCON           = 0xA0;
  
  // Init LCD
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  
  // Initialize globals
  timerCounter     = 0;
}
void main(void)
{   
    void LCD_disp(int x,int y);
    void welcome(void);
    TRISD = 0x00;
    Lcd_Init();
    
    welcome();                      //welcome screen

    
    while(1){
    LCD_disp(1,2);
    delays(2);
    LCD_disp(0,3);
    delays(2);
    }
    
}
Exemple #26
0
void Lcd_TC(void)
{
	/* initial LCD controller */
	Lcd_Init();
	/* clear screen */
	Lcd_Clr();
	Lcd_Active_Clr();
	/* draw rectangle pattern */ 
	Lcd_Draw_Box(0,0,80,60,15);
	Lcd_Draw_Box(80,0,160,60,15);
	Lcd_Draw_Box(160,0,240,60,15);
	Lcd_Draw_Box(240,0,320,60,15);
	Lcd_Draw_Box(0,60,80,120,15);
	Lcd_Draw_Box(80,60,160,120,15);
	Lcd_Draw_Box(160,60,240,120,15);
	Lcd_Draw_Box(240,60,320,120,15);
	Lcd_Draw_Box(0,120,80,180,15);
	Lcd_Draw_Box(80,120,160,180,15);
	Lcd_Draw_Box(160,120,240,180,15);
	Lcd_Draw_Box(240,120,320,180,15);
	Lcd_Draw_Box(0,180,80,240,15);
	Lcd_Draw_Box(80,180,160,240,15);
	Lcd_Draw_Box(160,180,240,240,15);
	Lcd_Draw_Box(240,180,320,240,15);
	/* output ASCII symbol */
	Lcd_DspAscII6x8(37,26,BLACK,"0");
	Lcd_DspAscII6x8(117,26,BLACK,"1");
	Lcd_DspAscII6x8(197,26,BLACK,"2");
	Lcd_DspAscII6x8(277,26,BLACK,"3");
	Lcd_DspAscII6x8(37,86,BLACK,"4");
	Lcd_DspAscII6x8(117,86,BLACK,"5");
	Lcd_DspAscII6x8(197,86,BLACK,"6");
	Lcd_DspAscII6x8(277,86,BLACK,"7");
	Lcd_DspAscII6x8(37,146,BLACK,"8");
	Lcd_DspAscII6x8(117,146,BLACK,"9");
	Lcd_DspAscII6x8(197,146,BLACK,"A");
	Lcd_DspAscII6x8(277,146,BLACK,"B");
	Lcd_DspAscII6x8(37,206,BLACK,"C");
	Lcd_DspAscII6x8(117,206,BLACK,"D");
	Lcd_DspAscII6x8(197,206,BLACK,"E");
	Lcd_DspAscII6x8(277,206,BLACK,"F");
	Lcd_Dma_Trans();
	Delay(400);
}
void main() {

  TRISA = 0b00000000; // set PORTA -> salidas
  TRISB = 0b01000000; // set PORTB -> salida menos el pin 6.
  ANSEL  = 0;              // Configure AN2 pin as analog
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
  INTCON = 0b10100000; // INTERRUPCION POR TIMER0 Y GIE ACTIVADOS.
  /* INTCON.T0IE = 1;                 /\* Activado interrupcion por timer0 *\/ */
  OPTION_REG = 0b10000111; //  TMR0 temporizado:  RBPU, TOCS= INTERNAL INSTRUCTION CLOCK= 0 PSA =0   1:256
  TRISC = 0b10000000;                          // PUERTOC COMO SALIDA exepto pin 7
  PORTC = 0;                          // LIMPIAR PUERTOC
  setupTimer1();
  Delay_us(10);                 /* wait for acquisition time*/
  Lcd_Init();                        // Initialize LCD

  /* Programa principal */
  Lcd_Out(2,0,txtDefault);                 // Write text in second row
  UART1_Init(9600);                         // initialize UART1 module
  Delay_ms(100);                  // Wait for UART module to stabilize
  moverEnAutomatico();
  while (1) {
    waitSignal();
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     // leer el dato recibido del celular
      waitSignal();
      switch (uart_rd) {
      case 'A': {               /* Modo automático */
        Lcd_Out(2,6,txtAutomatic);
        moverEnAutomatico();
        break;
      }
      case 'M': {
        moverManual();
        break;
      }
      default:
        break;
      }
    }
  }
}
Exemple #28
0
void init(void)
{
/******IO init******/
		P1M0 &= ~0X03;		//P10 P11 out
		P1M1 |= 0X03;

		P3M0 &= ~0X80;		//P37 out
		P3M0 |= 0X1c;		//P32 P33 P34 in
		P3M1 |= 0X80;
		P3M1 &= ~0X1c;

		P4M0 = 0X00;
		P4M1 = 0X00;
/******T0 init******/
	TMOD	=	0x01;
	TL0  	= 	0x00;		//中断中重装值
	TH0  	= 	0x01; 		//中断中清TF0标志位
	TR0		=	1;
	IE0		=	1;
	ET0		=	1;	  	
/******uart init******/
	SBUF	=   0;
	SCON	|=	0X40;
	RI 		= 	0;
	REN		=	1;
	TCLK	=	1;		 // T2 波特率发生
	RCLK	=	1;
	RCAP2L	=	18;		 // 2400 bit/s
	RCAP2H	=	0;


	TR2		=	1;
	ES0		=	1;
	EA		=	1;	
/******LCD init*****/
	LED		=	1;
	CS		=	1;
	WR		=	1;
	DATA	=	1;
	Lcd_Init(0xFF);
	LED = 0;
}
Exemple #29
0
//show clock
int main()
{
	/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
	 initialize the PLL and update the SystemFrequency variable. */
	xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
	xSysCtlDelay(10000);

	delay_init(72);
	Lcd_Init();
	Lcd_Clear(GRAY0);

	Gui_DrawFont_GBK16(30,50,BLUE,GRAY0,"Show Clock");
	Gui_DrawFont_GBK16(36,70,BLUE,GRAY0,"@ CooCox");
	delay_ms(2000);
	Lcd_Clear(GRAY0);

	while(1){
		Show_Clock();
	}
}
void main() {
unsigned int hold;

char txt[7];

Lcd_Init();

TRISD = 0x00; //PORTB as output
TRISA = 0xFF; //PORTA as input
ADCON1 = 0x0E; // Set AN0 channel pin as analog
CMCON |= 7; // Disable comparators
//ADCON0 = 0b00000000;
//ADCON1 = 0b00001110;
//ADCON2 = 0b00001000;
//ADCON0.ADON = 0x01;
ADC_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);


while (1){
//ADCON0.GO_DONE=1;
//while(ADCON0.GO_DONE!=0);
//hold = ((unsigned int)ADRESH)<<8|(ADRESL);
hold = ADC_READ(0);

LCD_Chr(1,1,5*hold/1024+48);
LCD_Chr(1,2,46);
LCD_Chr(1,3,(50*hold/1024)%10+48);
LCD_Chr(1,4,(20*hold/41)%10+48); //20/41 =~ 500/1024
LCD_Chr(1,5,86);
inttostr(hold,txt);
LCD_OUT(2,0,TXT);
//IntToStr(hold, txt);

//Lcd_Out(1,1,txt);

delay_ms(180);

}
}