Exemplo n.º 1
0
int read_parameters(TP_HANDLE tp_handle,char *ifilename, char *ofilename)
{
    int stat = 0;

    // ファイルの読み込み
    printf(">>> Reading file(%s)\n", ifilename);
    stat=tp_read(tp_handle,ifilename);
    if (stat == 0) {
        printf("# Successful completion of reading a file : %s\n", ifilename);
    } else {
        printf("# Error occurs during reading a file : C%d\n", stat);
        return 1;
    }


    //
    stat=tp_remove(tp_handle);
    if (stat == 0) {
        printf("# Successful completion of deleting a Data base.\n");
    } else {
        printf("# Error occurs during deleting a Data base : C%d\n", stat);
        return 1;
    }
    printf("\n");
    return 0;
}
Exemplo n.º 2
0
void cmd_lcd_test(uint_least16_t fgcolor, uint_least16_t bgcolor)
{
  uint_least8_t c=1, f_save=features;
  char tmp[32];
#ifdef TP_SUPPORT
  uint_least16_t x, y, z, last_x=0, last_y=0;
  uint_least32_t ms=0;

  tp_init();
  ldr_init();
  features = FEATURE_TP | FEATURE_LDR; //FEATURE_TP | FEATURE_LDR
#else
  uint_least8_t sw;
  int_least8_t pos=0, hpos=0, vpos=0;

  enc_init();
  features = FEATURE_ENC;
#endif

  lcd_fillrect(0,                   0, (LCD_WIDTH-1)/3,     LCD_HEIGHT-1, RGB(255,0,0));
  lcd_fillrect((LCD_WIDTH-1)/3,     0, ((LCD_WIDTH-1)/3)*2, LCD_HEIGHT-1, RGB(0,255,0));
  lcd_fillrect(((LCD_WIDTH-1)/3)*2, 0, LCD_WIDTH-1,         LCD_HEIGHT-1, RGB(0,0,255));
/*
  delay_ms(1500);
  lcd_clear(bgcolor);

  lcd_setorientation(  0); lcd_drawrect(10, 20, 40, 40, RGB(200,  0,  0)); lcd_drawtext(15, 25, "0  ", 0, RGB(200,  0,  0), 0, 0);
  lcd_setorientation( 90); lcd_drawrect(10, 20, 40, 40, RGB(  0,200,  0)); lcd_drawtext(15, 25, "90 ", 0, RGB(  0,200,  0), 0, 0);
  lcd_setorientation(180); lcd_drawrect(10, 20, 40, 40, RGB(  0,  0,200)); lcd_drawtext(15, 25, "180", 0, RGB(  0,  0,200), 0, 0);
  lcd_setorientation(270); lcd_drawrect(10, 20, 40, 40, RGB(200,  0,200)); lcd_drawtext(15, 25, "270", 0, RGB(200,  0,200), 0, 0);

  lcd_setorientation(0);
  lcd_drawline(0, LCD_WIDTH/4*1, LCD_WIDTH-1, LCD_WIDTH/4*1, RGB(120,120,120));
  lcd_drawline(0, LCD_WIDTH/4*2, LCD_WIDTH-1, LCD_WIDTH/4*2, RGB(120,120,120));
  lcd_drawline(0, LCD_WIDTH/4*3, LCD_WIDTH-1, LCD_WIDTH/4*3, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*1, 0, LCD_WIDTH/4*1, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*2, 0, LCD_WIDTH/4*2, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*3, 0, LCD_WIDTH/4*3, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawcircle(LCD_WIDTH/2, LCD_HEIGHT/2, 40, RGB(120,120,120));
*/

  lcd_drawtext(LCD_CENTER, LCD_HEIGHT/2-5, "v"VERSION, 0, 0, 0, 0);
  lcd_drawtext(LCD_CENTER, LCD_HEIGHT/2+5, "("__DATE__")", 0, 0, 0, 0);
  lcd_drawtext(LCD_CENTER, LCD_HEIGHT-10, "watterott.com", 1, 0, 0, 0);

  do
  {
#ifdef TP_SUPPORT
    tp_read();
    z = tp_getz();
    if(z)
    {
      x = tp_getx();
      y = tp_gety();
      if((x!=last_x) || (y!=last_y))
      {
        last_x = x;
        last_y = y;
        lcd_fillcircle(x, y, 4, fgcolor); //lcd_drawpixel(x, y);
        sprintf(tmp, "X%03i Y%03i Z%03i", x, x, z);
        lcd_drawtext(5, 5, tmp, 0, fgcolor, bgcolor, 1);
      }

      GPIO_SETPIN(LED_PORT, LED_PIN); //LED on
    }
    else
    {
      GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off
    }

    if(features & FEATURE_LDR)
    {
      if((get_ms() - ms) >= 100)
      {
        ms = get_ms();
        x = ldr_service(100);
        sprintf(tmp, "LDR %03i", x);
        lcd_drawtext(5, 15, tmp, 0, fgcolor, bgcolor, 1);
      }
    }

#else //TP_SUPPORT

    pos  += enc_getdelta();
    hpos += nav_gethdelta();
    vpos += nav_getvdelta();
    sprintf(tmp, "P%03i H%03i V%03i", pos, hpos, vpos);
    lcd_drawtext(5, 5, tmp, 0, fgcolor, bgcolor, 1);

    sw  = enc_getsw();
    sw |= nav_getsw();
    if(sw)
    {
      GPIO_SETPIN(LED_PORT, LED_PIN); //LED on
      if(sw & 0x02)
      {
        if(features == FEATURE_ENC)
        {
          sprintf(tmp, "NAV");
          nav_init();
          features = FEATURE_NAV;
        }
        else //if(features == FEATURE_NAV)
        {
          sprintf(tmp, "ENC");
          enc_init();
          features = FEATURE_ENC;
        }
        lcd_drawtext(5, 25, tmp, 0, fgcolor, bgcolor, 1);
        delay_ms(500);
        while(enc_getsw() || nav_getsw());
      }
      else if(sw & 0x01)
      {
        lcd_drawtext(5, 15, "press", 0, fgcolor, bgcolor, 1);
      }
    }
    else
    {
      GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off
    }
#endif
    if(if_available())
    {
      c = if_read8();
    }
  }while(c != 0);

  GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off

  lcd_clear(bgcolor);

  features = f_save;

  return;
}
Exemplo n.º 3
0
void cmd_tp_calibrate(uint_least16_t fgcolor, uint_least16_t bgcolor)
{
  uint_least8_t i;
  CAL_POINT lcd_points[3] = {CAL_POINT1, CAL_POINT2, CAL_POINT3}; //calibration point postions
  CAL_POINT tp_points[3];

  tp_init(); //enable/reset touch

  tp_read();
  if(tp_rawz())
  {
     lcd_clear(bgcolor);
     lcd_drawtext(10, 10, "Release Touchpanel.", 1, fgcolor, 0, 0);
     while(tp_rawz() > MIN_PRESSURE){ tp_read(); };
  }

  do
  {
    //clear screen and wait for touch release
    lcd_clear(bgcolor);
    lcd_setorientation(180);
    lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0);
    lcd_setorientation(0);
    lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0);

    for(i=0; i<3; )
    {
      //draw point
      lcd_drawcircle(lcd_points[i].x, lcd_points[i].y, 15, fgcolor);
      lcd_drawline(lcd_points[i].x-10, lcd_points[i].y,    lcd_points[i].x-3,  lcd_points[i].y,    fgcolor);
      lcd_drawline(lcd_points[i].x+3,  lcd_points[i].y,    lcd_points[i].x+10, lcd_points[i].y,    fgcolor);
      lcd_drawline(lcd_points[i].x,    lcd_points[i].y-10, lcd_points[i].x,    lcd_points[i].y-3,  fgcolor);
      lcd_drawline(lcd_points[i].x,    lcd_points[i].y+3,  lcd_points[i].x,    lcd_points[i].y+10, fgcolor);

      //touch detected? -> save point
      tp_read();
      if(tp_getz() > (MIN_PRESSURE*1.5))
      {
        //mark point
        lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 4, RGB(255,0,0));
        //wait and clear point
        delay_ms(400);
        lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 15, bgcolor);
        //save point
        tp_points[i].x = tp_rawx();
        tp_points[i].y = tp_rawy();
        i++;
        //wait till press is over
        while(tp_rawz() > MIN_PRESSURE){ tp_read(); };
      }

      //data available
      if(if_available())
      {
        if(if_read8() == 0)
        {
          i = 0xFF;
          break;
        }
      }
    }
  }
  while((i!=0xFF) && (tp_calmatrix(lcd_points, tp_points)!=0)); //calculate calibration matrix

  tp_init(); //reset touch

  lcd_clear(bgcolor);

  return;
}
Exemplo n.º 4
0
int main(){


  TP_HANDLE tp_hand;
  int status;

  double from, to, step;
  char node[10];
  char label[10];
  char value[64];
  double expanded[100];
  int i;
  double check[6]={ 50.000000,57.000000,64.000000,
		    71.000000,78.000000,85.000000,};
  double check2[5]={ 19,0.4,-3,10.3,-3.0,};
  double check3[5]={-3,-3,0.4,10.3,19,};
  double check4[5]={19,10.3,0.4,-3,-3,};
  int check_count;

  tp_hand=tp_createInstance();
  status = tp_read(tp_hand,"./tpp_examples/correct_range_list_1.tpp");
  status = tp_write(tp_hand,"./ctest.tpp");

  status = tp_currentNode(tp_hand,node);
  printf("%d %s\n",status,node);
  status = tp_changeNode(tp_hand,"config");
  status = tp_currentNode(tp_hand,node);
  printf("%d %s\n",status,node);
  printf("%d %s\n",status,node);
  printf("before strcmp \n");
  strcpy(label,"gridx3");
  printf("after strcmp \n");
  printf("%s",label);
  status = tp_getValue(tp_hand,label,value);  
  printf("%s %s",label,value);
  printf("%s %s",label,value);

  status = tp_splitRange(tp_hand,value,&from,&to,&step);

  printf("%lf %lf %lf",from,to,step);

  if( (from == 50.) && (to==89.4) &&(step==7) ){
    printf(" splitRange OK!\n");
  } else {
    printf(" splitRange not OK!\n");
  }

  status = tp_expandRange(tp_hand,value,expanded);
  
  check_count=0;
  for(i=0;i<6;++i){
    printf("%d %lf \n",i, expanded[i]);
    if(check[i]!=expanded[i]){check_count++;}

  }
  if (check_count ==0){
    printf("expandRange good\n");
  } else {
    printf("expandRange failed\n");
  }



  status = tp_getValue(tp_hand,"gridx4",value);
  status = tp_splitList(tp_hand,value,expanded,0);

  check_count=0;
  for(i=0;i<5;++i){
    printf("%d %lf \n",i, expanded[i]);
    if(check2[i]!=expanded[i]){check_count++;}

  }
  if (check_count ==0){
    printf("expandList good\n");
  } else {
    printf("expandList failed\n");
  }

  status = tp_splitList(tp_hand,value,expanded,1);
  check_count=0;
  for(i=0;i<5;++i){
    printf("%d %lf \n",i, expanded[i]);
    if(check3[i]!=expanded[i]){check_count++;}

  }
  if (check_count ==0){
    printf("expandList good\n");
  } else {
    printf("expandList failed\n");
  }
  status = tp_splitList(tp_hand,value,expanded,2);
  check_count=0;
  for(i=0;i<5;++i){
    printf("%d %lf \n",i, expanded[i]);
    if(check4[i]!=expanded[i]){check_count++;}

  }
  if (check_count ==0){
    printf("expandList good\n");
  } else {
    printf("expandList failed\n");
  }


  tp_deleteInstance(tp_hand);

}