void plotPoint(void){ ST7735_PlotPoint(temperature); // Measured temperature if((j&(N-1))==0){ // fs sampling, fs/N samples plotted per second ST7735_PlotNextErase(); // overwrites N points on same line } j++; // counts the number of samples }
int main(void){ char* lab9greeting = "Welcome to Lab 9!"; int temp; // int Temperature = 100; // DisableInterrupts(); // PLL_Init(Bus80MHz); // //ST7735_InitR(INITR_REDTAB); // Output_Init(); // UART0 only used for debugging // ST7735_Output_Init(); // ADC0_InitSWTriggerSeq3_Ch9(); //initialize the ADC // Timer0A_Init20HzInt(); //initialize the timer // ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE); // EnableInterrupts(); PLL_Init(Bus80MHz); // 80 MHz SYSCTL_RCGCGPIO_R |= 0x20; // activate port F ADC0_InitSWTriggerSeq3_Ch9(); // allow time to finish activating Timer0A_Init20HzInt(); // set up Timer0A for 100 Hz interrupts GPIO_PORTF_DIR_R |= 0x06; // make PF2, PF1 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x06; // disable alt funct on PF2, PF1 GPIO_PORTF_DEN_R |= 0x06; // enable digital I/O on PF2, PF1 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF PF2 = 0; // turn off LED ST7735_Output_Init(); ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE); //Init_Plot(); //ST7735_SetCursor(0,0); ST7735_OutString("Lab 9"); ST7735_PlotClear(1000,4000); // range from 0 to 4095 ST7735_SetCursor(0,1); ST7735_OutString("N="); ST7735_SetCursor(0,2); ST7735_OutString("T="); //ST7735_DecOut2(2500); ST7735_OutString(" C"); EnableInterrupts(); while(1){ ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue); // 0 to 4095 if(refresh){ refresh = 0; samples++; ST7735_PlotPoint(ADCvalue); // Measured temperature if((samples&(N-1))==0){ // fs sampling, fs/N samples plotted per second ST7735_PlotNextErase(); // overwrites N points on same line } if((samples%fs)==0){ // fs sampling, 1 Hz display of numerical data //do conversion here, set it equal to temp. temp = get_temp(ADCvalue); ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue); // 0 to 4095 ST7735_SetCursor(3,2);ST7735_DecOut2(temp); // 0.01 C } } } }
void ST7735_UpdateTemperatureGraph(uint32_t numSamples, uint16_t adcValue) { uint16_t temperature = getTemp(adcValue); // DEBUG // Magnify the plot to see the noise distribution better // ST7735_PlotPoint((temperature - 2200)*15); ST7735_PlotPoint(temperature); // Measured temperature if((numSamples&(N-1))==0){ // fs sampling, fs/N samples plotted per second ST7735_PlotNextErase(); // overwrites N points on same line } if((numSamples%FS)==0){ // fs sampling, 1 Hz display of numerical data ST7735_SetCursor(3,1); ST7735_OutUDec(adcValue); // 0 to 4095 ST7735_OutString(" "); // clear previous number ST7735_SetCursor(3,2); ST7735_sDecOut2(temperature); // 0.01 C } }