Browse Source

Add option to invert power values in ECH1560

fastled
Xose Pérez 7 years ago
parent
commit
5b2af0472f
3 changed files with 10 additions and 0 deletions
  1. +3
    -0
      code/espurna/config/general.h
  2. +1
    -0
      code/espurna/config/hardware.h
  3. +6
    -0
      code/espurna/power_ech1560.ino

+ 3
- 0
code/espurna/config/general.h View File

@ -598,6 +598,9 @@ PROGMEM const char* const custom_reset_string[] = {
#ifndef ECH1560_MISO_PIN #ifndef ECH1560_MISO_PIN
#define ECH1560_MISO_PIN 5 #define ECH1560_MISO_PIN 5
#endif #endif
#ifndef ECH1560_INVERTED
#define ECH1560_INVERTED 0
#endif
#define ECH1560_SYNC_INTERVAL 600 #define ECH1560_SYNC_INTERVAL 600
#define ECH1560_BAUDRATE 4800 #define ECH1560_BAUDRATE 4800


+ 1
- 0
code/espurna/config/hardware.h View File

@ -879,6 +879,7 @@
#define POWER_PROVIDER POWER_PROVIDER_ECH1560 #define POWER_PROVIDER POWER_PROVIDER_ECH1560
#define ECH1560_CLK_PIN 4 #define ECH1560_CLK_PIN 4
#define ECH1560_MISO_PIN 5 #define ECH1560_MISO_PIN 5
#define ECH1560_INVERTED 0
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Unknown hardware // Unknown hardware


+ 6
- 0
code/espurna/power_ech1560.ino View File

@ -97,6 +97,12 @@ void _ech1560_sync() {
} }
} }
#if ECH1560_INVERTED
byte1 = 255 - byte1;
byte2 = 255 - byte2;
byte3 = 255 - byte3;
#endif
// power = (Ba*255+Bb+Bc/255)/2 // power = (Ba*255+Bb+Bc/255)/2
_ech1560_apparent = ( (float) byte1 * 255 + (float) byte2 + (float) byte3 / 255.0) / 2; _ech1560_apparent = ( (float) byte1 * 255 + (float) byte2 + (float) byte3 / 255.0) / 2;
_ech1560_current = _ech1560_apparent / _ech1560_voltage; _ech1560_current = _ech1560_apparent / _ech1560_voltage;


Loading…
Cancel
Save