static void magic(struct Bitmap *bitmap, coord_t x, coord_t y)
{
	static const coord_t coords[] = { 120, 34, 90, 90, 30, 90, 0, 34, 60, 0, 90, 90, 0, 34, 120, 34, 30, 90, 60, 0 };
	unsigned int i;

	gfx_moveTo(bitmap, coords[countof(coords)-2]/2 + x, coords[countof(coords)-1]/3 + y);
	for (i = 0; i < countof(coords); i += 2)
		gfx_lineTo(bitmap, coords[i]/2 + x, coords[i+1]/3 + y);
}
Exemple #2
0
void do_plot() {
  delay(1);
  for (int i=0; i<181; i+=15) {
    nds3_read(i, 1);
    delay(1);    
  }

  
  gfx_term_clear();
  uint8_t idx=0;
  uint8_t step=1;
  uint8_t idist_last=0;
  
  while (idx<=180) {
    uint8_t x=64;
    uint8_t y=0;
    uint8_t idist = nds3_distances[idx];
    
    if (idist<8) idist=4;
    if (idist>70) idist=70;
    
    float dir = idx*M_PI/180;
    float dist = idist*(63.0/70);

    y += sin(dir) * dist;
    x += cos(dir) * dist;
    if (((idist>idist_last)?(idist-idist_last):(idist_last-idist)) > 6) {
      gfx_move(x,y);
      gfx_pixel(1);
    } else {
      gfx_lineTo(x,y);
    }
    idist_last = idist;
    idx+=step;
  }


  idx=0;
 
  while (idx<=180) {
    uint8_t x=64;
    uint8_t y=0;
    
    float dir = idx*M_PI/180;
    float dist = 63.0;
    y += sin(dir) * dist;
    x += cos(dir) * dist;
    if (idx==0) {
      gfx_move(x,y);
    } else {
      gfx_lineTo(x,y);
    }    
    idx+=step;
  }

  char txt[10];
  int i;

  gfx_term_goto(0,0);

  i=nds3_distances[0];
  sprintf(txt, "%2i\n", i);
  gfx_term_print(txt);

  i=nds3_distances[14];
  sprintf(txt, "%2i\n", i);
  gfx_term_print(txt);

  i=nds3_distances[15];
  sprintf(txt, "%2i\n", i);
  gfx_term_print(txt);
  
}