Detecting the down time of a system by subtracting the time when the sytem gives ON signal and when it goes OFF
You have the same state being tested twice:

if (c.state == LOW &amp;&amp; new_state == HIGH)   // input rose 


and:

else if (c.state == LOW &amp;&amp; new_state == HIGH)  // input fell


If "A", else if "A". It makes no sense. I think you wanted the second one to be the opposite:

else if (c.state == HIGH &amp;&amp; new_state == LOW)  // input fell


Also, this calculation in display_channel doesn't work:

if (seconds &gt;= 60)
{
  seconds = seconds % 60;
  minutes = minutes + 1;
}


For example, if seconds is 378, then seconds ends up as 18, and minutes as some undefined number plus 1.

That whole block should be replaced with:

minutes = seconds / 60;
seconds = seconds % 60;


In your code:


minutes starts off undefined
You add only 1 to minutes regardless of how many minutes have passed.