   
   oled.fillScreen(COLOR_BLACK);
   watch_show(0xFF);  
+
+  Serial.begin(9600);
+  if (EEPROM[0] != 0x03) {
+    EEPROM[0] = 0x03;
+    logbat = 1;
+
+    Serial.println("Battery log started");
+  } else {
+    Serial.println("Battery log detected, not overwriting");
+    for (eeaddr = 1; eeaddr < 1024; ++eeaddr) {
+      Serial.println(EEPROM[eeaddr], DEC);
+    }
+  }
+
+  power_twi_disable();
+  power_usart1_disable();
+  power_usb_disable();
+  power_adc_disable();
+  power_timer1_disable();
+  power_timer2_disable();
+  power_timer3_disable();
 }
 
 void loop() {
-  uint8_t changes = watch_tick();
+  power_spi_disable();
+
+  // sleep for a bit to save power. This is OK b/c timer0 which provides
+  // millis is not disabled
+  Xadow.goToSleep(SLEEP_MODE_IDLE, 100);
+
+  power_spi_enable();
+  uint8_t changes = watch_tick(millis());
   if (changes) {
-      watch_show(changes);
+    watch_show(changes);
+    //status_show();
+    // log voltage every minute
+    if (changes >= 2 && logbat) {
+      if (eeaddr < 1024) {
+        uint8_t batvol = Xadow.getBatVol()*10;
+        EEPROM[eeaddr] = batvol;
+        eeaddr += 1;
+      }
+    }
   }
 }

char _sbuf[64];
char _sbuf2[64];

void setup() {
  Xadow.init();
  Xadow.greenLed(LEDON);

  oled.init();
  oled.fillScreen(COLOR_BLACK);

#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>

#include "SGL.h"
#include "SSD1331.h"
