Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Added a boolean to disable blinky ticker when a blink pattern is posted #73

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Ticker timer;
// LED Output
DigitalOut led1(LED1);

bool doing_blink = 0;

/*
* The Led contains one property (pattern) and a function (blink).
* When the function blink is executed, the pattern is read, and the LED
Expand Down Expand Up @@ -155,12 +157,14 @@ class LedResource {

void do_blink(std::vector<uint32_t>* pattern, uint16_t position) {
// blink the LED
doing_blink = 1;
led1 = !led1;

// up the position, if we reached the end of the vector
if (position >= pattern->size()) {
// free memory, and exit this function
delete pattern;
doing_blink = 0;
return;
}

Expand Down Expand Up @@ -250,7 +254,7 @@ void trace_printer(const char* str) {
// Status indication
Ticker status_ticker;
DigitalOut status_led(LED1);
void blinky() { status_led = !status_led; }
void blinky() { status_led = doing_blink ? status_led : !status_led; }


// Entry point to the program
Expand Down