예제 #1
0
파일: 1.c 프로젝트: fffaraz/gpst
// USARTE1 Receiver interrupt service routine
interrupt [USARTE1_RXC_vect] void usarte1_rx_isr(void)
{
unsigned char status;
char data;

status=USARTE1.STATUS;
data=USARTE1.DATA;
if ((status & (USART_FERR_bm | USART_PERR_bm | USART_BUFOVF_bm)) == 0)
   {                 
   putchar(data);
   if(data==13 || data==10)
    lcd_putchar('|');
    else
   lcd_putchar(data); 
   
   rx_buffer_usarte1[rx_wr_index_usarte1++]=data;
#if RX_BUFFER_SIZE_USARTE1 == 256
   // special case for receiver buffer size=256
   if (++rx_counter_usarte1 == 0) rx_buffer_overflow_usarte1=1;
#else
   if (rx_wr_index_usarte1 == RX_BUFFER_SIZE_USARTE1) rx_wr_index_usarte1=0;
   if (++rx_counter_usarte1 == RX_BUFFER_SIZE_USARTE1)
      {
      rx_counter_usarte1=0;
      rx_buffer_overflow_usarte1=1;
      }
#endif
   }
}
예제 #2
0
unsigned int getkeyab(unsigned int dmin,unsigned int dmax,unsigned char display){   //bien x dung xac nhan dat timeout, nhap va0 so >=a <=b
	//unsigned char arrbuff[33];//so toi da 65536 la 5 chu + 1 null cua chuoi =6
	unsigned char i,strmax,strmin,sobam;
	unsigned long digi=0,temp,toadotruyen=lcd_wait();
	while(getbell()!=offbell);
	strmax=digi2text(lcd_buff,10,dmax)-1;//so chu so cua dmax, bi loi truyen tham so sai
	strmin=digi2text(lcd_buff,10,dmin)-1;
	if(display&minmax_){
		sprintf(lcd_buff,"%u->%u",dmin,dmax);
		lcd_putsxy(lcd_buff,0,lines-1);
		lcd_goto(toadotruyen);
	}
	
	if(display&PAXX_)for(i=0;i<strmax+1;i++){lcd_putchar('X');}
	lcd_goto(toadotruyen);
	
	for(i=(strmax);i!=0xFF;i--){
		//while(ir_in());
		thulaichuso:
		delay_ms(100);
		while((temp=ir_getkeytimeout(offbell&(~diir_),0))>9);//tranh tran so ma thoi
		sobam=(unsigned char)temp+0x30;
		temp=digi+temp*xpowy(10,i);
		if(strmin<i){if(temp>dmax)goto thulaichuso;}
		else {if((temp<dmin)||(temp>dmax)) goto thulaichuso;}
		
		if(display&phimtm_)lcd_putchar(sobam);
		//xongthem1chuso:
		digi=temp;
		setbell(binhthuong);
	}
	setbell(bellsucsesful);//da nhap thanh cong	
	while(getbell()!=offbell);
	return digi;
}
예제 #3
0
void lcdPutsByte(unsigned char value)
{
    unsigned char ten = (value % 100) / 10;
    lcd_putchar('0' + (value / 100));  
    lcd_putchar('0' + ten);
    lcd_putchar('0' + (value % 10));
}
예제 #4
0
int main(void)
{
	lcd_init();
	for (;;) {
		const char msg[] = "by tommyo";
		lcd_set_ddram_address(0);
		lcd_puts("avr_hd44780");
		_delay_ms(500);
		lcd_set_position(1, 6);
		lcd_on_off_control(1, 1, 0);
		_delay_ms(500);
		for (uint8_t i = 0; i < sizeof(msg)-1; i++) {
			_delay_ms(150);
			lcd_putchar(msg[i]);
		}
		_delay_ms(300);
		lcd_on_off_control(1, 1, 1);
		_delay_ms(3000);
		lcd_on_off_control(1, 0, 0);
		for (uint8_t i = 0; i < 2; i++) {
			for (uint8_t  k = 0; k < 16; k++) {
				for (uint8_t j = 0; j < 2; j++) {
					lcd_set_position(j, k);
					lcd_putchar((i % 2) ? ' ' : 0xFF);
				}
				_delay_ms(25);
			}
		}
		lcd_clear();
		_delay_ms(500);
	}
}
예제 #5
0
//------------------------------------------------------------------------------------
//dung ham put_time de in ra second, minute, hour, date, month, year
// input : gia tri cua bien can in ra
//         vi tri cua bien can in ra tren LCD
// hien thi 2 ki tu cua 1 bien 
// output : none
void put_time(unsigned char time,unsigned char x, unsigned char y) 
{
    unsigned char time_low,time_high;
    // tach bien time thanh 2 so hien thi tren lcd
    time_high = time/10 + 0x30;
    time_low  = time%10 + 0x30; 
    // di den vi tri x,y hien thi gia tri time
    lcd_gotoxy(x,y);
    lcd_putchar(time_high);
    lcd_putchar(time_low);
}
예제 #6
0
//-----------------------------------------------------------------------------------
//void put_data_info : hien thi thong tin thu ngay thang tren lcd
//input: gia tri gio phut giay
//output: none
void put_time_info()
{
    lcd_gotoxy(0,0);
    lcd_puts("    ");
    put_time(hour,4,0); 
    lcd_putchar(':');
    put_time(minute,7,0);
    lcd_putchar(':');
    put_time(second,10,0);
    lcd_gotoxy(12,0);
    lcd_puts("    ");
}
예제 #7
0
/* Function for displaying bargraph on the LCD display                        */
void Disp_Bargraph(int pos_x, int pos_y, int value) {
	int i;

	set_cursor (pos_x, pos_y);
	for (i = 0; i < 16; i++)  {
		if (value > 5)  {
			lcd_putchar (0x05);
			value -= 5;
		}  else  {
			lcd_putchar (value);
			value = 0;
		}
	}
}
예제 #8
0
void printTimer(uint8_t x, uint8_t y, t_timer tim){
    lcd_gotoxy(x,y);
    if (tim.H > 9){
        put_digit((tim.H / 10));
    }
    put_digit((tim.H % 10));
    lcd_putchar(':');
    put_digit((tim.M / 10));
    put_digit((tim.M % 10));
    lcd_putchar(':');
    put_digit((tim.S / 10));
    if (tim.H < 10){
        put_digit((tim.S % 10));
    }
}
예제 #9
0
void main(){
	Output_low(LCD_RW); //Che do ghi 
	LCD_init(); //Khoi tao LCD

	lcd_putcmd(0x01);
	delay_ms(100);
	printf(lcd_putchar,"Nhiet do: ");
	while (true){
		i2c_start();   //Tao dieu kien start de giao tiep
		//Dia chi thiet bi I2C(tra trang 9 cua Datasheet) sau khi da them bit 0 vao
		//0x48 (1001000 them bit 0 vao 10010000 = 0x90
		i2c_write(0x90); 
		i2c_write(0x00); //Gui lenh yeu cau doc nhiet do
		i2c_start();   //Tao lai dieu kien start
		//Dia chi thiet bi I2C(tra trang 9 cua Datasheet) sau khi da them bit 1 vao
		//0x48 (1001000 them bit 1 vao 10010001 = 0x91
		i2c_write(0x91); //Thiet bi chu yeu cau duoc doc du lieu cua thiet bi to
		temp = i2c_read(0); //Gui lenh doc gia tri nhiet do
		i2c_stop();      //Tao dieu kien Stop, ket thuc giao tiep
		LCD_SetPosition(0x09);
		printf(lcd_putchar,"%u",temp); //Hien thi nhiet do doc duoc len LCD 
		lcd_putchar(223);
		printf(lcd_putchar,"C");
		delay_ms(1000);
	}
}
예제 #10
0
void jfolo(unsigned char count){

    unsigned char junction_count=0;
    unsigned char timer=0;

    Forward();      // set motor move forward


    // sending display to lcd takes long time
    // junction reading and display less frequent.
    // use timer variable to count 20, then read once.
    while(junction_count<count){   //second junction
        timer++;
        if(timer>50){
            timer=0;        //clear timer
            motor(0,0);     //slow down for lcd display           
            do{
                junction_count=LSA08_GetJunction(); //check junction count
            }while(ERR_FLAG||(junction_count>10));   //checking no uart error

            lcd_goto(0);
            lcd_putchar('J'); 
            lcd_num(junction_count,3);
        }

        line_follow(); //PID line follow
    }
    Brake();
    
    __delay_ms(200);   
 

}
예제 #11
0
void lcd_putString(char* string, char length)
{
  char i;
  hd44780_outcmd(string[0]);     //first byte delivered is the cursor position 0x80 line 1, 0xC0, line 2
  for(i = 1; i < length; i++)
    lcd_putchar(string[i]);
}
//Routine to send string to LCD
void lcd_putstr(const char *str)
{
	while(*str != '\0')		//loop till string ends
	{
     	lcd_putchar(*str++);  		//send characters to LCD one by one					
	}		
}
예제 #13
0
/**
 * Given char data display it through LCD.
 *
 * @param {unsigned char dat} Character to display
 * @return void
 */
void lcd_please_display(unsigned char dat)
{
    unsigned char data;

    data  = dat / 100;
    data += 0x30;
    lcd_putchar(data);

    dat  %= 100;
    data  = dat / 10;
    data += 0x30;
    lcd_putchar(data);

    dat %= 10;
    data = dat + 0x30;
    lcd_putchar(data);
}
예제 #14
0
파일: mashing.c 프로젝트: za6o/MyProject
void display_temp(void){

	int digit=0, decimal=0;
				therm_read_temperatureRAW(&digit,&decimal);
				lcd_putint(digit);
				lcd_putchar('.');
				lcd_putint(decimal/10);
}
예제 #15
0
//-----------------------------------------------------------------------------------
//void put_data_info : hien thi thong tin thu ngay thang tren lcd
//input: none
//output: none
void put_date_info()
{
    lcd_gotoxy(0,1);
    lcd_puts(" ");  
    switch(day)
    { 
        // neu la chu nhat 
        case 1:
            lcd_puts("CN ");
         break;
        // neu la thu 2 
        case 2:
            lcd_puts("T2 ");
        break;
        //neu la thu 3
        case 3:
        lcd_puts("T3 ");
        break; 
        // neu la thu 4
        case 4:
        lcd_puts("T4 ");
        break; 
        // neu la thu 5
        case 5:
        lcd_puts("T5 ");
        break; 
        // neu la thu 6
        case 6:
        lcd_puts("T6 ");
        break; 
        // neu la thu 7
        case 7:
        lcd_puts("T7 ");
        break; 
        // neu khong co truong hop nao thi out
        default: 
        break;
    }
    put_time(date,4,1);
    lcd_putchar('-');
    put_time(month,7,1);
    lcd_putchar('-');
    lcd_gotoxy(10,1);   
    lcd_puts("20    "); 
    put_time(year,12,1);
}
예제 #16
0
// ham su ly du lieu nhan duoc tu uart
// dinh ki 1 phut gui ban tin nay qua uart 
void mode3_uart_send()
{
   // bat che do send uart len roi gui du lieu nhan duoc ra uart
   RS_485_EN=1;
   // send ban tin cap nhat nhiet do hoac do am qua rs485
   lcd_putchar(0x01);
   // sau khi gui lenh xong dua vao che do nhan du lieu
   RS_485_EN=0;  
}
예제 #17
0
void putchar(char c)
{
	if (print_to_lcd) 
	{
		lcd_putchar(c);
	} else {
		pm2_cout(c);
	}	

}
예제 #18
0
파일: v2.c 프로젝트: Manrul/Mikroprocesory
int lcd_put(char znak, FILE *s)
{
	if (znak == '\r')
		lcd_gotoxy(0, 0);
	else if (znak == '\n')
		lcd_gotoxy(0, 1);
	 else
		lcd_putchar(znak);
	
	return 0;
}
예제 #19
0
파일: lcd.c 프로젝트: dkrishna92/ARM
void lcd_putstring( unsigned char line, char *string )
{
  unsigned char len = MAX_CHAR_IN_ONE_LINE;

  lcd_gotoxy( line, 0 );
  while(*string != '\0' && len--)
  {
    lcd_putchar( *string );
    string++;
  }
}
예제 #20
0
// ============================================================================
void lcd_define_char(const char *pc,char char_code)
{
	char a , i;
	a = ((char_code<<3)|0x40) & 0xff;
	for (i = 0; i < 8 ;i++)
	{
		lcd_command(a++);
		clcd_Delay();
		lcd_putchar(pc[i]);
		clcd_Delay();
	}
}
예제 #21
0
파일: main.c 프로젝트: jackzkdavies/foobar-
void displayTime(int m, int s, int h){

	lcd_command(0x01); // clears display
	delay_millisec(2);

	lcd_putchar(div(m));
	lcd_putchar(mod(m));
	lcd_putchar(':');
	lcd_putchar(div(s));
	lcd_putchar(mod(s));
	lcd_putchar(':');
	lcd_putchar(div(h));
	lcd_putchar(mod(h));

}
예제 #22
0
/*******************************************************************************
* MAIN FUNCTION                                                                *
*******************************************************************************/
int main(void)
{
	unsigned char value = 0;	// declare a variable to store
	// ensure all the hardware port in zero initially
	PORTA = 0;
	PORTB = 0;
	PORTC = 0;
	PORTD = 0;
	PORTE = 0;

	// Initialize the I/O port direction, this must be configured according to circuit
	// please refer to PTK40A schematic for details
	// TRISX control pin direction, output pin must be configure as '0'
	// while input must be configure as '1'
	TRISA = 0b00010001;
	TRISB = 0b00001111;
	TRISC = 0b10010011;
	TRISD = 0;
	TRISE = 0;

	// Initialize ADC.
	adc_initialize();	//Ensure pin share with analog is being configured to digital correctly

	// Initialize 7 segments
	seg7_initialize();	//Ensure 7 segment is blank at beginning

	// Initialize LCD
	lcd_initialize();	//Initialize LCD before use

	beep(2); 	//buzzer sound for twice

	// PTK40A have a 4x4 matrix keypad, it has 16 key press.
	// Please refer to PTK40A schematic for the connection
	// Please refer to keypad.c for the details of function works
	// press keypress will display the value on LCD, you will need to release keypad to see value

	LCD_BACKLIGHT = 1;	//activate LCD Backlight

	lcd_putstr("Cytron PTK40A");	//display message on LCD
	lcd_2ndline();					//move cursor to 2nd line
	lcd_putstr("Keypad:");

	while(1) 	// create an infinite loop
	{
		lcd_goto(0x47);	//move cursor to after Keypad: on LCD
		lcd_putchar(c_key_to_ASCII(c_wait_keypad()));	// wait for keypress
														// convert to ASCII and display LCD
	}
	while(1) continue;	// infinite loop to prevent PIC from reset if there is no more program
}
예제 #23
0
void zero_init()
{
    lcd_clear();
    lcd_puts("Memory init");
    write_var(0, 0, 0x19);
    write_var(0, 1, 0x08);
    write_var(0, 2, 0x1E);  //30
           
    block = 0;            
    addr = 3;
    for(i = 0; i < MAX_PATTERNS; i++)
    {
        write_var(block, addr, v1.length);
        addr++;
            check_ab();
        for(j = 0; j < MAX_ITEMS; j++)                
        {                   
            lcd_gotoxy(0, 1);  
            
            lcd_puts(t_preset);
            lcd_putchar(' ');
            
            LCDWriteInt(i, 0);
            
            lcd_putchar(' ');
            lcd_puts(t_item);
            lcd_putchar(' ');
            
            LCDWriteInt(j, 0);
            lcd_putchar(' ');
            
            write_var(block, addr, v1.out[j]);
            addr++;
            check_ab();
        }
    }
}
예제 #24
0
void write_pattern(t_pattern patt, unsigned char num)
{
    #asm("cli")
    lcd_clear();
    lcd_puts("Memory write");
    addr = 3 + num * (MAX_ITEMS + 1);
    block = addr / 256;
    addr = addr % 256;
 
    write_var(block, addr, patt.length);

    addr++;
    check_ab();
    
    lcd_gotoxy(0, 1);
    
    lcd_puts(t_preset);
    lcd_putchar(' ');
    
    LCDWriteInt(num, 0);
    
    lcd_putchar(' ');
    lcd_puts(t_item);
    lcd_putchar(' ');

    for(j = 0; j < MAX_ITEMS; j++)                
    {                         
        lcd_gotoxy(14, 1);             
        LCDWriteInt(j, 0);
        lcd_putchar(' ');
        write_var(block, addr, patt.out[j]);
        addr++;
        check_ab();
    }
    #asm("sei")
}
예제 #25
0
t_pattern read_pattern(unsigned char num)
{
    t_pattern patt;

    #asm("cli")
    lcd_clear();
    lcd_puts("Memory read");
    addr = 3 + num * (MAX_ITEMS + 1);
    block = addr / 256;
    addr = addr % 256;
    
    patt.length = read_var(block, addr);
    
    addr++;
    check_ab();
    
    lcd_gotoxy(0, 1);
    lcd_puts(t_preset);
    lcd_putchar(' ');
    LCDWriteInt(num, 0);
    lcd_putchar(' ');
    lcd_puts(t_item);
    lcd_putchar(' ');

    for(j = 0; j < MAX_ITEMS; j++)                
    {                          
        lcd_gotoxy(14, 1);
        LCDWriteInt(j, 0);
        lcd_putchar(' ');
        patt.out[j] = read_var(block, addr);
        addr++;
        check_ab();
    }          
    #asm("sei")
    return patt;
}
예제 #26
0
파일: test.c 프로젝트: InfinityBRB/AMS
//Methode zum starten(warten auf Startlampe) 
void starting(void){
	servo_arc(0, 54);
	if (analog(LEFT_BACK)>WHITE){ 				//wenn links schwarz
		start = 'l';
	}else if (analog(RIGHT_BACK)>WHITE){		//wenn rechts schwarz
		start = 'r';
	}
	motPowLeft=8;
	motPowRight=8;
	lcd_putchar(start);
	while(analog(9)>100);
	timeoutAt = akt_time() + RUNTIME;
	setMotPow(motPowLeft,motPowRight);			//Gas geben:-)
	sperrtimeout = akt_time() + 400; 			//Sperrzeit zum Linienzählen
}
예제 #27
0
// ============================================================================
void lcd_putsf(char* data)	//Outputs string to LCD
{
	char *p;
	p = data;

	// check to make sure we have a good pointer
	if (!p)
		return;

	// print data
	for(; *p ; )
	{
		lcd_putchar(*p);
		p++;
	}
}
예제 #28
0
/*----------------------------------------------------------------------------*/
void my_putchar(u8 dat)
{
#if ((monitor == DISP_LCD_12832) || (monitor == DISP_LCD_12864_SER)  || (monitor == DISP_LCD_12864_PAR))
    {
        lcd_putchar(dat);
    }
#elif(monitor == DISP_LED5X7)
    {
        led_putchar(dat);
    }
#else
    {
        dat = dat;
    }
#endif
}
예제 #29
0
/**
********************************************************************************************
	Function Name :	process_lcd()

	Description :
	
	Input :	Void

	Output : Void

	Note :
**********************************************************************************************
*/
void process_lcd(void)
{
  S8 key;
  static U8 position = 0;
	
  key = xgetkey();
  if(is_valid_ascii(key))
  {
    lcd_gotoxy(LINE2, position);
    lcd_putchar(key);
    if(position == MAX_CHAR_IN_ONE_LINE)
    {
      lcd_clear();
      position = 0;
    }		
    position++;
  }
}
/*******************************************************************************
* PUBLIC FUNCTION: lcd_bcd
*
* PARAMETERS:
* ~ uc_digit, ui_number
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* convert the value in ui_number to BCD(Binary Code Decimal) and display the digit according to uc_digit needed.
*
*******************************************************************************/
void lcd_bcd(unsigned char uc_digit, unsigned int ui_number)
{
	unsigned int ui_decimal[5] ={ 0 };
	//extract 5 single digit from ui_number
		ui_decimal[4] = ui_number/10000;	// obtain the largest single digit, digit4 
		ui_decimal[3] = ui_number%10000;	// obtain the remainder 
		ui_decimal[2] = ui_decimal[3]%1000;			
		ui_decimal[3] = ui_decimal[3]/1000;			// obtain the 2nd largest single digit, digit3 
		ui_decimal[1] = ui_decimal[2]%100;
		ui_decimal[2] = ui_decimal[2]/100;			// obtain the 3rd largest single digit, digit2 
		ui_decimal[0] = ui_decimal[1]%10;			// obtain the smallest single digit, digit0 
		ui_decimal[1] = ui_decimal[1]/10;			// obtain the 4th largest single digit, digit1 
		
		if (uc_digit > 5) uc_digit = 5;			// limit to 5 digits only
		for( ; uc_digit > 0; uc_digit--)
		{
			lcd_putchar(ui_decimal[uc_digit - 1] + 0x30);			
		}
}