projects
/
Arduino-Nano-VA-meter
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
79ded4b
)
report only changed values on serial
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 16 Oct 2016 09:10:01 +0000
(11:10 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 16 Oct 2016 09:10:01 +0000
(11:10 +0200)
main.c
patch
|
blob
|
history
diff --git
a/main.c
b/main.c
index
181cde5
..
fc797a6
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-6,6
+6,9
@@
#define USART_BAUDRATE 9600
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
#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
void serial_init(){
// initialize USART (must call this before using it)
UBRR0=UBRR_VALUE; // set baud rate
@@
-86,6
+89,9
@@
volatile uint8_t regD;
volatile char current[4];
volatile char voltage[4];
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
void read_capture(){
// load the volatile capture variables with tue current pin state
@@
-185,7
+191,19
@@
void capture_full(){
if (capture_letter('1'+i)) {break;}
}
}
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('.');}
for(i=0;i<4;i++) {
serial_send(voltage[i]);
if (i==1){serial_send('.');}