Skip to content

Commit

Permalink
Apply VSC auto format to the code and indent macros for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
1technophile committed Dec 14, 2019
1 parent f7ec81f commit 695c275
Show file tree
Hide file tree
Showing 26 changed files with 4,497 additions and 3,686 deletions.
2 changes: 2 additions & 0 deletions docs/participate/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ agree to follow the code of conduct below

[code of conduct]: https://github.com/1technophile/OpenMQTTGateway/blob/master/CODE_OF_CONDUCT.md

[code style guide](https://google.github.io/styleguide/cppguide.html#Formatting)

Fork the [development branch](https://github.com/1technophile/OpenMQTTGateway/tree/development), then clone the repo

Make your modification,
Expand Down
57 changes: 25 additions & 32 deletions main/ZactuatorFASTLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@

#ifdef ZactuatorFASTLED

#ifdef ESP8266
#include <FastLED.h>
#else
#include <FastLED.h>
#endif
#include <ArduinoJson.h>

enum LEDState
{
OFF,
Expand Down Expand Up @@ -123,35 +119,32 @@ boolean FASTLEDtoMQTT()
{
return false;
}
void MQTTtoFASTLEDJSON(char *topicOri, JsonObject& jsonData)
void MQTTtoFASTLEDJSON(char *topicOri, JsonObject &jsonData)
{
trc(F("MQTTtoFASTLEDJSON: "));
currentLEDState = GENERAL;
trc(topicOri);
//number = (long)strtol(&datacallback[1], NULL, 16);



if (cmpToMainTopic(topicOri,subjectMQTTtoFASTLEDsetled))
if (cmpToMainTopic(topicOri, subjectMQTTtoFASTLEDsetled))
{
trc(F("JSON parsed"));
int ledNr = jsonData["led"];
trc(F("led"));
trc(ledNr);
const char *color = jsonData["hex"];
trc(F("hex"));

long number = (long)strtol(color, NULL, 16);
trc(number);
bool blink = jsonData["blink"];
if (ledNr <= FASTLED_NUM_LEDS)
{
trc(F("blink"));
trc(blink);
blinkLED[ledNr] = blink;
leds[ledNr] = number;
}

trc(F("JSON parsed"));
int ledNr = jsonData["led"];
trc(F("led"));
trc(ledNr);
const char *color = jsonData["hex"];
trc(F("hex"));

long number = (long)strtol(color, NULL, 16);
trc(number);
bool blink = jsonData["blink"];
if (ledNr <= FASTLED_NUM_LEDS)
{
trc(F("blink"));
trc(blink);
blinkLED[ledNr] = blink;
leds[ledNr] = number;
}
}
}
void MQTTtoFASTLED(char *topicOri, char *datacallback)
Expand All @@ -160,7 +153,7 @@ void MQTTtoFASTLED(char *topicOri, char *datacallback)
currentLEDState = GENERAL;
long number = 0;
trc(topicOri);
if (cmpToMainTopic(topicOri,subjectMQTTtoFASTLED))
if (cmpToMainTopic(topicOri, subjectMQTTtoFASTLED))
{
number = (long)strtol(&datacallback[1], NULL, 16);
trc(number);
Expand All @@ -170,18 +163,18 @@ void MQTTtoFASTLED(char *topicOri, char *datacallback)
}
FastLED.show();
}
else if (cmpToMainTopic(topicOri,subjectMQTTtoFASTLEDsetbrightness))
else if (cmpToMainTopic(topicOri, subjectMQTTtoFASTLEDsetbrightness))
{
number = (long)strtol(&datacallback[1], NULL, 16);
trc(number);
FastLED.setBrightness(number);
FastLED.show();
}
else if (cmpToMainTopic(topicOri,subjectMQTTtoFASTLEDsetanimation))
else if (cmpToMainTopic(topicOri, subjectMQTTtoFASTLEDsetanimation))
{
String payload = datacallback;
trc(payload);
if ( strstr(datacallback,"fire") != NULL)
if (strstr(datacallback, "fire") != NULL)
{
currentLEDState = FIRE;
gPal = HeatColors_p;
Expand All @@ -195,7 +188,7 @@ void MQTTtoFASTLED(char *topicOri, char *datacallback)
{
currentLEDState = OFF;
}
if (currentLEDState==OFF)
if (currentLEDState == OFF)
{
for (int i = 0; i < FASTLED_NUM_LEDS; i++)
{
Expand Down
29 changes: 18 additions & 11 deletions main/ZactuatorONOFF.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
#ifdef ZactuatorONOFF

#ifdef jsonReceiving
void MQTTtoONOFF(char * topicOri, JsonObject& ONOFFdata){

if (cmpToMainTopic(topicOri,subjectMQTTtoONOFF)){
void MQTTtoONOFF(char *topicOri, JsonObject &ONOFFdata)
{
if (cmpToMainTopic(topicOri, subjectMQTTtoONOFF))
{
trc(F("MQTTtoONOFF json data analysis"));
int boolSWITCHTYPE = ONOFFdata["state"] | 99;
int pin = ONOFFdata["pin"] | ACTUATOR_ONOFF_PIN;
if (boolSWITCHTYPE != 99) {
if (boolSWITCHTYPE != 99)
{
trc(F("MQTTtoONOFF boolSWITCHTYPE ok"));
trc(boolSWITCHTYPE);
trc(F("pin number"));
Expand All @@ -46,16 +48,20 @@ void MQTTtoONOFF(char * topicOri, JsonObject& ONOFFdata){
digitalWrite(pin, boolSWITCHTYPE);
// we acknowledge the sending by publishing the value to an acknowledgement topic
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
}else{
}
else
{
trc(F("MQTTtoONOFF failed json read"));
}
}
}
#endif

#ifdef simpleReceiving
void MQTTtoONOFF(char * topicOri, char * datacallback) {
if ((cmpToMainTopic(topicOri,subjectMQTTtoONOFF)) ){
void MQTTtoONOFF(char *topicOri, char *datacallback)
{
if ((cmpToMainTopic(topicOri, subjectMQTTtoONOFF)))
{

trc(F("MQTTtoONOFF"));
int pin = strtol(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
Expand All @@ -64,16 +70,17 @@ void MQTTtoONOFF(char * topicOri, char * datacallback) {
pinMode(pin, OUTPUT);

bool ON = false;
if (strstr(topicOri,ONKey) != NULL) ON = true;
if (strstr(topicOri,OFFKey) != NULL) ON = false;
if (strstr(topicOri, ONKey) != NULL)
ON = true;
if (strstr(topicOri, OFFKey) != NULL)
ON = false;

digitalWrite(pin, ON);
// we acknowledge the sending by publishing the value to an acknowledgement topic
char b = ON;
pub(subjectGTWONOFFtoMQTT, &b);
}
}
}
#endif


#endif
Loading

0 comments on commit 695c275

Please sign in to comment.