NewAskSin
 All Classes Files Functions Variables Groups Pages
StatusLed.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin driver implementation
3 // 2013-08-03 <trilu@gmx.de> Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 //- -----------------------------------------------------------------------------------------------------------------------
5 //- AskSin status led functions -------------------------------------------------------------------------------------------
6 //- with a lot of support from martin876 at FHEM forum
7 //- -----------------------------------------------------------------------------------------------------------------------
8 
9 #ifndef _LD_H
10 #define _LD_H
11 
12 #include "HAL.h"
13 
14 
15 struct s_blinkPattern { // struct for defining the blink pattern
16  uint8_t len :3; // length of pattern string
17  uint8_t dur :3; // how often the pattern has to be repeated, 0 for endless
18  uint8_t led0 :1; // red
19  uint8_t led1 :1; // green, if you like orange, set led0 and led1 to one
20  uint8_t pat[6]; // the pattern it self, pattern starts always with the on time, followed by off time.
21 }; // time is given in 10ms steps
22 
23 enum ledStat {nothing, pairing, pair_suc, pair_err, send, ack, noack, bat_low, defect, welcome, key_long};
24 
25 // we need two type of blink patterns, one with only one led and a second one with a bi color led
26  const struct s_blinkPattern sPairing[2] = { // 1; define pairing string
27  {2, 0, 1, 0, {50, 50,} },
28  {2, 0, 1, 1, {50, 50,} },
29  };
30  const struct s_blinkPattern sPair_suc[2] = { // 2; define pairing success
31  {2, 1, 1, 0, {200, 0,} },
32  {2, 1, 0, 1, {200, 0,} },
33  };
34  const struct s_blinkPattern sPair_err[2] = { // 3; define pairing error
35  {2, 3, 1, 0, {5, 10,} },
36  {2, 1, 1, 0, {200, 0,} },
37  };
38  const struct s_blinkPattern sSend[2] = { // 4; define send indicator
39  {2, 1, 1, 0, {5, 1,} },
40  {2, 1, 1, 1, {5, 1,} },
41  };
42  const struct s_blinkPattern sAck[2] = { // 5; define ack indicator
43  {0, 0, 0, 0, {0, 0,} },
44  {2, 1, 0, 1, {5, 1,} },
45  };
46  const struct s_blinkPattern sNoack[2] = { // 6; define no ack indicator
47  {0, 0, 0, 0, {0, 0,} },
48  {2, 1, 1, 0, {10, 1,} },
49  };
50  const struct s_blinkPattern sBattLow[2] = { // 7; define battery low indicator
51  {6, 3, 1, 0, {50, 10, 10, 10, 10, 100} },
52  {6, 3, 1, 0, {50, 10, 10, 10, 10 ,100} },
53  };
54  const struct s_blinkPattern sDefect[2] = { // 8; define defect indicator
55  {6, 3, 1, 0, {10, 10, 10, 10, 10, 100} },
56  {6, 3, 1, 0, {10, 10, 10, 10, 10, 100} },
57  };
58  const struct s_blinkPattern sWelcome[2] = { // 9; define welcome indicator
59  {6, 1, 1, 0, {10, 10, 50, 10, 50, 100} },
60  {6, 1, 0, 1, {10, 10, 50, 10, 50, 100} },
61  };
62  const struct s_blinkPattern sKeyLong[2] = { // 10; key long indicator
63  {2, 0, 1, 0, {20, 20, } },
64  {2, 0, 1, 0, {20, 20, } },
65  };
66 
67 
68 
69 class LD {
70  friend class AS;
71 
72  public: //---------------------------------------------------------------------------------------------------------
73  uint8_t active :1; // something active
74 
75  protected: //---------------------------------------------------------------------------------------------------------
76  private: //---------------------------------------------------------------------------------------------------------
77 
78  class AS *pHM; // pointer to main class for function calls
79 
80  const struct s_blinkPattern *blinkPtr; // pointer to blink struct
81 
82  uint8_t bLeds :2; // 1 or 2 leds
83  uint8_t lCnt :3; // counter for positioning inside of blink string
84  uint8_t dCnt :3; // duration counter
85 
86  public: //---------------------------------------------------------------------------------------------------------
87  void init(uint8_t leds, AS *ptrMain);
88  void set(ledStat stat);
89  void blinkRed(void);
90 
91  protected: //---------------------------------------------------------------------------------------------------------
92  private: //---------------------------------------------------------------------------------------------------------
93  LD();
94  void poll(void);
95 
96 };
97 
98 
99 #endif
Main class for implementation of the AskSin protocol stack. Every device needs exactly one instance o...
Definition: AS.h:39
Definition: StatusLed.h:69
Definition: StatusLed.h:15