mirror of
https://gitlab.com/fabinfra/fabhardware/fabpel.git
synced 2025-03-12 06:31:46 +01:00
Added: Sync
This commit is contained in:
parent
e187036c0f
commit
0ab32fc265
@ -27,6 +27,20 @@ char topic_send[TOPIC_BUFFER_SIZE];
|
||||
|
||||
byte led_color[SEGMENT_COUNT][4];
|
||||
|
||||
#define PATTERN_TIME 3000
|
||||
#define BLINK_COUNT 6
|
||||
|
||||
unsigned long last_time_blink = 0;
|
||||
unsigned long last_time_pulse = 0;
|
||||
unsigned long last_time_walk_fill = 0;
|
||||
int refresh_pulse = PATTERN_TIME / 2 / 255;
|
||||
int refresh_blink = PATTERN_TIME / BLINK_COUNT;
|
||||
int refresh_walk_fill = PATTERN_TIME / SEGMENT_COUNT;
|
||||
int value_blink = 0;
|
||||
int value_pulse = 0;
|
||||
int value_walk_fill = 0;
|
||||
int direction_pulse = 0;
|
||||
|
||||
byte limit(byte value)
|
||||
{
|
||||
if(value > LIMIT)
|
||||
@ -64,6 +78,7 @@ void callback(char* topic, byte* payload, unsigned int length)
|
||||
int mode_fill_len = (int)strlen("/fill");
|
||||
int mode_walk_len = (int)strlen("/walk");
|
||||
int buzzer_len = (int)strlen("/buzzer");
|
||||
int sync_len = (int)strlen("/sync");
|
||||
int clear_len = (int)strlen("/clear");
|
||||
int i = 0;
|
||||
if(!strcmp(topic + topic_len - mode_static_len, "/static"))
|
||||
@ -198,6 +213,19 @@ void callback(char* topic, byte* payload, unsigned int length)
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcmp(topic + topic_len - sync_len, "/sync"))
|
||||
{
|
||||
unsigned long time = millis();
|
||||
last_time_blink = time;
|
||||
last_time_pulse = time;
|
||||
last_time_walk_fill = time;
|
||||
|
||||
value_blink = 0;
|
||||
value_pulse = 0;
|
||||
value_walk_fill = 0;
|
||||
direction_pulse = 0;
|
||||
}
|
||||
|
||||
if(!strcmp(topic + topic_len - clear_len, "/clear"))
|
||||
{
|
||||
pixels.clear();
|
||||
@ -245,6 +273,10 @@ void reconnect()
|
||||
client.subscribe(topic_recv);
|
||||
snprintf (topic_recv, TOPIC_BUFFER_SIZE, "fabpel/%05d/buzzer", FABPELID);
|
||||
client.subscribe(topic_recv);
|
||||
snprintf (topic_recv, TOPIC_BUFFER_SIZE, "fabpel/%05d/sync", FABPELID);
|
||||
client.subscribe(topic_recv);
|
||||
snprintf (topic_recv, TOPIC_BUFFER_SIZE, "fabpel/sync");
|
||||
client.subscribe(topic_recv);
|
||||
snprintf (topic_recv, TOPIC_BUFFER_SIZE, "fabpel/%05d/clear", FABPELID);
|
||||
client.subscribe(topic_recv);
|
||||
}
|
||||
@ -275,20 +307,6 @@ void setup()
|
||||
pinMode(PIN_BUZZER, OUTPUT);
|
||||
}
|
||||
|
||||
#define PATTERN_TIME 3000
|
||||
#define BLINK_COUNT 6
|
||||
|
||||
unsigned long last_time_blink = 0;
|
||||
unsigned long last_time_pulse = 0;
|
||||
unsigned long last_time_walk_fill = 0;
|
||||
int refresh_pulse = PATTERN_TIME / 2 / 255;
|
||||
int refresh_blink = PATTERN_TIME / BLINK_COUNT;
|
||||
int refresh_walk_fill = PATTERN_TIME / SEGMENT_COUNT;
|
||||
int value_blink = 0;
|
||||
int value_pulse = 0;
|
||||
int value_walk_fill = 0;
|
||||
int direction_pulse = 0;
|
||||
|
||||
void loop()
|
||||
{
|
||||
int i, e;
|
||||
|
Loading…
x
Reference in New Issue
Block a user