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/
GraphicLed.cpp@1:a74e42cf52b2, 2015-04-05 (annotated)
- Committer:
- adelino
- Date:
- Sun Apr 05 13:54:48 2015 +0000
- Revision:
- 1:a74e42cf52b2
PicasoLib version 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adelino | 1:a74e42cf52b2 | 1 | #include "GraphicLed.h" |
adelino | 1:a74e42cf52b2 | 2 | |
adelino | 1:a74e42cf52b2 | 3 | GraphicLed::GraphicLed(Screen* mScreen,UINT16 _xc,UINT16 _yc,UINT16 _radius, |
adelino | 1:a74e42cf52b2 | 4 | Color _colorOn,Color _colorOff,State _state): |
adelino | 1:a74e42cf52b2 | 5 | Widget(mScreen,0,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_colorOn) |
adelino | 1:a74e42cf52b2 | 6 | { |
adelino | 1:a74e42cf52b2 | 7 | myColorOn=_colorOn; |
adelino | 1:a74e42cf52b2 | 8 | myColorOff=_colorOff; |
adelino | 1:a74e42cf52b2 | 9 | myRadius=_radius; |
adelino | 1:a74e42cf52b2 | 10 | myCenterX=_xc; |
adelino | 1:a74e42cf52b2 | 11 | myCenterY=_yc; |
adelino | 1:a74e42cf52b2 | 12 | |
adelino | 1:a74e42cf52b2 | 13 | myState=_state; |
adelino | 1:a74e42cf52b2 | 14 | myType=OBJ_LED; |
adelino | 1:a74e42cf52b2 | 15 | myScreen->addWidget((Widget*) this); |
adelino | 1:a74e42cf52b2 | 16 | } |
adelino | 1:a74e42cf52b2 | 17 | //--------------------------------------- |
adelino | 1:a74e42cf52b2 | 18 | GraphicLed::~GraphicLed(void) |
adelino | 1:a74e42cf52b2 | 19 | { |
adelino | 1:a74e42cf52b2 | 20 | } |
adelino | 1:a74e42cf52b2 | 21 | //--------------------------------------- |
adelino | 1:a74e42cf52b2 | 22 | void GraphicLed::draw(void) |
adelino | 1:a74e42cf52b2 | 23 | { |
adelino | 1:a74e42cf52b2 | 24 | if(myIsVisible==false) |
adelino | 1:a74e42cf52b2 | 25 | return; |
adelino | 1:a74e42cf52b2 | 26 | |
adelino | 1:a74e42cf52b2 | 27 | UINT16 state=getState(); |
adelino | 1:a74e42cf52b2 | 28 | |
adelino | 1:a74e42cf52b2 | 29 | PicasoSerial* ps=0; |
adelino | 1:a74e42cf52b2 | 30 | ps=myScreen->getPicasoSerial(); |
adelino | 1:a74e42cf52b2 | 31 | |
adelino | 1:a74e42cf52b2 | 32 | switch(state) { |
adelino | 1:a74e42cf52b2 | 33 | // |
adelino | 1:a74e42cf52b2 | 34 | case LED_STATE_ON: |
adelino | 1:a74e42cf52b2 | 35 | if(ps!=0) { |
adelino | 1:a74e42cf52b2 | 36 | ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOn); |
adelino | 1:a74e42cf52b2 | 37 | ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK); |
adelino | 1:a74e42cf52b2 | 38 | ps=0; |
adelino | 1:a74e42cf52b2 | 39 | } |
adelino | 1:a74e42cf52b2 | 40 | return; |
adelino | 1:a74e42cf52b2 | 41 | // |
adelino | 1:a74e42cf52b2 | 42 | case LED_STATE_OFF: |
adelino | 1:a74e42cf52b2 | 43 | if(ps!=0) { |
adelino | 1:a74e42cf52b2 | 44 | ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOff); |
adelino | 1:a74e42cf52b2 | 45 | ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK); |
adelino | 1:a74e42cf52b2 | 46 | ps=0; |
adelino | 1:a74e42cf52b2 | 47 | } |
adelino | 1:a74e42cf52b2 | 48 | return; |
adelino | 1:a74e42cf52b2 | 49 | // |
adelino | 1:a74e42cf52b2 | 50 | default: |
adelino | 1:a74e42cf52b2 | 51 | break; |
adelino | 1:a74e42cf52b2 | 52 | } |
adelino | 1:a74e42cf52b2 | 53 | |
adelino | 1:a74e42cf52b2 | 54 | } |
adelino | 1:a74e42cf52b2 | 55 | //--------------------------------------- |
adelino | 1:a74e42cf52b2 | 56 | void GraphicLed::setInvisible(bool _state) |
adelino | 1:a74e42cf52b2 | 57 | { |
adelino | 1:a74e42cf52b2 | 58 | // element devient invisible |
adelino | 1:a74e42cf52b2 | 59 | if(_state==true) { |
adelino | 1:a74e42cf52b2 | 60 | if(myIsVisible==false) |
adelino | 1:a74e42cf52b2 | 61 | return; |
adelino | 1:a74e42cf52b2 | 62 | |
adelino | 1:a74e42cf52b2 | 63 | myIsVisible=false; |
adelino | 1:a74e42cf52b2 | 64 | |
adelino | 1:a74e42cf52b2 | 65 | Color c= myScreen->getColorBkg(); |
adelino | 1:a74e42cf52b2 | 66 | |
adelino | 1:a74e42cf52b2 | 67 | PicasoSerial* ps=0; |
adelino | 1:a74e42cf52b2 | 68 | ps=myScreen->getPicasoSerial(); |
adelino | 1:a74e42cf52b2 | 69 | |
adelino | 1:a74e42cf52b2 | 70 | if(ps!=0) { |
adelino | 1:a74e42cf52b2 | 71 | ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c); |
adelino | 1:a74e42cf52b2 | 72 | } |
adelino | 1:a74e42cf52b2 | 73 | ps=0; |
adelino | 1:a74e42cf52b2 | 74 | } |
adelino | 1:a74e42cf52b2 | 75 | |
adelino | 1:a74e42cf52b2 | 76 | // element devient visible |
adelino | 1:a74e42cf52b2 | 77 | else { |
adelino | 1:a74e42cf52b2 | 78 | myIsVisible=true; |
adelino | 1:a74e42cf52b2 | 79 | |
adelino | 1:a74e42cf52b2 | 80 | |
adelino | 1:a74e42cf52b2 | 81 | this->draw(); |
adelino | 1:a74e42cf52b2 | 82 | } |
adelino | 1:a74e42cf52b2 | 83 | } |
adelino | 1:a74e42cf52b2 | 84 | //--------------------------------------- |
adelino | 1:a74e42cf52b2 | 85 | void GraphicLed::setState(State _state) |
adelino | 1:a74e42cf52b2 | 86 | { |
adelino | 1:a74e42cf52b2 | 87 | if(myIsVisible==false) |
adelino | 1:a74e42cf52b2 | 88 | return; |
adelino | 1:a74e42cf52b2 | 89 | |
adelino | 1:a74e42cf52b2 | 90 | if(myState==_state) |
adelino | 1:a74e42cf52b2 | 91 | return; |
adelino | 1:a74e42cf52b2 | 92 | |
adelino | 1:a74e42cf52b2 | 93 | myState=_state; |
adelino | 1:a74e42cf52b2 | 94 | |
adelino | 1:a74e42cf52b2 | 95 | this->draw(); |
adelino | 1:a74e42cf52b2 | 96 | } |