@@ -39,9 +39,9 @@ No heart beat indicates the program is stuck or blocked.
3939
4040Since version 0.3.0 a derived class ** HeartBeatSL** is added which can
4141send specific diagnostic or error patterns.
42- A pattern exists of 1 to 7 HIGH pulses separated by a fixed length LOW pulse.
42+ A pattern exists of 1 to 15 HIGH pulses separated by a fixed length LOW pulse.
4343The length of the HIGH pulses can be coded with characters S and L (short and long).
44- An example of an SOS pattern is "SLS ".
44+ An example of an SOS alike pattern is "SSSLLLSSS ".
4545The unit length of the base pulse is determined by the frequency.
4646
4747If a pattern is started it cannot be overwritten until it is either ready
@@ -65,7 +65,8 @@ If one wants to repeat a pattern the application has to repeat the call.
6565
6666To keep patterns recognizable one can exaggerate the difference in length.
6767121 is harder to differentiate than 131, a rule of thumb is to use multiples
68- of 3 (1, 3, 6 and 9) as length as it allows 4 length levels.
68+ of 3 (1, 3, 6 and 9) as length as it allows 4 length levels. Or use three
69+ levels (1 5 9) to keep it recognizeable.
6970
7071Many applications only need 2 lengths, short and long (BIOS alike),
7172but the interface allows more.
@@ -89,7 +90,6 @@ For more complex patterns, please check my pulsePattern library.
8990#include " HeartBeat.h"
9091```
9192
92-
9393### HeartBeat
9494
9595The interface of the base ** HeartBeat** consists of the following functions:
@@ -98,25 +98,33 @@ The interface of the base **HeartBeat** consists of the following functions:
9898- ** void begin(uint8_t pin, float frequency = 1.0)** to configure the HeartBeat.
9999The output pin should be unique.
100100The default frequency is 1.0.
101+ - ** void beat()** the worker; this function checks if the HeartBeat is enabled
102+ and the OUTPUT (LED) must be toggled.
103+ It must be called as often as possible to keep a steady pace,
104+ preferably at least 4 times the given frequency.
105+ Not calling ** beat()** effectively stops the heartbeat.
106+
107+
108+ ### Frequency and duty cycle
109+
101110- ** void setFrequency(float frequency = 1.0)** change the frequency of the pulsing.
102111The default frequency is 1.0.
103112Setting the frequency will not enable or disable the HeartBeat.
104113The frequency must be > 0.001 otherwise it will be constrained to 0.001.
105114On the upper side values beyond 10 Hz are hard for humans but are allowed.
115+ - ** float getFrequency()** returns set frequency (or constrained value).
106116- ** void setDutyCycle(float dutyCycle = 50)** duty cycle in percentage time HIGH.
107117The default duty cycle = 50 %.
108118The duty cycle must be between 0.0 and 100.0 %.
109119A value of 0 will put the heartbeat effectively off.
110- - ** float getFrequency()** returns set frequency (or constrained value).
111120- ** float getDutyCycle()** returns set duty cycle (or constrained value).
121+
122+
123+ ### Status
124+
112125- ** void enable()** enables the heart beat.
113126- ** void disable()** disable the heart beat. Will switch the pin to LOW.
114127- ** bool isEnabled()** returns true if the heart beat is enabled (running).
115- - ** void beat()** the worker; this function checks if the HeartBeat is enabled
116- and the OUTPUT (LED) must be toggled.
117- It must be called as often as possible to keep a steady pace,
118- preferably at least 4 times the given frequency.
119- Not calling ** beat()** effectively stops the heartbeat.
120128- ** uint8_t getState()** returns the state of the heartbeat.
121129Useful for debugging.
122130
@@ -128,7 +136,7 @@ The interface of **HeartBeatSL** adds of the following functions to **HeartBeat*
128136- ** HeartBeatSL()** constructor.
129137- ** bool code(const char \* str)** executes the pattern ONE time.
130138Repeating the pattern means repeating the call.
131- The max supported string length is ** 7 ** as pattern is stored in a byte.
139+ The max supported string length is ** 15 ** as pattern is stored in a byte.
132140- ** void codeOff()** explicitly stops the pattern. Forced stop.
133141- ** bool codeCompleted()** returns true if pattern is executed completely.
134142
@@ -150,7 +158,10 @@ void setup()
150158void loop ()
151159{
152160 HB.beat();
153- if (some_error) HB.code("LSSLSL"); // ==> L HHHHHH L H L H L HHH
161+ if (some_error)
162+ {
163+ HB.code("LSSLSL"); // ==> L HHHHHH L H L H L HHHHHH L H L HHH
164+ }
154165
155166 // other code here
156167}
@@ -167,7 +178,6 @@ void someOtherfunction()
167178Note: a code will be executed, even if the HB is disabled.
168179
169180
170-
171181### HeartBeatDiag
172182
173183The interface of ** HeartBeatDiag** adds of the following functions:
@@ -242,18 +252,18 @@ See examples
242252#### Should
243253
244254- add examples
245- - ACS712 current sensor
246255 - buffer % filled (e.g. stream)
247256
248257#### Could
249258
259+ - HBSL: add R at the end for repeat?
250260- investigate a pattern recognizer (fun)
251261 - e.g. with an LDR or lux sensor.
252- - HeartBeatSL
253- - extend code length to 16 (bit)?
262+ - send Morse characters?
254263
255264#### Wont
256265
266+ - add ** setColor(r, g, b)** for 8 colour RGBheartbeat (no PWM)
257267
258268## Support
259269
0 commit comments