From 04b3d6d78ab60ab7c15dd9affbef521acf584f1f Mon Sep 17 00:00:00 2001 From: Guillaume Milan Date: Fri, 10 May 2013 00:20:31 +0200 Subject: digital/lcd/src: give to the user some information of the robot status Give the color, the remaining time, the robot position, the robot destination. --- digital/lcd/src/font.hh | 191 ++++++++++++++++++++++++++++++++++++++++++++++++ digital/lcd/src/lcd.cc | 174 +++++++++++++++++++++++++++++++++++++++++++ digital/lcd/src/lcd.hh | 21 +++++- digital/lcd/src/main.cc | 149 ++++++++++++++++++++++++++++++++++++- 4 files changed, 532 insertions(+), 3 deletions(-) create mode 100644 digital/lcd/src/font.hh (limited to 'digital') diff --git a/digital/lcd/src/font.hh b/digital/lcd/src/font.hh new file mode 100644 index 00000000..aeeeaacf --- /dev/null +++ b/digital/lcd/src/font.hh @@ -0,0 +1,191 @@ +static unsigned char const Ascii[95][16] = { +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ + +{0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00},/*"!",1*/ + +{0x00,0x00,0x00,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",2*/ + +{0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x36,0x36,0x7F,0x36,0x36,0x00,0x00,0x00,0x00},/*"#",3*/ + +{0x00,0x18,0x18,0x3C,0x66,0x60,0x30,0x18,0x0C,0x06,0x66,0x3C,0x18,0x18,0x00,0x00},/*"$",4*/ + +{0x00,0x00,0x70,0xD8,0xDA,0x76,0x0C,0x18,0x30,0x6E,0x5B,0x1B,0x0E,0x00,0x00,0x00},/*"%",5*/ + +{0x00,0x00,0x00,0x38,0x6C,0x6C,0x38,0x60,0x6F,0x66,0x66,0x3B,0x00,0x00,0x00,0x00},/*"&",6*/ + +{0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ + +{0x00,0x00,0x00,0x0C,0x18,0x18,0x30,0x30,0x30,0x30,0x30,0x18,0x18,0x0C,0x00,0x00},/*"(",8*/ + +{0x00,0x00,0x00,0x30,0x18,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x30,0x00,0x00},/*")",9*/ + +{0x00,0x00,0x00,0x00,0x00,0x36,0x1C,0x7F,0x1C,0x36,0x00,0x00,0x00,0x00,0x00,0x00},/*"*",10*/ + +{0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00},/*"+",11*/ + +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00},/*",",12*/ + +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",13*/ + +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00},/*".",14*/ + +{0x00,0x00,0x00,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0x00,0x00,0x00},/*"/",15*/ + +{0x00,0x00,0x00,0x1E,0x33,0x37,0x37,0x33,0x3B,0x3B,0x33,0x1E,0x00,0x00,0x00,0x00},/*"0",16*/ + +{0x00,0x00,0x00,0x0C,0x1C,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00},/*"1",17*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x0C,0x18,0x30,0x60,0x7E,0x00,0x00,0x00,0x00},/*"2",18*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x1C,0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"3",19*/ + +{0x00,0x00,0x00,0x30,0x30,0x36,0x36,0x36,0x66,0x7F,0x06,0x06,0x00,0x00,0x00,0x00},/*"4",20*/ + +{0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00},/*"5",21*/ + +{0x00,0x00,0x00,0x1C,0x18,0x30,0x7C,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"6",22*/ + +{0x00,0x00,0x00,0x7E,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x30,0x00,0x00,0x00,0x00},/*"7",23*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x76,0x3C,0x6E,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"8",24*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x3E,0x0C,0x18,0x38,0x00,0x00,0x00,0x00},/*"9",25*/ + +{0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00},/*":",26*/ + +{0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00},/*";",27*/ + +{0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00},/*"<",28*/ + +{0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"=",29*/ + +{0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00},/*">",30*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x0C,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00},/*"?",31*/ + +{0x00,0x00,0x00,0x7E,0xC3,0xC3,0xCF,0xDB,0xDB,0xCF,0xC0,0x7F,0x00,0x00,0x00,0x00},/*"@",32*/ + +{0x00,0x00,0x00,0x18,0x3C,0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"A",33*/ + +{0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00},/*"B",34*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60,0x60,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"C",35*/ + +{0x00,0x00,0x00,0x78,0x6C,0x66,0x66,0x66,0x66,0x66,0x6C,0x78,0x00,0x00,0x00,0x00},/*"D",36*/ + +{0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00},/*"E",37*/ + +{0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00},/*"F",38*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60,0x6E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00},/*"G",39*/ + +{0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"H",40*/ + +{0x00,0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00},/*"I",41*/ + +{0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"J",42*/ + +{0x00,0x00,0x00,0x66,0x66,0x6C,0x6C,0x78,0x6C,0x6C,0x66,0x66,0x00,0x00,0x00,0x00},/*"K",43*/ + +{0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00},/*"L",44*/ + +{0x00,0x00,0x00,0x63,0x63,0x77,0x6B,0x6B,0x6B,0x63,0x63,0x63,0x00,0x00,0x00,0x00},/*"M",45*/ + +{0x00,0x00,0x00,0x63,0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x63,0x00,0x00,0x00,0x00},/*"N",46*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"O",47*/ + +{0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00},/*"P",48*/ + +{0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x0C,0x06,0x00,0x00},/*"Q",49*/ + +{0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"R",50*/ + +{0x00,0x00,0x00,0x3C,0x66,0x60,0x30,0x18,0x0C,0x06,0x66,0x3C,0x00,0x00,0x00,0x00},/*"S",51*/ + +{0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00},/*"T",52*/ + +{0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"U",53*/ + +{0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00},/*"V",54*/ + +{0x00,0x00,0x00,0x63,0x63,0x63,0x6B,0x6B,0x6B,0x36,0x36,0x36,0x00,0x00,0x00,0x00},/*"W",55*/ + +{0x00,0x00,0x00,0x66,0x66,0x34,0x18,0x18,0x2C,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"X",56*/ + +{0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00},/*"Y",57*/ + +{0x00,0x00,0x00,0x7E,0x06,0x06,0x0C,0x18,0x30,0x60,0x60,0x7E,0x00,0x00,0x00,0x00},/*"Z",58*/ + +{0x00,0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00},/*"[",59*/ + +{0x00,0x00,0x00,0x60,0x60,0x30,0x30,0x18,0x18,0x0C,0x0C,0x06,0x06,0x00,0x00,0x00},/*"\",60*/ + +{0x00,0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00},/*"]",61*/ + +{0x00,0x18,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/ + +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00},/*"_",63*/ + +{0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",64*/ + +{0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x06,0x3E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00},/*"a",65*/ + +{0x00,0x00,0x00,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00},/*"b",66*/ + +{0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x60,0x60,0x60,0x66,0x3C,0x00,0x00,0x00,0x00},/*"c",67*/ + +{0x00,0x00,0x00,0x06,0x06,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00},/*"d",68*/ + +{0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x7E,0x60,0x60,0x3C,0x00,0x00,0x00,0x00},/*"e",69*/ + +{0x00,0x00,0x00,0x1E,0x30,0x30,0x30,0x7E,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00},/*"f",70*/ + +{0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x06,0x06,0x7C,0x00},/*"g",71*/ + +{0x00,0x00,0x00,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"h",72*/ + +{0x00,0x00,0x18,0x18,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00},/*"i",73*/ + +{0x00,0x00,0x0C,0x0C,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x78,0x00},/*"j",74*/ + +{0x00,0x00,0x00,0x60,0x60,0x66,0x66,0x6C,0x78,0x6C,0x66,0x66,0x00,0x00,0x00,0x00},/*"k",75*/ + +{0x00,0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00},/*"l",76*/ + +{0x00,0x00,0x00,0x00,0x00,0x7E,0x6B,0x6B,0x6B,0x6B,0x6B,0x63,0x00,0x00,0x00,0x00},/*"m",77*/ + +{0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00},/*"n",78*/ + +{0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00},/*"o",79*/ + +{0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x00},/*"p",80*/ + +{0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x06,0x06,0x06,0x00},/*"q",81*/ + +{0x00,0x00,0x00,0x00,0x00,0x66,0x6E,0x70,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00},/*"r",82*/ + +{0x00,0x00,0x00,0x00,0x00,0x3E,0x60,0x60,0x3C,0x06,0x06,0x7C,0x00,0x00,0x00,0x00},/*"s",83*/ + +{0x00,0x00,0x00,0x30,0x30,0x7E,0x30,0x30,0x30,0x30,0x30,0x1E,0x00,0x00,0x00,0x00},/*"t",84*/ + +{0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00},/*"u",85*/ + +{0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00},/*"v",86*/ + +{0x00,0x00,0x00,0x00,0x00,0x63,0x6B,0x6B,0x6B,0x6B,0x36,0x36,0x00,0x00,0x00,0x00},/*"w",87*/ + +{0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C,0x18,0x3C,0x66,0x66,0x00,0x00,0x00,0x00},/*"x",88*/ + +{0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0,0x00},/*"y",89*/ + +{0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,0x18,0x30,0x60,0x7E,0x00,0x00,0x00,0x00},/*"z",90*/ + +{0x00,0x00,0x00,0x0C,0x18,0x18,0x18,0x30,0x60,0x30,0x18,0x18,0x18,0x0C,0x00,0x00},/*"{",91*/ + +{0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00},/*"|",92*/ + +{0x00,0x00,0x00,0x30,0x18,0x18,0x18,0x0C,0x06,0x0C,0x18,0x18,0x18,0x30,0x00,0x00},/*"}",93*/ + +{0x00,0x00,0x00,0x71,0xDB,0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"~",94*/ +}; diff --git a/digital/lcd/src/lcd.cc b/digital/lcd/src/lcd.cc index f2171025..38fbc25f 100644 --- a/digital/lcd/src/lcd.cc +++ b/digital/lcd/src/lcd.cc @@ -23,6 +23,8 @@ // }}} #include "lcd.hh" #include "ucoolib/utils/delay.hh" +#include "font.hh" + LCD::LCD () : cs_ (GPIOB, 10), rs_ (GPIOB, 11), wr_ (GPIOC, 9), rd_ (GPIOC, 6), @@ -221,4 +223,176 @@ LCD::read_reg (uint16_t index) cs_.set (); return data; } +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>=0 && format.y >=0) + { + for(int i=0 ; ix_max ||y<0 || y>y_max){return;} + set_cursor(x,y); + cs_.reset(); + write_index (0x0022); + write_data(color); + cs_.set(); +} + +void +LCD::circle ( uint16_t color , int radius , Rect pos) //draw a circle (no problem if a part of the circle is not on the screen) +{ + int x=0; + int y=radius; + int m=5-4*radius; + while(x<=y) + { + if(belong (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);} + + if(belong (-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);} + + if(belong (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);} + + if(belong (-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);} + + if(m > 0) + { + y=y-1; + m = m-8*y; + } + x=x+1; + m=m+8*x+4; + } +} +int +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 1;} + return 0; +} +void +LCD::draw_char( uint16_t color ,char caract, Rect pos)//draw a caracter +{ + if(pos.x+8> x_max || pos.y+16>y_max){return;} + caract =caract-32; + for( int i = 0 ; i<=16 ; i++) + { + for( int j =7 ; j>=0 ; j--) + { + if(Ascii[caract][i]&(1<> 3 << 11) | (g >> 2 << 5) | (b >> 3); } + ///draw a pixel if he belong to the screen + void blit_pixel ( uint16_t color , int x , int y); + ///make a border of a rectangle + void rectangle_empty (uint16_t color,Rect format, Rect pos); + ///make a filled rectangle with one color + void rectangle_fill (uint16_t color,Rect format, Rect pos); + ///draw a circle + void circle ( uint16_t color , int radius , Rect pos); //position of the center of the circle + ///write a caracter + void draw_char( uint16_t color ,char caract, Rect pos); + ///write a sentence center on pos + void draw_sentence( uint16_t color ,const char *sentence, Rect pos); private: void set_cursor (int x, int y); void write_index (uint16_t index); @@ -54,8 +73,8 @@ class LCD uint16_t read_data (); void write_reg (uint16_t index, uint16_t data); uint16_t read_reg (uint16_t index); + int belong ( int x, int y); //does the point belong to the screen? private: ucoo::Gpio cs_, rs_, wr_, rd_, reset_, bl_; }; - #endif // lcd_hh diff --git a/digital/lcd/src/main.cc b/digital/lcd/src/main.cc index 38016cd2..34dcbfe8 100644 --- a/digital/lcd/src/main.cc +++ b/digital/lcd/src/main.cc @@ -26,9 +26,23 @@ #include "ucoolib/arch/arch.hh" #include "ucoolib/utils/delay.hh" #include +#include + #include "ucoolib/hal/i2c/i2c.hh" #include "ucoolib/utils/crc.hh" +#include "ucoolib/utils/bytes.hh" +//uint16_t ucoo::bytes_pack (arg 1 ,arg 2 ); + + + +static char i2c_color[3]; +static int i2c_time; +static char i2c_cmd[100]="..."; +static Rect pos_r;//position du robot +static int nb_obs=0;//nb d'obstacle +static Rect pos_obs[4]; +static Rect pos_r_n; //next position of the robot static const int i2c_status_size = 3; static const int i2c_command_size = 16; @@ -56,14 +70,41 @@ i2c_handle (LCD &lcd, const char *buf, int size) char cmd = buf[2]; const char *arg = &buf[3]; int arg_nb = size - 3; + int j; switch (cmd) { case 'c': // Team color. if (arg_nb != 3) return; - lcd.clear (LCD::color (arg[0], arg[1], arg[2])); + i2c_color[0]=arg[0]; + i2c_color[1]=arg[1]; + i2c_color[2]=arg[2]; break; + case 't': + i2c_time=arg[0]; + break; + case 'p': //position of the robot + pos_r.x=ucoo::bytes_pack (arg[0] ,arg [1] )*0.10666; + pos_r.y=ucoo::bytes_pack (arg[2] ,arg [3] )*0.10666; + break; + case 'm': //message + strcpy(i2c_cmd,arg); + case 'o': //obstacle (barrier) + j=0; + nb_obs=arg[0]; + for(int i=1 ; i<=nb_obs*4 ; i=i+4) + { + pos_obs[j].x=ucoo::bytes_pack (arg[i] ,arg [i+1] )*0.10666; + + pos_obs[j].y=ucoo::bytes_pack (arg[i+2] ,arg [i+3] )*0.10666; + j++; + } + break; + case 'n'://next position of the robot + pos_r_n.x=ucoo::bytes_pack (arg[0] ,arg [1] )*0.10666; + pos_r_n.y=ucoo::bytes_pack (arg[2] ,arg [3] )*0.10666; + break; default: // Unknown command. return; @@ -89,6 +130,99 @@ i2c_poll (LCD &lcd, ucoo::I2cSlaveDataBuffer &i2c_data) sizeof (status) - 1); i2c_data.update (status, sizeof (status)); } +void +draw_bar (LCD lcd)//draw barrier (make a red circle where is approximatly the barrier) +{ + for(int i=0; i 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; // Init. + LCD lcd; + //ucoo::delay_ms (1000); + draw_table (lcd); // Wait orders. while (1) { + draw_table (lcd);//draw the table + draw_robot (lcd);//draw the robot and his destination on the table i2c_poll (lcd, i2c_data); - ucoo::delay_ms (1); + ucoo::delay_ms (1000); + } } -- cgit v1.2.3