1 #include "commands.h"
\r
6 * @purpose Implementation of commands for Datalogger
\r
17 #include "LCD_functions.h"
\r
23 uint8 read_adc(char * arg)
\r
27 for (uint8 i=0; i < 8; ++i)
\r
29 USART_printf("%i ", ADC_read(i));
\r
34 for (char * a = arg; *a != '\0'; ++a)
\r
36 //uint8 channel = *a - '0';
\r
37 //if (channel >= 0 && channel <= 7)
\r
38 USART_printf("%f %f ", ADC_read(*a - '0'), sqrt(setup.adc_variance[(*a - '0')]));
\r
40 LCD_printf("%i", (uint)(setup.adc_values[(int)(arg[0] - '0')]));
\r
42 USART_printf("\r\n");
\r
47 uint8 poll_adc(char * arg)
\r
50 //USART_printf("# poll\r\n");
\r
52 //USART_printf("#t ADC0 ADC1 ADC2 ADC3 ADC4 ADC5 ADC6 ADC7\r\n);
\r
55 setup.elapsed_time = 0;
\r
56 USART_printf("%l ", tmr);
\r
58 if (arg[0] == '\0' || arg[1] == 't')
\r
64 //if (setup.elapsed_time > setup.poll_delay)
\r
66 // USART_printf("# tmr>delay\r\n");
\r
70 while (setup.elapsed_time < setup.poll_delay)
\r
72 if (USART_Poll() != '\0')
\r
74 //USART_printf("# STOP %i\r\n", tmr+setup.elapsed_time);
\r
79 tmr += setup.elapsed_time;
\r
81 while (tmr < setup.poll_timeout);
\r
82 //USART_printf("# done.\r\n");
\r
87 uint8 set_dac(char * arg)
\r
91 setup.dac_value = atoi(arg);
\r
92 DAC_Set(setup.dac_value);
\r
94 USART_printf("# DAC %i\r\n", setup.dac_value);
\r
95 LCD_printf("D %i", setup.dac_value);
\r
99 uint8 set_averages(char * arg)
\r
101 if (arg[0] != '\0')
\r
103 setup.adc_averages = atoi(arg);
\r
105 USART_printf("# Avgs %i\r\n", setup.adc_averages);
\r
106 LCD_printf("Avgs %i", setup.adc_averages);
\r
110 uint8 set_timeout(char * arg)
\r
112 if (arg[0] != '\0')
\r
114 setup.poll_timeout = atoi(arg);
\r
116 USART_printf("# timeout %i\r\n", setup.poll_timeout);
\r
117 LCD_printf("timeout %i", setup.poll_timeout);
\r
121 uint8 set_delay(char * arg)
\r
123 if (arg[0] != '\0')
\r
125 setup.poll_delay = atoi(arg);
\r
127 USART_printf("# delay %i\r\n", setup.poll_delay);
\r
128 LCD_printf("delay %i", setup.poll_delay);
\r
132 uint8 reset(char * arg)
\r
139 uint8 config(char * arg)
\r
141 if (arg[0] == '\0')
\r
149 setup.poll_delay = (uint)atoi(arg+1);
\r
152 setup.adc_averages = (uint)atoi(arg+1);
\r
155 setup.poll_timeout = (uint)atoi(arg+1);
\r