 
 ///////////////
 
+static bool serial_active = false;
+
 //send-receive with processing if it's time
   if(millis()>next_millis)
   {
     if (Serial.available())
     {
-      SerialReceive();
+      if (SerialReceive())
+      {
+         serial_active=true;
+      }
     }
-    SendStatusPacket();
-    next_millis+=100;
+    if (serial_active)
+    {
+      SendStatusPacket();
+    }
+    next_millis+=500;
   }
 }
 

const int SPI_SCLK         = 15;
const int SPI_MOSI         = 16;
const int ENC_BUTTON       = 18; //Maybe this should be an interrupt. if it does, we need to move CS to a different pin
const int SPARE_18         = 18;
const int SPARE_19         = 19;
const int CURRENT_FEEDBACK = 20;
const int CRADLE_SENSOR    = 21;
const int OLED_RESET       = 4; //the library asks for a reset pin, but our OLED doesn't have one 


//This should only run at the start of the program, then it disables itself
ISR(TIMER1_COMPA_vect)
{
  static bool one_shot = false;
  if (!one_shot)
  {
  //clear the Timer 1 B interrupt flag so it doesn't fire right after we enable it. We only want to detect new interrupts, not old ones.
  TIFR1 |= _BV(OCF1B);
  //Enable only interrupt B, This also disables A since A has done it's one and only job of synchronizing the B interrupt.
  TIMSK1 = _BV(OCIE1B);
  one_shot = true;
  }
//4 pulses for debugging
   PulsePin(debug_pin_B);
   PulsePin(debug_pin_B);
   current_sense_raw=analogRead(CURRENT_SENSE);
   PulsePin(debug_pin_B);
   PulsePin(debug_pin_B);

   // 
}


