//+++++++++++++++++++++++++ PrintMenue_03 ++++++++++++++++++++++++++++++ void PrintMenue_03(char *FullFileName, long NumberOfLines, long CurrentLine, long CurrentX, long CurrentY, long StartTime,int Scale){ char TextLine[300]; long CurrentTime, ProcessHours = 0, ProcessMinutes = 0, ProcessSeconds = 0; CurrentTime = time(0); CurrentTime -= StartTime; while (CurrentTime > 3600){ ProcessHours++; CurrentTime -= 3600; } while (CurrentTime > 60){ ProcessMinutes++; CurrentTime -= 60; } ProcessSeconds = CurrentTime; clrscr(1, MessageY - 2); MessageText("*** Plotting file ***", 1, 1, 1); sprintf(TextLine, "File name: %s", FullFileName); MessageText(TextLine, 10, 3, 0); sprintf(TextLine, "Number of lines: %ld", NumberOfLines); MessageText(TextLine, 10, 5, 0); sprintf(TextLine, "Current Position(%ld): X = %ld, Y = %ld ", CurrentLine, CurrentX, CurrentY); MessageText(TextLine, 10, 6, 0); sprintf(TextLine, "Process time: %02ld:%02ld:%02ld", ProcessHours, ProcessMinutes, ProcessSeconds); MessageText(TextLine, 10, 7, 0); sprintf(TextLine, "Scale Value: %ld",Scale); MessageText(TextLine, 10, 4, 0); }
// ---------------------------------------------------------------------------- // CAknExQueryView::SetTitlePane( TInt aOutlineId ) // Sets text of title pane. // ---------------------------------------------------------------------------- // void CAknExQueryView::SetTitlePaneL( TInt aOutlineId ) { TInt titleId( KAknExQueryInitId ); TBool defaultFlg( EFalse ); iContainer->DeleteLabelL(); iContainer->DeleteListBoxL(); iCurrentOutline = aOutlineId; // Set current display outlinenumber switch ( aOutlineId ) { case EAknExQueryNoOutline: defaultFlg = ETrue; break; case EAknExQueryOutline1: titleId = R_AKNEXQUERY_OUTLINE1; break; case EAknExQueryOutline4: titleId = R_AKNEXQUERY_OUTLINE4; break; case EAknExQueryOutline8: titleId = R_AKNEXQUERY_OUTLINE8; break; case EAknExQueryOutline10: titleId = R_AKNEXQUERY_OUTLINE10; break; case EAknExQueryOutline16: titleId = R_AKNEXQUERY_OUTLINE16; break; case EAknExQueryOutline44: titleId = R_AKNEXQUERY_OUTLINE44; break; case EAknExQueryOutline48: titleId = R_AKNEXQUERY_OUTLINE48; break; case EAknExQueryOutline52: titleId = R_AKNEXQUERY_OUTLINE52; break; case EAknExQueryOutline54: titleId = R_AKNEXQUERY_OUTLINE54; break; case EAknExQueryOutline61: titleId = R_AKNEXQUERY_OUTLINE61; break; default: defaultFlg = ETrue; break; } // Fetches pointer to the default title pane control. CAknTitlePane* titlePane = static_cast<CAknTitlePane*> ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); if ( !defaultFlg ) { // Makes and sets text whitch is used title pane. TBuf<KAknExQueryTitleBufLength> MessageText( KAknExQueryBufferEmpty ); iCoeEnv->ReadResource( MessageText, titleId ); titlePane->SetTextL( MessageText ); } else { titlePane->SetTextToDefaultL(); } }
void moveXY(int Xdist, int Ydist) { char TextLine[1000] = ""; long tempX = 0, tempY = 0; int i = 0; unsigned char reverseX = 0, reverseY = 0; sprintf(TextLine, "Moving X: %ld, Moving Y: %ld", Xdist, Ydist); MessageText(TextLine, MessageX, MessageY, 0); if(posX==-1||posY==-1) initalize(); if(posX+Xdist>MAXSIZEX) //make sure we dont go out of bounds too high Xdist = MAXSIZEX-posX; if(posX+Xdist<0) //make sure we dont go out of bound too low Xdist = -posX; if(posY+Ydist>MAXSIZEY) Ydist = MAXSIZEY-posY; if(posY+Ydist<0) Ydist = -posY; if(Xdist==0&&Ydist==0) return; int Xspeed = 100; int Yspeed = 100; bool foundX = false; bool foundY = false; if(Xdist==0||Ydist==0) { if(Xdist>0) //need to go fowards { power(motorXA,Xspeed); power(motorXB,0); }else if (Xdist<0) //need to go backword { power(motorXA,0); power(motorXB,Xspeed); }else //already at the correct x point { power(motorXA,0); power(motorXB,0); foundX = true; } if(Ydist>0) { //need to go fowards power(motorYA,Yspeed); power(motorYB,0); }else if (Ydist<0) //need to go backwords { power(motorYA,0); power(motorYB,Yspeed); }else //alrady at the correct pint { power(motorYA,0); power(motorYB,0); foundY = true; } }else { if(abs(Xdist)>=abs(Ydist)) { Xspeed = 100; Yspeed = (abs(Ydist)/abs(Xdist))*Xspeed; } else { Yspeed = 100; Xspeed = (abs(Xdist)/abs(Ydist))*Yspeed; } } while(!foundX||!foundY) { int result = didTick(!foundX,!foundY); if(!foundX) { if(result==1) { if(Xdist>0) { posX += 10; Xdist -= 10; //increment the posY for we moved the machine //decrease the value that we still have to go } else { posX -= 10; Xdist += 10; } if(abs(Xdist)<20) { if(Xdist>0) //need to go fowards { power(motorXA,.5*Xspeed); power(motorXB,0); }else //need to go backword { power(motorXA,0); power(motorXB,.5*Xspeed); } } if(Xdist==0) { power(motorXA,0); power(motorXB,0); foundX = true; } } } if(!foundY) { if(result==-1) { if(Ydist>0) { posY += 10; Ydist -= 10; //increment the posY for we moved the machine //decrease the value that we still have to go } else { posY -= 10; Ydist += 10; } if(abs(Ydist)<20) { if(Ydist>0) //need to go fowards { power(motorYA,.5*Yspeed); power(motorYB,0); }else //need to go backword { power(motorYA,0); power(motorYB,.5*Yspeed); } } if(Ydist==0) { power(motorYA,0); power(motorYB,0); foundY = true; } } } delay(1); } }
//+++++++++++++++++++++++++ PrintMenue_01 ++++++++++++++++++++++++++++++ void PrintMenue_01(char * PlotFile, double scale, double width, double height, long MoveLength, int plotterMode){ char TextLine[300]; clrscr(1, MessageY-2); MessageText("*** Main menu plotter ***", 1, 1, 1); sprintf(TextLine, "M - move length, current value = %ld steps. F5=1, F6=10, F7=100, F8=1000", MoveLength); MessageText(TextLine, 10, 3, 0); MessageText("Cursor right - move plotter in positive X direction", 10, 4, 0); MessageText("Cursor left - move plotter in negative X direction", 10, 5, 0); MessageText("Cursor up - move plotter in positive Y direction", 10, 6, 0); MessageText("Cursor down - move plotter in negative Y direction", 10, 7, 0); if(plotterMode == 1){ MessageText("Page up - lift pen", 10, 8, 0); MessageText("Page down - touch down pen", 10, 9, 0); } if(plotterMode == 0){ MessageText("Page up - move Plotter in positive Z direction", 10, 8, 0); MessageText("Page down - move Plotter in negative Z direction", 10, 9, 0); } sprintf(TextLine, "F - choose file. Current file = \"%s\"", PlotFile); MessageText(TextLine, 10, 10, 0); MessageText("0 - move plotter to 0/0", 10, 11, 0); sprintf(TextLine, "S - scale. Current value = %0.4f. W = %0.1fcm, H = %0.1fcm", scale, width, height); MessageText(TextLine, 10, 12, 0); MessageText("P - plot file", 10, 13, 0); if(plotterMode == 0){ MessageText("T - toggle functionality, currently: MILLING", 10, 14, 0); } if(plotterMode == 1){ MessageText("T - toggle functionality, currently: PLOTTING", 10, 14, 0); } if(plotterMode == 2){ MessageText("T - toggle functionality, currently: PRINTING", 10, 14, 0); } MessageText("Esc - leave program", 10, 16, 0); }
int main(int argc, char **argv) { int ADCvalue01 = 0; int StepSpeed = 100; //Stepping speed (smaler value = faster) int i = 0; int KeyHit = 0; int KeyCode[5]; int SingleKey=0; char TextLine[300]; char FileName[100] = ""; char FileNameOld[100] = ""; char FullFileName[300]; char a; char IsDigit[]="-1234567890"; int ReadState = 0; int MenueLevel = 0; int FileSelected = 0; int FileStartRow = 0; int stopPlot = 0; long xMin = 1000000, xMax = -1000000; long yMin = 1000000, yMax = -1000000; long coordinateCount = 0; long coordinatePlot = 0; long currentPlotX = 0, currentPlotY = 0, currentPlotDown = 1; long xNow = 0, yNow = 0, zNow = 0; char *pEnd; FILE *PlotFile; double Scale = 1.0; double OldScale = 1.0; double PicWidth = 0.0; double PicHeight = 0.0; long MoveLength = 100; long OldMoveLength = 200; long PlotStartTime = 0; int MoveFinished = 0; long stepPause = 5000; long stepPauseNormal = 5000; long stepPauseMaterial = 20000; long zHub = 200; int plotterMode = 1; char FileInfo[3]; long FileSize; long LongTemp; long DataOffset; long HeaderSize; long PictureWidth; long PictureHeight; int IntTemp; int ColorDepth; long CompressionType; long PictureSize; long XPixelPerMeter; long YPixelPerMeter; long ColorNumber; long ColorUsed; int PixelRed, PixelGreen, PixelBlue; int PixOK = 0; long StepsPerPixelX = 50, StepsPerPixelY = 50; long JetOffset1 = 40, JetOffset2 = 40; //Mapping between wiringPi and pin order of my I/O board. //This was necessary, because I used a wrong description of the GPIOs //You have to change the order according to your board! //@@@THESE ARE ALL OUTPUS!! strcpy(FileName, "noFiLE"); if (wiringPiSetup () == -1){ printf("Could not run wiringPiSetup!"); exit(1); } getmaxyx(stdscr, MaxRows, MaxCols); MessageY = MaxRows-3; clrscr(1, MaxRows); PrintRow('-', MessageY - 1); initscr(); noecho(); cbreak(); start_color(); while(!quit) { clearScreen(); char * choices[] = {"Plot File","Manual Control","Servo Control","Opto Sensor Control","X&Y Control","initalize","Exit"}; char *description[] = { "You select a file to plot and will plot the file on the plotter", "Will give you full control over the plotter for debuging or demenstration", "Lets you enter and test different duration of pulses sent to the servo for fine tuning and debugging", "Will read in the togleing of the opto sensor for debuging", "Will let you have control how much to move in x and y by ticks more precisly", "Test initalization procedure", "Will exit the prgram"}; int result = menus("Hello and Welcome to my creation please sleect a mode", choices,description,7,20); switch (result) { case 1: ; /* FILE * fp; char * line = NULL; size_t len = 0; ssize_t read; fp = fopen ("sampleGcode.txt","r");*/ //Plot file char dir[1024]; getcwd(dir,sizeof(dir)); MessageText("3 seconds until plotting starts !!!!!!!!!!!!!!!!!", 1, 2, 0); delay(3000); if((PlotFile=chooseFile(dir))==NULL){ sprintf(TextLine, "Can't open file '%s'!\n", FullFileName); strcpy(FileName, "NoFiLE"); ErrorText(TextLine); } else{ currentPlotX = 0; currentPlotY = 0; PlotStartTime = time(0); PrintMenue_03(FullFileName, coordinateCount, 0, 0, 0, PlotStartTime,Scale); coordinatePlot = 0; stopPlot = 0; if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } while(!(feof(PlotFile)) && stopPlot == 0){ fread(&a, 1, 1, PlotFile); if(a == '>'){ ReadState = 0; } if(ReadState == 0 || ReadState == 1){ TextLine[i] = a; TextLine[i+1] = '\0'; i++; } if(ReadState == 2 || ReadState == 3){ if(strchr(IsDigit, a) != NULL){ TextLine[i] = a; TextLine[i+1] = '\0'; i++; } } if(ReadState == 2){ if(strchr(IsDigit, a) == NULL){ if(strlen(TextLine) > 0){ xNow = (strtol(TextLine, &pEnd, 10) - xMin) * 0.33333 * Scale; ReadState = 3; i=0; TextLine[0]='\0'; } } } if(ReadState == 3){ if(strchr(IsDigit, a) == NULL){ if(strlen(TextLine) > 0){ yNow = ((yMax - strtol(TextLine, &pEnd, 10)) - yMin) * 0.33333 * Scale;//Flip around y-axis coordinatePlot++; PrintMenue_03(FullFileName, coordinateCount, coordinatePlot, xNow, yNow, PlotStartTime, Scale); if(stopPlot == 0){ stopPlot =0; moveXY(xNow - currentPlotX, yNow - currentPlotY); currentPlotX = xNow; currentPlotY = yNow; // sprintf(TextLine, "xNow=%ld, yNow=%ld", xNow, yNow); // MessageText(TextLine, MessageX+1, MessageY+1, 0); // getch(); } else{ if(currentPlotDown == 1){ if(plotterMode == 1){ penMove(1); } currentPlotDown = 0; } } if(currentPlotDown == 0){ if(stopPlot == 0){ penMove(0); currentPlotDown = 1; } } ReadState = 2; i=0; TextLine[0]='\0'; } } } if(strcmp(TextLine, "<path") == 0){ if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } ReadState = 2; i = 0; TextLine[0]='\0'; } if(a == '<'){ i = 1; TextLine[0] = a; TextLine[1] = '\0'; ReadState = 1; } } fclose(PlotFile); if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } PrintMenue_03(FullFileName, coordinateCount, coordinatePlot, 0, 0, PlotStartTime,Scale); moveXY(-currentPlotX, -currentPlotY); currentPlotX = 0; currentPlotY = 0; while(kbhit()){ getch(); } MessageText("Finished! Press any key to return to main menu.", MessageX, MessageY, 0); getch(); break; } break; case 2: manualControl(); break; case 3: servoControl(); break; case 4: optoControl(); break; case 5: xyControl(); break; case 6: initalize(); break; case -1: default: system("reset"); quit=true; break; } } allSTOP(); endwin(); return 0; }