+ if(adc_state==2)
+ {
+ uint8_t i = track_current_head;
+ track_current_sum -= track_current_samples[i];
+ track_current_samples[i] = value;
+ track_current_sum += value;
+ track_current_head = (i+1)&15;
+
+ if(track_current_sum>track_current_peak)
+ track_current_peak = track_current_sum;
+
+ if(track_current_sum>overcurrent_limit)
+ {
+ output_set_power(0);
+ PORTB |= 0x02;
+ if(!overcurrent_sent)
+ {
+ overcurrent_sent = 1;
+ interface_send1(OVERCURRENT);
+ }
+ }
+ else if(overcurrent_sent && output_is_power_on())
+ {
+ PORTB &= ~0x02;
+ overcurrent_sent = 0;
+ }
+ }
+ else if(adc_state==4)