From 75b3860a3f18b149ddd7fa1930e2ab800ba17906 Mon Sep 17 00:00:00 2001 From: Guillaume Milan Date: Fri, 10 May 2013 23:11:56 +0200 Subject: digital/lcd/src: fix the problem of intendation in the code Fix the problem of intendation but it may stay some one --- digital/lcd/src/lcd.cc | 50 ++++++++++++++++++++++++++----------------------- digital/lcd/src/main.cc | 33 +++++++++++++++++++------------- 2 files changed, 47 insertions(+), 36 deletions(-) (limited to 'digital/lcd') diff --git a/digital/lcd/src/lcd.cc b/digital/lcd/src/lcd.cc index 60fded3d..bac2bc51 100644 --- a/digital/lcd/src/lcd.cc +++ b/digital/lcd/src/lcd.cc @@ -227,22 +227,24 @@ void LCD::rectangle_fill (uint16_t color,Rect format, Rect pos)//make a filled rectangle { set_cursor(pos.x , pos.y); - if(format.x+pos.x> x_max){format.x=x_max-pos.x;} - if(format.y+pos.y> y_max){format.y=y_max-pos.y;} + if(format.x+pos.x> x_max) + format.x=x_max-pos.x; + if(format.y+pos.y> y_max) + format.y=y_max-pos.y; if(format.x>=0 && format.y >=0) { - for(int i=0 ; ix_max ||y<0 || y>y_max){return;} + if(x<0 || x>x_max ||y<0 || y>y_max) + return; set_cursor(x,y); cs_.reset(); write_index (0x0022); @@ -299,28 +302,28 @@ LCD::circle ( uint16_t color , int radius , Rect pos) //draw a circle (no proble while(x<=y) { if(belong (x+pos.x , y+pos.y)) - {blit_pixel(color , x+pos.x , y+pos.y);} + blit_pixel(color , x+pos.x , y+pos.y); if(belong ( y+pos.x , x+pos.y)) - {blit_pixel(color , y+pos.x , x+pos.y);} + blit_pixel(color , y+pos.x , x+pos.y); if(belong (-x+pos.x , y+pos.y)) - {blit_pixel(color , -x+pos.x , y+pos.y);} + blit_pixel(color , -x+pos.x , y+pos.y); if(belong (-y+pos.x , x+pos.y)) - {blit_pixel(color , -y+pos.x , x+pos.y);} + blit_pixel(color , -y+pos.x , x+pos.y); if(belong (x+pos.x , -y+pos.y)) - {blit_pixel(color , x+pos.x , -y+pos.y);} + blit_pixel(color , x+pos.x , -y+pos.y); if(belong ( y+pos.x , -x+pos.y)) - {blit_pixel(color , y+pos.x , -x+pos.y);} + blit_pixel(color , y+pos.x , -x+pos.y); if(belong (-x+pos.x , -y+pos.y)) - {blit_pixel(color , -x+pos.x , -y+pos.y);} + blit_pixel(color , -x+pos.x , -y+pos.y); if(belong (-y+pos.x , -x+pos.y)) - {blit_pixel(color , -y+pos.x , -x+pos.y);} + blit_pixel(color , -y+pos.x , -x+pos.y); if(m > 0) { @@ -335,7 +338,7 @@ bool LCD::belong (int x , int y) //test if the point A(x,y) belong to the screen { if(0<=x && x<=x_max && 0<=y && y<=y_max) - {return true;} + return true; return false; } void @@ -347,7 +350,8 @@ LCD::draw_char( uint16_t color ,char caract, Rect pos)//draw a caracter { for( int j =7 ; j>=0 ; j--) { - if(Ascii[caract][i]&(1<90){strcpy(i2c_cmd,"ERROR I2C time");} + if(arg[0]>90) + strcpy(i2c_cmd,"ERROR I2C time"); i2c_time=arg[0]; break; case 'p': //position of the robot pos_r.x=ucoo::bytes_pack (arg[0] ,arg [1] );//position in mm pos_r.y=ucoo::bytes_pack (arg[2] ,arg [3] ); if(!conv_pos(pos_r)) - {strcpy(i2c_cmd,"ERROR I2C position");} + strcpy(i2c_cmd,"ERROR I2C position"); break; case 'm': //message strcpy(i2c_cmd,arg); @@ -111,14 +113,14 @@ i2c_handle (LCD &lcd, const char *buf, int size) pos_obs[j].y=ucoo::bytes_pack (arg[i+2] ,arg [i+3] ); j++; if(!conv_pos(pos_obs[j])) - {strcpy(i2c_cmd,"ERROR I2C obstacle");} + strcpy(i2c_cmd,"ERROR I2C obstacle"); } break; case 'n'://next position of the robot pos_r_n.x=ucoo::bytes_pack (arg[0] ,arg [1] ); pos_r_n.y=ucoo::bytes_pack (arg[2] ,arg [3] ); if(!conv_pos(pos_r_n)) - {strcpy(i2c_cmd,"ERROR I2C next pos");} + strcpy(i2c_cmd,"ERROR I2C next pos"); break; default: // Unknown command. @@ -177,10 +179,15 @@ draw_time (LCD lcd) //write the remaining time Rect pos_d;pos_d.x=292;pos_d.y=223;//digit one char dizaine = i2c_time/10 +48; char unite = i2c_time%10 +48; - if(i2c_time<0){lcd.draw_sentence (0,"ERROR",pos_d);} - else{ - if(i2c_time/10!=0){lcd.draw_char( 0 ,dizaine,pos_d);} - lcd.draw_char( 0 ,unite,pos_u);} + + if(i2c_time<0) + lcd.draw_sentence (0,"ERROR",pos_d); + else + { + if(i2c_time/10!=0) + lcd.draw_char( 0 ,dizaine,pos_d); + lcd.draw_char( 0 ,unite,pos_u); + } } void @@ -253,10 +260,10 @@ main (int argc, const char **argv) ucoo::I2cSlaveDataBufferSize i2c_data; i2c.register_data (0x20, i2c_data); //Init global variable - i2c_color[0]=0;i2c_color[1]=0;i2c_color[2]=0; - i2c_time=90; - pos_r_n.x=160;pos_r_n.y=120; - pos_r.x=160;pos_r.y=120; + i2c_color[0]=0;i2c_color[1]=0;i2c_color[2]=0; + i2c_time=90; + pos_r_n.x=160;pos_r_n.y=120; + pos_r.x=160;pos_r.y=120; // Init. LCD lcd; //ucoo::delay_ms (1000); -- cgit v1.2.3