<commit_before>#include "application.h"

// This #include statement was automatically added by the Spark IDE.
#include "flipflop.h"

// This #include statement was automatically added by the Spark IDE.
#include "mag3110.h"

/*
    MAG3110 Watermeter Reader
    Author: <NAME>
    Email: kbaker at alumni dot ithaca dot edu
    
    Very loosely based off of: MAG3110 Breakout Example Code
                           by: <NAME>, aaron at sparkfun dot com

    Track magnetic impeller of a water meter using a digital compass.

*/

mag3110 m = mag3110();
flipflop counter = flipflop();
volatile bool magready = true;

#define LED        D7
#define MAG_INT    D2

void magisr(void){
  magready = true;
}

void setup()
{
  Serial.begin(9600);  // start serial for output
  Serial.println("Cloud!");

  //let us know we are connected to cloud so we can re-flash bad code
  pinMode(LED, OUTPUT);
  digitalWrite(LED,HIGH);
  unsigned long time = millis();
  while (millis() < time + 10000 or SPARK_FLASH_UPDATE){
     SPARK_WLAN_Loop();
  }
  digitalWrite(LED,LOW);

  //to late, hold on tight!
  Serial.println("Starting...");
  Wire.begin();        // join i2c bus (address optional for master)
  pinMode(MAG_INT, INPUT_PULLDOWN);
  m.config();          // turn the MAG3110 on
  Serial.println("Configured");
  attachInterrupt(MAG_INT, magisr, RISING);
  Serial.println("Interrupt Enabled");
}

void loop()
{
  if (magready){
    magready = false; //we know this interrupt has happened, make sure we can catch the next one
    digitalWrite(LED,HIGH);
    if (m.fastread()){
      Serial.println("I2C Read Error");
      magready = true; //we should try and re-read
    }
    digitalWrite(LED,LOW);
    if (digitalRead(MAG_INT)){
      magready = true;
    }
  }
  else if (m.available()){
    counter.append(m.getz());
    counter.debug();
    m.advance();
  }
}

void print_values(void)
{
  Serial.print("x=");
  Serial.print(m.getx());
  Serial.print(",y=");
  Serial.print(m.gety());
  Serial.print(",z=");
  Serial.println(m.getz());
}<commit_msg>throw away what is now basically in flipflop debug<commit_after>#include "application.h"

// This #include statement was automatically added by the Spark IDE.
#include "flipflop.h"

// This #include statement was automatically added by the Spark IDE.
#include "mag3110.h"

/*
    MAG3110 Watermeter Reader
    Author: <NAME>
    Email: kbaker at alumni dot ithaca dot edu
    
    Very loosely based off of: MAG3110 Breakout Example Code
                           by: <NAME>, aaron at sparkfun dot com

    Track magnetic impeller of a water meter using a digital compass.

*/

mag3110 m = mag3110();
flipflop counter = flipflop();
volatile bool magready = true;

#define LED        D7
#define MAG_INT    D2

void magisr(void){
  magready = true;
}

void setup()
{
  Serial.begin(9600);  // start serial for output
  Serial.println("Cloud!");

  //let us know we are connected to cloud so we can re-flash bad code
  pinMode(LED, OUTPUT);
  digitalWrite(LED,HIGH);
  unsigned long time = millis();
  while (millis() < time + 10000 or SPARK_FLASH_UPDATE){
     SPARK_WLAN_Loop();
  }
  digitalWrite(LED,LOW);

  //to late, hold on tight!
  Serial.println("Starting...");
  Wire.begin();        // join i2c bus (address optional for master)
  pinMode(MAG_INT, INPUT_PULLDOWN);
  m.config();          // turn the MAG3110 on
  Serial.println("Configured");
  attachInterrupt(MAG_INT, magisr, RISING);
  Serial.println("Interrupt Enabled");
}

void loop()
{
  if (magready){
    magready = false; //we know this interrupt has happened, make sure we can catch the next one
    digitalWrite(LED,HIGH);
    if (m.fastread()){
      Serial.println("I2C Read Error");
      magready = true; //we should try and re-read
    }
    digitalWrite(LED,LOW);
    if (digitalRead(MAG_INT)){
      magready = true;
    }
  }
  else if (m.available()){
    counter.append(m.getz());
    counter.debug();
    m.advance();
  }
}
{'fraction_non_alphanumeric': 0.12297570850202429, 'fraction_numerical': 0.018724696356275303, 'mean_word_length': 3.0879007238883145, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '455573', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1282, 'n_words': 404}