Skip to content

Commit

Permalink
Fix VA
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Jun 8, 2024
1 parent 0d1b8c4 commit fcc7535
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
8 changes: 7 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ Language: Cpp
BasedOnStyle: LLVM

AccessModifierOffset: -2
AlignConsecutiveMacros: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Inline
BinPackArguments: false
ColumnLimit: 0
ContinuationIndentWidth: 2
FixNamespaceComments: false
IndentAccessModifiers: true
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 2
NamespaceIndentation: All
PointerAlignment: Left
ReferenceAlignment: Left
TabWidth: 2
UseTab: Never
UseTab: Never
28 changes: 14 additions & 14 deletions src/MycilaJSY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
#include "MycilaJSY.h"

#ifdef MYCILA_LOGGER_SUPPORT
#include <MycilaLogger.h>
#include <MycilaLogger.h>
extern Mycila::Logger logger;
#define LOGD(tag, format, ...) logger.debug(tag, format, ##__VA_ARGS__)
#define LOGI(tag, format, ...) logger.info(tag, format, ##__VA_ARGS__)
#define LOGW(tag, format, ...) logger.warn(tag, format, ##__VA_ARGS__)
#define LOGE(tag, format, ...) logger.error(tag, format, ##__VA_ARGS__)
#define LOGD(tag, format, ...) logger.debug(tag, format, ##__VA_ARGS__)
#define LOGI(tag, format, ...) logger.info(tag, format, ##__VA_ARGS__)
#define LOGW(tag, format, ...) logger.warn(tag, format, ##__VA_ARGS__)
#define LOGE(tag, format, ...) logger.error(tag, format, ##__VA_ARGS__)
#else
#define LOGD(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__)
#define LOGI(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__)
#define LOGW(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__)
#define LOGE(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
#define LOGD(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__)
#define LOGI(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__)
#define LOGW(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__)
#define LOGE(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
#endif

#define TAG "JSY"

#define JSY_READ_RESPONSE_SIZE 61
#define JSY_READ_RESPONSE_SIZE 61
#define JSY_RESET_RESPONSE_SIZE 8
#define JSY_BAUDS_RESPONSE_SIZE 8

static const uint8_t JSY_READ_MSG[] = {0x01, 0x03, 0x00, 0x48, 0x00, 0x0E, 0x44, 0x18};

#ifndef GPIO_IS_VALID_OUTPUT_GPIO
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
#endif

#ifndef GPIO_IS_VALID_GPIO
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
#endif

void Mycila::JSY::begin(HardwareSerial& serial, const int8_t rxPin, const int8_t txPin, const bool async, uint8_t core, uint32_t stackSize, uint32_t pause) {
Expand Down
22 changes: 11 additions & 11 deletions src/MycilaJSY.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
#include <mutex>

#ifdef MYCILA_JSON_SUPPORT
#include <ArduinoJson.h>
#include <ArduinoJson.h>
#endif

#define MYCILA_JSY_VERSION "9.0.0"
#define MYCILA_JSY_VERSION_MAJOR 9
#define MYCILA_JSY_VERSION_MINOR 0
#define MYCILA_JSY_VERSION "9.0.0"
#define MYCILA_JSY_VERSION_MAJOR 9
#define MYCILA_JSY_VERSION_MINOR 0
#define MYCILA_JSY_VERSION_REVISION 0

#ifndef MYCILA_JSY_ASYNC_CORE
#define MYCILA_JSY_ASYNC_CORE 0
#define MYCILA_JSY_ASYNC_CORE 0
#endif

#ifndef MYCILA_JSY_ASYNC_PRIORITY
#define MYCILA_JSY_ASYNC_PRIORITY 1
#define MYCILA_JSY_ASYNC_PRIORITY 1
#endif

#ifndef MYCILA_JSY_ASYNC_STACK_SIZE
#define MYCILA_JSY_ASYNC_STACK_SIZE 2048
#define MYCILA_JSY_ASYNC_STACK_SIZE 2048
#endif

// time in milliseconds to wait between each read in async mode
#ifndef MYCILA_JSY_ASYNC_READ_PAUSE_MS
#define MYCILA_JSY_ASYNC_READ_PAUSE_MS 0
#define MYCILA_JSY_ASYNC_READ_PAUSE_MS 0
#endif

#ifndef MYCILA_JSY_READ_TIMEOUT_MS
#define MYCILA_JSY_READ_TIMEOUT_MS 200
#define MYCILA_JSY_READ_TIMEOUT_MS 200
#endif

namespace Mycila {
Expand Down Expand Up @@ -115,8 +115,8 @@ namespace Mycila {
float getVoltage1() const { return _voltage1; }
float getVoltage2() const { return _voltage2; }
// apparent power in VA
float getApparentPower1() const { return _power1 / _powerFactor1; }
float getApparentPower2() const { return _power2 / _powerFactor2; }
float getApparentPower1() const { return _powerFactor1 == 0 ? 0 : _power1 / _powerFactor1; }
float getApparentPower2() const { return _powerFactor2 == 0 ? 0 : _power2 / _powerFactor2; }

// get the uptime in milliseconds of the last successful read
uint32_t getTime() const { return _lastReadSuccess; }
Expand Down

0 comments on commit fcc7535

Please sign in to comment.