Skip to content

Commit

Permalink
Add constants
Browse files Browse the repository at this point in the history
  • Loading branch information
nazt committed Mar 18, 2016
1 parent 918e9bd commit 6dae08e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CMMCEasy.h
Expand Up @@ -4,13 +4,15 @@
#endif
#include <Arduino.h>
#include "./CMMC_Blink.hpp"
#include "./CMMC_Interval.hpp"

class CMMCEasy
{
private:

public:
CMMC_Blink blinker;
CMMC_Interval interval;

CMMCEasy() {
// _ticker1 = new Ticker;
Expand Down
34 changes: 28 additions & 6 deletions CMMC_Blink.hpp
Expand Up @@ -5,22 +5,37 @@

class CMMC_Blink
{
private:
unsigned int _ledPin = 254;
Ticker *_ticker;

public:

typedef enum {
BLINK_TYPE_TICKER = 1,
BLINK_TYPE_INTERVAL,
} blink_t;

static const blink_t TYPE_TICKER = BLINK_TYPE_TICKER;
static const blink_t TYPE_INTERVAL = BLINK_TYPE_INTERVAL;


CMMC_Blink init(blink_t type = BLINK_TYPE_TICKER) {
if (type == BLINK_TYPE_TICKER) {
this->_ticker = new Ticker;
}
_initialized = true;
return *this;
}

void setPin(uint8_t pin) {
pinMode(_ledPin, OUTPUT);
digitalWrite(_ledPin, LOW);
_ledPin = pin;
}

CMMC_Blink() {
this->_ticker = new Ticker;
CMMC_Blink(blink_t type = BLINK_TYPE_TICKER) {
_type = type;
};

CMMC_Blink(Ticker *ticker) {
_initialized = true;
this->_ticker = ticker;
};

Expand All @@ -30,6 +45,7 @@ class CMMC_Blink
}

void blink(int ms) {
if (!_initialized) return;
if (_ledPin == 254) return;
static int _pin = this->_ledPin;
this->_ticker->detach();
Expand All @@ -41,6 +57,12 @@ class CMMC_Blink
this->_ticker->attach_ms(ms, lambda);
}

private:
unsigned int _ledPin = 254;
Ticker *_ticker;
blink_t _type;
bool _initialized = false;

};


Expand Down
9 changes: 6 additions & 3 deletions platformio.ini
Expand Up @@ -17,8 +17,11 @@
# Automatic targets - enable auto-uploading
# targets = upload

[env:espresso_lite_v1]
[env:espresso_lite_v2]
platform = espressif
framework = arduino
board = espresso_lite_v1
extra_script = extra_script.py
board = espresso_lite_v2
upload_resetmethod = ck
; upload_speed = 230400
upload_speed = 460800
; extra_script = extra_script.py

0 comments on commit 6dae08e

Please sign in to comment.