   if( strcasecmp(cmd, "ping") == 0 )
   {
     Serial.print("P ");
-    Serial.println(value);
+    Serial.println(val_ok ? value : 0);
   }
   else if( strcasecmp(cmd, "recall") == 0 )
   {
-    //Serial.println("R M1 01:23:45.678 123345 123");
-    Serial.println("E not implemented");
+    if( val_ok && value < event_count && (event_count < EVENT_MAX || value >= event_count - EVENT_MAX) )
+    {
+      Serial.print("R ");
+      print_event(value % EVENT_MAX);
+      Serial.write(' ');
+      Serial.println(value);
+      //Serial.println("R M1 01:23:45.678 123345 123");
+    }
+    else
+    {
+      Serial.println("E bad value");
+    }
   }
   else if( strcasecmp(cmd, "clear") == 0 )
   {
-    //Serial.println("C");
-    Serial.println("E not implemented");
+    event_count = 0;
+    Serial.println("C 0");
+  }
+  else if( strcasecmp(cmd, "count") == 0 )
+  {
+    Serial.print("C ");
+    Serial.println(event_count);
+  }
+  else if( strcasecmp(cmd, "max") == 0 )
+  {
+    Serial.print("M ");
+    Serial.println(EVENT_MAX);
   }
   else if( strcasecmp(cmd, "debounce") == 0 )
   {

  uint32_t  debounce_count;
  uint32_t  deadtime_count;
  uint32_t  time;
} trigger_state_t;

typedef struct
{
  uint32_t time;
  time_source_t source;
} time_event_t;

volatile uint32_t debounce = DEFAULT_DEBOUNCE; // max number of debounce cycles
volatile uint32_t deadtime = DEFAULT_DEADTIME; // deadtime before next trigger

volatile uint32_t ms_time = 0; // master millisecond time

volatile uint32_t trigger_count = 0;

volatile trigger_state_t start_trigger = {PIN_TS, false, 0, 0};
volatile trigger_state_t finish_trigger = {PIN_TF, false, 0, 0};
volatile trigger_state_t manual_start_trigger = {PIN_MTS, false, 0, 0};
volatile trigger_state_t manual_finish_trigger = {PIN_MTF, false, 0, 0};

bool update_trigger( volatile trigger_state_t * trigger )
{


void loop(void)
{
  static uint32_t count = 0;

  digitalWrite(PIN_LED, HIGH);

  if( count > event_count )
  {
    count = 0;
  }

  if( count < event_count )
  {
    Serial.print("T ");
    print_event(count % EVENT_MAX);
    Serial.write(' ');
    Serial.println(count);
    count++;
  }

  command_update();
