#define USART_BAUDRATE 9600
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
+// this will output only changes on serial
+#define SERIAL_CHANGES 1
+
void serial_init(){
// initialize USART (must call this before using it)
UBRR0=UBRR_VALUE; // set baud rate
volatile char current[4];
volatile char voltage[4];
+volatile int display_sum = 0;
+volatile int last_display_sum = 0;
+
void read_capture(){
// load the volatile capture variables with tue current pin state
if (capture_letter('1'+i)) {break;}
}
}
-
+
+#if SERIAL_CHANGES
+ // don't send same values over serial
+ for(i=0;i<4;i++) {
+ display_sum = voltage[i] + current[i];
+ }
+ if ( display_sum == last_display_sum ) {
+ return;
+ } else {
+ last_display_sum = display_sum;
+ }
+#endif
+
for(i=0;i<4;i++) {
serial_send(voltage[i]);
if (i==1){serial_send('.');}