Пример #1
0
int main()
{
   char port_read;
   double ans;
   char disp_buf[20]; 
   int i=0;
   
   DDRB=0x07;   // first three outputs                                                 
   DDRC=0xFF;  // output
   LCD_INIT();
   sei();
   ADMUX=0x00;  // CHANNEL 0 AS INPUT
   ADCSRA=0xCF;
   PORTB=0x00;
   PORTC=0x00;
   while(1)
       {	
 	     ADCSRA|=0x40;    //START OF CONVERSION
	     _delay_ms(20);
         port_read=ADCL;
         ans=(port_read/255)*5.00;
	     sprintf(disp_buf,"%f",ans); 
         for(i=0;disp_buf[i]!='\0';i++)
	        {
              PORTC=disp_buf[i];
	          DATA();
			}
	   }
return 0;
}
Пример #2
0
void main(void)
{
	 int ADC10_Result=0;
	 double ADC10_RESULT=0;
	 char a[5];
	 int i;
	lcd_init();
	adc_init();
	LCD_INIT();
	/*SET_XY(0*T_CHAR,0);
	W_STR("X");
	SET_XY(0*T_CHAR,1);
	W_STR("Z");
	SET_XY(0*T_CHAR,2);
	W_STR("J");
	SET_XY(0*T_CHAR,3);
	W_STR("jiaodu");
	SET_XY(0*T_CHAR,4);
	W_STR("jiaosudu");
	 */


	while(1)
	{

		for(i=0;i<20;i++)
		{
		ADC10CTL0 |=ENC+ADC10SC;      //开始转换
		     while((ADC10CTL0 &ADC10IFG)==0); //等待ADC10IFG标志变高(转换完成)
		     ADC10_Result+=ADC10MEM;        //读取采样结果
		}
		ADC10_RESULT=ADC10_Result/20*100;
		ADC10_RESULT=ADC10_Result/1024*5/2;
		ADC10_RESULT=(ADC10_Result-ADC_STEP)/ADC_G;
                
		//if(ADC10_RESULT>=1)
			//ADC10_RESULT=1.0;
		ADC10_RESULT=asin(ADC10_Result/100.0)/3.14*180;
                ADC10_Result=(int)abs(ADC10_Result);
		a[0]=ADC10_Result/100+48;
		a[1]=ADC10_Result/10%10+48;
		a[2]='.';
		a[3]=ADC10_Result%10+48;
		a[4]='\0';
		SET_XY(0*T_CHAR,0);
		W_STR(a);
		for(i=0;i<500;i++)
		{
			for(ADC10_Result=0;ADC10_Result<10;ADC10_Result++)
			{
				;

			}

		}

	}

}
int lcd_open(struct inode *inode, struct file *filp)
{
	printk(KERN_INFO "lcd_couscous: release\n");
	LCD_INIT();
	LCD_HOME();
	LCD_CLEAR();
	if(MINOR(inode->i_rdev) != 0) {
		printk("mauvais numero d unite\n");
		return -EINVAL;
	}
	return 0;
}
Пример #4
0
void main(void)
{
 double a,b;
 unsigned int c,i;
 char f[4];

 LCD_INIT();

 _delay_ms(10);
 DDRA=0x00;

 sei();
 ADMUX=0x00;
 ADMUX|=(1<<ADLAR);
 ADCSRA=0xCF;
	
 DDRB=0xFF;
	
 PORTB=0x00;
 PORTD=0x00;



while(1)
{
	a=ADCH;
	b=((a/255)*5);
	
	itoa(b,f,10);



	for(i=0;i<3;i++)
	{

	PORTD=f[i];
	_delay_ms(5);
	DATA();
	
	
	}
	
	_delay_ms(1000);
	PORTD=0x01;
	CMD ();
	



	_delay_ms(100);
}

}
Пример #5
0
void MenuHandler( void *pvParameters )
{
	unsigned int key;
	unsigned char str[20]="";
    LCD_INIT ();
    startMenu();
    while(1)
    {
        if( xKeySemaphore != NULL )
        {

            if( xSemaphoreTake( xKeySemaphore, ( portTickType ) 10 ) == pdTRUE )
            {
            	if( xKeyQueue != 0 )
            	 {
					 if( xQueueReceive( xKeyQueue, &( key ), ( portTickType ) 10 ) )
					 {
						 sprintf(&str,"%i",key);
						// LCD_STRING (&str);
						 if((key&GPIO_Pin_10)==0)
						 {

							 Menu_Previous();
						 }

						 if((key&GPIO_Pin_11)==0)
						 {
							 Menu_Next();
						 }

						 if((key&GPIO_Pin_12)==0)
						 {
							 Menu_Child();
						 }

						 if((key&GPIO_Pin_0)==1)
						 {
							 Menu_Parent();
						 }
					 }
            	 }
            }
            else
            {

            }
        }

    	vTaskDelay(10);
    }
}
Пример #6
0
/*!
 *  @brief      LCD初始化
 *  @since      v5.0
 */
void LCD_init(void)
{
    Site_t site = {0, 0};
    Size_t size ;

    LCD_INIT();                             //初始化LCD

    //LCD_SET_DIR(LCD_DIR+1);

    //由于初始化的时候进行 屏幕方向 选择,因而初始化完成后,才获取宽高
    size.W = LCD_W;
    size.H = LCD_H;

    LCD_rectangle(site, size, BCOLOUR);     //初始化背景
}
Пример #7
0
void ALL_Init(void)
{
  SOPT1 &= 0x3F; //disable cop
  MCG_Init();
  //PTED_Init(); 
  //LED_Init();
  //KBI_Init();
  RTC_Init();
  //SPI_Init();
  //ATD_Init();
  //SCI_Init();
  //PWM_Init();
  IIC_Init();
  
  //HCS08_EE_Init();   //初始化Flash控制寄存器
  PCF8563_Init();
  LCD_INIT();
   
}
void main(void)
{
 unsigned char count=0;	// Counter variable
 LCD_INIT();
 LCD_CMD(LINE1);
 LCD_WRITE("**BALL-COUNTER**");
 LCD_CMD(DON_COFF);
 counter_display(count);

 while(1)
 {
	 if(touch_sensor==0)//If Touch detected
	 {
	 count++;  //Counter incremented
	 counter_display(count); //Display Number
	 buzzer=0;	//Buzzer ON
	 delay_ms(1000); //Delay for correction if any
	 }
	 else
	 {
	  buzzer=1;	//Buzzer OFF
	 }
 } 
}
Пример #9
0
int main(void)
{
    /*** LOCAL VARIABLES ***/

    /*** CONFIGURE OSCILLATOR ***/
    SET_FreqOsc( FRCDIV_8MHZ );                     //Set Frequency of Oscillator

    /*** CONFIGURE HARDWARE ****/
    Hardware_INIT();                                //Intialize Hardware
    Hardware.ConfigPins_Default();                  //Configure Hardware

    //NOTE: PPS Unlock & Lock Sequence not required when Using  Hardware.ConfigPins_Default()
     __builtin_write_OSCCONL(OSCCON & 0xbf);        //UNLCOK PPS
        Hardware.ConfigPins_PWM(USE2);              //Configure the PWM Pins to use
     __builtin_write_OSCCONL(OSCCON | 0x40);        //LOCK PPS

//      __builtin_write_OSCCONL(OSCCON & 0xbf);        //UNLCOK PPS
//    Hardware.ConfigPins_Motor(USE1|USE2);
//    __builtin_write_OSCCONL(OSCCON | 0x40);        //LOCK PPS

    MotA1 = C_ON; // Set state to OFF
    MotA2 = C_OFF; // Set state to OFF
    
    /*** INITIALIZE PERIPHERAL ***/
    CLKDIVbits.RCDIV0=0;     //clock divider to 0
    PWM2_INIT(PWMsrc_FOSC, 10);
//
    PWM2_SET_PulseWidth(5);                        //Set PWM1 Dutycycle Time 5 mSec
     //To Test, Probe the Pin1 of PWM connector J7

    LCD_INIT();                                     //Initialize LCD
//    LED1_DIR = DIR_OUT;                    // Set LED1 as Output
//    LED1 = C_OFF;                      	// Set state to OFF
//    RE5_IN;


    

    // AN0 input pin is analog

    AD1CON1 = 0x2202; // Configure sample clock source
    // and conversion trigger mode.
    // Unsigned Fraction format (FORM<1:0>=10),
    // Manual conversion trigger (SSRC<2:0>=000),
    // Manual start of sampling (ASAM=0),
    // No operation in Idle mode (ADSIDL=1),
    // S/H in Sample (SAMP = 1)
    AD1CON2 = 0; // Configure A/D voltage reference
    // and buffer fill modes.
    // Vr+ and Vr- from AVdd and AVss (VCFG<2:0>=000),
    // Inputs are not scanned,
    // Interrupt after every sample
    AD1CON3 = 0x0100; // Configure sample time = 1Tad,
    // A/D conversion clock as Tcy
    AD1CHS = 1; // Configure input channels,
    // S/H+ input is AN1,
    // S/H- input is Vr- (AVss).
    AD1CSSL = 0; // No inputs are scanned.
    IFS0bits.AD1IF = 0; // Clear A/D conversion interrupt.
    // Configure A/D interrupt priority bits (AD1IP<2:0>) here, if
    // required. Default priority level is 4.
//    IEC0bits.AD1IE = 1; // Enable A/D conversion interrupt
    AD1CON1bits.ADON = 1; // Turn on A/D
    AD1CON1bits.SAMP = 1; // Start sampling the input   

    //this just gives us a little delay between measurements
    U32 i = 0xFFFFF; //sets i to 1048575
    while (i--); //delay function

    AD1CON1bits.SAMP = 0; // End A/D sampling and start conversion
    // Example code for A/D ISR:


    
    
    
    
//    sensor_read = LATE;

    /*8** APPLICATION CODE BEGINS ***/
    v_PrintData_U16= 2013;                          // Store some Value to print


    /*** ENTER ETERNITY ***/
    while(1)
    {
//        MotA1 = C_ON; // Set state to OFF
//        MotA2 = C_OFF; // Set state to OFF

        
        /*** RECURRING CODE HERE***/
//        sprintf(A_Str_U8,"%d ", v_PrintData_U16);       // Print variable to string
//        LCD_WriteString(1, 0, A_Str_U8);                //print varible on Line1

//        sprintf(A_Str_U8,"BRIGOSHA TECH.");            // Print variable to string
//        LCD_WriteString(2, 2, A_Str_U8);               //print string on second line second column
        //Use TIMER Interrupts to perform time based tasks at fixed interval.
        //Use Peripheral Interrupts to perform event based tasks
        v_PrintData_U16++;

        AD1CON1bits.SAMP = 1; // start sampling...

        U32 i = 0xFFFF; //sets i to 1048575
        while (i--); //delay function

        AD1CON1bits.SAMP = 0; // start converting
        while (!AD1CON1bits.DONE){}; // conversion done?
        ADCValue = ADC1BUF0; // yes then get ADC value

        LCD_Clear();
        sprintf(A_Str_U8,"%u ", ADCValue);       // Print variable to string
        LCD_WriteString(2, 2, A_Str_U8);                //print varible on Line1
        //
    }

}
Пример #10
0
int main(void)
{
    /*** LOCAL VARIABLES ***/
    unsigned int period , period2, config1=0 ,config2=0;
    Int_flag = 0;
    /*** CONFIGURE OSCILLATOR ***/
    SET_FreqOsc( FRCDIV_1MHZ );                    //Set Frequency
    
    /*** CONFIGURE HARDWARE ****/
    Hardware_INIT();                               //Initialise Hardware functions
    LCD_INIT();
    //NOTE: PPS Unlock & Lock Sequence not required when Using  Hardware.ConfigPins_Default()
     __builtin_write_OSCCONL(OSCCON & 0xbf);        //UNLCOK PPS
//        Hardware.ConfigPins_PWM(USE1 | USE2 | USE4 | USE3 );              //Configure the PWM Pins to use
        PWM4_DIR = DIR_OUT; // Set PWM4 as Output
        PWM4 = C_OFF;
        iPPSInput(IN_FN_PPS_IC1, IN_PIN_PPS_RP10);
        iPPSOutput(OUT_PIN_PPS_RP12, OUT_FN_PPS_OC1);
        iPPSOutput(OUT_PIN_PPS_RP11, OUT_FN_PPS_OC9);
     __builtin_write_OSCCONL(OSCCON | 0x40);        //LOCK PPS
    Int_flag = 0;
    
    // timers
    T1CON = 0x8000;
    T2CON = 0x8000;
    T1CONbits.TCKPS = 0b00;
    T2CONbits.TCKPS = 0b01;
    T3CON = 0x8000;
    T4CON = 0x8000;
    T4CONbits.TCKPS = 0b01;

    // input capture
    ConfigIntCapture1(IC_INT_ON | IC_INT_PRIOR_4);
    config1 = IC_IDLE_STOP | IC_TIMER2_SRC | IC_INT_1CAPTURE | IC_EVERY_EDGE;
    config2 = IC_CASCADE_DISABLE /*| IC_SYNC_ENABLE | IC_SYNC_TRIG_IN_TMR2*/;
    OpenCapture1_GB(config1, config2);

    // output compare
    EnableIntOC9;
    OC9R = 0x5FF0;
    OC9RS = 0x5FF4;
    OC9CON1bits.OCTSEL = 0b000;
    OC9CON2bits.SYNCSEL = 0x1F;
    OC9CON1bits.OCM = 0b110;
    OC9CON2bits.OCINV =  1;
//    PR1 = 2000;// period for timer 1
//    PR2 = 0xFFFF;

//    IFS0bits.IC1IF = 0; // Clear the IC1 interrupt status flag
//    IEC0bits.IC1IE = 1; // Enable IC1 interrupts
//    IPC0bits.IC1IP = 1; // Set module interrupt priority as 1
    //    IC1CON1 = 0x1C24;
    //    IC1CON2 = 0x0040;
//    IC1CON1bits.ICSIDL = 0; //Continue in idle mode
//    IC1CON1bits.ICI = 0b00; //Interrupt on every capture
//    IC1CON1bits.ICM = 0b001; //Every edge

//    EnableIntIC1;

     /*** INITIALIZE PERIPHERAL ***/
//     TIMER3_INIT( 1000, TMR_INT_PRI7 );
     PWM1_INIT(PWMsrc_FOSC, 20);                    //Set PWM Period of 20 mSec
//     PWM3_INIT(PWMsrc_Timer1, 100);                    //Set PWM Period of 1000 mSec
//     PWM3_INIT(PWMsrc_FOSC, 30);
     /*** APPLICATION CODE BEGINS ***/
//     PWM3_SET_PulseWidth(1);
     PWM1_SET_PulseWidth(1.3);

//     PWM3_SET_PulseWidth(10);

                            //Set PWM1 Dutycycle Time 5 mSec
     //To Test, Probe the Pin1 of PWM connector J7

    LED1_DIR = DIR_OUT; // Set LED1 as Output
    LED1 = C_OFF;
    LED2_DIR = DIR_OUT; // Set LED1 as Output
    LED2 = C_OFF;
    LED3_DIR = DIR_OUT; // Set LED1 as Output
    LED3 = C_OFF;
    /*** ENTER ETERNITY ***/
     int buf[100];
     Int_flag = 2;
    

         //LOCK PPS
    while (1) {
//        while (!read_enable);

         //wait till two succssive falling edges
//        M_ToggleIO(LED1);
//        period = timer_second_edge - timer_first_edge;
//        period2 = 65535 + timer_first_edge - timer_second_edge;


            
            int j;
            for(j=1;j<5;j++){
                if(edge_buffer[j+1] - edge_buffer[j] > 30){
                    if(edge_buffer[j+1] - edge_buffer[j] < 500){
                        pulse = edge_buffer[j+1] - edge_buffer[j];
                        break;
                    }else{
                        pulse = 11111;
                    }
                }else{
                    pulse = 11111;
                }
            }
            
            if(pulse != 11111){
                LCD_Clear();
                sprintf(A_Str_U8, "%u", pulse); // Print variable to string
                LCD_WriteString(1, 1, A_Str_U8);
            }

//            sprintf(A_Str_U8, "%u", timer_second_edge); // Print variable to string
//            LCD_WriteString(1, 8, A_Str_U8);
//            sprintf(A_Str_U8, "%u", abs(timer_second_edge - timer_first_edge)); // Print variable to string
//            LCD_WriteString(2, 1, A_Str_U8);
//            sprintf(A_Str_U8, "%u", abs(timer_third_edge - timer_second_edge)); // Print variable to string
//            LCD_WriteString(2, 7, A_Str_U8);
//            DELAY_mSec(100);
//            sprintf(A_Str_U8, "%d", Interrupt_Count); // Print variable to string
//            LCD_WriteString(2, 8, A_Str_U8);

//        Int_flag = 0;
            read_enable = 0;
        
//        __builtin_write_OSCCONL(OSCCON & 0xbf);
//        iPPSOutput(OUT_PIN_PPS_RP10, OUT_FN_PPS_OC4);
//        __builtin_write_OSCCONL(OSCCON | 0x40);
//
//        PWM4 = C_OFF;
//        PWM4 = C_ON;
//        PWM4 = C_OFF;
//        DELAY_mSec(200);
        
//        DELAY_mSec(200);
//        LATEbits.LATE5 = 1;
//        DELAY_mSec(500);
//        LATEbits.LATE5 = 0;

//        ReadCapture1_v4(buf) ;
        /*** RECURRING CODE HERE***/
        //Use TIMER Interrupts to perform time based tasks at fixed interval.
        //Use Peripheral Interrupts to perform event based tasks
        int i;
        for (i = 40; i < 100; i++) {
            PWM1_SET_PulseWidth(0.02 * i);
            DELAY_mSec(20);

        }
        while (i>=40) {
            PWM1_SET_PulseWidth(0.02 * i);
            DELAY_mSec(20);
            i--;
        }
    }
      
}
Пример #11
0
int main()
{
	characters_init();
	PORT_INIT();
	LCD_INIT();
	init_key();
	//设定mah 2580 为3000mah 4b00 为6000
	/*while(!ds_reset());
	ds_write_byte(CMD_ONEWIRE_SKIP_ROM);
	ds_write_byte(CMD_ONEWIRE_WRITE);
	ds_write_byte(CMD_ADDR_ACR);
	ds_write_byte(0X4b);
	ds_write_byte(0X00);*/
	int count = 5; 
	char key;
	while(1)
	{
		key = get_key();
		//switch mode and in edit edit.
		if(key==1)
		{	
			//in mode 1 go to next cursor 
			if(yes&&mode==1)
			{		
				//go back to the begining of the line
				if(pos_mode1==4){LCD_WR_COM(0X02);}
				else
				{
					//cursor to the next
					LCD_WR_COM(0X14);
				}
				//the position of mode1 add
				pos_mode1 = (pos_mode1+1)%5;
			}
			else if(yes&&mode==2)
			{
				//go to the begining of the first line
				if(pos_mode2==4){LCD_WR_COM(0X02);}
				else
				{
						LCD_WR_COM(0x14);
				}
				pos_mode2 = (pos_mode2+1)%5;
			}
			else
			{
				switch_mode(1);
				mode = (mode+1)%3;
			}
		}
		if(key==3)
		{
			yes = ~yes;
			switch_mode(3);
		}
		if(key==2)
		{
			if(mode==1&&yes)
			{
				res[pos_mode1]=(res[pos_mode1]+1-'0')%10+'0';
				LCD_WR_COM(0X80+pos_mode1);
				LCD_WR_DATA(res[pos_mode1]);
				LCD_WR_COM(0X10);
				
			}
			if(mode==2&&yes)
			{
				fullc[pos_mode2] = (fullc[pos_mode2]+1-'0')%10+'0';	
				LCD_WR_COM(0x80+pos_mode2);
				LCD_WR_DATA(fullc[pos_mode2]);
				LCD_WR_COM(0X10);
			}
		}
		if(mode==0)
		{
			if(count==0)
			{
				count=4;
				LCD_CLEAR();
			}
			count--;
		}
		update();
		mode_pro();
		_delay_ms(50);
	}

}
/*******************************************************************************
* Function Name  : Demo_Init
* Description    : Initializes the demonstration application
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Demo_Init(void)
{
  ClockConfigure();

/************************ LCD Initialization *************************/

  /* Configure LCD_DATA_PORT for data transfer to/from LCD */
  PortInitStructure.PORT_Pin = LCD_DATA_BAS_8_0;
  PortInitStructure.PORT_FUNC = PORT_FUNC_PORT;
  PortInitStructure.PORT_OE = PORT_OE_IN;
  PortInitStructure.PORT_SPEED = PORT_SPEED_SLOW;
  PortInitStructure.PORT_MODE = PORT_MODE_DIGITAL;

  PORT_Init(LCD_DATA_PORT_0, &PortInitStructure);
  PortInitStructure.PORT_Pin = LCD_DATA_BAS_8_1;
  PORT_Init(LCD_DATA_PORT_1, &PortInitStructure);

  /* Configure LCD_RD_WR_PORT for read/write control */
  /* Switch LCD into data output mode */
  PORT_SetBits(LCD_RD_WR_PORT, LCD_RD_WR_PIN);

  PortInitStructure.PORT_Pin = LCD_RD_WR_PIN;
  PortInitStructure.PORT_OE = PORT_OE_OUT;

  PORT_Init(LCD_RD_WR_PORT, &PortInitStructure);

  /* Configure LCD_CLOCK_PORT for CLOCK signal control*/
  /* Set LCD CLOCK signal to its initial value (0) */
  PORT_ResetBits(LCD_CLOCK_PORT, LCD_CLOCK_PIN);

  PortInitStructure.PORT_Pin = LCD_CLOCK_PIN;
  PortInitStructure.PORT_SPEED = PORT_SPEED_FAST;

  PORT_Init(LCD_CLOCK_PORT, &PortInitStructure);

  /* Configure LCD_CRYSTAL_PORT for LCD crystal control */
  /* De-select both LCD crystals*/
  PORT_ResetBits(LCD_CRYSTAL_PORT, LCD_CRYSTAL_PINs);

  PortInitStructure.PORT_Pin = LCD_CRYSTAL_PINs;
  PortInitStructure.PORT_SPEED = PORT_SPEED_SLOW;

  PORT_Init(LCD_CRYSTAL_PORT, &PortInitStructure);

  /* Configure LCD_CMD_DATA_PORT for data/command mode switching */
  PortInitStructure.PORT_Pin = LCD_CMD_DATA_PIN;

  PORT_Init(LCD_CMD_DATA_PORT, &PortInitStructure);

  /* Configure LCD_RESET_PORT for RESET signal control */
  /* Zeroing LCD RES signal (initial state) */
  PORT_ResetBits(LCD_RESET_PORT, LCD_RESET_PIN);

  PortInitStructure.PORT_Pin = LCD_RESET_PIN;
  PortInitStructure.PORT_SPEED = PORT_SPEED_FAST;

  PORT_Init(LCD_RESET_PORT, &PortInitStructure);

  LCD_INIT();

/************************ Joystick Initialization *************************/

  /* Configure SEL_PORT for input to handle joystick event SEL */
  PortInitStructure.PORT_Pin   = SEL_PIN;
  PortInitStructure.PORT_OE    = PORT_OE_IN;
  PortInitStructure.PORT_FUNC  = PORT_FUNC_PORT;
  PortInitStructure.PORT_SPEED = PORT_SPEED_SLOW;

  PORT_Init(SEL_PORT, &PortInitStructure);

  /* Configure UP_PORT for input to handle joystick event UP */
  PortInitStructure.PORT_Pin   = UP_PIN;

  PORT_Init(UP_PORT, &PortInitStructure);

  /* Configure DOWN_PORT for input to handle joystick event DOWN */
  PortInitStructure.PORT_Pin   = DOWN_PIN;

  PORT_Init(DOWN_PORT, &PortInitStructure);

  /* Configure LEFT_PORT for input to handle joystick event LEFT */
  PortInitStructure.PORT_Pin   = LEFT_PIN;

  PORT_Init(LEFT_PORT, &PortInitStructure);

  /* Configure RIGHT_PORT for input to handle joystick event RIGHT */
  PortInitStructure.PORT_Pin   = RIGHT_PIN;

  PORT_Init(RIGHT_PORT, &PortInitStructure);

/************************ LEDs Initialization *************************/

  /* Configure LEDs_PORT for output to switch LEDs on/off */
  PortInitStructure.PORT_Pin   = LEDs_PINs;
  PortInitStructure.PORT_OE    = PORT_OE_OUT;
  PortInitStructure.PORT_FUNC  = PORT_FUNC_PORT;

  PORT_Init(LEDs_PORT, &PortInitStructure);

  /* All LEDs switch off */
  PORT_ResetBits(LEDs_PORT, LEDs_PINs);
}
Пример #13
0
bool _SYS_OUT_INIT(int out_port)
{
    LCD_INIT();
    return true;
}
Пример #14
0
void main(void)
{
 float a,b,e;
 unsigned int c,d,i;
 char f[1],g[3];

 LCD_INIT();

 _delay_ms(10);
 DDRA=0x00;

 sei();
 ADMUX=0x00;
 ADMUX|=(1<<ADLAR);
 ADCSRA=0xCF;
	
 DDRB=0xFF;
	
 PORTB=0x00;
 PORTD=0x00;



while(1)
{	
	a=ADCH;
	b=(((a/255)*5)*100);
	c=b/100;
	e=c*100;
	d=b-e;
	

	itoa(c,f,10);

	for(i=0;i<1;i++)
	{

	PORTD=f[i];
	_delay_ms(5);
	DATA();		
	}

	PORTD='.';
	_delay_ms(5);
	DATA();
	
	itoa(d,g,10);

	for(i=0;i<2;i++)
	{

	PORTD=g[i];
	_delay_ms(5);
	DATA();		
	}
	_delay_ms(1000);

	PORTD=0x01;
	CMD ();
	
	
}

}
Пример #15
0
int main (void)
{	
	/// Configure Devices //////////////////////////////////////
	// Display configuration:
		frontLCD.ddr = &DDRD;
		frontLCD.port = &PORTD;
		frontLCD.pin = &PIND;
		frontLCD.pinNr_EN = PD5;
		frontLCD.pinNr_RS = PD4;
		frontLCD.pinNr_D4 = PD0;
		frontLCD.pinNr_D5 = PD1;
		frontLCD.pinNr_D6 = PD2;
		frontLCD.pinNr_D7 = PD3;

    // Buttion A configuration
		button_A.ddr = &DDRC;
		button_A.port = &PORTC;
		button_A.pin = &PINC;
		button_A.pinNr = PC7;
		button_A.internPullup = True;
		button_A.bounce_ms = 40;
		
	// Buttion B configuration
		button_B.ddr = &DDRC;
		button_B.port = &PORTC;
		button_B.pin = &PINC;
		button_B.pinNr = PC4;
		button_B.internPullup = True;
		button_B.bounce_ms = 40;	

    // Rotary encoder A  configuration
		encoder_A.ddr = &DDRC;
		encoder_A.port = &PORTC;
		encoder_A.pin = &PINC;
		encoder_A.pinNr_A = PC6;
		encoder_A.pinNr_B = PC5;
		encoder_A.internPullup = True;
		encoder_A.autoAcceleration = True;
		encoder_A.accerelationFactor = 200;
	
	// Rotary encoder B  configuration
		encoder_B.ddr = &DDRC;
		encoder_B.port = &PORTC;
		encoder_B.pin = &PINC;
		encoder_B.pinNr_A = PC3;
		encoder_B.pinNr_B = PC2;
		encoder_B.internPullup = True;
		encoder_B.autoAcceleration = True;
		encoder_B.accerelationFactor = 100;
	/// END Configure Devices //////////////////////////////////
	
	/// INIT Devices ///////////////////////////////////////////
	// INIT display
		LCD_INIT(&frontLCD);
		LCD_CLEAR(&frontLCD);

    // INIT buttons	
		BUTTON_INIT(&button_A);
		BUTTON_INIT(&button_B);

    // INIT rotary encoders
		ROTARYENC_INIT(&encoder_A);
		ROTARYENC_INIT(&encoder_B);		
	/// END INIT Devices ///////////////////////////////////////
	
	while(1)
        MainMenu(); // Enter main-menu (see below)

	return 0;
}