Library for 3.2'' uLcd Picaso Display4D system Picaso Serial Environment Command Set web: http://www.4dsystems.com.au/product/20/67/Processors_Graphics/PICASO/

Revision:
0:65fd8b1cbf86
diff -r 000000000000 -r 65fd8b1cbf86 ObjetGraphic.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjetGraphic.cpp	Sun Jul 06 10:36:27 2014 +0000
@@ -0,0 +1,2608 @@
+
+#include "ObjetGraphic.h"
+
+PicasoSerial* ps=0;
+
+Screen::Screen(PicasoSerial* serial,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _colorBkg):
+    myXpos(_x),myYpos(_y),myWidth(_w),myHeight(_h),myColorBkg(_colorBkg)
+{
+    mySerial=serial;
+}
+//------------------------------------
+Screen::~Screen(void)
+{
+    ps=0;
+
+    for(int i=0; i<myVectorObjet.size(); i++) {
+        delete  myVectorObjet[i];
+        myVectorObjet[i]=0;
+    }
+}
+//------------------------------------
+UINT16 Screen::getXpos(void)
+{
+    return this->myXpos;
+}
+//----------------------------------
+UINT16 Screen::getYpos(void)
+{
+    return this->myYpos;
+}
+//------------------------------------
+UINT16 Screen::getWidth(void)
+{
+    return this->myWidth;
+}
+//-------------------------------------
+UINT16 Screen::getHeight(void)
+{
+    return this->myHeight;
+}
+//------------------------------------
+void Screen::drawObj(ObjetHeader* pObj)
+{
+    pObj->draw();
+
+}
+//------------------------------------
+void Screen::drawAll(void)
+{
+    mySerial->draw_filled_rectangle(myXpos,myYpos,myXpos+myWidth,myYpos+myHeight,myColorBkg);
+
+    //
+    for(int i=0; i<myVectorObjet.size(); i++) {
+        drawObj(myVectorObjet[i]);
+    }
+}
+//-------------------------------------
+void Screen::drawCells(void)
+{
+    for(int i=1; i<3; i++) {
+        mySerial->draw_line(80*i,0,80*i,320,BLACK);
+    }
+    //
+    for(int i=1; i<4; i++) {
+        mySerial->draw_line(0,80*i,240,80*i,BLACK);
+    }
+
+}
+//-------------------------------------
+void Screen::addObj(ObjetHeader* pObj)
+{
+    myVectorObjet.push_back(pObj);
+}
+//---------------------------------------
+PicasoSerial* Screen::getPicasoSerial(void)
+{
+    return  mySerial;
+}
+//---------------------------------------
+Color Screen::getColorBkg(void)
+{
+    return myColorBkg;
+}
+//--------------------------------------
+bool Screen::isContent(ObjetHeader* pObj, UINT16 _x,UINT16 _y)
+{
+    UINT16 xd=pObj->getXpos();
+    UINT16 w=pObj->getWidth();
+    UINT16 xf=xd+w;
+
+    UINT16 yd=pObj->getYpos();
+    UINT16 h=pObj->getHeight();
+    UINT16 yf=yd+h;
+
+    if(_x >= xd && _x<= xf && _y>=yd && _y<= yf) {
+        return true;
+    }
+
+    return false;
+
+}
+//-------------------------------------
+ObjetHeader* Screen::getObjetPosition(UINT16 _x,UINT16 _y)
+{
+
+    if(myVectorObjet.size()==0)
+        return NULL;
+
+    //
+    for(int i=0; i<myVectorObjet.size(); i++) {
+        if(isContent(myVectorObjet[i],_x,_y))
+            return myVectorObjet[i];
+    }
+    return NULL;
+}
+//-------------------------------------
+ObjetHeader* Screen::getObjetById(UINT16 _id)
+{
+    if(myVectorObjet.size()==0)
+        return NULL;
+
+    //
+    for(int i=0; i<myVectorObjet.size(); i++) {
+        if((myVectorObjet[i]->getElementId())== _id)
+            return myVectorObjet[i];
+    }
+    return NULL;
+
+}
+//-------------------------------------
+TouchEvent Screen::getTouchEvent(GraphicMessage* msg)
+{
+    TouchEvent ev=EVENT_NO_ACTIVITY;
+    UINT16 xp=0;
+    UINT16 yp=0;
+
+    ev=mySerial->touch_get_status();
+
+    //
+    if(ev >EVENT_NO_ACTIVITY) {
+        xp=mySerial->touch_get_x();
+        yp=mySerial->touch_get_y();
+
+        msg->event=ev;
+        msg->posiX=xp;
+        msg->posiY=yp;
+        msg->objId=0;
+
+        return ev;
+    } else {
+        
+        msg->event=EVENT_NO_ACTIVITY;
+        msg->posiX=0;
+        msg->posiY=0;
+        msg->objId=0;
+    }
+    //
+    return ev;
+}
+//-------------------------------------
+void Screen::getProcessMessage(GraphicMessage* msg)
+{
+    UINT16 xt=msg->posiX;
+    UINT16 yt=msg->posiY;
+    UINT16 res=0;
+
+    ObjetHeader* obj=NULL;
+
+    obj=getObjetPosition(xt,yt);
+
+    if(obj!=NULL && obj->getIsVisible()==true) {
+        res=obj->getElementId();
+        msg->objId=res;
+    } else {
+        msg->objId=0;
+    }
+
+}
+//-------------------------------------
+//
+//
+//
+//---------------------------------------
+ObjetHeader::ObjetHeader(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _color,bool _isVisible):
+    myScreen(mScreen),myElementId(_id),myX(_x),myY(_y),myWidth(_w),myHeight(_h),myColor(_color),myElementIsVisible(_isVisible)
+{
+
+    myElementState=STATE_ON;
+    myIsUpdateAutomatic=true;
+
+    myXMoveMin=myScreen->getXpos();
+    myYMoveMin=myScreen->getYpos();
+
+    myXMoveMax=myXMoveMin+myScreen->getWidth();
+    myYMoveMax= myYMoveMin+myScreen->getHeight();
+
+    mySpeedX=0.0;
+    mySpeedY=0.0;
+}
+//-------------------------------------
+ObjetHeader::~ObjetHeader(void)
+{
+}
+//-------------------------------------
+void ObjetHeader::updateCellId(void)
+{
+    UINT16 cellX=myX/(ObjetHeader::CELL_DIM);
+    UINT16 cellY=myY/(ObjetHeader::CELL_DIM);
+
+    myCellId=cellX+(cellY*ObjetHeader::CELL_COL);
+}
+//-------------------------------------
+UINT16 ObjetHeader::getCellId(void)
+{
+    return this->myCellId;
+}
+//-------------------------------------
+void ObjetHeader::setUpdateAutomatic(bool _state)
+{
+    myIsUpdateAutomatic=_state;
+}
+//---------------------------------------
+bool ObjetHeader::getUpdateAutomatic(void)
+{
+    return this->myIsUpdateAutomatic;
+}
+//-------------------------------------
+bool ObjetHeader::overlapWith(ObjetHeader* pObj)
+{
+    return overlap(this,pObj);
+}
+//-------------------------------------
+bool ObjetHeader::overlap(ObjetHeader* pObj1,ObjetHeader* pObj2)
+{
+    UINT16 x1=pObj1->getXpos();
+    UINT16 x2=pObj2->getXpos();
+
+    UINT16 y1=pObj1->getYpos();
+    UINT16 y2=pObj2->getYpos();
+
+    UINT16 xa=pObj1->getXpos()+pObj1->getWidth();
+    UINT16 xb=pObj2->getXpos()+pObj2->getWidth();
+
+    UINT16 ya=pObj1->getYpos()+pObj1->getHeight();
+    UINT16 yb=pObj2->getYpos()+pObj2->getHeight();
+
+    //
+    if(x1 <xb && xa>x2 && y1<yb && ya>y2) {
+
+        return true;
+    } else {
+        return false;
+    }
+
+}
+//-------------------------------------
+void ObjetHeader::elementUpdate(void)
+{
+    switch(myElementState) {
+            //
+        case BUMP_DOWN:
+            setInvertSpeedY();
+            myElementState=STATE_ON;
+            break;
+            //
+        case BUMP_LEFT:
+            setInvertSpeedX();
+            myElementState=STATE_ON;
+            break;
+            //
+        case BUMP_RIGHT:
+            setInvertSpeedX();
+            myElementState=STATE_ON;
+            break;
+            //
+        case BUMP_UP:
+            setInvertSpeedY();
+            myElementState=STATE_ON;
+            break;
+            //
+        case STATE_OFF:
+            break;
+            //
+        default:
+            break;
+    }
+    //
+}
+//-------------------------------------
+void ObjetHeader::draw(void)
+{
+//to do
+}
+//-------------------------------------
+UINT16 ObjetHeader::getXpos(void)
+{
+    return this->myX;
+}
+//---------------------------------------
+UINT16 ObjetHeader::getYpos(void)
+{
+    return this->myY;
+}
+//----------------------------------------
+UINT16 ObjetHeader::getWidth(void)
+{
+    return this->myWidth;
+}
+//----------------------------------------
+UINT16 ObjetHeader::getHeight(void)
+{
+    return this->myHeight;
+}
+//----------------------------------------
+UINT16 ObjetHeader::getElementId(void)
+{
+    return this->myElementId;
+}
+//----------------------------------------
+GRAPHIC_OBJ_TYPE ObjetHeader::getElementType(void)
+{
+    return this->myElementType;
+}
+//----------------------------------------
+bool ObjetHeader::getIsVisible(void)
+{
+    return this->myElementIsVisible;
+}
+//----------------------------------------
+float ObjetHeader::getSpeedX(void)
+{
+    return this->mySpeedX;
+}
+//----------------------------------------
+float ObjetHeader::getSpeedY(void)
+{
+    return this->mySpeedY;
+}
+//----------------------------------------
+Color ObjetHeader::getColor(void)
+{
+    return myColor;
+}
+//----------------------------------------
+void ObjetHeader::setVisibility(bool _val)
+{
+    (this->myElementIsVisible)=_val;
+}
+//----------------------------------------
+State ObjetHeader::getElementState(void)
+{
+    return this->myElementState;
+}
+//----------------------------------------
+void ObjetHeader::setInvertSpeedX(void)
+{
+    mySpeedX=-(this->mySpeedX);
+}
+//----------------------------------------
+void ObjetHeader::setInvertSpeedY(void)
+{
+    mySpeedY=-(this->mySpeedY);
+}
+//----------------------------------------
+void ObjetHeader::setSpeedX(float _speedX)
+{
+    mySpeedX=_speedX;
+}
+//----------------------------------------
+void ObjetHeader::setSpeedY(float _speedY)
+{
+    mySpeedY=_speedY;
+}
+//----------------------------------------
+void ObjetHeader::setSpeedXY(float _speedX,float _speedY)
+{
+    mySpeedX=_speedX;
+    mySpeedY=_speedY;
+}
+//------------------------------------------
+void ObjetHeader::setColor(Color _color)
+{
+    myColor=_color;
+}
+//------------------------------------------
+void ObjetHeader::setElementState(State _state)
+{
+    myElementState=_state;
+}
+//------------------------------------------
+void ObjetHeader::setElementId(UINT16 _id)
+{
+    myElementId=_id;
+}
+//------------------------------------------
+void ObjetHeader::setXpos(UINT16 _xpos)
+{
+    this->myX=_xpos;
+}
+//------------------------------------------
+void ObjetHeader::setYpos(UINT16 _ypos)
+{
+    this->myY=_ypos;
+}
+//-------------------------------------------
+//
+//
+//
+//--------------------------------------------
+void Isocele::updateOrientation(void)
+{
+    switch(myOrientation) {
+            //
+        case Isocele::ORIENTATION_UP:
+            mySpeedX=0.0;
+            mySpeedY=-mySpeed;
+
+            myX=myXcenter-myRadius;
+            myY=myYcenter-myRadius;
+            myWidth=myRadius+myRadius;
+            myHeight=myRadius;
+
+            myX1=myXcenter;
+            myY1=myYcenter-myRadius;
+
+            myX2=myXcenter-myRadius;
+            myY2=myYcenter;
+
+            myX3=myXcenter+myRadius;
+            myY3=myYcenter;
+            break;
+
+            //
+        case Isocele::ORIENTATION_RIGHT:
+            mySpeedX=mySpeed;
+            mySpeedY=0.0;
+
+            myX=myXcenter;
+            myY=myYcenter-myRadius;
+            myWidth=myRadius;
+            myHeight=myRadius+myRadius;
+
+            myX1=myXcenter;
+            myY1=myYcenter-myRadius;
+
+            myX2=myXcenter;
+            myY2=myYcenter+myRadius;
+
+            myX3=myXcenter+myRadius;
+            myY3=myYcenter;
+            break;
+
+            //
+        case Isocele::ORIENTATION_DOWN:
+            mySpeedX=0.0;
+            mySpeedY=mySpeed;
+
+            myX=myXcenter-myRadius;
+            myY=myYcenter;
+            myWidth=myRadius+myRadius;
+            myHeight=myRadius;
+
+            myX1=myXcenter-myRadius;
+            myY1=myYcenter;
+
+            myX2=myXcenter;
+            myY2=myYcenter+myRadius;
+
+            myX3=myXcenter+myRadius;
+            myY3=myYcenter;
+            break;
+
+            //
+        case Isocele::ORIENTATION_LEFT:
+            mySpeedX=-mySpeed;
+            mySpeedY=0.0;
+
+            myX=myXcenter-myRadius;
+            myY=myYcenter-myRadius;
+            myWidth=myRadius;
+            myHeight=myRadius+myRadius;
+
+            myX1=myXcenter-myRadius;
+            myY1=myYcenter;
+
+            myX2=myXcenter;
+            myY2=myYcenter+myRadius;
+
+            myX3=myXcenter;
+            myY3=myYcenter-myRadius;
+            break;
+
+            //
+        default:
+            break;
+
+    }
+
+}
+//--------------------------------------------
+Isocele::Isocele(Screen* mScreen,UINT16 _id,UINT16 xc,UINT16 yc,UINT16 radius,int orientation,float _speed,
+                 Color color,bool isVisible): ObjetHeader(mScreen,_id,xc-radius,yc-radius,radius+radius,radius,color,isVisible)
+{
+    myXcenter=xc;
+    myYcenter=yc;
+    myRadius=radius;
+    myOrientation=orientation;
+    mySpeed=_speed;
+
+    updateOrientation();
+
+    myIsUpdateAutomatic=false;
+
+    myElementType=OBJ_ISOCELE;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//--------------------------------------------
+void Isocele::draw(void)
+{
+    // isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,myColor);
+        //
+        //ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,BLACK);
+    }
+}
+//---------------------------------------------
+Isocele::~Isocele(void)
+{
+}
+//--------------------------------------------
+void Isocele:: setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,c);
+            //ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+        this->draw();
+    }
+}
+//-------------------------------------------
+void Isocele::setNewPosition(INT16 _xcnew,INT16 _ycnew)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myXcenter==_xcnew && myYcenter==_ycnew)
+        return;
+    //
+    this->setInvisible(true); // colorie le cir avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xcnew+myRadius >= myXMoveMax) {
+        _xcnew=myXMoveMax-myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+    }
+
+    //test Xmin
+    if(_xcnew <= myRadius) {
+        _xcnew=myXMoveMin+myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+    }
+    //test Ymax
+    if(_ycnew +myRadius >= myYMoveMax && _ycnew >0) {
+        _ycnew = myYMoveMax- myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ycnew <= myRadius) {
+        _ycnew=myYMoveMin+myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+    }
+    //
+    myXcenter=_xcnew;
+    myYcenter=_ycnew;
+
+    updateOrientation();
+
+
+    this->draw();
+}
+//--------------------------------------------
+void Isocele::myElementUpdate(void)
+{
+    switch(myElementState) {
+            //
+        case BUMP_DOWN:
+            setInvertSpeedY();
+            myElementState=STATE_ON;
+            myOrientation=Isocele::ORIENTATION_UP;
+            break;
+            //
+        case BUMP_LEFT:
+            setInvertSpeedX();
+            myElementState=STATE_ON;
+            myOrientation=Isocele::ORIENTATION_RIGHT;
+            break;
+            //
+        case BUMP_RIGHT:
+            setInvertSpeedX();
+            myElementState=STATE_ON;
+            myOrientation=Isocele::ORIENTATION_LEFT;
+            break;
+            //
+        case BUMP_UP:
+            setInvertSpeedY();
+            myElementState=STATE_ON;
+            myOrientation=Isocele::ORIENTATION_DOWN;
+            break;
+            //
+        case STATE_OFF:
+            break;
+            //
+        default:
+            break;
+    }
+}
+//--------------------------------------------
+void Isocele::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        myElementUpdate();
+    //
+    float xnew=myXcenter+mySpeedX*delta;
+    float ynew=myYcenter+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xnew,(INT16)ynew);
+
+    updateCellId();
+}
+//--------------------------------------------
+void Isocele::setOrientation(int _orientation)
+{
+    myOrientation=_orientation;
+
+}
+//--------------------------------------------
+int Isocele::getOrientation(void)
+{
+    return this->myOrientation;
+}
+//--------------------------------------------
+UINT16 Isocele::getXcenter(void)
+{
+    return this->myXcenter;
+}
+//--------------------------------------------
+UINT16 Isocele::getYcenter(void)
+{
+    return this->myYcenter;
+}
+//--------------------------------------------
+void Isocele::turnLeft(void)
+{
+    myOrientation+=1;
+
+    if(myOrientation >Isocele::ORIENTATION_RIGHT)
+        myOrientation=ORIENTATION_UP;
+
+}
+//--------------------------------------------
+void Isocele::turnRight(void)
+{
+    myOrientation-=1;
+
+    if(myOrientation <Isocele::ORIENTATION_UP)
+        myOrientation=ORIENTATION_RIGHT;
+
+}
+//--------------------------------------------
+//
+//
+//
+Rectangle::Rectangle(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _color,bool _isVisible):
+    ObjetHeader(mScreen,_id,_x,_y,_w,_h,_color,_isVisible)
+{
+    myElementType=OBJ_RECTANGLE;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//------------------------------------
+Rectangle::~Rectangle(void)
+{
+}
+//------------------------------------
+void Rectangle::draw(void)
+{
+    // isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,myColor);
+    }
+}
+//-------------------------------------
+void Rectangle::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+        this->draw();
+    }
+}
+//--------------------------------------
+void Rectangle::setNewPosition(INT16 _xnew,INT16 _ynew)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    //
+    if(myX==_xnew && myY==_ynew)
+        return;
+
+    setInvisible(true); // colorie le rec avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xnew+myWidth >= myXMoveMax) {
+        _xnew=myXMoveMax-myWidth;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+
+    }
+
+    //test Xmin
+    if(_xnew <= myXMoveMin) {
+        _xnew=myXMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+
+    }
+    //test Ymax
+    if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
+        _ynew = myYMoveMax- myHeight;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ynew <= myYMoveMin) {
+        _ynew=myYMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+
+    }
+    //
+    myX=_xnew;
+    myY=_ynew;
+
+
+    this->draw();
+}
+//--------------------------------------
+void Rectangle::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        elementUpdate();
+    //
+    float xnew=myX+mySpeedX*delta;
+    float ynew=myY+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xnew,(INT16)ynew);
+
+    updateCellId();
+}
+//-------------------------------------
+//
+//
+Circle::Circle(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radius,Color _color,bool _isVisible):
+    ObjetHeader(mScreen,_id,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_color,_isVisible)
+{
+    myRadius=_radius;
+    myCenterX=_xc;
+    myCenterY=_yc;
+    myElementType=OBJ_CIRCLE;
+
+    myScreen->addObj((ObjetHeader*) this);
+
+}
+//-----------------------------------------
+Circle::~Circle(void)
+{
+}
+//------------------------------------------
+void Circle::draw(void)
+{
+// isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColor);
+    }
+}
+//------------------------------------------
+void Circle::setCenterX(UINT16 _xcenter)
+{
+    this->myCenterX=_xcenter;
+}
+//------------------------------------------
+void Circle::setCenterY(UINT16 _ycenter)
+{
+    this->myCenterY=_ycenter;
+}
+//------------------------------------------
+UINT16 Circle::getCenterX(void)
+{
+    return this->myCenterX;
+}
+//-------------------------------------------
+UINT16 Circle::getCenterY(void)
+{
+    return this->myCenterY;
+}
+//--------------------------------------------
+void Circle::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//---------------------------------------------
+void Circle::setNewPosition(INT16 _xcnew,INT16 _ycnew)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myCenterX==_xcnew && myCenterY==_ycnew)
+        return;
+    //
+    this->setInvisible(true); // colorie le cir avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xcnew+myRadius >= myXMoveMax) {
+        _xcnew=myXMoveMax-myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+    }
+
+    //test Xmin
+    if(_xcnew <= myRadius) {
+        _xcnew=myXMoveMin+myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+    }
+    //test Ymax
+    if(_ycnew +myRadius >= myYMoveMax && _ycnew >0) {
+        _ycnew = myYMoveMax- myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ycnew <= myRadius) {
+        _ycnew=myYMoveMin+myRadius;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+    }
+    //
+    myCenterX=_xcnew;
+    myCenterY=_ycnew;
+
+    myX=_xcnew-myRadius;
+    myY=_ycnew-myRadius;
+
+
+    this->draw();
+}
+//----------------------------------------------
+void Circle::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        elementUpdate();
+
+    float xcnew=myCenterX+mySpeedX*delta;
+    float ycnew=myCenterY+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xcnew,(INT16)ycnew);
+
+    updateCellId();
+}
+//----------------------------------------------
+//
+//
+//
+Ellipse::Ellipse(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radiusX,UINT16 _radiusY,Color _color,
+                 bool _isVisible):ObjetHeader(mScreen,_id,_xc-_radiusX,_yc-_radiusY,_radiusX+_radiusX,_radiusY+_radiusY,_color,_isVisible)
+{
+    myCenterX=_xc;
+    myCenterY=_yc;
+    myRadiusX=_radiusX;
+    myRadiusY=_radiusY;
+
+    myElementType=OBJ_ELLIPSE;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//----------------------------------------------
+void Ellipse::draw(void)
+{
+    // isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_ellipse(myCenterX,myCenterY,myRadiusX,myRadiusY,myColor);
+    }
+}
+//----------------------------------------------
+void Ellipse::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        elementUpdate();
+
+    float xcnew=myCenterX+mySpeedX*delta;
+    float ycnew=myCenterY+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xcnew,(INT16)ycnew);
+
+    updateCellId();
+}
+//-----------------------------------------------
+void Ellipse::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_ellipse(myCenterX,myCenterY,myRadiusX,myRadiusY,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//-----------------------------------------------
+void Ellipse::setNewPosition(INT16 _xcnew,INT16 _ycnew)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myCenterX==_xcnew && myCenterY==_ycnew)
+        return;
+    //
+    this->setInvisible(true); // colorie le cir avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xcnew+myRadiusX >= myXMoveMax) {
+        _xcnew=myXMoveMax-myRadiusX;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+    }
+
+    //test Xmin
+    if(_xcnew <= myRadiusX) {
+        _xcnew=myXMoveMin+myRadiusX;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+    }
+    //test Ymax
+    if(_ycnew +myRadiusY >= myYMoveMax && _ycnew >0) {
+        _ycnew = myYMoveMax- myRadiusY;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ycnew <= myRadiusY) {
+        _ycnew=myYMoveMin+myRadiusY;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+    }
+    //
+    myCenterX=_xcnew;
+    myCenterY=_ycnew;
+
+    myX=_xcnew-myRadiusX;
+    myY=_ycnew-myRadiusY;
+
+
+    this->draw();
+}
+//-----------------------------------------------
+Ellipse::~Ellipse(void)
+{
+}
+//----------------------------------------------
+UINT16 Ellipse::getCenterX(void)
+{
+    return this->myCenterX;
+}
+//---------------------------------------------
+UINT16 Ellipse::getCenterY(void)
+{
+    return this->myCenterY;
+}
+//----------------------------------------------
+void Ellipse::setCenterX(UINT16 _xcenter)
+{
+    myCenterX=_xcenter;
+}
+//----------------------------------------------
+void Ellipse::setCenterY(UINT16 _ycenter)
+{
+    myCenterY=_ycenter;
+}
+//----------------------------------------------
+//
+//
+//
+Triangle::Triangle(Screen* mScreen,UINT16 _id,UINT16 _x1,UINT16 _y1,
+                   UINT16 _x2,UINT16 _y2,
+                   UINT16 _x3,UINT16 _y3,Color _color,bool _isVisible):
+    ObjetHeader(mScreen,_id,_x2,_y1,_x3-_x2,_y3-_y1,_color,_isVisible)
+{
+    myX1=_x1;
+    myY1=_y1;
+    myX2=_x2;
+    myY2=_y2;
+    myX3=_x3;
+    myY3=_y3;
+    myU=_x1-_x2;
+    myV=_y2-_y1;
+
+    myElementType=OBJ_TRIANGLE;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//-----------------------------------------------
+Triangle::~Triangle(void)
+{
+}
+//-----------------------------------------------
+void Triangle::draw(void)
+{
+// isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,myColor);
+    }
+}
+//------------------------------------------------
+void Triangle::setInvisible(bool _state)
+{
+// element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+        this->draw();
+    }
+}
+//------------------------------------------------
+void Triangle::setNewPosition(INT16 _xnew,INT16 _ynew)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myX==_xnew && myY==_ynew)
+        return;
+    setInvisible(true); // colorie le tri avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xnew+myWidth >= myXMoveMax) {
+        _xnew=myXMoveMax-myWidth;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+    }
+    //
+    //test Xmin
+    if(_xnew <= myXMoveMin) {
+        _xnew=myXMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+    }
+    //test Ymax
+    if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
+        _ynew = myYMoveMax- myHeight;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ynew <= myYMoveMin) {
+        _ynew=myYMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+    }
+
+    //
+    myX=_xnew;
+    myY=_ynew;
+
+    myX1=_xnew+myU;
+    myY1=_ynew;
+
+    myX2=_xnew;
+    myY2=_ynew+myV;
+
+    myX3=_xnew+myWidth;
+    myY3=_ynew+myHeight;
+
+    this->draw();
+}
+//------------------------------------------------
+void Triangle::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        elementUpdate();
+    //
+    float xnew=myX+mySpeedX*delta;
+    float ynew=myY+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xnew,(INT16)ynew);
+
+    updateCellId();
+}
+//-------------------------------------------------
+//
+//
+Diamond::Diamond(Screen* mScreen,UINT16 _id,UINT16 x1,UINT16 y1,UINT16 x2,UINT16 y2,
+                 UINT16 x3,UINT16 y3,UINT16 x4,UINT16 y4,Color _color,bool _isVisible):ObjetHeader(mScreen,_id,x1,y4,x3-x1,y2-y4,_color,_isVisible)
+{
+    myX1=x1;
+    myY1=y1;
+
+    myX2=x2;
+    myY2=y2;
+
+    myX3=x3;
+    myY3=y3;
+
+    myX4=x4;
+    myY4=y4;
+
+    myU1=x4-x1;
+    myU2=x2-x1;
+
+    myV1=y1-y4;
+    myV2=y3-y4;
+
+
+    myElementType=OBJ_DIAMOND;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//-----------------------------------------
+void Diamond::draw(void)
+{
+    // isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_filled_diamond(myX1,myY1,myX2,myY2,myX3,myY3,myX4,myY4,myColor);
+    }
+}
+//-----------------------------------------
+Diamond::~Diamond(void)
+{
+}
+//----------------------------
+void Diamond::update(float delta)
+{
+    if(myIsUpdateAutomatic)
+        elementUpdate();
+    //
+    float xnew=myX+mySpeedX*delta;
+    float ynew=myY+mySpeedY*delta;
+
+    this->setNewPosition((INT16)xnew,(INT16)ynew);
+
+    updateCellId();
+}
+//-------------------------------
+void Diamond::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_diamond(myX1,myY1,myX2,myY2,myX3,myY3,myX4,myY4,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+        this->draw();
+    }
+}
+//---------------------------------
+void Diamond::setNewPosition(INT16 _xnew,INT16 _ynew)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myX==_xnew && myY==_ynew)
+        return;
+    setInvisible(true); // colorie le tri avec couleur de la screen
+
+    myElementIsVisible=true;
+
+    //test Xmax
+    if(_xnew+myWidth >= myXMoveMax) {
+        _xnew=myXMoveMax-myWidth;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_RIGHT;
+    }
+    //
+    //test Xmin
+    if(_xnew <= myXMoveMin) {
+        _xnew=myXMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_LEFT;
+    }
+    //test Ymax
+    if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
+        _ynew = myYMoveMax- myHeight;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_DOWN;
+    }
+    //test yminMin;
+    if(_ynew <= myYMoveMin) {
+        _ynew=myYMoveMin;
+
+        if(myElementState==STATE_ON)
+            myElementState=BUMP_UP;
+    }
+
+    //
+    myX=_xnew;
+    myY=_ynew;
+
+    myX1=_xnew;
+    myY1=_ynew+myV1;
+
+    myX2=_xnew+myU2;
+    myY2=_ynew+myHeight;
+
+    myX3=_xnew+myWidth;
+    myY3=_ynew+myV2;
+
+    myX4=_xnew+myU1;
+    myY4=_ynew;
+
+    this->draw();
+}
+//---------------------------------
+//
+//
+//
+Label::Label(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,
+             string _text,Font _font,Color _colorText,Color _colorBkg,
+             bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,10,10,_colorBkg,_isVisible)
+
+{
+    myText=_text;
+    myFont=_font;
+    myColorText=_colorText;
+
+    myElementType=OBJ_LABEL;
+
+    //
+    UINT16 largeur=0;
+    UINT16 hauteur=16;
+    UINT16 taille=0;
+    UINT16 incLargeur=12;
+
+    switch(_font) {
+            //
+        case FONT_2:
+            incLargeur=8;
+            hauteur=8;
+            largeur=8;
+            break;
+
+            //
+        case FONT_3:
+            incLargeur=8;
+            hauteur=12;
+            largeur=8;
+            break;
+            //
+        case FONT_1:
+            incLargeur=5;
+            hauteur=7;
+            largeur=5;
+            break;
+
+            //
+        default:
+            incLargeur=12;
+            hauteur=16;
+            largeur=8;
+            break;
+    }
+    //cherche taille
+    
+    /*
+    while(*_text) 
+    {
+        taille++;
+        largeur=largeur+incLargeur;
+        _text++;
+    }
+    _text=_text-taille;
+    
+    */
+    taille=_text.size();
+    largeur=incLargeur*taille;
+    
+    if(largeur > incLargeur)
+        largeur=largeur-incLargeur;
+
+    myWidth=largeur;
+    myHeight=hauteur;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//-----------------------------------------------------
+Label::~Label(void)
+{
+    //myText=0;
+}
+//-----------------------------------------------------
+void Label::draw(void)
+{
+    // isVisible ?
+    if(myElementIsVisible==false) {
+        return;
+    }
+    //
+
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+
+        ps->draw_string(myText,myX,myY,myFont,myColorText,myColor);
+    }
+}
+//------------------------------------------------------
+void Label::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+        this->draw();
+    }
+}
+//-------------------------------------------------------
+void Label::setNewText(string _newText)
+{
+    //if(myElementIsVisible==false)
+    //    return;
+
+    UINT16 hauteur=16;
+    UINT16 incLargeur=12;
+    UINT16 taille=0;
+
+    switch(myFont) {
+            //
+        case FONT_2:
+            incLargeur=8;
+            hauteur=8;
+            break;
+
+            //
+        case FONT_3:
+            incLargeur=8;
+            hauteur=12;
+            break;
+            //
+        case FONT_1:
+            incLargeur=5;
+            hauteur=7;
+            break;
+
+            //
+        default:
+            incLargeur=12;
+            hauteur=16;
+            break;
+    }
+    
+    taille=_newText.size();
+    
+    //myWidth=_nbChar*incLargeur;
+    myWidth=taille*incLargeur;
+    myHeight=hauteur;
+    myText=_newText;
+
+    setInvisible(true);
+    setInvisible(false);
+    // this->draw();
+}
+//-------------------------------------------------------
+GraphicLed::GraphicLed(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radius,
+                       Color _colorOn,Color _colorOff,State _state,
+                       bool _isVisible):ObjetHeader(mScreen,_id,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_colorOn,_isVisible)
+{
+    myColorOn=_colorOn;
+    myColorOff=_colorOff;
+    myRadius=_radius;
+    myCenterX=_xc;
+    myCenterY=_yc;
+
+    myElementState=_state;
+    myElementType=OBJ_LED;
+    myScreen->addObj((ObjetHeader*) this);
+}
+//---------------------------------------
+GraphicLed::~GraphicLed(void)
+{
+}
+//---------------------------------------
+void GraphicLed::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    UINT16 state=getElementState();
+
+    //static PicasoSerial* ps=0;
+    ps=myScreen->getPicasoSerial();
+
+    switch(state) {
+            //
+        case LED_STATE_ON:
+            if(ps!=0) {
+                ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOn);
+                ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK);
+            }
+            return;
+            //
+        case LED_STATE_OFF:
+            if(ps!=0) {
+                ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOff);
+                ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK);
+            }
+            return;
+            //
+        default:
+            break;
+    }
+}
+//---------------------------------------
+void GraphicLed::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        //static PicasoSerial* ps=0;
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//---------------------------------------
+void GraphicLed::setState(State _state)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    if(myElementState==_state)
+        return;
+
+    myElementState=_state;
+
+    this->draw();
+}
+//---------------------------------------
+Button::Button(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,string _text,Font _font,
+               Color _colorText,Color _colorBtn,State _state,
+               bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,0,0,_colorBtn,_isVisible)
+
+{
+    myText=_text;
+    myFont=_font;
+    myColorText=_colorText;
+
+    myElementState=_state;
+    myElementType=OBJ_BUTTON;
+
+    //
+    UINT16 largeur=0;
+    UINT16 hauteur=16;
+    UINT16 taille=0;
+    UINT16 incLargeur=12;
+
+    switch(_font) {
+            //
+        case FONT_2:
+            incLargeur=8;
+            hauteur=8;
+            largeur=8;
+            break;
+
+            //
+        case FONT_3:
+            incLargeur=8;
+            hauteur=12;
+            largeur=8;
+            break;
+            //
+        case FONT_1:
+            incLargeur=5;
+            hauteur=7;
+            largeur=5;
+            break;
+
+            //
+        default:
+            incLargeur=12;
+            hauteur=16;
+            largeur=8;
+            break;
+    }
+    
+    //cherche taille
+    /*
+    while(*_text) {
+        taille++;
+        largeur=largeur+incLargeur;
+        _text++;
+    }
+    _text=_text-taille;
+    */
+    taille=_text.size();
+    
+    largeur=taille*incLargeur;
+    
+    if(largeur > incLargeur)
+        largeur=largeur-incLargeur;
+
+    myWidth=largeur+incLargeur+incLargeur;
+    myHeight=hauteur+incLargeur+incLargeur;
+
+    myScreen->addObj((ObjetHeader*) this);
+    
+    //
+    
+}
+//--------------------------------------
+Button::~Button(void)
+{
+}
+//---------------------------------------
+void Button::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    UINT16 state=getElementState();
+
+    ps=myScreen->getPicasoSerial();
+
+    switch(state) {
+            //
+        case BUTTON_STATE_PRESSED:
+            if(ps!=0) {
+                ps->draw_button(myText,myX,myY,myFont,BUTTON_STATE_PRESSED,myColor,WHITE);
+
+            }
+            return;
+            //
+        case BUTTON_STATE_RELEASED:
+            if(ps!=0) {
+                ps->draw_button(myText,myX,myY,myFont,BUTTON_STATE_RELEASED,myColor,myColorText);
+
+            }
+            return;
+            //
+        default:
+            break;
+    }
+}
+
+//-----------------------------------
+void Button::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//------------------------------------
+void Button::setState(State _state)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    if(myElementState==_state)
+        return;
+
+    myElementState=_state;
+
+    this->draw();
+}
+//-------------------------------------
+Slider::Slider(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,int _valMax,int _value,
+               Color _colorBkg,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,_colorBkg,_isVisible)
+{
+
+    myValueMax=_valMax;
+    myValue=_value;
+
+    myElementType=OBJ_SLIDER;
+    myElementState=SLIDER_STATE_RELEASED;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//---------------------------------------
+Slider::~Slider(void)
+{
+}
+//---------------------------------------
+void Slider::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+
+
+    ps=myScreen->getPicasoSerial();
+
+    if(ps!=0) {
+        ps->draw_slider(0x0000,myX,myY,myX+myWidth,myY+myHeight,myColor,myValueMax,myValue);
+    }
+
+}
+//--------------------------------------
+void Slider::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//-------------------------------------
+int Slider::getValue(GraphicMessage* pmsg)
+{
+    TouchEvent msgEvent=pmsg->event;
+
+    UINT16 xn=pmsg->posiX;
+
+
+    if(myElementIsVisible==false)
+        return 0;
+    //
+
+    if(msgEvent==EVENT_RELEASE) {
+        myElementState=SLIDER_STATE_RELEASED;
+    }
+    //
+    if(msgEvent==EVENT_MOVE) {
+        myElementState=SLIDER_STATE_MOVE;
+        UINT16 dis=xn-myX;
+        UINT16 a=dis*myValueMax;
+        myValue=(a/myWidth);
+
+        this->draw();
+    }
+    return myValue;
+}
+//-------------------------------------
+Input::Input(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,float _valMin,float _valInc,
+             float _valMax,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,WHITE,_isVisible)
+{
+    myValMin=_valMin;
+    myValInc=_valInc;
+    myValMax=_valMax;
+    myValue=0.0;
+    myColorBkg=WHITE;
+    myColorCursorUp=BLUE;
+    myColorCursorDown=BLUE;
+
+    myElementType=OBJ_INPUT;
+    myElementState=INPUT_STATE_RELEASED;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//-------------------------------------
+Input::~Input(void)
+{
+}
+//-------------------------------------
+void Input::setColorBkg(Color _color)
+{
+    myColorBkg=_color;
+    this->draw();
+}
+//--------------------------------------
+void Input::setColorCursorUp(Color _color)
+{
+    myColorCursorUp=_color;
+    this->draw();
+}
+//-------------------------------------
+void Input::setColorCursorDown(Color _color)
+{
+    myColorCursorDown=_color;
+    this->draw();
+}
+//-------------------------------------
+void Input::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    ps=myScreen->getPicasoSerial();
+
+    //rect up
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight/2,myColorBkg);
+
+    //rect down
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX,myY+myHeight/2+3,myX+myWidth,myY+3+myHeight,myColorBkg);
+
+    //fleche up
+    UINT16 x1=myX+myWidth/2;
+    UINT16 y1=myY;
+
+    UINT16 x2=myX+myWidth;
+    UINT16 y2=myY+myHeight/2;
+
+    UINT16 x3=myX;
+    UINT16 y3=myY+myHeight/2;
+    if(ps!=0)
+        ps->draw_filled_triangle(x1,y1,x2,y2,x3,y3, myColorCursorUp);
+
+    //fleche down
+    x1=myX;
+    y1=myY+3+myHeight/2;
+
+    x2=myX+myWidth;
+    y2=y1;
+
+    x3=myX+myWidth/2;
+    y3=y2+myHeight/2;
+    if(ps!=0)
+        ps->draw_filled_triangle(x1,y1,x2,y2,x3,y3, myColorCursorDown);
+
+    //cadre
+    if(ps!=0)
+        ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight+3,BLACK);
+
+}
+//-------------------------------------
+void Input::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight+3,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//--------------------------------------
+float Input::getValue(GraphicMessage* msg)
+{
+    if(myElementIsVisible==false)
+        return 0.0;
+    float val=0.0;
+    //
+    TouchEvent ev=msg->event;
+    UINT16 yn=msg->posiY;
+
+    UINT16 y0=myY;
+    UINT16 ybut1=y0+myHeight/2;
+    UINT16 ybut2=y0+myHeight;
+    Color couleurUp=myColorCursorUp;
+    Color couleurDown=myColorCursorDown;
+
+    if(ev==EVENT_PRESS && myElementState==INPUT_STATE_RELEASED) {
+        //up ?
+        if(yn >= y0 && yn <= ybut1) {
+            myElementState=INPUT_STATE_PRESSED_UP;
+            setColorCursorUp(WHITE);
+            wait(0.1);
+            setColorCursorUp(couleurUp);
+
+            val=myValue+myValInc;
+            if(val >myValMax)
+                val=myValMax;
+
+            myValue=val;
+        }
+        //
+        //down?
+        if(yn >= ybut1 && yn <= ybut2) {
+            myElementState=INPUT_STATE_PRESSED_DOWN;
+            setColorCursorDown(WHITE);
+            wait(0.1);
+            setColorCursorDown(couleurDown);
+
+            val=myValue-myValInc;
+            if(val <myValMin)
+                val=myValMin;
+
+            myValue=val;
+        }
+    }
+    //
+    if(ev==EVENT_RELEASE || ev==EVENT_MOVE) {
+        myElementState=INPUT_STATE_RELEASED;
+    }
+
+    return myValue;
+}
+//--------------------------------------
+Switch::Switch(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,
+               bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,WHITE,_isVisible)
+{
+    myColorOn=GREEN;
+    myColorOff=RED;
+    myColorCursor=WHITE;
+
+    myElementType=OBJ_SWITCH;
+    myElementState=SWITCH_STATE_OFF;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//---------------------------------------
+Switch::~Switch(void)
+{
+}
+//---------------------------------------
+void Switch::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    ps=myScreen->getPicasoSerial();
+
+    State state=myElementState;
+
+    Color gauche=WHITE;
+    Color droite=WHITE;
+
+    switch(state) {
+            //
+        case SWITCH_STATE_ON:
+            droite=myColorOn;
+            gauche=myColorCursor;
+            break;
+
+            //
+        case SWITCH_STATE_OFF:
+            droite=myColorCursor;
+            gauche=myColorOff;
+            break;
+
+            //
+        default:
+            break;
+    }
+    //
+
+    //rect gauche
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX,myY,myX+myWidth/2,myY+myHeight,gauche);
+
+    //rect droite
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myWidth/2,myY,myX+myWidth,myY+myHeight,droite);
+
+    //cadre
+    if(ps!=0) {
+        ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,BLACK);
+        ps->draw_rectangle(myX,myY,myX+myWidth/2,myY+myHeight,BLACK);
+
+    }
+
+}
+//----------------------------------------
+void Switch::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//-----------------------------------------
+void Switch::setState(State _state)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    if(myElementState==_state)
+        return;
+
+    myElementState=_state;
+
+    this->draw();
+}
+//-----------------------------------------
+void Switch::changeState(GraphicMessage* msg)
+{
+    TouchEvent ev=msg->event;
+
+    if(myElementIsVisible==false)
+        return;
+
+    if(ev==EVENT_PRESS && myElementState==SWITCH_STATE_OFF) {
+        this->setState(SWITCH_STATE_ON);
+        return;
+    }
+    //
+    if(ev==EVENT_PRESS && myElementState==SWITCH_STATE_ON) {
+        this->setState(SWITCH_STATE_OFF);
+        return;
+    }
+    //
+    if(ev==EVENT_MOVE || ev==EVENT_RELEASE)
+        return;
+}
+//----------------------------------------
+DigitLed::DigitLed(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,bool _ptVisible,
+                   bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,36,52,WHITE,_isVisible)
+{
+    myValue=0;
+    myColorBkg=YELLOW;
+    myColorSeg=RED;
+    myIncX=4;
+    myIncY=4;
+
+    isPtVisible=_ptVisible;
+
+    myElementType=OBJ_DIGIT_LED;
+    myElementState=DIGIT_LED_STATE_ON;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//-----------------------------------------
+DigitLed::~DigitLed(void)
+{
+}
+//-----------------------------------------
+void DigitLed::setColorBkg(Color _colorBkg)
+{
+    if(myColorBkg==_colorBkg)
+        return;
+
+    myColorBkg=_colorBkg;
+    this->draw();
+}
+//------------------------------------------
+void DigitLed::setColorSeg(Color _colorSeg)
+{
+    if(myColorSeg==_colorSeg)
+        return;
+
+    myColorSeg=_colorSeg;
+    this->draw();
+}
+//-----------------------------------------
+void DigitLed::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    ps=myScreen->getPicasoSerial();
+
+    //rec
+    if(ps!=0) {
+        ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,myColorBkg);
+    }
+
+    if(isPtVisible)
+        draw_seg_pt(ps);
+
+    //
+    switch(myValue) {
+        case 0:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_e(ps);
+            draw_seg_f(ps);
+            break;
+            //
+        case 1:
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            break;
+            //
+        case 2:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_d(ps);
+            draw_seg_e(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 3:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 4:
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            draw_seg_f(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 5:
+            draw_seg_a(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_f(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 6:
+            draw_seg_a(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_e(ps);
+            draw_seg_f(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 7:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            break;
+            //
+        case 8:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_e(ps);
+            draw_seg_f(ps);
+            draw_seg_g(ps);
+            break;
+            //
+        case 9:
+            draw_seg_a(ps);
+            draw_seg_b(ps);
+            draw_seg_c(ps);
+            draw_seg_d(ps);
+            draw_seg_f(ps);
+            draw_seg_g(ps);
+            break;
+    }
+
+}
+//-----------------------------------------
+void DigitLed::setValue(char _value)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    if(myValue==_value)
+        return;
+
+
+    if(_value >9)
+        _value=9;
+
+    myValue=_value;
+
+    this->draw();
+}
+//-----------------------------------------
+void DigitLed::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//-----------------------------------------
+void DigitLed::setPtVisible(bool _state)
+{
+    if(isPtVisible==_state)
+        return;
+
+    isPtVisible=_state;
+}
+//-----------------------------------------
+void DigitLed::draw_seg_a(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myIncX,
+                                  myY,
+                                  myX+7*myIncX,
+                                  myY+myIncY,
+                                  myColorSeg);
+}
+//------------------------------------------
+void DigitLed::draw_seg_b(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+6*myIncX,
+                                  myY,
+                                  myX+7*myIncX,
+                                  myY+5*myIncY,
+                                  myColorSeg);
+}
+//-------------------------------------------
+void DigitLed::draw_seg_c(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+6*myIncX,
+                                  myY+8*myIncY,
+                                  myX+7*myIncX,
+                                  myY+myHeight,
+                                  myColorSeg);
+}
+//--------------------------------------------
+void DigitLed::draw_seg_d(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myIncX,
+                                  myY+myHeight-myIncY,
+                                  myX+7*myIncX,
+                                  myY+myHeight,
+                                  myColorSeg);
+}
+//-----------------------------------------
+void DigitLed::draw_seg_e(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myIncX,
+                                  myY+myHeight-5*myIncY,
+                                  myX+2*myIncX,
+                                  myY+myHeight,
+                                  myColorSeg);
+}
+//-----------------------------------------
+void DigitLed::draw_seg_f(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myIncX,
+                                  myY,
+                                  myX+2*myIncX,
+                                  myY+5*myIncY,
+                                  myColorSeg);
+}
+//------------------------------------------
+void DigitLed::draw_seg_g(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myIncX,
+                                  myY+6*myIncY,
+                                  myX+7*myIncX,
+                                  myY+7*myIncY,
+                                  myColorSeg);
+}
+//------------------------------------------
+void DigitLed::draw_seg_pt(PicasoSerial* ps)
+{
+    if(ps!=0)
+        ps->draw_filled_rectangle(myX+myWidth-myIncX,
+                                  myY+myHeight-myIncY,
+                                  myX+myWidth,
+                                  myY+myHeight,
+                                  myColorSeg);
+}
+//-------------------------------------------
+Digit3Led::Digit3Led(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,
+                     UINT8 _resolution,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,108,52,YELLOW,_isVisible)
+{
+    myColorBkg=YELLOW;
+    myColorSeg=RED;
+    myValue=0.0;
+    myResolution=_resolution;
+
+    myDigitLedCentaine= new DigitLed(mScreen,_id,_x,_y,false,true);
+    myDigitLedDizaine=new DigitLed(mScreen,_id,_x+36,_y,false,true);
+    myDigitLedUnite= new DigitLed(mScreen,_id,_x+36+36,_y,false,true);
+
+
+    myElementType= OBJ_DIGITAL_3_LED;
+    myElementState=DIGIT_LED_STATE_ON;
+
+    myScreen->addObj((ObjetHeader*) this);
+}
+//------------------------------------------
+Digit3Led::~Digit3Led(void)
+{
+    delete(myDigitLedCentaine);
+    myDigitLedCentaine=0;
+    delete(myDigitLedDizaine);
+    myDigitLedDizaine=0;
+    delete(myDigitLedUnite);
+    myDigitLedUnite=0;
+}
+//------------------------------------------
+void Digit3Led::draw(void)
+{
+    if(myElementIsVisible==false)
+        return;
+
+    myDigitLedCentaine->draw();
+    myDigitLedDizaine->draw();
+    myDigitLedUnite->draw();
+
+}
+//------------------------------------------
+void Digit3Led::setInvisible(bool _state)
+{
+    // element devient invisible
+    if(_state==true) {
+        if(myElementIsVisible==false)
+            return;
+
+        myElementIsVisible=false;
+
+        Color c= myScreen->getColorBkg();
+
+        ps=myScreen->getPicasoSerial();
+
+        if(ps!=0) {
+            ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
+        }
+    }
+
+    // element devient visible
+    else {
+        myElementIsVisible=true;
+
+
+        this->draw();
+    }
+}
+//-----------------------------------------
+void Digit3Led::setValue(float _value)
+{
+    if(myElementIsVisible==false)
+        return;
+    //
+    if(myValue==_value)
+        return;
+    //
+    myValue=_value;
+    UINT16 temp=0;
+
+    char centaine=0;
+    char dizaine=0;
+    char unite=0;
+
+    //the Pt?
+    switch(myResolution) {
+        case 1:     //xxx
+            temp=(UINT16)_value;
+            myDigitLedCentaine->setPtVisible(false);
+            myDigitLedDizaine->setPtVisible(false);
+            myDigitLedUnite->setPtVisible(false);
+            break;
+            //
+        case 10:    //xx.x
+            temp=(UINT16)(_value*10);
+            myDigitLedCentaine->setPtVisible(false);
+            myDigitLedDizaine->setPtVisible(true);
+            myDigitLedUnite->setPtVisible(false);
+            break;
+            //
+        case 100:   //x.xx
+            temp=(UINT16)(_value*100);
+            myDigitLedCentaine->setPtVisible(true);
+            myDigitLedDizaine->setPtVisible(false);
+            myDigitLedUnite->setPtVisible(false);
+            break;
+
+        default:
+            break;
+    }
+    //
+    if(temp <100) {
+        centaine=0;
+        myDigitLedCentaine->setInvisible(true);
+    } else {
+        myDigitLedCentaine->setInvisible(false);
+        centaine=(char)(temp/100);
+        temp=temp-(centaine*100);
+    }
+    //
+    if(temp <10) {
+        dizaine=0;
+    } else {
+        dizaine=(char)(temp/10);
+        temp=temp-(dizaine*10);
+    }
+    //
+    unite=(char)temp;
+
+    myDigitLedCentaine->setValue(centaine);
+    myDigitLedDizaine->setValue(dizaine);
+    myDigitLedUnite->setValue(unite);
+
+    this->draw();
+}
+//------------------------------------------
+void Digit3Led::setColorBkg(Color _colorBkg)
+{
+    if(myColorBkg==_colorBkg)
+        return;
+
+    myColorBkg=_colorBkg;
+    myDigitLedCentaine->setColorBkg(_colorBkg);
+    myDigitLedDizaine->setColorBkg(_colorBkg);
+    myDigitLedUnite->setColorBkg(_colorBkg);
+
+    this->draw();
+}
+//------------------------------------------
+void Digit3Led::setColorSeg(Color _colorSeg)
+{
+    if(myColorSeg==_colorSeg)
+        return;
+
+    myColorSeg=_colorSeg;
+    myDigitLedCentaine->setColorSeg(_colorSeg);
+    myDigitLedDizaine->setColorSeg(_colorSeg);
+    myDigitLedUnite->setColorSeg(_colorSeg);
+
+    this->draw();
+}
+//-----------------------------------------
\ No newline at end of file