⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sign7.c

📁 国外大学生毕业设计
💻 C
📖 第 1 页 / 共 2 页
字号:
                    per4=abs(percent[3]);
                    per5=abs(percent[4]);
                    sprintf(lcd_buffer,"%2d %2d %2d %2d %2d", per1,per2,per3,per4,per5);
                    lcd_puts(lcd_buffer); 
                    if (my_index == 9 && (diff> sensitivity)) //letter j needs movement
                    begin 
                        lcd_gotoxy(0,3);
                        lcd_putsf("     MATCH!     ");
                        task4(); //display for 1 sec   
                        task4(); //display for 1 sec   
                        lcd_clear();
                        index_found = 1;  
                        
                    end
                    else if (my_index == 25 && (diff> sensitivity))
                    begin
                        lcd_gotoxy(0,3);
                        lcd_putsf("     MATCH!     ");
                        task4(); //display for 1 sec   
                        task4(); //display for 1 sec   
                        lcd_clear();
                        index_found = 1; 
                    end
                    else if ((diff<= sensitivity) && (my_index != 9) &&(my_index != 25))
                    begin
                        lcd_gotoxy(0,3);
                        lcd_putsf("     MATCH!     ");
                        task4(); //display for 1 sec   
                        task4(); //display for 1 sec   
                        lcd_clear();
                        index_found = 1;                     
                    end   
                    
                    
                    
                    
                end
                /*else 
                begin
                    printf("Place 3 \r\n");
                    task4(); //display for 1 sec 
                    lcd_gotoxy(2,3); 	    //position to upper left on display 
                    sprintf(lcd_buffer,"LOOKS LIKE %c    ", letters[my_letter]); 
                    lcd_puts(lcd_buffer);
                end*/    
           end      
           else 
            begin
            lcd_gotoxy(2,1); 	    //position to upper left on display
            sprintf(lcd_buffer,"%cT %cI %cM %cR %cP",dir[0],dir[1],dir[2],dir[3],dir[4]); 
            lcd_puts(lcd_buffer);  
            
            lcd_gotoxy(0,2); 	    //position to upper left on display 
            lcd_putsf("%:              "); 	//string from flash    
            lcd_gotoxy(0,3); 	    //position to upper left on display 
            lcd_putsf("                "); 	//string from flash                         
            
            flag=0; 
            //convert to percentage
            for(i=0; i<5; i++)
            begin
                if(abs(percent[i])>99)
                    flag=1;
            end
            if(flag == 0)
            begin
                lcd_gotoxy(2,2); 	    //position to upper left on display   
                per1=abs(percent[0]);
                per2=abs(percent[1]);
                per3=abs(percent[2]);
                per4=abs(percent[3]);
                per5=abs(percent[4]);
                sprintf(lcd_buffer,"%2d %2d %2d %2d %2d", per1,per2,per3,per4,per5); 
                lcd_puts(lcd_buffer); 
            end
            else
            begin
                lcd_gotoxy(2,2); 	    //position to upper left on display 
                lcd_putsf("-- -- -- -- --");  
            end
            lcd_gotoxy(0,3);
            lcd_putsf("                ");     
           end // else
           
        
  end  //else if (~PIND.7) 
  
   
  
end  
 
//********************************************************** 
//Task 2  print the system time
void task2(void) 
begin
  time2=t2;  				//reset the task timer
  puts_int(); 
end   

//********************************************************** 
//Task 3  print the system time
void task3(void) 
begin
  
  time3=t3;     //reset the task timer  
  switch (PushState)
  begin
     case NoPush: 
        if (PIND.6 != 0) PushState=MaybePush;
        else PushState=NoPush;
        break;
     case MaybePush:
        if (PIND.6 != 0) 
        begin
           PushState=Pushed;   
           PushFlag=1;
        end
        else PushState=NoPush;
        break;
     case Pushed:  
        if (PIND.6 != 0) PushState=Pushed; 
        else PushState=MaybeNoPush;    
        break;
     case MaybeNoPush:
        if (PIND.6 != 0) PushState=Pushed; 
        else 
        begin
           PushState=NoPush;
           PushFlag=0;
        end    
        break;
  end
end
 
void task4(void)
begin
    time4 = t4; 
    while(time4>0);
end  
//********************************************************** 
//  -- non-blocking keyboard check initializes ISR-driven
// receive. This routine merely sets up the ISR, which then
//does all the work of getting a command.
void gets_int(void) 
begin
  r_ready=0;
  r_index=0;
  UCSRB.7=1;
end

//********************************************************** 
//  -- nonblocking print: initializes ISR-driven
// transmit. This routine merely sets up the ISR, then
//send one character, The ISR does all the work.   
void puts_int(void) 
begin
  t_ready=0;
  t_index=0;
  if (t_buffer[0]>0) 
  begin
  	putchar(t_buffer[0]);
  	UCSRB.5=1;
 end 
end

void calc_percent(int my_letter, int pos[5])
begin
     finger f; 
     int alphaf[5], posf[5];
     for (f=thumb;f<=pinky;f++)
     begin
          alphaf[f] = alpha[my_letter][f];
          posf[f] = pos[f];     
          percent[f]=((100*(alphaf[f]-posf[f]))/(alphaf[f]));      
     end 
end  

void plusminus()
begin
     //negative percentages means bend fingers
     finger f;
     for (f=thumb;f<=pinky;f++)
     begin
          if(percent[f]<0)
          begin
               dir[f]='-';
          end          
          else 
          begin 
               dir[f]='+';
          end
     end
end

//matches finger positions to appropriate letter
int match(int pos[])
begin
	int end_index = 26, i,j=0;
	int alpha_index[26];
	finger f;
	bool found=FALSE;

	for(i=0;i<26;i++) alpha_index[i]=i;

	for (f=thumb;f<=pinky;f++)
	begin 
		found = FALSE; 
		for(i=0;i<end_index;i++)
 		begin
			//found finger position
			if ((alpha[alpha_index[i]][f] >= pos[f]-RANGE) && (alpha[alpha_index[i]][f] <= pos[f]+RANGE))
			begin
				alpha_index[j++]=alpha_index[i];
				found = TRUE;
			end
		end
		
		//if no position is found for the list 
		//of possible letters, then exit loop
		if (found==FALSE) return NOTFOUND;

		end_index = j;
		j=0;
	end

	return alpha_index[0];		
end

void set_values(letter l, int arr[]) 
begin

	finger f; 
	for (f=thumb;f<=pinky;f++)
	begin
		alpha[l][f]=arr[f];  
	end 
	
    index_set[N++] = (int) l; 
end     

void main(void)
begin


   lcd_init(LCDwidth);      	//initialize the display
   lcd_clear();    
   //set up timer 0  

   //init vars and ports
   PushState = NoPush;
   PushFlag = 0;
   DDRB = 0xff;  
   PORTB = 0x00;  
   DDRD=0x3f;    // PORT A is an output  
   PORTD = 0xff; 
 
   //init the A to D converter 
   //channel zero/ left adj /EXTERNAL Aref
   //!!!CONNECT Aref jumper!!!!
   ADMUX = 0x60;   
   //enable ADC and set prescaler to 1/128*16MHz=125,000
   //and clear interupt enable
   //and start a conversion
   ADCSR = 0b11000111; 

  //serial setop for debugging using printf, etc.     
  UCSRB = 0x18 ;
  UBRRL = 103 ;
  putsf("\r\nStarting...\r\n");  
         
  //set up timer 0     
  OCR0=250;	   			//1 mSec
  TIMSK=2;	   			//turn on timer 0 cmp-match ISR 
  TCCR0=0b00001011;		//prescalar to 64  and Clr-on-match 
  
  //init the task timers
  time1=t1;
  time2=t2;  
  time3=t3;  
  
  r_ready=0;
  t_ready=1;  
     
  //crank up the ISRs
  #asm
  	sei
  #endasm  
 
  gets_int();
  lcd_clear();
  lcd_gotoxy(2,1); 	   
  lcd_putsf("SIGN LANGUAGE"); 

  lcd_gotoxy(3,2); 	   
  lcd_putsf("INTERPRETER");
  task4();
  task4();
  
      
   printf("BEGIN HERE......");

   // measure and display loop
   while (1)
   begin  
    if (time1==0)	task1();
    if (time2==0) 	task2(); 
    if (time3==0)   task3();
    
       
  end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -