/*
 * Use studuino for analog datalogger
 *
 * This program reads by 2 bytes (16 bits) in EEPROM.
 * the number of recorded sensor value can decide by checking initialize value(0xffff).
 * 
 */
#include "EEPROM.h"

#define COUNTER_ID    0
#define DATA_ID       1

void setup() {
  Serial.begin(38400);
  Serial.setTimeout(200);
  Serial.flush();

  
  // Read from EEPROM and Send to PC
  for (int i = 0;i < 512;i++) {
    // Read
    byte data = EEPROM.read(i);

    // Send
    outputSignal(COUNTER_ID, i);
    outputSignal(DATA_ID   , data);
  }

}

void loop() {
}

void sensorReport(byte id, byte value) {
  Serial.write( B00000000
                | ((id & B1111) << 2)
                | ((value >> 6) & B11));
  Serial.write( B01000000 | (value & B111111));
}


