Tacometro auditivo para autos de 4 cilindros y 4 tiempos
Dependencies: FastAnalogIn NVIC_set_all_priorities TextLCD mbed-dsp mbed
Fork of KL25Z_FFT_Demo_tony by
main.cpp@4:9fae1f1b731a, 2016-11-19 (annotated)
- Committer:
- efrain95
- Date:
- Sat Nov 19 06:47:31 2016 +0000
- Revision:
- 4:9fae1f1b731a
- Parent:
- 3:1c6625b2d363
Tacometro para motor de 4 tiempos y 4 cilindros
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony1tf | 0:b8c9dffbbe7e | 1 | // Audio Spectrum Display |
tony1tf | 0:b8c9dffbbe7e | 2 | // Copyright 2013 Tony DiCola (tony@tonydicola.com) |
tony1tf | 0:b8c9dffbbe7e | 3 | // Code ported from the guide at http://learn.adafruit.com/fft-fun-with-fourier-transforms?view=all |
tony1tf | 0:b8c9dffbbe7e | 4 | // mods by Tony Abbey to simplify code to drive tri-colour LED as a "colour organ" |
tony1tf | 0:b8c9dffbbe7e | 5 | |
tony1tf | 0:b8c9dffbbe7e | 6 | #include "mbed.h" |
tony1tf | 0:b8c9dffbbe7e | 7 | #include "NVIC_set_all_priorities.h" |
tony1tf | 0:b8c9dffbbe7e | 8 | #include <ctype.h> |
tony1tf | 0:b8c9dffbbe7e | 9 | #include "arm_math.h" |
tony1tf | 0:b8c9dffbbe7e | 10 | #include "arm_const_structs.h" |
tony1tf | 0:b8c9dffbbe7e | 11 | #include "FastAnalogIn.h" |
luisda130595 | 1:7421267b0777 | 12 | #include <string> |
efrain95 | 4:9fae1f1b731a | 13 | #include "TextLCD.h" |
tony1tf | 0:b8c9dffbbe7e | 14 | |
luisda130595 | 1:7421267b0777 | 15 | FastAnalogIn Audio(PTC2); |
tony1tf | 0:b8c9dffbbe7e | 16 | Serial pc(USBTX, USBRX); |
efrain95 | 4:9fae1f1b731a | 17 | TextLCD lcd(PTB0,PTB1,PTC9,PTC8,PTA5,PTA4, TextLCD::LCD16x2); // rs, e, d4-d7 |
tony1tf | 0:b8c9dffbbe7e | 18 | |
tony1tf | 0:b8c9dffbbe7e | 19 | |
tony1tf | 0:b8c9dffbbe7e | 20 | //#define RGBW_ext // Disable this line when you want to use the KL25Z on-board RGB LED. |
tony1tf | 0:b8c9dffbbe7e | 21 | |
tony1tf | 0:b8c9dffbbe7e | 22 | |
tony1tf | 0:b8c9dffbbe7e | 23 | #ifndef RGBW_ext |
tony1tf | 0:b8c9dffbbe7e | 24 | // RGB direct output to PWM channels - on-board RGB LED |
tony1tf | 0:b8c9dffbbe7e | 25 | PwmOut gled(LED_GREEN); |
tony1tf | 0:b8c9dffbbe7e | 26 | PwmOut rled(LED_RED); |
tony1tf | 0:b8c9dffbbe7e | 27 | PwmOut bled(LED_BLUE); |
tony1tf | 0:b8c9dffbbe7e | 28 | #else |
tony1tf | 0:b8c9dffbbe7e | 29 | // HSI to RGBW conversion with direct output to external PWM channels - RGBW LED |
tony1tf | 0:b8c9dffbbe7e | 30 | // hsi2rgbw_pwm led(PTD4, PTA12, PTA4, PTA5); //Red, Green, Blue, White |
tony1tf | 0:b8c9dffbbe7e | 31 | #endif |
tony1tf | 0:b8c9dffbbe7e | 32 | |
tony1tf | 0:b8c9dffbbe7e | 33 | // Dummy ISR for disabling NMI on PTA4 - !! DO NOT REMOVE THIS !! |
tony1tf | 0:b8c9dffbbe7e | 34 | // More info at https://mbed.org/questions/1387/How-can-I-access-the-FTFA_FOPT-register-/ |
tony1tf | 0:b8c9dffbbe7e | 35 | extern "C" void NMI_Handler() { |
tony1tf | 0:b8c9dffbbe7e | 36 | DigitalIn test(PTA4); |
tony1tf | 0:b8c9dffbbe7e | 37 | } |
tony1tf | 0:b8c9dffbbe7e | 38 | |
tony1tf | 0:b8c9dffbbe7e | 39 | |
tony1tf | 0:b8c9dffbbe7e | 40 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 41 | // CONFIGURATION |
tony1tf | 0:b8c9dffbbe7e | 42 | // These values can be changed to alter the behavior of the spectrum display. |
tony1tf | 0:b8c9dffbbe7e | 43 | // KL25Z limitations |
tony1tf | 0:b8c9dffbbe7e | 44 | // ----------------- |
tony1tf | 0:b8c9dffbbe7e | 45 | // - When used with the Spectrogram python script : |
tony1tf | 0:b8c9dffbbe7e | 46 | // There is a substantial time lag between the music and the screen output. |
tony1tf | 0:b8c9dffbbe7e | 47 | // Max allowed SAMPLE_RATE_HZ is 40000 |
tony1tf | 0:b8c9dffbbe7e | 48 | // Max allowed FFT_SIZE is 64 |
tony1tf | 0:b8c9dffbbe7e | 49 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 50 | // A value >= 1000 and <= 1000 + PIXEL_COUNT fixes the output to a single frequency |
tony1tf | 0:b8c9dffbbe7e | 51 | // window = a single color. |
luisda130595 | 1:7421267b0777 | 52 | int SAMPLE_RATE_HZ = 1000; // Sample rate of the audio in hertz. |
hermes_3673 | 3:1c6625b2d363 | 53 | float freq=0; |
tony1tf | 0:b8c9dffbbe7e | 54 | // Useful for turning the LED display on and off with commands from the serial port. |
efrain95 | 4:9fae1f1b731a | 55 | const int FFT_SIZE = 512; // Size of the FFT. |
tony1tf | 0:b8c9dffbbe7e | 56 | |
tony1tf | 0:b8c9dffbbe7e | 57 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 58 | // INTERNAL STATE |
tony1tf | 0:b8c9dffbbe7e | 59 | // These shouldn't be modified unless you know what you're doing. |
tony1tf | 0:b8c9dffbbe7e | 60 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 61 | const static arm_cfft_instance_f32 *S; |
tony1tf | 0:b8c9dffbbe7e | 62 | Ticker samplingTimer; |
tony1tf | 0:b8c9dffbbe7e | 63 | float samples[FFT_SIZE*2]; |
tony1tf | 0:b8c9dffbbe7e | 64 | float magnitudes[FFT_SIZE]; |
tony1tf | 0:b8c9dffbbe7e | 65 | int sampleCounter = 0; |
luisda130595 | 2:177596541c8d | 66 | int maxFrequencyValue = 0; |
hermes_3673 | 3:1c6625b2d363 | 67 | float maxValue=0.0; |
hermes_3673 | 3:1c6625b2d363 | 68 | int posicion=0; |
hermes_3673 | 3:1c6625b2d363 | 69 | int counter=0; |
luisda130595 | 2:177596541c8d | 70 | int FFTFrequency = 0; |
efrain95 | 4:9fae1f1b731a | 71 | float filtro[FFT_SIZE]; |
tony1tf | 0:b8c9dffbbe7e | 72 | |
tony1tf | 0:b8c9dffbbe7e | 73 | // Convert a frequency to the appropriate FFT bin it will fall within. |
tony1tf | 0:b8c9dffbbe7e | 74 | int frequencyToBin(float frequency) |
tony1tf | 0:b8c9dffbbe7e | 75 | { |
tony1tf | 0:b8c9dffbbe7e | 76 | float binFrequency = float(SAMPLE_RATE_HZ) / float(FFT_SIZE); |
tony1tf | 0:b8c9dffbbe7e | 77 | return int(frequency / binFrequency); |
tony1tf | 0:b8c9dffbbe7e | 78 | } |
tony1tf | 0:b8c9dffbbe7e | 79 | |
tony1tf | 0:b8c9dffbbe7e | 80 | |
tony1tf | 0:b8c9dffbbe7e | 81 | |
tony1tf | 0:b8c9dffbbe7e | 82 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 83 | // SAMPLING FUNCTIONS |
tony1tf | 0:b8c9dffbbe7e | 84 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 85 | |
tony1tf | 0:b8c9dffbbe7e | 86 | void samplingCallback() |
tony1tf | 0:b8c9dffbbe7e | 87 | { |
tony1tf | 0:b8c9dffbbe7e | 88 | // Read from the ADC and store the sample data |
tony1tf | 0:b8c9dffbbe7e | 89 | samples[sampleCounter] = (1023 * Audio) - 511.0f; |
tony1tf | 0:b8c9dffbbe7e | 90 | // Complex FFT functions require a coefficient for the imaginary part of the input. |
tony1tf | 0:b8c9dffbbe7e | 91 | // Since we only have real data, set this coefficient to zero. |
tony1tf | 0:b8c9dffbbe7e | 92 | samples[sampleCounter+1] = 0.0; |
tony1tf | 0:b8c9dffbbe7e | 93 | // Update sample buffer position and stop after the buffer is filled |
tony1tf | 0:b8c9dffbbe7e | 94 | sampleCounter += 2; |
tony1tf | 0:b8c9dffbbe7e | 95 | if (sampleCounter >= FFT_SIZE*2) { |
tony1tf | 0:b8c9dffbbe7e | 96 | samplingTimer.detach(); |
tony1tf | 0:b8c9dffbbe7e | 97 | } |
tony1tf | 0:b8c9dffbbe7e | 98 | } |
efrain95 | 4:9fae1f1b731a | 99 | void aplicarfiltro() |
efrain95 | 4:9fae1f1b731a | 100 | { |
efrain95 | 4:9fae1f1b731a | 101 | float aux; |
efrain95 | 4:9fae1f1b731a | 102 | for(int i=0;i<=FFT_SIZE;i++) |
efrain95 | 4:9fae1f1b731a | 103 | { |
efrain95 | 4:9fae1f1b731a | 104 | aux=filtro[i]*magnitudes[i]; |
efrain95 | 4:9fae1f1b731a | 105 | magnitudes[i]=aux; |
efrain95 | 4:9fae1f1b731a | 106 | } |
efrain95 | 4:9fae1f1b731a | 107 | } |
efrain95 | 4:9fae1f1b731a | 108 | void generarfiltro() |
efrain95 | 4:9fae1f1b731a | 109 | { |
efrain95 | 4:9fae1f1b731a | 110 | |
efrain95 | 4:9fae1f1b731a | 111 | for(int i=0;i<=FFT_SIZE;i++) |
efrain95 | 4:9fae1f1b731a | 112 | { |
efrain95 | 4:9fae1f1b731a | 113 | if(i>9) |
efrain95 | 4:9fae1f1b731a | 114 | { |
efrain95 | 4:9fae1f1b731a | 115 | if(i<82) |
efrain95 | 4:9fae1f1b731a | 116 | { |
efrain95 | 4:9fae1f1b731a | 117 | filtro[i]=1.0; |
efrain95 | 4:9fae1f1b731a | 118 | } |
efrain95 | 4:9fae1f1b731a | 119 | } |
efrain95 | 4:9fae1f1b731a | 120 | if(i<10) |
efrain95 | 4:9fae1f1b731a | 121 | { |
efrain95 | 4:9fae1f1b731a | 122 | filtro[i]=0.0; |
efrain95 | 4:9fae1f1b731a | 123 | } |
efrain95 | 4:9fae1f1b731a | 124 | if(i>81) |
efrain95 | 4:9fae1f1b731a | 125 | { |
efrain95 | 4:9fae1f1b731a | 126 | filtro[i]=0; |
efrain95 | 4:9fae1f1b731a | 127 | } |
efrain95 | 4:9fae1f1b731a | 128 | } |
efrain95 | 4:9fae1f1b731a | 129 | } |
tony1tf | 0:b8c9dffbbe7e | 130 | void samplingBegin() |
tony1tf | 0:b8c9dffbbe7e | 131 | { |
tony1tf | 0:b8c9dffbbe7e | 132 | // Reset sample buffer position and start callback at necessary rate. |
tony1tf | 0:b8c9dffbbe7e | 133 | sampleCounter = 0; |
tony1tf | 0:b8c9dffbbe7e | 134 | samplingTimer.attach_us(&samplingCallback, 1000000/SAMPLE_RATE_HZ); |
tony1tf | 0:b8c9dffbbe7e | 135 | } |
tony1tf | 0:b8c9dffbbe7e | 136 | |
tony1tf | 0:b8c9dffbbe7e | 137 | bool samplingIsDone() |
tony1tf | 0:b8c9dffbbe7e | 138 | { |
tony1tf | 0:b8c9dffbbe7e | 139 | return sampleCounter >= FFT_SIZE*2; |
tony1tf | 0:b8c9dffbbe7e | 140 | } |
tony1tf | 0:b8c9dffbbe7e | 141 | |
tony1tf | 0:b8c9dffbbe7e | 142 | //////////////////////////////////////////////////////////////////////////////// |
luisda130595 | 1:7421267b0777 | 143 | // FREQUENCY |
tony1tf | 0:b8c9dffbbe7e | 144 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 145 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 146 | // MAIN FUNCTION |
tony1tf | 0:b8c9dffbbe7e | 147 | //////////////////////////////////////////////////////////////////////////////// |
tony1tf | 0:b8c9dffbbe7e | 148 | |
tony1tf | 0:b8c9dffbbe7e | 149 | int main() |
tony1tf | 0:b8c9dffbbe7e | 150 | { |
tony1tf | 0:b8c9dffbbe7e | 151 | NVIC_set_all_irq_priorities(1); |
tony1tf | 0:b8c9dffbbe7e | 152 | NVIC_SetPriority(UART0_IRQn, 0); |
efrain95 | 4:9fae1f1b731a | 153 | lcd.cls(); |
efrain95 | 4:9fae1f1b731a | 154 | lcd.printf("RPM: "); |
efrain95 | 4:9fae1f1b731a | 155 | lcd.locate(0,1); |
efrain95 | 4:9fae1f1b731a | 156 | lcd.printf("F= "); |
efrain95 | 4:9fae1f1b731a | 157 | const int columnafrec=3; |
efrain95 | 4:9fae1f1b731a | 158 | const int columnarpm=5; |
efrain95 | 4:9fae1f1b731a | 159 | const int filafrec=1; |
efrain95 | 4:9fae1f1b731a | 160 | const int filarpm=0; |
tony1tf | 0:b8c9dffbbe7e | 161 | |
tony1tf | 0:b8c9dffbbe7e | 162 | // Begin sampling audio |
tony1tf | 0:b8c9dffbbe7e | 163 | samplingBegin(); |
tony1tf | 0:b8c9dffbbe7e | 164 | |
tony1tf | 0:b8c9dffbbe7e | 165 | // Init arm_ccft_32 |
tony1tf | 0:b8c9dffbbe7e | 166 | switch (FFT_SIZE) |
tony1tf | 0:b8c9dffbbe7e | 167 | { |
tony1tf | 0:b8c9dffbbe7e | 168 | case 16: |
tony1tf | 0:b8c9dffbbe7e | 169 | S = & arm_cfft_sR_f32_len16; |
tony1tf | 0:b8c9dffbbe7e | 170 | break; |
tony1tf | 0:b8c9dffbbe7e | 171 | case 32: |
tony1tf | 0:b8c9dffbbe7e | 172 | S = & arm_cfft_sR_f32_len32; |
tony1tf | 0:b8c9dffbbe7e | 173 | break; |
tony1tf | 0:b8c9dffbbe7e | 174 | case 64: |
tony1tf | 0:b8c9dffbbe7e | 175 | S = & arm_cfft_sR_f32_len64; |
tony1tf | 0:b8c9dffbbe7e | 176 | break; |
tony1tf | 0:b8c9dffbbe7e | 177 | case 128: |
tony1tf | 0:b8c9dffbbe7e | 178 | S = & arm_cfft_sR_f32_len128; |
tony1tf | 0:b8c9dffbbe7e | 179 | break; |
tony1tf | 0:b8c9dffbbe7e | 180 | case 256: |
tony1tf | 0:b8c9dffbbe7e | 181 | S = & arm_cfft_sR_f32_len256; |
tony1tf | 0:b8c9dffbbe7e | 182 | break; |
tony1tf | 0:b8c9dffbbe7e | 183 | case 512: |
tony1tf | 0:b8c9dffbbe7e | 184 | S = & arm_cfft_sR_f32_len512; |
tony1tf | 0:b8c9dffbbe7e | 185 | break; |
tony1tf | 0:b8c9dffbbe7e | 186 | case 1024: |
tony1tf | 0:b8c9dffbbe7e | 187 | S = & arm_cfft_sR_f32_len1024; |
tony1tf | 0:b8c9dffbbe7e | 188 | break; |
tony1tf | 0:b8c9dffbbe7e | 189 | case 2048: |
tony1tf | 0:b8c9dffbbe7e | 190 | S = & arm_cfft_sR_f32_len2048; |
tony1tf | 0:b8c9dffbbe7e | 191 | break; |
tony1tf | 0:b8c9dffbbe7e | 192 | case 4096: |
tony1tf | 0:b8c9dffbbe7e | 193 | S = & arm_cfft_sR_f32_len4096; |
tony1tf | 0:b8c9dffbbe7e | 194 | break; |
tony1tf | 0:b8c9dffbbe7e | 195 | } |
tony1tf | 0:b8c9dffbbe7e | 196 | |
luisda130595 | 1:7421267b0777 | 197 | while(true) { |
tony1tf | 0:b8c9dffbbe7e | 198 | // Calculate FFT if a full sample is available. |
tony1tf | 0:b8c9dffbbe7e | 199 | if (samplingIsDone()) { |
tony1tf | 0:b8c9dffbbe7e | 200 | // Run FFT on sample data. |
tony1tf | 0:b8c9dffbbe7e | 201 | arm_cfft_f32(S, samples, 0, 1); |
tony1tf | 0:b8c9dffbbe7e | 202 | // Calculate magnitude of complex numbers output by the FFT. |
tony1tf | 0:b8c9dffbbe7e | 203 | arm_cmplx_mag_f32(samples, magnitudes, FFT_SIZE); |
efrain95 | 4:9fae1f1b731a | 204 | //generar y aplicar filtro de 20hz y 200hz |
efrain95 | 4:9fae1f1b731a | 205 | generarfiltro(); |
efrain95 | 4:9fae1f1b731a | 206 | aplicarfiltro(); |
luisda130595 | 1:7421267b0777 | 207 | //Obtaining the value of the frequency |
hermes_3673 | 3:1c6625b2d363 | 208 | posicion=0; |
hermes_3673 | 3:1c6625b2d363 | 209 | counter=0; |
hermes_3673 | 3:1c6625b2d363 | 210 | maxValue=0.0; |
hermes_3673 | 3:1c6625b2d363 | 211 | do{ |
hermes_3673 | 3:1c6625b2d363 | 212 | counter++; |
hermes_3673 | 3:1c6625b2d363 | 213 | if(magnitudes[counter]>maxValue){ |
hermes_3673 | 3:1c6625b2d363 | 214 | maxValue=magnitudes[counter]; |
hermes_3673 | 3:1c6625b2d363 | 215 | posicion=counter; |
hermes_3673 | 3:1c6625b2d363 | 216 | } |
hermes_3673 | 3:1c6625b2d363 | 217 | |
hermes_3673 | 3:1c6625b2d363 | 218 | }while(counter<256); |
luisda130595 | 1:7421267b0777 | 219 | |
tony1tf | 0:b8c9dffbbe7e | 220 | // Restart audio sampling. |
tony1tf | 0:b8c9dffbbe7e | 221 | samplingBegin(); |
hermes_3673 | 3:1c6625b2d363 | 222 | } |
hermes_3673 | 3:1c6625b2d363 | 223 | freq=(float) posicion; |
efrain95 | 4:9fae1f1b731a | 224 | freq=freq*1.953125; |
efrain95 | 4:9fae1f1b731a | 225 | if(freq<25) |
efrain95 | 4:9fae1f1b731a | 226 | { |
efrain95 | 4:9fae1f1b731a | 227 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 228 | lcd.printf("<750 "); |
efrain95 | 4:9fae1f1b731a | 229 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 230 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 231 | } |
efrain95 | 4:9fae1f1b731a | 232 | if(freq>=25 ) |
hermes_3673 | 3:1c6625b2d363 | 233 | { |
efrain95 | 4:9fae1f1b731a | 234 | if(freq<39) |
efrain95 | 4:9fae1f1b731a | 235 | { |
efrain95 | 4:9fae1f1b731a | 236 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 237 | lcd.printf("%i ",(int)(750+(freq-25)*20.83)); |
efrain95 | 4:9fae1f1b731a | 238 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 239 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 240 | } |
hermes_3673 | 3:1c6625b2d363 | 241 | } |
efrain95 | 4:9fae1f1b731a | 242 | if(freq>=39 ) |
hermes_3673 | 3:1c6625b2d363 | 243 | { |
efrain95 | 4:9fae1f1b731a | 244 | if(freq<54) |
efrain95 | 4:9fae1f1b731a | 245 | { |
efrain95 | 4:9fae1f1b731a | 246 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 247 | lcd.printf("%i ",(int)(1000+(freq-39)*33.33)); |
efrain95 | 4:9fae1f1b731a | 248 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 249 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 250 | |
efrain95 | 4:9fae1f1b731a | 251 | } |
hermes_3673 | 3:1c6625b2d363 | 252 | } |
efrain95 | 4:9fae1f1b731a | 253 | if(freq>=54 ) |
hermes_3673 | 3:1c6625b2d363 | 254 | { |
efrain95 | 4:9fae1f1b731a | 255 | if(freq<=61 ) |
efrain95 | 4:9fae1f1b731a | 256 | { |
efrain95 | 4:9fae1f1b731a | 257 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 258 | lcd.printf("%i ",(int)(1500+(freq-54)*71.42)); |
efrain95 | 4:9fae1f1b731a | 259 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 260 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 261 | } |
efrain95 | 4:9fae1f1b731a | 262 | } |
efrain95 | 4:9fae1f1b731a | 263 | if(freq>61 ) |
efrain95 | 4:9fae1f1b731a | 264 | { |
efrain95 | 4:9fae1f1b731a | 265 | if(freq<=82 ) |
efrain95 | 4:9fae1f1b731a | 266 | { |
efrain95 | 4:9fae1f1b731a | 267 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 268 | lcd.printf("%i ",((int)(2000+(freq-62)*23.8))); |
efrain95 | 4:9fae1f1b731a | 269 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 270 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 271 | } |
hermes_3673 | 3:1c6625b2d363 | 272 | } |
efrain95 | 4:9fae1f1b731a | 273 | if(freq>82 ) |
hermes_3673 | 3:1c6625b2d363 | 274 | { |
efrain95 | 4:9fae1f1b731a | 275 | if(freq<=102 ) |
efrain95 | 4:9fae1f1b731a | 276 | { |
efrain95 | 4:9fae1f1b731a | 277 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 278 | lcd.printf("%i ",(int)(2500+(freq-83)*25)); |
efrain95 | 4:9fae1f1b731a | 279 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 280 | lcd.printf("%i ",(int)freq); |
efrain95 | 4:9fae1f1b731a | 281 | } |
hermes_3673 | 3:1c6625b2d363 | 282 | } |
efrain95 | 4:9fae1f1b731a | 283 | if(freq>102 ) |
efrain95 | 4:9fae1f1b731a | 284 | { |
efrain95 | 4:9fae1f1b731a | 285 | if(freq<=107) |
efrain95 | 4:9fae1f1b731a | 286 | { |
efrain95 | 4:9fae1f1b731a | 287 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 288 | lcd.printf("%i ",(int)(3000+(freq-103)*100)); |
efrain95 | 4:9fae1f1b731a | 289 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 290 | lcd.printf("%i",(int)freq); |
efrain95 | 4:9fae1f1b731a | 291 | } |
efrain95 | 4:9fae1f1b731a | 292 | } |
efrain95 | 4:9fae1f1b731a | 293 | if(freq>107 ) |
hermes_3673 | 3:1c6625b2d363 | 294 | { |
efrain95 | 4:9fae1f1b731a | 295 | if(freq<=129) |
efrain95 | 4:9fae1f1b731a | 296 | { |
efrain95 | 4:9fae1f1b731a | 297 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 298 | lcd.printf("%i ",(int)(3500+(freq-108)*22.72)); |
efrain95 | 4:9fae1f1b731a | 299 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 300 | lcd.printf("%i",(int)freq); |
efrain95 | 4:9fae1f1b731a | 301 | } |
hermes_3673 | 3:1c6625b2d363 | 302 | } |
efrain95 | 4:9fae1f1b731a | 303 | if(freq>129) |
hermes_3673 | 3:1c6625b2d363 | 304 | { |
efrain95 | 4:9fae1f1b731a | 305 | |
efrain95 | 4:9fae1f1b731a | 306 | if(freq<=133) |
efrain95 | 4:9fae1f1b731a | 307 | { |
efrain95 | 4:9fae1f1b731a | 308 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 309 | lcd.printf("4000 "); |
efrain95 | 4:9fae1f1b731a | 310 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 311 | lcd.printf("%i",(int)freq); |
efrain95 | 4:9fae1f1b731a | 312 | } |
hermes_3673 | 3:1c6625b2d363 | 313 | } |
efrain95 | 4:9fae1f1b731a | 314 | if(freq>133) |
efrain95 | 4:9fae1f1b731a | 315 | { |
efrain95 | 4:9fae1f1b731a | 316 | lcd.locate(columnarpm,filarpm); |
efrain95 | 4:9fae1f1b731a | 317 | lcd.printf("4000>"); |
efrain95 | 4:9fae1f1b731a | 318 | lcd.locate(columnafrec,filafrec); |
efrain95 | 4:9fae1f1b731a | 319 | lcd.printf("%i",(int)freq); |
efrain95 | 4:9fae1f1b731a | 320 | } |
tony1tf | 0:b8c9dffbbe7e | 321 | } |
luisda130595 | 1:7421267b0777 | 322 | |
tony1tf | 0:b8c9dffbbe7e | 323 | } |