void SDCard::initsd() { sdactive = false; #if SDSS >- 1 #if defined(SDCARDDETECT) && SDCARDDETECT>-1 if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED) return; #endif /*if(dir[0].isOpen()) dir[0].close();*/ if(!fat.begin(SDSS,SPI_FULL_SPEED)) { Com::printFLN(Com::tSDInitFail); return; } sdactive = true; Printer::setMenuMode(MENU_MODE_SD_MOUNTED,true); fat.chdir(); if(selectFile("init.g",true)) { startPrint(); } #endif }
void Print_Formatter(FILE *stream, CONST_FORMAT_PTR format) { Print_Data_Type printer; LOCK_CM_MUTEX; startPrint(stream, &printer); if (format) Print_Formatter1(stream, &printer, format, 0); else printString(stream, &printer, "NULL Format", 0); endPrint(stream, &printer); UNLOCK_CM_MUTEX; }
void Print_Formatted_Data(FILE *stream, CONST_FORMAT_PTR format, const void *dataPtr) { Print_Data_Type printer; LOCK_CM_MUTEX; startPrint(stream, &printer); Print_Structured_Data(stream, &printer, format, (CONST_GENERIC_DATA_PTR)dataPtr, 0, (FORMAT_PTR)NULL, 0); endPrint(stream, &printer); UNLOCK_CM_MUTEX; }
void CardReader::checkautostart(bool force) { if (!force && (!autostart_stilltocheck || next_autostart_ms >= millis())) return; autostart_stilltocheck = false; if (!cardOK) { initsd(); if (!cardOK) return; // fail } fat.chdir(true); if(selectFile("init.g", true)) startPrint(); }
task listenToBluetooth(){ int receiver, method, payload; while(true) { receiver = messageParm[0]; method = messageParm[1]; payload = messageParm[2]; if(receiver != 0 || method != 0 || payload != 0){ PlaySound(soundBlip); switch(method){ case PRINTER_PRINT: // print the letter startPrint(payload); break; default: PlaySound(soundException); // method not supported } ClearMessage(); } wait1Msec(500); } }
void SDCard::initsd() { sdactive = false; #if SDSS > -1 #if SDCARDDETECT > -1 if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED) return; #endif HAL::pingWatchdog(); HAL::delayMilliseconds(50); // wait for stabilization of contacts, bootup ... fat.begin(SDSS, SPI_FULL_SPEED); // dummy init of SD_CARD HAL::delayMilliseconds(50); // wait for init end HAL::pingWatchdog(); /*if(dir[0].isOpen()) dir[0].close();*/ if(!fat.begin(SDSS, SPI_FULL_SPEED)) { Com::printFLN(Com::tSDInitFail); sdmode = 100; // prevent automount loop! return; } sdactive = true; Printer::setMenuMode(MENU_MODE_SD_MOUNTED, true); HAL::pingWatchdog(); fat.chdir(); #if defined(EEPROM_AVAILABLE) && EEPROM_AVAILABLE == EEPROM_SDCARD HAL::importEEPROM(); #endif if(selectFile("init.g", true)) { startPrint(); } #endif }
void map (int argc, char *argv[], HWND hWnd, char *dirpath, char *map_filename) { char *datatitle; char *maptitle; char *zname; DATATYPE data_type; double hscale, vscale; double xmin, xmax, ymin, ymax; double *x, *y, *z; double *fit, *resid; int fit_degree; int i, k; int npoint; int zdigits; unsigned long *code; /* get data to plot */ npoint = prepdata (argc, argv, &datatitle, &data_type, &code, &x, &y, &z, &fit_degree, &fit, &resid); /* use select conditions to select points */ k = 0; for (i = 0; i < npoint; i++) { double fitval, residval; if (fit_degree > 0) { fitval = fit[i]; residval = resid[i]; } else { fitval = residval = 0.0; } if (opt_select (code[i], x[i], y[i], z[i], fit_degree, fitval, residval)) { code[k] = code[i]; x[k] = x[i]; y[k] = y[i]; z[k] = z[i]; if (fit_degree) { fit[k] = fit[i]; resid[k] = resid[i]; } ++k; } } npoint = k; if (npoint == 0) error_stop ("no points remain after selections in output.opt",""); /* prepare map title */ opt_zvalue (&zname, &zdigits); if (strlen (datatitle) > 100 || strlen (zname) > 100) error_stop ("data title or observed value name too long", ""); maptitle = (char *) malloc (250); if (maptitle == NULL) error_stop ("cannot allocate vector for map title", ""); switch (data_type) { case CODE: sprintf_s (maptitle, 250, "%s - Station Codes", datatitle); break; case OBS: sprintf_s (maptitle, 250, "%s - %s Values", datatitle, zname); break; case FIT: sprintf_s (maptitle, 250, "%s - Degree %d Fit of %s Values", datatitle, fit_degree, zname); break; case RESID: sprintf_s (maptitle, 250, "%s - Degree %d Fit Residual of %s Values", datatitle, fit_degree, zname); break; } /* determine range of coordinate values */ xmin = ymin = 1.e+30; xmax = ymax = -xmin; for (i = 0; i < npoint; i++) { xmin = x[i] < xmin ? x[i] : xmin; ymin = y[i] < ymin ? y[i] : ymin; xmax = x[i] > xmax ? x[i] : xmax; ymax = y[i] > ymax ? y[i] : ymax; } /* convert coordinates to map scale inches, assuming that the */ /* x and y values are longitude and latitude, respectively */ { double center_latitude = (ymin + ymax) / 2; double cos_cent; double degrees_per_radian = M_PI / 180.; double s, t; long ratio; opt_scale (&ratio); cos_cent = cos (center_latitude * degrees_per_radian); t = 1 - cos_cent * cos_cent * 0.006693422; s = (cos_cent * 2.5026656e+8) / sqrt (t); hscale = ratio / (s * degrees_per_radian); t = (6.305541e+16 - 0.006693422 * s * s); t = t * sqrt (t) / 6.284403e+16; vscale = ratio / (t * degrees_per_radian); for (i = 0; i < npoint; i++) { x[i] = - x[i] / hscale; /* switch sign on longitude for */ /* correct map orientation */ y[i] = y[i] / vscale; } { /* must also switch sign on */ double hold = xmin; /* xmin and xmax */ xmin = - xmax / hscale; xmax = - hold / hscale; } ymin = ymin / vscale; ymax = ymax / vscale; } /* create pdf map file */ startPrint(hWnd, dirpath, map_filename, maptitle); printHeader(maptitle); printStations(data_type, npoint, code, x, y, z, fit, resid, hscale, vscale, xmin, xmax, ymin, ymax, zdigits); endPrint(); return; }