Example #1
0
int main(void) {
  sei(); // enable interrupts
  leds_init();
  pwm_init();
  bot_init();
  i2c_init();

  if (display_init()!=0) {
    leds_set_displaylight(50);
    if (display_type==2) {
      gfx_init();
    }
  }
  
  gfx_fill(0x00);
  gfx_move(15, 0);
  gfx_set_proportional(1);
  gfx_print_text("nibo");
  gfx_set_proportional(0);

  uint8_t pos=0;
  uint8_t state=0;

  gfx_term_print("Move 0\n");
  nds3_move(0);
  while (nds3_get_busy()) {
    delay(1);
  }
  
  while (1) {
    gfx_draw_mode(GFX_DM_JAM2);

    check_voltage();

   
    //gfx_term_print("Measure 90, 15\n");
      delay(1);
    nds3_measure(180, 1);
    while (nds3_get_busy()) {
      delay(1);
    }

      delay(1);
    //gfx_term_print("Read -90, 15\n");
    do_plot();

      delay(1);
    nds3_measure(0, 1);
    while (nds3_get_busy()) {
      delay(1);
    }

      delay(1);
    //gfx_term_print("Read 90, 15\n");
    nds3_read(0, 15);
    do_plot();
    
    
  }
}
Example #2
0
/**
 * @brief scans the surrounding of the nibo with the nds3
 * @param degree the angle resolution of the nds3 scan, defines the number of values returned -> (180/degree)+1
 * @return the nds measurement
 */
uint8_t *ndsScan(uint8_t degree) {

	uint8_t winkel = 0;
	static uint8_t points[180] = {};

	for(winkel = 0; winkel < 180; winkel = winkel + degree){

		nds3_move(winkel);

		//delay for the movement of the servo, more for the first move
		if(winkel == 0){
			delay(900);
		}else {
			delay(100);
		}

		//updating the coprozessor, to get the current value
		copro_update();
		points[winkel / degree] = nds3_get_dist();
	}

	nds3_move(90);
	return points;
}
Example #3
0
/**
 * @brief initialize nds3 module
 */
void ndsScan_init(){
	i2c_init();
	nds3_move(90);
}