
Impedance Fast Circuitry Software
Fork of DSP_200kHz by
Jareds_DSP/print_data.cpp@81:30d699e951a8, 2017-08-30 (annotated)
- Committer:
- baxterja
- Date:
- Wed Aug 30 00:02:06 2017 +0000
- Revision:
- 81:30d699e951a8
- Parent:
- 78:10b2916b8f5c
- Child:
- 83:0d068da1c6b7
I added a check for inf and nan before the print statement.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
baxterja | 76:704fc58ffcd0 | 1 | #include "print_data.h" |
baxterja | 76:704fc58ffcd0 | 2 | |
baxterja | 78:10b2916b8f5c | 3 | #define NUM_PRINT_INPUTS 2 |
baxterja | 77:1ee17a9e9f8b | 4 | DigitalOut status_2(D4); |
baxterja | 78:10b2916b8f5c | 5 | int printing_length[NUM_PRINT_INPUTS] = {0}; |
baxterja | 78:10b2916b8f5c | 6 | int printing_counter[NUM_PRINT_INPUTS] = {0}; |
baxterja | 78:10b2916b8f5c | 7 | char print_buffer[NUM_PRINT_INPUTS][50]; |
baxterja | 78:10b2916b8f5c | 8 | |
baxterja | 76:704fc58ffcd0 | 9 | |
baxterja | 77:1ee17a9e9f8b | 10 | |
baxterja | 77:1ee17a9e9f8b | 11 | void print_filter_data(Serial *pc) |
baxterja | 76:704fc58ffcd0 | 12 | { |
baxterja | 78:10b2916b8f5c | 13 | static int current_print_frequency = 0; |
baxterja | 78:10b2916b8f5c | 14 | if (printing_counter[current_print_frequency]>=printing_length[current_print_frequency]) |
baxterja | 78:10b2916b8f5c | 15 | { |
baxterja | 78:10b2916b8f5c | 16 | printing_counter[current_print_frequency]= 0; |
baxterja | 78:10b2916b8f5c | 17 | printing_length[current_print_frequency] = 0; |
baxterja | 78:10b2916b8f5c | 18 | current_print_frequency++; |
baxterja | 78:10b2916b8f5c | 19 | if (current_print_frequency>=NUM_PRINT_INPUTS) |
baxterja | 78:10b2916b8f5c | 20 | { |
baxterja | 78:10b2916b8f5c | 21 | current_print_frequency=0; |
baxterja | 78:10b2916b8f5c | 22 | } |
baxterja | 76:704fc58ffcd0 | 23 | return; |
baxterja | 78:10b2916b8f5c | 24 | } |
baxterja | 76:704fc58ffcd0 | 25 | status_2 = 1; |
baxterja | 77:1ee17a9e9f8b | 26 | //printf("Y"); |
baxterja | 78:10b2916b8f5c | 27 | pc->printf("%c",print_buffer[current_print_frequency][printing_counter[current_print_frequency]]); |
baxterja | 78:10b2916b8f5c | 28 | printing_counter[current_print_frequency]++; |
baxterja | 77:1ee17a9e9f8b | 29 | |
baxterja | 76:704fc58ffcd0 | 30 | status_2 = 0; |
baxterja | 76:704fc58ffcd0 | 31 | } |
baxterja | 78:10b2916b8f5c | 32 | void set_print_buffer(float mag,float phase, int print_identifier) |
baxterja | 76:704fc58ffcd0 | 33 | { |
baxterja | 81:30d699e951a8 | 34 | if(isnan(mag)||isinf(mag)||isnan(phase)||isinf(phase)) |
baxterja | 81:30d699e951a8 | 35 | { |
baxterja | 81:30d699e951a8 | 36 | return; |
baxterja | 81:30d699e951a8 | 37 | } |
baxterja | 78:10b2916b8f5c | 38 | |
baxterja | 76:704fc58ffcd0 | 39 | if (printing_counter<printing_length) |
baxterja | 76:704fc58ffcd0 | 40 | { |
baxterja | 76:704fc58ffcd0 | 41 | printf("PRINT OVERLOAD\n\r"); |
baxterja | 76:704fc58ffcd0 | 42 | } |
baxterja | 77:1ee17a9e9f8b | 43 | |
baxterja | 78:10b2916b8f5c | 44 | printing_length[print_identifier]=sprintf (print_buffer[print_identifier], "%d %E %f\n\r",print_identifier, mag, phase); |
baxterja | 78:10b2916b8f5c | 45 | //printing_counter[print_identifier] = 0; |
baxterja | 77:1ee17a9e9f8b | 46 | |
baxterja | 76:704fc58ffcd0 | 47 | } |