 // If DEBUG reporting is turned on, we report every "ReportVoltageDelay" measurements.
 //----------------------------------------
 
-int batt_report_count = 0;
-  
+#if (DEBUG & DEBUG_BATT)
+  int batt_report_count = 0;
+#endif
+
 void measure_battery(void)
 {
   // get the time since the last measurement

  last_volts_time = now_milli;
      
  // measure voltage, we will get a value of 1023 for 3.3 volts
  // adjust the divider (32.0/9.92) to calibrate
  UINT measured = analogRead(mc_BattVolts);
  MeasuredVoltage = (3.3 * measured) / 1023 * 32.0/9.92;

#if (DEBUG & DEBUG_BATT)
  if (++batt_report_count > 0)
  {
    Serial.printf(F("raw volts=%d, "), measured);
  }
#endif

  // figure out which battery symbol to use
  if (MeasuredVoltage < MinVoltage)
  {
    if (MeasuredVoltage < 1.0)
    {
      BatterySymbol = battnone;
#if (DEBUG & DEBUG_BATT)
      if (batt_report_count > 0)
        Serial.printf(F("no battery\n"));
#endif      
    }
    else
    {
      BatterySymbol = battunder;
#if (DEBUG & DEBUG_BATT)
      if (batt_report_count > 0)
        Serial.printf(F("battery under voltage\n"));
#endif      
    }
  }
  else if (MeasuredVoltage > MaxVoltage)
  {
    BatterySymbol = battover;
#if (DEBUG & DEBUG_BATT)
    if (batt_report_count > 0)
      Serial.printf(F("battery over voltage\n"));
#endif      
  }
  else
  {
    int percent = (int) ((MeasuredVoltage - MinVoltage) / (MaxVoltage - MinVoltage) * 100.0);
    int batt_bucket = (int) (percent/20);
    BatterySymbol = batt_syms[batt_bucket + 2];
#if (DEBUG & DEBUG_BATT)
    if (batt_report_count > 0)
    {
      Serial.printf(F("actual volts=%f, percent=%d, batt_bucket=%d\n"),
                      MeasuredVoltage, percent, batt_bucket);
    batt_report_count = -ReportVoltageDelay;
    }
#endif
  }


void display_battery(void)
{
#if SHOW_VOLTAGE
  // display measured voltage
  sprintf(FreqBuffer, "%.2fv", MeasuredVoltage);
  lcd.setCursor(9, 1);
  lcd.print(FreqBuffer);
#endif

  // create special battery character
  lcd.createChar(BatteryChar, BatterySymbol);

