diff --git a/Source/.settings/language.settings.xml b/Source/.settings/language.settings.xml new file mode 100644 index 0000000..5b3def7 --- /dev/null +++ b/Source/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/include/hal.h b/Source/include/hal.h index 7757585..b526e13 100644 --- a/Source/include/hal.h +++ b/Source/include/hal.h @@ -162,6 +162,7 @@ extern const Gpio_Pin I2C_SDA; extern const Gpio_Pin FLIP_FLOP_ENABLE; extern const Gpio_Pin RED_LED; +extern const Gpio_Pin FIVE_VOLT_REGULATOR_ENABLE; // extern const Gpio_Pin NC_1; // extern const Gpio_Pin DAC_SWITCHES; diff --git a/Source/src/adc.c b/Source/src/adc.c index 5697081..d0f96c8 100644 --- a/Source/src/adc.c +++ b/Source/src/adc.c @@ -124,12 +124,14 @@ void initAdc() void adcGetConversion() { - HAL_StatusTypeDef result = HAL_ADC_PollForConversion(&AdcHandle1, 10); - result = HAL_ADC_PollForConversion(&AdcHandle2, 10); - result = HAL_ADC_PollForConversion(&AdcHandle3, 10); + HAL_StatusTypeDef result = HAL_ADC_PollForConversion(&AdcHandle1, 100); + result = HAL_ADC_PollForConversion(&AdcHandle2, 100); + result = HAL_ADC_PollForConversion(&AdcHandle3, 100); if (result == HAL_OK) { + //while(HAL_ADC_GetState(&AdcHandle1) != HAL_ADC_STATE_REG_EOC); + /* Check if the continous conversion of regular channel is finished */ if(HAL_ADC_GetState(&AdcHandle1) == 0x300 /*HAL_ADC_STATE_REG_EOC*/ && HAL_ADC_GetState(&AdcHandle2) == 0x300 /*HAL_ADC_STATE_REG_EOC*/ diff --git a/Source/src/hal.c b/Source/src/hal.c index 12c17de..81bf797 100644 --- a/Source/src/hal.c +++ b/Source/src/hal.c @@ -202,6 +202,9 @@ const Gpio_Pin FLIP_FLOP_ENABLE = const Gpio_Pin RED_LED = { GPIOE, GPIO_PIN_13 }; +const Gpio_Pin FIVE_VOLT_REGULATOR_ENABLE = + { GPIOE, GPIO_PIN_2 }; + //// timer pins //const Timer_Pin LED_G = //{ @@ -868,6 +871,13 @@ hal_setupPins (void) gpioInitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init (FLIP_FLOP_ENABLE.port, &gpioInitStructure); HAL_GPIO_WritePin (FLIP_FLOP_ENABLE.port, TRX_SWITCH.pin, 0); + + gpioInitStructure.Pin = FIVE_VOLT_REGULATOR_ENABLE.pin; + gpioInitStructure.Speed = GPIO_SPEED_LOW; + gpioInitStructure.Mode = GPIO_MODE_OUTPUT_PP; + gpioInitStructure.Pull = GPIO_NOPULL; + HAL_GPIO_Init (FIVE_VOLT_REGULATOR_ENABLE.port, &gpioInitStructure); + HAL_GPIO_WritePin (FIVE_VOLT_REGULATOR_ENABLE.port, FIVE_VOLT_REGULATOR_ENABLE.pin, 0); } // diff --git a/Source/src/main.c b/Source/src/main.c index 501c33e..cc05e31 100644 --- a/Source/src/main.c +++ b/Source/src/main.c @@ -1337,67 +1337,74 @@ void updateDisplay(uint8_t force) displayUpdating = 0; } +int newWaterFallData = 0; void drawWaterfall() { - static float magnitudes[FFT_SIZE]; - static float mags; - static uint8_t waterfallScanLine = 0; + if(newWaterFallData == 1) + { + static float magnitudes[FFT_SIZE]; + static float mags; + static uint8_t waterfallScanLine = 0; - unsigned short *gradient; + unsigned short *gradient; - if(transmitting) - gradient = &bitmapIronGradient; - else - gradient = &bitmapWebSdrGradient; + if(transmitting) + gradient = &bitmapIronGradient; + else + gradient = &bitmapWebSdrGradient; - //arm_cmplx_mag_f32(samplesDisplay, magnitudes, FFT_SIZE); - arm_cmplx_mag_f32(samplesDisplay, magnitudes, FFT_SIZE); + //arm_cmplx_mag_f32(samplesDisplay, magnitudes, FFT_SIZE); + arm_cmplx_mag_f32(samplesDisplay, magnitudes, FFT_SIZE); - float fftMax = 0; //AH! These are being reset each time! Static makes them persistant right? Does it also ensure they are - float fftMin = 100; //only initialized once? Have to try it when I get home. It would certainly be nice if the waterfall - static float fftMaxMax = 0; //didn't change in brightness so much. Later, I may want to fix these values, or at least, make them - static float logMax; //manually controllable, sorta, you know? - uint8_t i; - for(i = 1; i < 255; i++) //If bin 0 is the DC offset, should we skip it in this calculation? - { - float mags = magnitudes[i]; - if(mags > fftMax) fftMax = mags; - if(mags < fftMin) fftMin = mags; - } - //logMax = log2(fftMax); + float fftMax = 0; //AH! These are being reset each time! Static makes them persistant right? Does it also ensure they are + float fftMin = 100; //only initialized once? Have to try it when I get home. It would certainly be nice if the waterfall + static float fftMaxMax = 0; //didn't change in brightness so much. Later, I may want to fix these values, or at least, make them + static float logMax; //manually controllable, sorta, you know? + uint8_t i; + for(i = 1; i < 255; i++) //If bin 0 is the DC offset, should we skip it in this calculation? + { + float mags = magnitudes[i]; + if(mags > fftMax) fftMax = mags; + if(mags < fftMin) fftMin = mags; + } + //logMax = log2(fftMax); - if(fftMax > fftMaxMax) fftMaxMax += fftMax * 0.1; - logMax = log2(fftMaxMax); - fftMaxMax *= 0.99; - if (fftMaxMax > fftMaxMaxMax) fftMaxMax = fftMaxMaxMax; - if (fftMaxMax < fftMaxMaxMin) fftMaxMax = fftMaxMaxMin; + if(fftMax > fftMaxMax) fftMaxMax += fftMax * 0.1; + logMax = log2(fftMaxMax); + fftMaxMax *= 0.99; + if (fftMaxMax > fftMaxMaxMax) fftMaxMax = fftMaxMaxMax; + if (fftMaxMax < fftMaxMaxMin) fftMaxMax = fftMaxMaxMin; - // TODO: Got rid of the first bin because it's just DC offset, right? - // but now narrow signal can disappear when they are right at the center.... - // Will that be better when I lower the sample frequency? Maybe I should do that next. + // TODO: Got rid of the first bin because it's just DC offset, right? + // but now narrow signal can disappear when they are right at the center.... + // Will that be better when I lower the sample frequency? Maybe I should do that next. - Adafruit_ILI9340_setAddrWindow(waterfallScanLine, 0, waterfallScanLine, 120); - for(i = 120; i != 0; i--) - { - mags = (log2(magnitudes[i] + 1)) / fftMaxMax * 100; //Log needs to be at least 1 right? We could do a + (1-fftMin) maybe? Worth it? - //mags = magnitudes[i] / fftMaxMax * 32; - //Adafruit_ILI9340_drawPixel(waterfallScanLine, (120 - i), gradient[(uint8_t) mags]); - Adafruit_ILI9340_pushColor(gradient[(uint8_t) mags]); - } + Adafruit_ILI9340_setAddrWindow(waterfallScanLine, 0, waterfallScanLine, 120); + for(i = 120; i != 0; i--) + { + mags = (log2(magnitudes[i] + 1)) / fftMaxMax * 100; //Log needs to be at least 1 right? We could do a + (1-fftMin) maybe? Worth it? + //mags = magnitudes[i] / fftMaxMax * 32; + //Adafruit_ILI9340_drawPixel(waterfallScanLine, (120 - i), gradient[(uint8_t) mags]); + Adafruit_ILI9340_pushColor(gradient[(uint8_t) mags]); + } - Adafruit_ILI9340_setAddrWindow(waterfallScanLine, 120, waterfallScanLine, 239); - for(i = 255; i > 135; i--) - { - mags = (log2(magnitudes[i] + 1)) / fftMaxMax * 100; - //mags = magnitudes[i] / fftMaxMax * 32; - //Adafruit_ILI9340_drawPixel(waterfallScanLine, 359 - (i - 15), gradient[(uint8_t) mags]); - Adafruit_ILI9340_pushColor(gradient[(uint8_t) mags]); - } + Adafruit_ILI9340_setAddrWindow(waterfallScanLine, 120, waterfallScanLine, 239); + for(i = 255; i > 135; i--) + { + mags = (log2(magnitudes[i] + 1)) / fftMaxMax * 100; + //mags = magnitudes[i] / fftMaxMax * 32; + //Adafruit_ILI9340_drawPixel(waterfallScanLine, 359 - (i - 15), gradient[(uint8_t) mags]); + Adafruit_ILI9340_pushColor(gradient[(uint8_t) mags]); + } + + waterfallScanLine++; + if(waterfallScanLine > 119) waterfallScanLine = 0; + Adafruit_ILI9340_setVertialScrollStartAddress((/*119 -*/ waterfallScanLine) /*+ 200*/); + + newWaterFallData = 0; + } - waterfallScanLine++; - if(waterfallScanLine > 119) waterfallScanLine = 0; - Adafruit_ILI9340_setVertialScrollStartAddress((/*119 -*/ waterfallScanLine) /*+ 200*/); } void fillSamepleWithTone(int tone, float *samples) @@ -1552,6 +1559,7 @@ void processStream() //blink_led_off(); sampleRun = 0; + newWaterFallData = 1; } //clearTimUpdateFlag(&TimHandle4);