Пример #1
0
int main() {
    state = new LaosStatus();
    state->setState(BOOTING);
    if (! check_sd()) mbed_reset();
    if (SDcheckFirmware()) mbed_reset();
    cfg =  new GlobalConfig("config.txt");
    mot = new LaosMotion();
    // wait until cover is closed
    state->setState(WAITFORCOVER);
    while (! mot->isStart() );
    // home
    state->setState(HOMING);
    mot->home(cfg->xhome,cfg->yhome, cfg->zhome);
    // clean sd card?
    if (cfg->cleandir) cleandir();
    // configure network
    eth_speed = 0;
    eth = EthConfig();
    eth_speed = 1;
    // set up TFTP server thread
    osThreadCreate(osThread(tftp_thread), NULL);
    // set up Queue (planner-filler) thread
    osThreadCreate(osThread(queue_thread), NULL);

    while (1) {
        if (mot->qstate == IDLE) {
            mot->filename = getLaosFile();
            if (mot->filename) mot->qstate = NEW;
        }
        if (mot->qstate == DONE) {
            removefile(mot->filename);
            delete(mot->filename);
        }
        osDelay(500);
    }
}
Пример #2
0
/**
*** Main function
**/
int main() 
{
  systime.start();
  //float x, y, z;
  eth_speed = 1;
  
  dsp = new LaosDisplay();
  printf( VERSION_STRING "...\nBOOT...\n" ); 
  mnu = new LaosMenu(dsp);
  eth_speed=0;

 printf("TEST SD...\n"); 
  char testfile[] = "test.txt";
  FILE *fp = sd.openfile(testfile, "wb");
  if ( fp == NULL )
  {
    mnu->SetScreen("SD NOT READY!"); 
    wait(2.0);
    mbed_reset();
  }
  else
  {
    printf("SD: READY...\n");
    fclose(fp);
    removefile(testfile);
  }
  
  // See if there's a .bin file on the SD
  // if so, put it on the MBED and reboot
  if (SDcheckFirmware()) mbed_reset();
  
  mnu->SetScreen(VERSION_STRING);
  printf("START...\n");
  cfg =  new GlobalConfig("config.txt");
  mnu->SetScreen("CONFIG OK...."); 
  printf("CONFIG OK...\n");
  if (!cfg->nodisplay)
    dsp->testI2C();
  
  printf("MOTION...\n"); 
  mot = new LaosMotion();
    
  eth = EthConfig();
  eth_speed=1;
      
  printf("SERVER...\n");
  srv = new TFTPServer(cfg->port);
  mnu->SetScreen("SERVER OK...."); 
  wait(0.5);
  mnu->SetScreen(10); // IP
  wait(1.0);
  
  printf("RUN...\n");
  
  // Wait for key, and then home
  
  if ( cfg->autohome )
  {
    printf("WAIT FOR COVER...\n");
    wait(1);
  
  
  // Start homing
    mnu->SetScreen("WAIT FOR COVER....");
    //if ( cfg->waitforstart ) 
      while ( !mot->isStart() );
    mnu->SetScreen("HOME....");
    printf("HOME...\n");

    mot->home(cfg->xhome,cfg->yhome, cfg->zhome);
    // if ( !mot->isHome ) exit(1);
    printf("HOME DONE. (%d,%d, %d)\n",cfg->xhome,cfg->yhome,cfg->zhome);
  }
  else
    printf("Homing skipped: %d\n", cfg->autohome);

  // clean sd card?
  if (cfg->cleandir) cleandir();
  mnu->SetScreen("");  

  if (cfg->nodisplay) {
    printf("No display set\n\r");
    main_nodisplay();
  } else {
    printf("Entering display\n\r");
    main_menu();
  }
}