1 #ifndef _LEDCtrl_LEDCtrl_h 2 #define _LEDCtrl_LEDCtrl_h 3 4 #include <CtrlLib/CtrlLib.h> 5 6 using namespace Upp; 7 8 9 // Definition of one LED character 10 // 8 int values are necessary 11 #define LED_VALUES_PER_CHARACTER 7 12 13 class LEDCtrl : public Ctrl { 14 public: 15 typedef LEDCtrl CLASSNAME; 16 LEDCtrl(); 17 LEDCtrl( String Value, 18 int OneLEDSize = 2, // 2 pixels for one LED 19 Color FgLightOnColor = LtRed, 20 Color FgLightOffColor = Black, 21 Color BgColor = Black ); 22 ~LEDCtrl() ; 23 24 virtual void Paint(Draw& w); 25 26 LEDCtrl& SetString( String Value ) ; 27 LEDCtrl& SetFgLightOnColor( Color Value ) ; 28 LEDCtrl& SetFgLightOffColor( Color Value ) ; 29 LEDCtrl& SetBgColor( Color Value ) ; 30 LEDCtrl& SetStringSize( int CharactersNumber ) ; 31 LEDCtrl& SetLEDSize( int LEDSize ) ; 32 LEDCtrl& SetPosZ( int X, int Y ) ; 33 34 protected : 35 LEDCtrl& SetDisplayedString( String Value ) ; 36 37 private : 38 VectorMap<String, Array<int> > LEDSet ; 39 Array<int> UnknownLED ; 40 Color FgLightOnColor ; 41 Color FgLightOffColor ; 42 Color BgColor ; 43 String DisplayedString ; 44 int OneLEDSize ; 45 int CharNumber ; 46 int PosX ; 47 int PosY ; 48 49 void InitializeLEDSet( void ) ; 50 Array<bool> DecomposeLine( int ) ; 51 }; 52 53 54 55 class AnimatedLEDCtrl : public LEDCtrl { 56 public: 57 typedef AnimatedLEDCtrl CLASSNAME; 58 typedef enum { 59 LED_SLIDING = 0, 60 LED_BLINKING 61 } LEDAnimationType ; 62 63 AnimatedLEDCtrl(); 64 AnimatedLEDCtrl( String Value, 65 LEDAnimationType Type = LED_SLIDING, 66 int MaxCharNumber = 20, 67 int Timer = 1000, // 1 second 68 int OneLEDSize = 2, // 2 pixels for one LED 69 Color FgLightOnColor = LtRed, 70 Color FgLightOffColor = Black, 71 Color BgColor = Black ); 72 ~AnimatedLEDCtrl() ; 73 74 AnimatedLEDCtrl& SetString( String Value ) ; SetTimer(int _Timer)75 AnimatedLEDCtrl& SetTimer(int _Timer) {Timer = _Timer; return *this;}; // In ms 76 AnimatedLEDCtrl& SetAnimationType( LEDAnimationType Type ) ; SetMaxCharNumber(int _MaxCharNumber)77 AnimatedLEDCtrl& SetMaxCharNumber(int _MaxCharNumber) {MaxCharNumber = _MaxCharNumber; return *this;}; 78 79 private : 80 String TheDisplayedString ; 81 String TheSourceString ; 82 int DisplayedStringLength ; 83 int MaxCharNumber ; 84 int CharIndex ; 85 int Timer ; 86 LEDAnimationType Type ; 87 88 void DoSliding( void ) ; 89 void DoBlinking( void ) ; 90 }; 91 92 93 #endif 94 95