Formatovani, drobne korektury.

This commit is contained in:
Pavel Brychta 2020-03-24 08:44:11 +01:00
parent 3ff15595af
commit 4c8af5fd1b
4 changed files with 98 additions and 110 deletions

View File

@ -12,7 +12,7 @@
"type": "git",
"url": "http://git.xpablo.cz/xPablo.cz/SigLed"
},
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=SigLED
version=1.0.0
version=1.0.1
author=Pavel Brychta
maintainer=Pavel Brychta
sentence=Handle signalling LED easily

View File

@ -4,6 +4,7 @@
SigLED::SigLED(int pin, int ledon, int ledoff)
{
_pin = pin;
_ledon = ledon;
_ledoff = ledoff;
@ -12,10 +13,8 @@ SigLED::SigLED(int pin, int ledon, int ledoff)
void SigLED::rtLed(void)
{
switch (_state)
{
case LS_RUN:
{
switch (_state) {
case LS_RUN: {
uint8_t instr;
if (NULL != _signal)
@ -24,8 +23,7 @@ void SigLED::rtLed(void)
instr = pgm_read_byte(_pptr);
else
instr = LEDS_STOP;
switch (instr & 0xc0)
{
switch (instr & 0xc0) {
case LEDS_ONFOR:
digitalWrite(_pin, _ledon);
_timer = 10ul * ((instr & 0x3F) + 1);
@ -52,8 +50,7 @@ void SigLED::rtLed(void)
case LS_WAIT:
--_timer;
if (0 == _timer)
{
if (0 == _timer) {
_state = LS_RUN;
++_ptr;
++_pptr;
@ -87,6 +84,7 @@ void SigLED::set(const uint8_t *signal)
void SigLED::set(PGM_P signal)
{
noInterrupts();
_psignal = signal;
_pptr = _psignal;
@ -95,7 +93,7 @@ void SigLED::set(PGM_P signal)
interrupts();
}
void SigLED::start()
void SigLED::start(void)
{
noInterrupts();

View File

@ -25,13 +25,7 @@
#include <Ticker.h>
#include <pgmspace.h>
typedef struct
{
}ledsignal_t;
enum
{
enum {
LEDS_ONFOR = 0x00, // rozsviti LED na delku, ktera je uvedena v nizsich 6-ti bitech (+1) [100ms], 0 znamena, ze se rozsviti na 100ms
LEDS_OFFFOR = 0x40,
LEDS_STOP = 0x80,
@ -40,9 +34,8 @@ enum
class SigLED
{
// typedef void (LED::*runtime)(void);
protected:
protected:
int _pin; // pin, na kterem je LED pripojena
Ticker _handler; // obsluha LED signalizace
const uint8_t *_signal; // ukazatel na vzor signalizace
@ -52,20 +45,17 @@ class SigLED
uint32_t _timer; // casovani
int _ledon;
int _ledoff;
enum
{
enum {
LS_IDLE, // klid, cekame na zmenu (zavolani set, nebo start)
LS_RUN, // bezi automat
LS_WAIT, // cekame v automatu
}_state; // stav automatu
public:
} _state; // stav automatu
public:
SigLED(int pin, int ledon, int ledoff);
void begin(void);
void set(const uint8_t *signal);
// void set(const __FlashStringHelper *signal);
void set(PGM_P signal);
void start();
// static void lh(void *ptr);
void start(void);
static void lh(SigLED *ptr);
void rtLed(void); // vykonna metoda
};