Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 02_LAB_serial_protocol by
Diff: main.cpp
- Revision:
- 20:b7f2e428b24c
- Parent:
- 19:082e74f5e5ab
--- a/main.cpp Thu Oct 19 23:43:31 2017 +0000
+++ b/main.cpp Fri Oct 20 00:50:00 2017 +0000
@@ -7,7 +7,6 @@
Serial command(USBTX, USBRX);
-#define DEBUG 1
uint8_t buffer_cmd[BUFF_SIZE]={0,0,0,0};
@@ -87,55 +86,9 @@
command.printf("draw line: ");
command.printf("Coord Xi= %i Coord Yi = %i Coord Xf= %i Coord Yf = %i\n", xi,yi,xf,yf);
#endif
- // line( xi, yi, xf, yf);
-
- float xp; float yp;
- float m=100000; float b;
- int st=1 ;
- m=(float)(yf-yi)/(xf-xi);
+ line( xi, yi, xf, yf);
- int run=1;
- if (abs(m)<=1){
- b=(float)yf-(float)(m*xf);
- command.printf(" m = %f b= %f \n", m,b);
- xp =xi;
- while(run)
- {
- yp =m*xp+b;
-
- print_bin2hex(xp); print_bin2hex(yp);
- command.printf(" \n");
- if (xf>xi){
- xp=xp+st;
- if (xp>xf)run=0;
- }else {
- xp-=st;
- if (xp<xf)run=0;
- }
-
- }
- }else{
- m=(float)(xf-xi)/(yf-yi);
- b=(float)xf-(float)(m*yf);
- command.printf(" m = %f b= %f \n", m,b);
- yp =yi;
- while(run)
- {
- xp =m*yp+b;
-
- print_bin2hex(xp); print_bin2hex(yp);
- command.printf(" \n");
- if (yf>yi){
- yp=yp+st;
- if (yp>yf)run=0;
- }else {
- yp-=st;
- if (yp<yf)run=0;
- }
-
- }
- }
-}
+ }
void command_rectangle(){
uint8_t x=buffer_cmd[REC_POS_X];
@@ -150,9 +103,14 @@
rectangle( x, y, width, height);
}
void command_cicle(){
+ uint8_t x=buffer_cmd[CICLE_POS_X];
+ uint8_t y=buffer_cmd[CICLE_POS_Y];
+ uint8_t r=buffer_cmd[CICLE_POS_R];
#if DEBUG
command.printf("draw cicle: ");
+ command.printf("Centro X= %i Centro Y = %i radio= %i \n", x,y,r);
#endif
+ circle(x,y,r);
}
void command_home(){
#if DEBUG
@@ -168,6 +126,7 @@
void command_sstime(){
#if DEBUG
command.printf("config tiempo entre movimientos de los servos: ");
+ command.printf("SSTIME = %i\n", buffer_cmd[POS_1]);
#endif
put_sstime(buffer_cmd[POS_1]);
}
@@ -178,17 +137,17 @@
}
void command_pause(){
#if DEBUG
- command.printf("picolo en pausa ");
+ command.printf("piccolo en pausa ");
#endif
}
void command_reanudar(){
#if DEBUG
- command.printf("reanuda picolo ");
+ command.printf("reanuda piccolo ");
#endif
}
void command_stepmotor(){
#if DEBUG
- command.printf("comando mover picolo: ");
+ command.printf("comando mover piccolo: ");
#endif
}
