 
 #define EEPROM_READ_ADDR 0
 
+struct config_t
+{
+  int state;
+  double consumption_total;
+  int pulse_count_current_kwh;
+} storage;
+
+double particle_total_kwh = 0;
 char consumption_total_str[10] = "00000.00";
 
-float consumption_current = 0.0F;
+double particle_consumption_current = 0;
 char consumption_current_str[6] = "Wait";
 
 long time_since_last_pulse = millis();

#include "roboto_thin_20.h"
#include "images.h"


#include "eepromanything.h"

#define PULSES_PER_KWH 375
#define WH_PER_PULSE (1000.0F / PULSES_PER_KWH)

struct config_t
{
  int state;
  float consumption_total;
  int pulse_count_current_kwh;
} storage;

#define BTN_1 9
#define BTN_2 8

};

bool isConnected = false;
bool b1_pressed = false;
bool b2_pressed = false;
bool b3_pressed = false;
bool b4_pressed = false;
bool pulse_triggered = false;

void toggle_b1() { b1_pressed = true; }
void toggle_b2() { b2_pressed = true; }
void toggle_b3() { b3_pressed = true; }
void toggle_b4() { b4_pressed = true; }
void trigger_pulse() { pulse_triggered = true; }

void setup() {
  Particle.variable("total", particle_total_kwh);
  Particle.variable("current", particle_consumption_current);
  EEPROM_readAnything(EEPROM_READ_ADDR, storage);
  if(storage.state != 0xFA) {
    storage.state = 0xFA;
    storage.consumption_total = 56713.0f;
    storage.pulse_count_current_kwh = 370;
    EEPROM_writeAnything(EEPROM_READ_ADDR, storage);
  }
  
  dtostrf(storage.consumption_total, 6, 2, consumption_total_str);
  
  ui.setTargetFPS(30);
  ui.setActiveSymbole(activeSymbole);
  ui.setInactiveSymbole(inactiveSymbole);
  ui.setIndicatorPosition(TOP);
  ui.setIndicatorDirection(LEFT_RIGHT);
  ui.setFrameAnimation(SLIDE_LEFT);
  ui.setTimePerFrame(7000);
  ui.setFrames(frames, 2);
  ui.setOverlays(overlays, 1);
  ui.init();

  display.flipScreenVertically();
