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/
Diff: GraphicLed.cpp
- Revision:
- 1:a74e42cf52b2
diff -r 65fd8b1cbf86 -r a74e42cf52b2 GraphicLed.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GraphicLed.cpp Sun Apr 05 13:54:48 2015 +0000 @@ -0,0 +1,96 @@ +#include "GraphicLed.h" + +GraphicLed::GraphicLed(Screen* mScreen,UINT16 _xc,UINT16 _yc,UINT16 _radius, + Color _colorOn,Color _colorOff,State _state): + Widget(mScreen,0,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_colorOn) +{ + myColorOn=_colorOn; + myColorOff=_colorOff; + myRadius=_radius; + myCenterX=_xc; + myCenterY=_yc; + + myState=_state; + myType=OBJ_LED; + myScreen->addWidget((Widget*) this); +} +//--------------------------------------- +GraphicLed::~GraphicLed(void) +{ +} +//--------------------------------------- +void GraphicLed::draw(void) +{ + if(myIsVisible==false) + return; + + UINT16 state=getState(); + + 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); + ps=0; + } + return; + // + case LED_STATE_OFF: + if(ps!=0) { + ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOff); + ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK); + ps=0; + } + return; + // + default: + break; + } + +} +//--------------------------------------- +void GraphicLed::setInvisible(bool _state) +{ + // element devient invisible + if(_state==true) { + if(myIsVisible==false) + return; + + myIsVisible=false; + + Color c= myScreen->getColorBkg(); + + PicasoSerial* ps=0; + ps=myScreen->getPicasoSerial(); + + if(ps!=0) { + ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c); + } + ps=0; + } + + // element devient visible + else { + myIsVisible=true; + + + this->draw(); + } +} +//--------------------------------------- +void GraphicLed::setState(State _state) +{ + if(myIsVisible==false) + return; + + if(myState==_state) + return; + + myState=_state; + + this->draw(); +} \ No newline at end of file