 
   print_state("index/pointer/minutes:");
   Serial.printf("\r\n\tnext trend block #%d, next history block #%d", sensorData.nextTrend, sensorData.nextHistory);
-  Serial.printf("\r\n\tminutes elapsed: %d, minutes distance to most recent history value: %d", sensorData.minutesSinceStart, sensorData.minutesHistoryOffset);
+  Serial.printf("\r\n\tminutes elapsed: %d, minutes distance to most recent history value: -%d", sensorData.minutesSinceStart, sensorData.minutesHistoryOffset);
 
   // copy 16 trend data
   int index = 0;

  p = (dataConfig*)ADDRESS_OF_PAGE(MY_FLASH_PAGE);
  // init and open serial line
  Serial.begin(9600);
  // time sto settle, avoid serial ghost characters
  delay(2000); 

  Serial.print("\r\n=== loop #"); Serial.print(loop_cnt);
  Serial.print(" =====================================================================================================");

  print_statef("LBridge starting");
  Serial.printf("\r\n\tBLE name: %s, %s%s from %s", LB_NAME, LB_VERSION, LB_MINOR_VERSION, LB_DATETIME);
  Serial.printf("\r\n\tRAM used: %d, , Flash used: %d", ramUsed(), flashUsed());
  Serial.printf("\r\n\tQueue size: %d (%d h)", DXQUEUESIZE, DXQUEUESIZE/12);
  Serial.printf("\r\n\tCompiled Options:");
#ifdef SIM_MINUTES_UPCOUNT
  Serial.printf("\r\n\t\tsimulate sensor minutes upcount");
#endif
#ifdef USE_DEAD_SENSOR
  Serial.printf("\r\n\t\tusage of dead sensors allowed");
#else
  Serial.printf("\r\n\t\tdetect dead sensor - quit sending readings after 14,5d");
#endif
#ifdef USE_SPIKE_FILTER
  Serial.printf("\r\n\t\tremove spikes > +-%d (%f mmol/l)", SPIKE_HEIGHT, (float)(SPIKE_HEIGHT/18.02));
#else
  Serial.printf("\r\n\t\tdont detect and remove spikes");
#endif

  print_state("setup - start - ");

  return free_memory;
}

/*
 * print current timestamp
 */
char * current_timestamp(char *outbuffer)
{
  unsigned long ms = mymillis();

  sprintf(outbuffer, "\r\n[%03d][%03d][%03d] ", ms/60000, (ms/1000)%60, ms%1000);
  return(outbuffer);
}

void print_state(String str)
{
  char ob[80];

  Serial.printf("%s%s", current_timestamp(ob), str.cstr());
//  Serial.print(str);
}

int print_statef(const char *format, ...)
{
  va_list vl;
  char op[256];
  char *opp;

  memset(op, 0, sizeof(op));      // for 0 termination

  current_timestamp(op);          // set current timestamp

  opp = &op[strlen(op)];
  va_start(vl, format);
  
  while (*format)
  {
    if (*format == '%')
    {
      format++;
      char ch = *format;
      if (! ch)
        break;
      else if (ch == '%')
        *opp++ = *format;
      else if (ch == 'b') {
        unsigned u = va_arg(vl, unsigned);
        utoa(u, opp, 2);
        opp = &op[strlen(op)];
      }
      else if (ch == 'c') {
        int ch = va_arg(vl, int);
        *opp++ = (char)ch;
      }
      else if (ch == 'd') {
        int i = va_arg(vl, int);
        itoa(i, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'l') {
        unsigned long i = va_arg(vl, unsigned long);
        ultoa(i, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'u') {
        unsigned u = va_arg(vl, unsigned);
        utoa(u, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'x') {
        unsigned x = va_arg(vl, unsigned);
        itoa(x, opp, 16);
        opp = &op[strlen(op)];
      }
      else if (ch == 's') {
        char *s = va_arg(vl, char *);
        strcat(op, s);
        opp = &op[strlen(op)];
      }
      else if (ch == 'f') {
        char format[20];
        double d = va_arg(vl, double);
        sprintf(opp, "%d.%02d", (int)d, ((int)(d*100))%100);
        opp = &op[strlen(op)];
      }
    }
    else
     *opp++ = *format;
    format++;
  }
  
  va_end(vl);

  Serial.print(op);

  return 1;
} 

int myprintf(const char *format, ...)
{
  va_list vl;
  char op[256];
  char *opp;

  memset(op, 0, sizeof(op));  // for 0 termination
  opp = &op[0];               // set pointer to array start
  va_start(vl, format);
  
  while (*format) {
    if (*format == '%') {     // format descriptor found?
      format++;
      char ch = *format;
      if (! ch)
        break;
      else if (ch == '%')
        *opp++ = *format;
      else if (ch == 'b') {
        unsigned u = va_arg(vl, unsigned);
        utoa(u, opp, 2);
        opp = &op[strlen(op)];
      }
      else if (ch == 'c') {
        int ch = va_arg(vl, int);
        *opp++ = (char)ch;
      }
      else if (ch == 'd') {
        int i = va_arg(vl, int);
        itoa(i, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'l') {
        unsigned long i = va_arg(vl, unsigned long);
        ultoa(i, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'u') {
        unsigned u = va_arg(vl, unsigned);
        utoa(u, opp, 10);
        opp = &op[strlen(op)];
      }
      else if (ch == 'x') {
        unsigned x = va_arg(vl, unsigned);
        itoa(x, opp, 16);
        opp = &op[strlen(op)];
      }
      else if (ch == 's') {
        char *s = va_arg(vl, char *);
        strcat(op, s);
        opp = &op[strlen(op)];
      }
      else if (ch == 'f') {
        char format[20];
        double d = va_arg(vl, double);
        sprintf(opp, "%d.%02d", (int)d, ((int)(d*100))%100);
        opp = &op[strlen(op)];
      }
    }
    else
     *opp++ = *format;
    format++;
  }
  
  va_end(vl);

  Serial.print(op);

  return 1;
} 

int old_print_statef(const char *format, ...)
{
  va_list vl;
  size_t n = 0;
