/*************************************************** * Draw file list */ void drawFileList(void) { if (currentFile >= fileListSz) currentFile = 0; if (currentFile < 0) currentFile = fileListSz - 1; if ((firstFileInWin + currentFile) >= FILE_LIST_ROWS) firstFileInWin = currentFile - FILE_LIST_ROWS + 1; if (firstFileInWin > currentFile) firstFileInWin = currentFile; if (firstFileInWin < 0) firstFileInWin = 0; win_showMenuScroll(0, 0, 38, FILE_LIST_ROWS, firstFileInWin, currentFile, fileListSz); for (int i = 0; i < fileListSz; i++) { if (i == currentFile) scr_fontColorInvers(); else scr_fontColorNormal(); scr_printf("%s\n", &fileList[i][0]); } }
static int load_modules () { const char *STEP_OK = "*"; const char *FAILED = "failed to load with"; int ret, ipcfg_ret = 0; size_t i; const char *IPCONFIG_DAT_PATHS[] = { "mc0:/BIDATA-SYSTEM/IPCONFIG.DAT", /* japan */ "mc0:/BADATA-SYSTEM/IPCONFIG.DAT", /* us */ "mc0:/BEDATA-SYSTEM/IPCONFIG.DAT", /* europe */ "mc0:/SYS-CONF/IPCONFIG.DAT", /* old location */ NULL }; #if defined (LOAD_MRBROWN_PATCHES) sbv_patch_enable_lmb (); sbv_patch_disable_prefix_check (); scr_printf (STEP_OK); #endif #if defined (LOAD_SIOMAN_AND_MC) ret = SifLoadModule ("rom0:SIO2MAN", 0, NULL); if (ret > 0) scr_printf (STEP_OK); else { scr_printf ("\nrom0:SIO2MAN %s %d\n", FAILED, ret); return (-1); } ret = SifLoadModule ("rom0:MCMAN", 0, NULL); if (ret > 0) scr_printf (STEP_OK); else { scr_printf ("\nrom0:MCMAN %s %d\n", FAILED, ret); return (-1); } ret = SifLoadModule ("rom0:MCSERV", 0, NULL); if (ret > 0) scr_printf (STEP_OK); else { scr_printf ("\nrom0:MCSERV %s %d\n", FAILED, ret); return (-1); } #endif SifExecModuleBuffer (&iomanx_irx, size_iomanx_irx, 0, NULL, &ret); if (ret == 0) scr_printf (STEP_OK); else { scr_printf ("IOMANX.IRX %s %d\n", FAILED, ret); return (-1); } SifExecModuleBuffer (&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret); if (ret == 0) scr_printf (STEP_OK); else { scr_printf ("PS2DEV9.IRX %s %d\n", FAILED, ret); return (-1); } SifExecModuleBuffer (&ps2atad_irx, size_ps2atad_irx, 0, NULL, &ret); if (ret == 0) scr_printf (STEP_OK); else { scr_printf ("PS2ATAD.IRX %s %d\n", FAILED, ret); return (-1); } SifExecModuleBuffer (&ps2ip_irx, size_ps2ip_irx, 0, NULL, &ret); if (ret == 0) scr_printf (STEP_OK); else { scr_printf ("PS2IP.IRX %s %d\n", FAILED, ret); return (-1); } ipcfg_ret = -1; for (i = 0; ipcfg_ret != 0 && IPCONFIG_DAT_PATHS[i] != NULL; ++i) { ipcfg_ret = setup_ip (IPCONFIG_DAT_PATHS[i], if_conf, &if_conf_len); } SifExecModuleBuffer (&ps2smap_irx, size_ps2smap_irx, if_conf_len, if_conf, &ret); if (ret == 0) scr_printf (STEP_OK); else { scr_printf ("PS2SMAP.IRX %s %d\n", FAILED, ret); return (-1); } scr_printf ("\n"); switch (ipcfg_ret) { case 0: scr_printf ("\nusing %s\n", IPCONFIG_DAT_PATHS[i - 1]); break; case -1: scr_printf ("\nuse one of the following locations to set IP address:\n"); for (i = 0; IPCONFIG_DAT_PATHS[i] != NULL; ++i) scr_printf (" %s\n", IPCONFIG_DAT_PATHS[i]); break; case -2: scr_printf ("\nusing %s\n", IPCONFIG_DAT_PATHS[i - 1]); scr_printf ("\ninvalid configuration file format; use:\n" "ip_address network_mask gateway_ip\n" "separated by a single space; for example:" "192.168.0.10 255.255.255.0 192.168.0.1\n\n"); break; } scr_printf ("Playstation 2 IP address: %s\n", if_conf); return (0); }
/* * Edit or delete a user (cmd=25 to edit/create, 96 to delete) */ void edituser(CtdlIPC *ipc, int cmd) { char buf[SIZ]; char who[USERNAME_SIZE]; char newname[USERNAME_SIZE]; struct ctdluser *user = NULL; int newnow = 0; int r; /* IPC response code */ int change_name = 0; strcpy(newname, ""); newprompt("User name: ", who, 29); while ((r = CtdlIPCAideGetUserParameters(ipc, who, &user, buf)) / 100 != 2) { scr_printf("%s\n", buf); if (cmd == 25) { scr_printf("Do you want to create this user? "); if (yesno()) { r = CtdlIPCCreateUser(ipc, who, 0, buf); if (r / 100 == 2) { newnow = 1; continue; } scr_printf("%s\n", buf); } } free(user); return; } if (cmd == 25) { val_user(ipc, user->fullname, 0); /* Display registration */ if (!newnow) { change_name = 1; while (change_name == 1) { if (boolprompt("Change name", 0)) { strprompt("New name", newname, USERNAME_SIZE-1); r = CtdlIPCRenameUser(ipc, user->fullname, newname, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); } else { strcpy(user->fullname, newname); change_name = 0; } } else { change_name = 0; } } } if (newnow || boolprompt("Change password", 0)) { strprompt("Password", user->password, -19); } user->axlevel = intprompt("Access level", user->axlevel, 0, 6); if (boolprompt("Permission to send Internet mail", (user->flags & US_INTERNET))) user->flags |= US_INTERNET; else user->flags &= ~US_INTERNET; if (boolprompt("Ask user to register again", !(user->flags & US_REGIS))) user->flags &= ~US_REGIS; else user->flags |= US_REGIS; user->timescalled = intprompt("Times called", user->timescalled, 0, INT_MAX); user->posted = intprompt("Messages posted", user->posted, 0, INT_MAX); user->lastcall = boolprompt("Set last call to now", 0) ? time(NULL) : user->lastcall; user->USuserpurge = intprompt("Purge time (in days, 0 for system default", user->USuserpurge, 0, INT_MAX); } if (cmd == 96) { scr_printf("Do you want to delete this user? "); if (!yesno()) { free(user); return; } user->axlevel = AxDeleted; } r = CtdlIPCAideSetUserParameters(ipc, user, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); } free(user); }
/* * modes are: 0 - .EC command, 1 - .EC for new user, * 2 - toggle Xpert mode 3 - toggle floor mode */ void enter_config(CtdlIPC *ipc, int mode) { char buf[SIZ]; struct ctdluser *user = NULL; int r; /* IPC response code */ r = CtdlIPCGetConfig(ipc, &user, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); free(user); return; } if (mode == 0 || mode == 1) { user->flags = set_attr(ipc, user->flags, "Are you an experienced Citadel user", US_EXPERT, 0); if ((user->flags & US_EXPERT) == 0 && mode == 1) { free(user); return; } user->flags = set_attr( ipc, user->flags, "Print last old message on New message request", US_LASTOLD, 0 ); user->flags = set_attr( ipc, user->flags, "Prompt after each message", US_NOPROMPT, 1 ); if ((user->flags & US_NOPROMPT) == 0) { user->flags = set_attr( ipc, user->flags, "Use 'disappearing' prompts", US_DISAPPEAR, 0 ); } user->flags = set_attr( ipc, user->flags, "Pause after each screenful of text", US_PAGINATOR, 0 ); if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) { user->flags = set_attr( ipc, user->flags, "<N>ext and <S>top work at paginator prompt", US_PROMPTCTL, 0 ); } if (rc_floor_mode == RC_DEFAULT) { user->flags = set_attr( ipc, user->flags, "View rooms by floor", US_FLOORS, 0 ); } if (rc_ansi_color == 3) { user->flags = set_attr( ipc, user->flags, "Enable color support", US_COLOR, 0 ); } if ((user->flags & US_EXPERT) == 0) { formout(ipc, "unlisted"); } user->flags = set_attr( ipc, user->flags, "Be unlisted in userlog", US_UNLISTED, 0 ); if (!IsEmptyStr(editor_path)) { user->flags = set_attr( ipc, user->flags, "Always enter messages with the full-screen editor", US_EXTEDIT, 0 ); } } if (mode == 2) { if (user->flags & US_EXPERT) { user->flags ^= US_EXPERT; scr_printf("Expert mode now OFF\n"); } else { user->flags |= US_EXPERT; scr_printf("Expert mode now ON\n"); } } if (mode == 3) { if (user->flags & US_FLOORS) { user->flags ^= US_FLOORS; scr_printf("Floor mode now OFF\n"); } else { user->flags |= US_FLOORS; scr_printf("Floor mode now ON\n"); } } r = CtdlIPCSetConfig(ipc, user, buf); if (r / 100 != 2) scr_printf("%s\n", buf); userflags = user->flags; free(user); }
uint8_t cnc_waitSMotorReady(void) { #if (USE_LCD != 0) static uint32_t time = 0; #endif #if (USE_STEP_DEBUG == 1) static uint8_t isStepDump = false; #endif int i; do { if (stepm_getRemainLines() > 1) { scr_fontColor(Yellow, Black); for (i = 0; i < STEPS_MOTORS; i++) { int32_t globalSteps = stepm_getCurGlobalStepsNum(i); double n = (double)globalSteps / axisK[i]; scr_gotoxy(1 + i * 10, 3); scr_printf("%c:%f ", axisName[i], n); #if (USE_ENCODER == 1) if (i == 2) { int32_t enVal = encoderZvalue(); double encValmm = (double)(enVal * MM_PER_360) / ENCODER_Z_CNT_PER_360; scr_gotoxy(1 + 2 * 10, 4); scr_printf("errZ:%f ", encValmm - n); if (isEncoderCorrection) { scr_gotoxy(1, 6); scr_printf("dZ:%d[%d] ", encoderCorrectionDelta, encoderCorrectionMaxDelta); scr_gotoxy(15, 6); scr_printf("Up:%d Dn:%d ", encoderCorrectionCntUp, encoderCorrectionCntDown); } } #endif } #if (USE_STEP_DEBUG == 1) if (isStepDump) step_dump(); #endif #if (USE_LCD != 0) if (time != Seconds()) { uint32_t t; time = Seconds(); t = time - startWorkTime; scr_gotoxy(30, 12); scr_fontColor(Cyan, Black); scr_printf("%02d:%02d:%02d", t / 3600, (t / 60) % 60, t % 60); } #endif } #if (USE_KEYBOARD != 0) switch (kbd_getKey()) { case KEY_C: stepm_EmergeStop(); return false; case KEY_A: isPause = true; break; case KEY_0: #if (USE_ENCODER == 1) isEncoderCorrection = false; #endif scr_gotoxy(1, 6); scr_clrEndl(); break; case KEY_1: #if (USE_ENCODER == 1) isEncoderCorrection = true; #endif break; case KEY_7: #if (USE_STEP_DEBUG == 1) isStepDump = true; #endif break; case KEY_8: #if (USE_STEP_DEBUG == 1) isStepDump = false; #endif break; } #endif } while (stepm_LinesBufferIsFull()); if (limits_chk()) { stepm_EmergeStop(); #if (USE_LCD != 0) scr_fontColor(Red, Black); scr_gotoxy(7, 11); scr_puts("LIMITS ERROR!"); scr_clrEndl(); #endif return false; } return true; }
void cnc_gfile(char *fileName, int mode) { #if (USE_LCD != 0) && (MAX_SHOW_GCODE_LINES > 0) int n; #endif int lineNum; uint8_t hasMoreLines; initGcodeProc(); #if (USE_SDCARD != 0) FIL fid; FRESULT res = f_open(&fid, fileName, FA_READ); if (res != FR_OK) { win_showErrorWin(); #if (USE_SDCARD == 1) scr_printf("Error open file:'%s'\nStatus:%d [%d]", fileName, (int)res, SD_errno); #elif (USE_SDCARD == 2) scr_printf("Error open file:'%s'\nStatus:%d", fileName, (int)res); #endif return; } #endif curGCodeMode = mode; #if (USE_LCD != 0) if ((curGCodeMode & GFILE_MODE_MASK_SHOW) != 0) { scr_Rectangle(crdXtoScr(0), crdYtoScr(MAX_TABLE_SIZE_Y), crdXtoScr(MAX_TABLE_SIZE_X), crdYtoScr(0), Red, false); scr_Line(prev_scrX, 30, prev_scrX, 240 - 30, Green); scr_Line(50, prev_scrY, 320 - 50, prev_scrY, Green); } #endif if ((curGCodeMode & GFILE_MODE_MASK_EXEC) != 0) { #if (USE_KEYBOARD == 1) scr_fontColor(Blue, Black); scr_gotoxy(3, 14); scr_puts("C-Cancel A-Pause 0/1-encoder"); #elif (USE_KEYBOARD == 2) SetTouchKeys(kbdGFile); #endif } lineNum = 1; hasMoreLines = true; do { char *p = cncFileBuf, *str; while (true) { *p = 0; str = p + 1; if ((cncFileBuf + sizeof(cncFileBuf) - str) < (MAX_STR_SIZE + 1)) break; #if (USE_SDCARD != 0) if (f_gets(str, MAX_STR_SIZE, &fid) == NULL) { hasMoreLines = false; break; } #endif str_trim(str); *p = (uint8_t)strlen(str) + 1; p += *p + 1; } for (p = cncFileBuf; !isGcodeStop && *p != 0; lineNum++, p += *p + 1) { uint8_t st; str = p + 1; if ((curGCodeMode & GFILE_MODE_MASK_EXEC) != 0) { GCODE_CMD *gp; #if (USE_LCD != 0) && (MAX_SHOW_GCODE_LINES > 0) int i; #endif linesBuffer.gcodePtrCur++; if (linesBuffer.gcodePtrCur > (MAX_SHOW_GCODE_LINES - 1)) linesBuffer.gcodePtrCur = 0; gp = &linesBuffer.gcode[linesBuffer.gcodePtrCur]; strcpy(gp->cmd, str); gp->lineNum = lineNum; #if (USE_LCD != 0) && (MAX_SHOW_GCODE_LINES > 0) scr_fontColor(Green, Black); // if(stepm_getRemainLines() > 1) { for (i = 0, n = linesBuffer.gcodePtrCur + 1; i < MAX_SHOW_GCODE_LINES; i++, n++) { if (n > (MAX_SHOW_GCODE_LINES - 1)) n = 0; gp = &linesBuffer.gcode[n]; scr_gotoxy(1, i); if (gp->lineNum) scr_printf("%d:%s", gp->lineNum, gp->cmd); scr_clrEndl(); } // } #endif } DBG("\n [gcode:%d] %s", lineNum, str); st = gc_execute_line(str); if (st != GCSTATUS_OK) { #if (USE_LCD != 0) scr_fontColor(Red, Black); scr_gotoxy(1, 11); switch (st) { case GCSTATUS_BAD_NUMBER_FORMAT: scr_puts("BAD_NUMBER_FORMAT"); break; case GCSTATUS_EXPECTED_COMMAND_LETTER: scr_puts("EXPECTED_COMMAND_LETTER"); break; case GCSTATUS_UNSUPPORTED_STATEMENT: scr_puts("UNSUPPORTED_STATEMENT"); break; case GCSTATUS_FLOATING_POINT_ERROR: scr_puts("FLOATING_POINT_ERROR"); break; case GCSTATUS_UNSUPPORTED_PARAM: scr_puts("UNSUPPORTED_PARAM"); break; case GCSTATUS_UNSOPORTED_FEEDRATE: scr_puts("GCSTATUS_UNSUPPORTED_FEEDRATE"); break; case GCSTATUS_TABLE_SIZE_OVER_X: scr_puts("GCSTATUS_TABLE_SIZE_OVER_X"); break; case GCSTATUS_TABLE_SIZE_OVER_Y: scr_puts("GCSTATUS_TABLE_SIZE_OVER_Y"); break; case GCSTATUS_TABLE_SIZE_OVER_Z: scr_puts("GCSTATUS_TABLE_SIZE_OVER_Z"); break; case GCSTATUS_CANCELED: scr_puts("GCSTATUS_CANCELED"); break; } scr_printf(" at line %d:\n %s", lineNum, str); #endif #if (USE_SDCARD != 0) f_close(&fid); #endif return; } } } while (!isGcodeStop && hasMoreLines); #if (USE_SDCARD != 0) f_close(&fid); #endif if ((curGCodeMode & GFILE_MODE_MASK_EXEC) == 0) { #if (USE_LCD != 0) short scrX = crdXtoScr(TABLE_CENTER_X); short scrY = crdYtoScr(TABLE_CENTER_Y); int t1 = commonTimeIdeal / 1000; int t2 = commonTimeReal / 1000; scr_Line(scrX - 8, scrY, scrX + 8, scrY, Red); scr_Line(scrX, scrY - 8, scrX, scrY + 8, Red); scr_fontColor(Green, Black); scr_gotoxy(1, 0); scr_printf("Time %02d:%02d:%02d(%02d:%02d:%02d) N.cmd:%d", t1 / 3600, (t1 / 60) % 60, t1 % 60, t2 / 3600, (t2 / 60) % 60, t2 % 60, lineNum ); scr_printf("\n X%f/%f Y%f/%f Z%f/%f", minX, maxX, minY, maxY, minZ, maxZ); #endif } else { #ifndef NO_ACCELERATION_CORRECTION cnc_line(0, 0, 0, 0, 0, 0); cnc_line(0, 0, 0, 0, 0, 0); #endif } }
void manualMode(void) { static uint8_t limits = 0xFF; const double axisK[4] = { SM_X_STEPS_PER_MM, SM_Y_STEPS_PER_MM, SM_Z_STEPS_PER_MM, SM_E_STEPS_PER_MM }; int i, k = SM_X_STEPS_PER_MM; uint32_t frq[4] = { SM_MANUAL_MODE_STEPS_PER_SEC * K_FRQ, SM_MANUAL_MODE_STEPS_PER_SEC * K_FRQ, SM_MANUAL_MODE_STEPS_PER_SEC * K_FRQ, SM_MANUAL_MODE_STEPS_PER_SEC * K_FRQ }; uint8_t dir[4] = { 0, 0, 0, 0 }; uint32_t steps[4] = { 0, 0, 0, 0 }; LCD_Clear(Black); scr_setfullTextWindow(); scr_gotoxy(6, 0); scr_fontColor(Green, Black); scr_puts("CNC MANUAL MODE"); scr_fontColor(Yellow, Black); scr_puts("\n key '6' - [X+] key '4' - [X-] "); scr_puts("\n key '2' - [Y+] key '8' - [Y-] "); scr_puts("\n key '1' - [Z+] key '7' - [Z-] "); scr_puts("\n key '3' - [E+] key '9' - [E-] "); scr_puts("\n 'A'k+1 'B'k-1 '*'k=1 '#'k++"); scr_puts("\n step motors 'D' - full stop"); scr_puts("\n 0 - zero 5 - goto zero C - exit"); delayMs(700); while (kbd_getKey() >= 0) {}; while (true) { scr_fontColor(White, Black); for (i = 0; i < 3; i++) { double n = (double)stepm_getCurGlobalStepsNum(i) / axisK[i]; scr_gotoxy(1 + i * 10, TEXT_Y_MAX - 4); scr_printf("%c:%f ", axisName[i], n); if (i < 3) { scr_gotoxy(1, TEXT_Y_MAX - 3 + i); scr_printf("steps %c:%d ", axisName[i], stepm_getCurGlobalStepsNum(i)); } #if (USE_ENCODER == 1) if (i == 2) { int32_t v = encoderZvalue(); scr_gotoxy(25, TEXT_Y_MAX - 1); scr_printf("encZ:%d ", v); scr_gotoxy(1 + 2 * 10, TEXT_Y_MAX - 5); scr_printf("errZ:%f ", (double)(v*MM_PER_360) / ENCODER_Z_CNT_PER_360 - n); } #endif dir[i] = 0; steps[i] = 0; } scr_fontColor(Blue, Black); scr_gotoxy(2, TEXT_Y_MAX - 7); scr_printf("step per key press: %f mm ", (double)k / SM_X_STEPS_PER_MM); switch (kbd_getKey()) { case KEY_0: while (stepm_inProc() && kbd_getKey() != KEY_C) {} stepm_ZeroGlobalCrd(); #if (USE_ENCODER == 1) encoderZreset(); encoderCorrectionCntUp = encoderCorrectionCntDown = encoderCorrectionDelta = encoderCorrectionMaxDelta = 0; #endif break; case KEY_6: steps[0] = k; dir[0] = 1; stepm_addMove(steps, frq, dir); break; case KEY_4: steps[0] = k; dir[0] = 0; stepm_addMove(steps, frq, dir); break; case KEY_2: steps[1] = k; dir[1] = 1; stepm_addMove(steps, frq, dir); break; case KEY_8: steps[1] = k; dir[1] = 0; stepm_addMove(steps, frq, dir); break; case KEY_1: steps[2] = k; dir[2] = 1; stepm_addMove(steps, frq, dir); break; case KEY_7: steps[2] = k; dir[2] = 0; stepm_addMove(steps, frq, dir); break; case KEY_3: steps[3] = k; dir[3] = 1; stepm_addMove(steps, frq, dir); break; case KEY_9: steps[3] = k; dir[3] = 0; stepm_addMove(steps, frq, dir); break; case KEY_5: while (stepm_inProc() && kbd_getKey() != KEY_C) {} if (stepm_getCurGlobalStepsNum(0) != 0 || stepm_getCurGlobalStepsNum(1) != 0) { steps[0] = labs(stepm_getCurGlobalStepsNum(0)); dir[0] = stepm_getCurGlobalStepsNum(0) < 0; steps[1] = labs(stepm_getCurGlobalStepsNum(1)); dir[1] = stepm_getCurGlobalStepsNum(1) < 0; steps[2] = 0; dir[2] = 0; } else { steps[0] = steps[1] = 0; dir[0] = dir[1] = 0; steps[2] = labs(stepm_getCurGlobalStepsNum(2)); dir[2] = stepm_getCurGlobalStepsNum(2) < 0; } stepm_addMove(steps, frq, dir); break; case KEY_A: if (k < SM_X_STEPS_PER_MM) k++; break; case KEY_B: if (k > 1) k--; break; case KEY_STAR: k = 1; break; case KEY_DIES: if (k < SM_X_STEPS_PER_MM) k += SM_X_STEPS_PER_MM / 8; break; case KEY_C: stepm_EmergeStop(); return; case KEY_D: stepm_EmergeStop(); break; } if (limits != limits_chk()) { limits = limits_chk(); scr_Rectangle(304, 232, 309, 239, limitX_chk() ? Red : Green, true); scr_Rectangle(310, 232, 315, 239, limitY_chk() ? Red : Green, true); scr_Rectangle(314, 232, 319, 239, limitZ_chk() ? Red : Green, true); } } }
/* ---------------- prob_vec_info -------------------------- * Print information about the probability vector. * This uses the ugly machinery to write into scratch space. * Changed so it always writes out the total of probabilities * and the sum of squares of probabilities. */ char * prob_vec_info (struct prob_vec *p_v) { char *ret = NULL; float *totals, *total2; size_t i, j, k, m, n, tomall; if (p_v -> mship == NULL) prob_vec_expand (p_v); scr_reset(); scr_printf ("# Probability vector as "); if (p_v->norm_type == PVEC_TRUE_PROB) scr_printf ("true probability form\n"); else if ( p_v->norm_type == PVEC_UNIT_VEC) scr_printf ("unit vector normalised\n"); else scr_printf ("unknown normalised form\n"); scr_printf ("# protein length: %u ", (unsigned) p_v->prot_len); scr_printf (" num vectors: %u ", (unsigned) p_v->n_pvec); scr_printf (" fragment length: %u ", (unsigned) p_v->frag_len); scr_printf (" num classes: %u\n", (unsigned) p_v->n_class); scr_printf ("# res class\n"); scr_printf ("# num"); for (i = 0; i < p_v->n_class; i++) scr_printf ("%8d", i + 1); scr_printf ("%8s", "total"); scr_printf ("%8s", "tot^2"); scr_printf ("\n"); tomall = p_v->n_pvec * sizeof (totals[0]); totals = E_MALLOC (tomall); memset (totals, 0, tomall); total2 = E_MALLOC (tomall); memset (total2, 0, tomall); for (j = 0; j < p_v->n_pvec; j++) { for (k = 0; k < p_v->n_class; k++) { totals [j] += p_v->mship [j][k]; total2 [j] += (p_v->mship [j][k] * p_v->mship [j][k]); } } for (m = 0; m < p_v->n_pvec; m++) { scr_printf ("%5u ", m); for (n = 0; n < p_v->n_class; n++) scr_printf ("%7.2g ", p_v->mship[m][n]); scr_printf ("%7.2g %7.2g", totals[m], total2[m]); ret = scr_printf ("\n"); } free (totals); free (total2); return ret; }
/*************************************************** * Main */ int main() { bool rereadDir = false, redrawScr = true, redrawDir = false; SystemStartup(); #if (USE_SDCARD == 1) rereadDir = true; FRESULT fres = f_mount(0, &fatfs); if (fres != FR_OK) { showCriticalStatus( " Mount SD error [code:%d]\n" " SD card used for any CNC process\n" " Only RESET possible at now", fres); WAIT_KEY_C(); } #elif (USE_SDCARD == 2) && (USE_KEYBOARD != 0) FRESULT fres; #endif initSmParam(); while (1) { if (SystemProcess() == SYS_READ_FLASH) rereadDir = true; if (rereadDir) { rereadDir = false; readFileList(); redrawScr = true; } if (redrawScr) { redrawScr = false; LCD_Clear(Black); #if (USE_KEYBOARD == 1) win_showMenu(0, 144, 40, 4); scr_puts( "0 - start gcode 1 - manual mode\n" "2 - show gcode 3 - delete file\n" "4 - set time 5 - file info\n" //"6 - scan mode\t " "7 - save conf.file (v1.1)"); #endif #if (USE_KEYBOARD == 2) SetTouchKeys(kbdSelectFile); #endif redrawDir = true; } if (redrawDir) { redrawDir = false; drawFileList(); } showStatusString(); #if (USE_KEYBOARD != 0) switch (kbd_getKey()) { case KEY_A: currentFile--; redrawDir = true; break; case KEY_B: currentFile++; redrawDir = true; break; #if (USE_KEYBOARD == 1) case KEY_STAR: currentFile += FILE_LIST_ROWS; redrawDir = true; break; case KEY_DIES: currentFile -= FILE_LIST_ROWS; redrawDir = true; break; #endif // // Start GCode // case KEY_0: { FLASH_KEYS(); #if (USE_LCD == 1) uint32_t stime; stime = Seconds(); #endif cnc_gfile(&fileList[currentFile][0], GFILE_MODE_MASK_EXEC); while (stepm_inProc()) { scr_fontColor(Yellow, Blue); scr_gotoxy(1, 13); scr_printf(" remain moves: %d", stepm_getRemainLines()); scr_clrEndl(); } stepm_EmergeStop(); #if (USE_LCD == 1) scr_fontColor(Yellow, Blue); scr_gotoxy(0, 13); scr_puts(" FINISH. PRESS C-KEY"); scr_clrEndl(); stime = Seconds() - stime; scr_fontColor(Yellow, Blue); scr_gotoxy(0, 14); scr_printf(" work time: %02d:%02d", stime / 60, stime % 60); scr_clrEndl(); #endif #if (USE_LCD == 2) SetTouchKeys(kbdLast2Lines); #endif FLASH_KEYS(); WAIT_KEY_C(); redrawScr = true; break; } // // Manual Mode // case KEY_1: manualMode(); redrawScr = true; break; #if (USE_SDCARD == 1) // // Show GCode // case KEY_2: FLASH_KEYS(); cnc_gfile(&fileList[currentFile][0], GFILE_MODE_MASK_SHOW | GFILE_MODE_MASK_CHK); scr_printf("\n PRESS C-KEY"); FLASH_KEYS(); while (kbd_getKey() != KEY_C); redrawScr = true; break; // // Delete file // case KEY_3: if (questionYesNo("Delete file:\n'%s'?", &fileList[currentFile][0])) { rereadDir = true; f_unlink(&fileList[currentFile][0]); } else redrawScr = true; break; #endif #if (USE_RTC == 1) // // Set time // case KEY_4: setTime(); redrawScr = true; break; // // Save conf. file // case KEY_7: win_showMsgWin(); saveSmParam(); scr_printf("\n\n\n PRESS C-KEY"); WAIT_KEY_C(); redrawScr = true; break; #endif #if (USE_SDCARD != 0) // // File info // case KEY_5: { FILINFO finf; FIL fid; int c, n; memset(&finf, 0, sizeof(finf)); win_showMsgWin(); scr_setScroll(false); scr_printf("File:%s", &fileList[currentFile][0]); f_stat(&fileList[currentFile][0], &finf); scr_gotoxy(0, 1); scr_printf("Size:%d\n", (uint32_t)finf.fsize); fres = f_open(&fid, &fileList[currentFile][0], FA_READ); if (fres != FR_OK) { #if (USE_SDCARD == 1) scr_printf("Error open file: '%s'\nStatus:%d [%d]", &fileList[currentFile][0], fres, SD_errno); #elif (USE_SDCARD == 2) scr_printf("Error open file: '%s'\nStatus:%d", &fileList[currentFile][0], fres); #endif } else { char str[150]; scr_fontColorInvers(); scr_setScroll(false); // Read lines from 3 to 6 from file and display it for (n = 2; n < 7 && f_gets(str, sizeof(str), &fid) != NULL; n++) { scr_gotoxy(0, n); scr_puts(str_trim(str)); } } scr_fontColorNormal(); scr_gotoxy(8, 7); scr_printf("PRESS C-KEY"); redrawScr = true; do { c = kbd_getKey(); if (c == KEY_B) { char str[150]; scr_fontColorInvers(); for (n = 2; n < 7 && f_gets(str, sizeof(str), &fid) != NULL; n++) { scr_gotoxy(0, n); scr_puts(str_trim(str)); scr_clrEndl(); } } } while (c != KEY_C); f_close(&fid); rereadDir = true; } break; #endif } #endif } }