
Impedance Fast Circuitry Software
Fork of DSP_200kHz by
Jareds_DSP/print_data.cpp@86:b3520f4453cf, 2018-06-22 (annotated)
- Committer:
- baxterja
- Date:
- Fri Jun 22 18:13:46 2018 +0000
- Revision:
- 86:b3520f4453cf
- Parent:
- 84:5b4466dd2326
Added Time stamping to the output
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 | 86:b3520f4453cf | 11 | |
baxterja | 84:5b4466dd2326 | 12 | void print_filter_data(Serial *pc, bool is_actively_printing) |
baxterja | 76:704fc58ffcd0 | 13 | { |
baxterja | 78:10b2916b8f5c | 14 | static int current_print_frequency = 0; |
baxterja | 78:10b2916b8f5c | 15 | if (printing_counter[current_print_frequency]>=printing_length[current_print_frequency]) |
baxterja | 78:10b2916b8f5c | 16 | { |
baxterja | 78:10b2916b8f5c | 17 | printing_counter[current_print_frequency]= 0; |
baxterja | 78:10b2916b8f5c | 18 | printing_length[current_print_frequency] = 0; |
baxterja | 78:10b2916b8f5c | 19 | current_print_frequency++; |
baxterja | 78:10b2916b8f5c | 20 | if (current_print_frequency>=NUM_PRINT_INPUTS) |
baxterja | 78:10b2916b8f5c | 21 | { |
baxterja | 78:10b2916b8f5c | 22 | current_print_frequency=0; |
baxterja | 78:10b2916b8f5c | 23 | } |
baxterja | 76:704fc58ffcd0 | 24 | return; |
baxterja | 78:10b2916b8f5c | 25 | } |
baxterja | 76:704fc58ffcd0 | 26 | status_2 = 1; |
baxterja | 77:1ee17a9e9f8b | 27 | //printf("Y"); |
baxterja | 84:5b4466dd2326 | 28 | if (is_actively_printing) |
baxterja | 84:5b4466dd2326 | 29 | { |
baxterja | 84:5b4466dd2326 | 30 | pc->printf("%c",print_buffer[current_print_frequency][printing_counter[current_print_frequency]]); |
baxterja | 84:5b4466dd2326 | 31 | } |
baxterja | 78:10b2916b8f5c | 32 | printing_counter[current_print_frequency]++; |
baxterja | 77:1ee17a9e9f8b | 33 | |
baxterja | 76:704fc58ffcd0 | 34 | status_2 = 0; |
baxterja | 76:704fc58ffcd0 | 35 | } |
baxterja | 84:5b4466dd2326 | 36 | void set_print_buffer(double mag,double phase, int print_identifier) |
baxterja | 76:704fc58ffcd0 | 37 | { |
baxterja | 77:1ee17a9e9f8b | 38 | |
baxterja | 78:10b2916b8f5c | 39 | |
baxterja | 76:704fc58ffcd0 | 40 | if (printing_counter<printing_length) |
baxterja | 76:704fc58ffcd0 | 41 | { |
baxterja | 76:704fc58ffcd0 | 42 | printf("PRINT OVERLOAD\n\r"); |
baxterja | 76:704fc58ffcd0 | 43 | } |
baxterja | 77:1ee17a9e9f8b | 44 | |
baxterja | 86:b3520f4453cf | 45 | printing_length[print_identifier]=sprintf (print_buffer[print_identifier], "%d %.3E %.3f %.4f\n\r",print_identifier, mag, phase, timer.read()); |
baxterja | 78:10b2916b8f5c | 46 | //printing_counter[print_identifier] = 0; |
baxterja | 77:1ee17a9e9f8b | 47 | |
baxterja | 76:704fc58ffcd0 | 48 | } |