handle update even when not cycling
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include "BluefruitConfig.h"
|
||||
|
||||
#define REQUIRE_SERIAL false
|
||||
#define BT_SCAN_MS 100
|
||||
#define BT_SCAN_MS 50
|
||||
#define MIN_FIRMWARE "0.7.0"
|
||||
#define FACTORYRESET true
|
||||
#define DIM_FACTOR 80
|
||||
@@ -112,7 +112,7 @@ void BleUartRX(char payload[], uint16_t payload_len){
|
||||
}
|
||||
// run whichever command was requested
|
||||
if (cmd_byte == 's'){
|
||||
setWait(data, data_len);
|
||||
set_wait(data, data_len);
|
||||
} else if (cmd_byte == 'p') {
|
||||
set_pattern(data, data_len);
|
||||
} else if (cmd_byte == 'a') {
|
||||
@@ -153,6 +153,22 @@ class Strip {
|
||||
pixel.show();
|
||||
}
|
||||
|
||||
void update(void){
|
||||
unsigned long now = millis();
|
||||
if (now - wait > last){
|
||||
last = now;
|
||||
offset += 1;
|
||||
if (offset == num_pixels){
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
if (pattern == 'o'){
|
||||
off();
|
||||
} else {
|
||||
rainbow();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void rainbow(void){
|
||||
uint8_t r = 255;
|
||||
@@ -198,28 +214,11 @@ class Strip {
|
||||
}
|
||||
pixel.show();
|
||||
}
|
||||
|
||||
public:
|
||||
void update(void){
|
||||
unsigned long now = millis();
|
||||
if (now - wait > last){
|
||||
last = now;
|
||||
if (pattern == 'o'){
|
||||
off();
|
||||
} else {
|
||||
rainbow();
|
||||
}
|
||||
offset += 1;
|
||||
if (offset == num_pixels){
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
volatile Strip strip = Strip(6, 144);
|
||||
|
||||
void setWait(char data[], uint16_t len){
|
||||
void set_wait(char data[], uint16_t len){
|
||||
String wait = "";
|
||||
for (uint16_t index=0; index<len; index++){
|
||||
wait += (char)data[index];
|
||||
@@ -258,6 +257,7 @@ void set_amplitude(char data[], uint16_t len){
|
||||
}
|
||||
|
||||
void do_rx_send(void){
|
||||
/* if to_rx is set to a message, try to send it over bluetooth */
|
||||
if (to_rx == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user