예제 #1
0
void erzhihua_x(uint8 (*ab)[136],uint8 ms)  //二值化阀值ms选择1:混合2:中间值3:平均值
{
  uint8 zuida,zuixiao,fazhi;//最大最小阀值
  uint32 zongzhi;           //总值
  uint8 fazhi1,fazhi2;                    //阀值1 2 
  uint8 i,j;
  zuida=ab[0][0];
  zuixiao=ab[0][0];
  zongzhi=0;
  for(i=0;i<165;i++)
  {  
    for(j=0;j<136;j++)
    {
      if(ab[i][j]>zuida)zuida=ab[i][j];
      if(ab[i][j]<zuixiao)zuixiao=ab[i][j];
      zongzhi=zongzhi+ab[i][j];
    }
  }
  fazhi1=(zuida+zuixiao)/2;
  fazhi2=zongzhi/22440;
  if(ms==1)
    fazhi=(fazhi1+fazhi2)/2;
  if(ms==2)
    fazhi=fazhi1-0x10;
  if(ms==3)
    fazhi=fazhi2;
  for(i=0;i<165;i++)
  {  
    for(j=0;j<136;j++)
    {
      if(ab[i][j]>fazhi) ab[i][j]=0xfe;
      else ab[i][j]=0x01;
    }  
  }
  if(ab[160][67]==0xfe)
    qd=67;
  else
  {
    if((ab[160][33]==0xfe)&(ab[160][101]==0x01))
      qd=33;
    if((ab[160][33]==0x01)&(ab[160][101]==0xfe))
      qd=101;
    if((ab[160][33]==0x01)&(ab[160][101]==0x01))
      qd=67;
  }
  qd=zhongzhi_zx_2D(ab,160,qd);
  for(i=10;i>0;i--)
  {
    sdsj[0][i-1]=zhongzhi_zbx_2D(ab,i*10+50,qd);Display_number ((i-1)/5*64+1,(i-1)%5,sdsj[0][i]);
    sdsj[1][i-1]=zhongzhi_ybx_2D(ab,i*10+50,qd);
    if(i!=10)
      Display_number ((i-1)/5*64+33,(i-1)%5,sdsj[1][i]);
    else
      Display_number (97,4,sdsj[1][9]);
    qd=zhongzhi_zx_2D(ab,i*10+50,qd);
  }
}
예제 #2
0
void chuli_float(float zhi)
{
  unsigned char temp1=0,temp2=0,temp3=0;
  temp1=(int)(zhi*10)/100;
  temp2=(int)zhi%10;
  temp3=(int)(zhi*10)%10;
  
  Display_number(1,3,temp1); 
  LCD_WDAT(temp2+48);

  Display(1,4,"."); 
  LCD_WDAT(temp3+48);
  
   Display(1,5,"℃"); 
}
예제 #3
0
파일: main.c 프로젝트: chenxuuu/SmartCar
/*!
 *  @brief      OLED显示
 *  @since      v1.0
 *  @note       没啥
 *  Sample usage:           oled_display();
 */
void oled_display()
{
    //第一行显示拨码开关状态
    OLED_P6x8Str(0, 0, "12345678");
    OLED_P6x8Str(50, 0, "speed:");	    Display_number(86, 0, vPID.Setpoint);
    OLED_P6x8Str(50, 1, "Error:");	    Display_number(86, 1, Error);
    OLED_P6x8Str(0, 2, "slope:");	    DisplayFloat(36, 2, slope.slope);
    OLED_P6x8Str(80, 2, "P:");	        DisplayFloatpid(92, 2, actuator_P);
    OLED_P6x8Str(0, 3, "Distance:");	Display_number(54, 3, distance);
    OLED_P6x8Str(86, 3, "D:");	        DisplayFloatpid(98, 3, actuator_D);
    OLED_P6x8Str(0, 4, "Bluetooth:");   
    if(bluetooth == 1)
        OLED_P6x8Str(60, 4, "connected ");
    else if(bluetooth == 0)
        OLED_P6x8Str(60, 4, "disconnect");
    else
        OLED_P6x8Str(60, 4, "off       ");
    OLED_P6x8Str(0, 5, "stop?");
    if(stop_done)
        OLED_P6x8Str(36, 5, "yes");
    else
        OLED_P6x8Str(36, 5, "no");

    #if ( CAR_NUMBER == 1 )
        OLED_P6x8Str(0, 7, "Interesting");
        OLED_P6x8Str(91, 7, "Car:1A");
    #endif
    #if ( CAR_NUMBER == 2 )
        OLED_P6x8Str(0, 7, "Interesting");
        OLED_P6x8Str(91, 7, "Car:2B");
    #endif

    if(!gpio_get (PTE1))
        OLED_P6x8Str(0, 1, "^");
    else
        OLED_P6x8Str(0, 1, " ");

    if(!gpio_get (PTE2))
        OLED_P6x8Str(6, 1, "^");
    else
        OLED_P6x8Str(6, 1, " ");

    if(!gpio_get (PTE3))
        OLED_P6x8Str(12, 1, "^");
    else
        OLED_P6x8Str(12, 1, " ");

    if(!gpio_get (PTE4))
        OLED_P6x8Str(18, 1, "^");
    else
        OLED_P6x8Str(18, 1, " ");

    if(!gpio_get (PTE5))
        OLED_P6x8Str(24, 1, "^");
    else
        OLED_P6x8Str(24, 1, " ");

    if(!gpio_get (PTE6))
        OLED_P6x8Str(30, 1, "^");
    else
        OLED_P6x8Str(30, 1, " ");

    if(!gpio_get (PTE7))
        OLED_P6x8Str(36, 1, "^");
    else
        OLED_P6x8Str(36, 1, " ");

    if(!gpio_get (PTE8))
        OLED_P6x8Str(42, 1, "^");
    else
        OLED_P6x8Str(42, 1, " ");

    if(key_check(KEY_A) == KEY_DOWN)
    {
        OLED_Init();    //OLED初始化  防花屏
    }

    if(key_check(KEY_U) == KEY_DOWN)     //按K2重新获取两边线数组,串口接收
    {
        get_initial_value(img, &slope);

        printf("const int left_initial[110] ={");
        for(i = 0; i < 110; i++)
        {
            printf("%d, ", slope.left_initial_value[i]);
            //printf("[%d]=%d\n", i, slope.right_initial_value[i]);
        }
        printf("};\nconst int right_initial[110] ={");
        for(i = 0; i < 110; i++)
        {
            printf("%d, ", slope.right_initial_value[i]);
            //printf("[%d]=%d\n", i, slope.right_initial_value[i]);
        }
        printf("};//Pay attention to delete the last \",\"\n");
        //initial_value_get=1;
    }

}