Browse Source

Merge branch 'dev' of github.com:xoseperez/espurna into dev

rules-rpn
Xose Pérez 5 years ago
parent
commit
60abd56079
4 changed files with 44 additions and 11 deletions
  1. +17
    -0
      code/espurna/config/sensors.h
  2. +20
    -4
      code/espurna/libs/SyncClientWrap.h
  3. +1
    -1
      code/espurna/ntp.ino
  4. +6
    -6
      code/espurna/sensors/CSE7766Sensor.h

+ 17
- 0
code/espurna/config/sensors.h View File

@ -856,6 +856,22 @@
#define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how #define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how
#endif // often the sensor takes a measurement. #endif // often the sensor takes a measurement.
//------------------------------------------------------------------------------
// MAX6675
// Enable support by passing MAX6675_SUPPORT=1 build flag
//------------------------------------------------------------------------------
#ifndef MAX6675_CS_PIN
#define MAX6675_CS_PIN 13
#endif
#ifndef MAX6675_SO_PIN
#define MAX6675_SO_PIN 12
#endif
#ifndef MAX6675_SCK_PIN
#define MAX6675_SCK_PIN 14
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// EZOPH pH meter // EZOPH pH meter
// Enable support by passing EZOPH_SUPPORT=1 build flag // Enable support by passing EZOPH_SUPPORT=1 build flag
@ -916,6 +932,7 @@
V9261F_SUPPORT || \ V9261F_SUPPORT || \
VEML6075_SUPPORT || \ VEML6075_SUPPORT || \
VL53L1X_SUPPORT || \ VL53L1X_SUPPORT || \
MAX6675_SUPPORT || \
EZOPH_SUPPORT \ EZOPH_SUPPORT \
) )
#endif #endif


+ 20
- 4
code/espurna/libs/SyncClientWrap.h View File

@ -9,13 +9,29 @@ Temporary wrap to fix https://github.com/me-no-dev/ESPAsyncTCP/issues/109
#include <SyncClient.h> #include <SyncClient.h>
// ref Core 2.5.0: cores/esp8266/IPAddress.h
#ifndef CONST
#include <lwip/init.h>
#if LWIP_VERSION_MAJOR == 1
#define CONST
#else
#define CONST const
#endif
#endif
class SyncClientWrap: public SyncClient { class SyncClientWrap: public SyncClient {
public: public:
SyncClientWrap() {}
~SyncClientWrap() {}
// int connect(const char*, uint16_t);
using SyncClient::connect;
int connect(const char *host, uint16_t port);
int connect(CONST IPAddress& ip, uint16_t port) { return connect(ip, port); }
bool flush(unsigned int maxWaitMs = 0) { flush(); return true; }
bool stop(unsigned int maxWaitMs = 0) { stop(); return true; }
int connect(CONST IPAddress& ip, uint16_t port) { IPAddress _ip(ip); return SyncClient::connect(_ip, port); }
bool flush(unsigned int maxWaitMs = 0) { SyncClient::flush(); return true; }
bool stop(unsigned int maxWaitMs = 0) { SyncClient::stop(); return true; }
}; };

+ 1
- 1
code/espurna/ntp.ino View File

@ -12,7 +12,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <WiFiClient.h> #include <WiFiClient.h>
#include <Ticker.h> #include <Ticker.h>
#include <libs/NtpClientWrap.h>
#include "libs/NtpClientWrap.h"
Ticker _ntp_defer; Ticker _ntp_defer;


+ 6
- 6
code/espurna/sensors/CSE7766Sensor.h View File

@ -22,7 +22,7 @@ class CSE7766Sensor : public BaseSensor {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
CSE7766Sensor(): BaseSensor(), _data() { CSE7766Sensor(): BaseSensor(), _data() {
_count = 6;
_count = 7;
_sensor_id = SENSOR_CSE7766_ID; _sensor_id = SENSOR_CSE7766_ID;
} }
@ -161,7 +161,7 @@ class CSE7766Sensor : public BaseSensor {
if (index == 0) return MAGNITUDE_CURRENT; if (index == 0) return MAGNITUDE_CURRENT;
if (index == 1) return MAGNITUDE_VOLTAGE; if (index == 1) return MAGNITUDE_VOLTAGE;
if (index == 2) return MAGNITUDE_POWER_ACTIVE; if (index == 2) return MAGNITUDE_POWER_ACTIVE;
if (index == 3) return MAGNITUDE_POWER_REACTIVE;
if (index == 3) return MAGNITUDE_POWER_REACTIVE;
if (index == 4) return MAGNITUDE_POWER_APPARENT; if (index == 4) return MAGNITUDE_POWER_APPARENT;
if (index == 5) return MAGNITUDE_POWER_FACTOR; if (index == 5) return MAGNITUDE_POWER_FACTOR;
if (index == 6) return MAGNITUDE_ENERGY; if (index == 6) return MAGNITUDE_ENERGY;
@ -275,10 +275,10 @@ class CSE7766Sensor : public BaseSensor {
} }
} }
// Calculate reactive power
_reactive = 0;
unsigned int active = _active;
unsigned int apparent = _voltage * _current;
// Calculate reactive power
_reactive = 0;
unsigned int active = _active;
unsigned int apparent = _voltage * _current;
if (apparent > active) { if (apparent > active) {
_reactive = sqrt(apparent * apparent - active * active); _reactive = sqrt(apparent * apparent - active * active);
} else { } else {


Loading…
Cancel
Save