Final code for our 4180 Drawing Robot!
Dependencies: 4DGL-uLCD-SE gCodeParser mbed
main.cpp
- Committer:
- jford38
- Date:
- 2014-04-29
- Revision:
- 0:40576dfac535
- Child:
- 1:ad895d72e9ed
File content as of revision 0:40576dfac535:
#include "mbed.h" #include "gparser.h" #include "MODSERIAL.h" #include "motor.h" #include "drawBot.h" #include "uLCD_4DGL.h" #define CMD_LIST_SIZE 512 MODSERIAL gpc(USBTX, USBRX); uLCD_4DGL uLCD(p9, p10, p11); //G_cmd gcmd_list[CMD_LIST_SIZE]; // buffer to be filled with commands, main program retrieves commands from here extern G_cmd* gcmd_list; extern list_position; Motor mL(p29, p30, p26, p27, p28, p25, RIGHT_MOTOR); Motor mR(p12, p13, p16, p15, p14, p17, LEFT_MOTOR); DrawBot bot(&mL, &mR, p21, 0.5, 45.125); int main() { parserInit(); int list_pos = fillInCmdList(); uLCD.printf("%d\r\n",list_pos); for(int c=0; c<list_pos; c++) { G_cmd* next = gcmd_list+c; uLCD.printf("G:%d X%.2f Y%.2f Z%.2f I%.2f J%.2f\n",next->X, next->Y, next->Z, next->I,next->J,next->F); wait(10); uLCD.cls(); switch(next->G) { case 0: case 1: //Draw a line. if(next->X != -1 && next->Y != -1) { bot.line_safe(next->X, next->Y); } if(next->Z > 0) { bot.pen_up(); }else if(next->Z == 0) { bot.pen_down(); } break; case 2: //Draw an arc or something. //bot->arc(px+i, py+j, next_cmd->X, next_cmd->Z); break; case 3: //Draw a different arc or something. break; default: break; } } bot.disable(); }