Esempio n. 1
0
//debug code
int main(void){
	PLL_Init(Bus80MHz);	// bus clock at 50 MHz
  Output_Init();
	SYSCTL_RCGCGPIO_R |= 0x20;       // activate port F
	//ADC0_InitTimer0ATriggerSeq3(2, F30HZ); // ADC channel 0, 1000 Hz sampling
	ADC0_InitTimer0ATriggerSeq3PD3(F30HZ);
  //ADC0_InitSWTriggerSeq3_Ch9();
	while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready?
  GPIO_PORTF_DIR_R |= 0x02;        // make PF1 output (PF1 built-in LEDs)
  GPIO_PORTF_AFSEL_R &= ~0x02;     // disable alt funct on PF1
  GPIO_PORTF_DEN_R |= 0x02;        // enable digital I/O on PF1
                                   // configure PF1 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;          // disable analog functionality on PF
  EnableInterrupts();

	plotInit();
		
	while(1){
		GPIO_PORTF_DATA_R ^= 0x02;           // toggle LED
		//ADCvalue = ADC0_InSeq3();
		temperature = adcToTemp(ADCvalue + offset);
		plotPoint();
		ST7735_SetCursor(1,2);
		ST7735_sDecOut2(temperature);
		ST7735_SetCursor(2,1);
		ST7735_OutUDec(ADCvalue + offset);
	}
}
Esempio n. 2
0
int main(void){uint32_t i;
  PLL_Init(Bus80MHz);
  PortF_Init();
  ST7735_InitR(INITR_REDTAB);
  while(1){
    ST7735_FillScreen(0);  // set screen to black
    ST7735_SetCursor(0,0);
    printf("Lab 1\rST7735_sDecOut3\r");
    for(i=0; i<13; i++){
      ST7735_sDecOut3(outTests1[i].InNumber);  // your solution
      ST7735_OutString((char*)outTests1[i].OutBuffer); // expected solution
    }
    //Pause();
  
    ST7735_FillScreen(0);  // set screen to black
    ST7735_SetCursor(0,0);
    printf("ST7735_uBinOut8\r");
    for(i=0; i<14; i++){
      ST7735_uBinOut8(outTests2[i].InNumber);  // your solution
      ST7735_OutString((char*)outTests2[i].OutBuffer); // expected solution
    }
    //Pause();
    
    ST7735_XYplotInit("Circle",-2500, 2500, -2500, 2500);
    ST7735_XYplot(180,(int32_t *)CircleXbuf,(int32_t *)CircleYbuf);
    //Pause();
    
    ST7735_XYplotInit("Star- upper right",-450, 150, -400, 200);
    ST7735_XYplot(50,(int32_t *)StarXbuf,(int32_t *)StarYbuf);
    Pause(); 
  } 
} 
Esempio n. 3
0
//------------HotPotato_DrawStatus------------
// Draws p1 status elements on the top of the screen
// Input: none
// Output: none
void HotPotato_DrawStatus(void){
	ST7735_SetCursor(16, 1);
	LCD_OutDec(Characters[0].hp/hpDivisor);					// Write hp status
	if(Characters[0].hp == 0){							// Write death status
		ST7735_SetCursor(6, 5);
		ST7735_OutString("You Dead.");
		Music_Stop();
	}
	int temp=0;
	for(int i = 0; i<characterCount; i++)													// get count on players alive @@@ TEMP ADD FOR CHECK OUT
		if(Characters[i].active){
			temp++;
		}
	if(Characters[0].potato){								// Write "it" status
		ST7735_SetCursor(16, 2);
		ST7735_OutString("It!");
		ST7735_DrawBitmap(110, 17, Sprite[smallPotato].array, 8,8);
		if(temp==1)
		{
			ST7735_SetCursor(6, 5);
			ST7735_OutString("You Win!");			// write win status
			Music_Stop();
			Characters[0].hp++;
		}
	}
	else{																		// Write "not-it" status
		ST7735_SetCursor(14, 2);
		ST7735_OutString("Not it");
	}
}
Esempio n. 4
0
int main(void){
	Output_Init();
//	ST7735_XYplotInit("Temp", 0, 100, 0, 100);
  PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init100HzInt();               // 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
	EnableInterrupts();
	ST7735_SetCursor(6,0);
	printf("C");
	ST7735_SetCursor(13,0);
	printf("ADC");
  while(1){
    PF1 ^= 0x02;  // toggles when running in main
		temperature = adcToTemp(ADCvalue);
		ST7735_SetCursor(0,0);
		ST7735_sDecOut2(temperature);
		ST7735_SetCursor(9,0);
		ST7735_OutUDec(ADCvalue);
  }	
}
Esempio n. 5
0
int main(void){
//Initialize all below:
	TExaS_Init();       // Bus clock is 80 MHz 
	ADC_Init();    			// initialize to sample ADC1
	ST7735_InitR(INITR_REDTAB);
	SysTick_Init();		
	UART_Init();
	FiFo_Init();
  PortF_Init();
	EnableInterrupts();
	
	while(1){
		while(ADCStatus == 0){};	//Poll ADCStatus flag 
		ADCStatus = 0;						//clear flag
		//Prints from a full FIFO --> BUT must know when 
		//we get to the end 			--> uses while loop to check this condition,
		//and a for loop to print 5 times
		ST7735_SetCursor(6,5);
		//Infinite loop if the fifo is empty / if returns fail
		while (FiFo_Get(&data) == 0) {};
		FiFo_Get(&data);
		for(int i = 1; i <= 5; i++){
			ST7735_OutChar(data);
			FiFo_Get(&data);
		}
		FiFo_Get(&data);
		FiFo_Get(&data);		
		ST7735_SetCursor(12,5);
		ST7735_OutString(" cm");	// print " cm"
	}

}
Esempio n. 6
0
int ParseWeather(char* resp){
	char* sub_str;
	uint32_t offs;
	int i;
	int j = 0;
	
	sub_str = strstr(ResponseJson, "conds:");
	offs = (int) ((int) sub_str - (int)ResponseJson );
	
	for(int i = offs; ResponseJson[i] != '\n'; i++){
		ST7735_SetCursor(j,4);
		ST7735_OutChar(ResponseJson[i]);
		j++;
	}
	j = 0;
	
	sub_str = strstr(ResponseJson, "temp:");
	offs = (int) ((int) sub_str - (int)ResponseJson );
	
	for(int i = offs; ResponseJson[i] != '\n'; i++){
		ST7735_SetCursor(j,5);
		ST7735_OutChar(ResponseJson[i]);
		j++;
	}
	
	return 0;
}
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(1);

  Output_Init();
  ST7735_FillScreen(0x0000);            // set screen to black
  
  ST7735_DrawBitmap(52, 159, PlayerShip0, 18,8); // player ship middle bottom
  ST7735_DrawBitmap(53, 151, Bunker0, 18,5);

  ST7735_DrawBitmap(0, 9, SmallEnemy10pointA, 16,10);
  ST7735_DrawBitmap(20,9, SmallEnemy10pointB, 16,10);
  ST7735_DrawBitmap(40, 9, SmallEnemy20pointA, 16,10);
  ST7735_DrawBitmap(60, 9, SmallEnemy20pointB, 16,10);
  ST7735_DrawBitmap(80, 9, SmallEnemy30pointA, 16,10);
  ST7735_DrawBitmap(100, 9, SmallEnemy30pointB, 16,10);


  Delay100ms(50);              // delay 5 sec at 80 MHz


  ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);
  while(1){
  }

}
Esempio n. 8
0
void Init_Plot(void){
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");

}
Esempio n. 9
0
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 
			}

		}
	}

  
}
Esempio n. 10
0
void ST7735_InitTemperatureGraph()
{
    ST7735_SetCursor(0,0); 
    ST7735_OutString("Temperature Data");
    ST7735_PlotClear(1000,4000);  // range from 0 to 4095
    ST7735_SetCursor(0,1); 
    ST7735_OutString("N=");
    ST7735_SetCursor(0,2); 
    ST7735_OutString("T= "); 
    ST7735_sDecOut2(2500);
    ST7735_OutString(" C");
}
Esempio n. 11
0
void plotInit(void){
	ST7735_SetCursor(0,0); 
	ST7735_OutString("Temp");
	ST7735_PlotClear(1000,4000);  // range from 0 to 4095
	ST7735_SetCursor(0,1); 
	ST7735_OutString("N=");
	ST7735_SetCursor(0,2); 
	ST7735_OutString("T="); 
	ST7735_sDecOut2(0000);
	ST7735_SetCursor(7,2); 
  ST7735_OutString("C");
}
Esempio n. 12
0
void printSensorValues(int line) {
	ST7735_SetCursor(0,line);ST7735_OutUDec(Ping1);
	ST7735_OutString("   ");
	ST7735_SetCursor(4,line);ST7735_OutUDec(Ping2);
	ST7735_OutString("   ");
	ST7735_SetCursor(8,line);ST7735_OutUDec(Ping3);
	ST7735_OutString("   ");
	ST7735_SetCursor(0,line+5);ST7735_OutUDec(IR_L);
	ST7735_OutString("   ");
	ST7735_SetCursor(6,line+5);ST7735_OutUDec(IR_R);
	ST7735_OutString("   ");
}
Esempio n. 13
0
int main(void) {
	DisableInterrupts();
	PLL_Init(Bus80MHz);             // bus clock at 50 MHz
  Tach_Init();										// initialize the Tach measureing input capture
	PWM0B_Init(40000, 30000); 			// 1000 Hz
	Buttons_Init();
	ST7735_InitR(INITR_REDTAB);
	SysTick_Init();

	EnableInterrupts();

	int32_t x = 0;
	ST7735_SetCursor(0,0);
	printf("Speed:\nTarget:");
	while(1) {
		ST7735_SetCursor(8, 0);
		int32_t speed = Tach_GetSpeed();
		int32_t speedY = ST7735_TFTHEIGHT - 20 - speed / 4;
		printf("%5d.%01d rps", speed / 10, speed % 10);
		ST7735_SetCursor(8, 1);
		printf("%5d.%01d rps", Target_Speed / 10, Target_Speed % 10);
		
		if(x == 0) ST7735_PlotClear(32, 159);
		/*
		Speed = 200000000/Period; // 0.1 rps
	
	if(PID_delay == 0){
		E = Target_Speed-Speed;   // 0.1 rps
		U += (40*E)/64;  // discrete integral
		if(U < 100) U=100;        // Constrain output
		if(U>39900) U=39900;      // 100 to 39900
		PWM0B_Duty(U);            // output
		PID_delay = 4;
	}
	else {
		PID_delay -= 1;
	}*/
		while(! SysTick_ShouldDraw());
		ST7735_DrawPixel(x+1, speedY+1, ST7735_RED);
		ST7735_DrawPixel(x+1, speedY, ST7735_RED);
		ST7735_DrawPixel(x, speedY+1, ST7735_RED);
		ST7735_DrawPixel(x, speedY, ST7735_RED);
		x = (x + 1) % ST7735_TFTWIDTH;

		
		WaitForInterrupt();
	}
}
Esempio n. 14
0
File: Lab1.c Progetto: herettic/445L
//------------main----------------------------
int main(void){
  PLL_Init();
	SysTick_Init();
	Switch_Init();
  Output_Init();
	
	// print intro screen to lab
	printf("   Fixed-point Lab\n");
  printf("\n\n\n\n\n\n\n\n\n\n");
	printf("          By:\n");
	printf("    Brandon Boesch\n");
	printf("    Curtis Martin\n");
	printf("  Press SW2 to begin\n");
	ST7735_DrawBitmap(30, 108, bmp_Logo, 70, 100);

	// begin tests
	while(PF0 == 0x01){};
  Fixed_uDecOut2_test();
	while(PF0 == 0x01){};
	Fixed_sDecOut3_test();
	while(PF0 == 0x01){};
	Fixed_uBinOut8_test();
  while(PF0 == 0x01){};
	// outro screen
	Output_Clear();
	ST7735_SetCursor(0,0);
  printf("Tests complete!");
	ST7735_DrawBitmap(6, 159, bmp_thumbs, 114, 146);
	
  while(1){};
}
Esempio n. 15
0
int main(void){ 
	DisableInterrupts();
	PLL_Init(Bus80MHz);	// bus clock at 80 MHz
	UART_Init();
	ST7735_InitR(INITR_REDTAB);
	ADC0_InitTimerTriggerSeq3_Ch0();
		
	EnableInterrupts();
	
	/*
	UART_OutString("Points: \r\n");
	while(currentIndex < 100);
	for(int i = 0; i < 100; i += 1) {
		UART_OutUDec(data[i]);
		UART_OutString("\r\n");
	}
	*/
	while(1) {
		ST7735_SetCursor(0, 0);
		int32_t currentTemperature = Temperature_Convert(ADC_FIFO_CurrentValue());
		printf("Temperature %5d.%02d\n", currentTemperature / 100, currentTemperature % 100);
		ST7735_PlotClear(32, 159);
		//TODO change color?
		
		for(int i = 0; i < FIFO_SIZE; i += 1) {
			int32_t point = 128 - Temperature_Convert(ADC_FIFO_Get()[i]) * 2 / 100;
			ST7735_DrawPixel(i+1, point+1, ST7735_RED);
			ST7735_DrawPixel(i+1, point, ST7735_RED);
			ST7735_DrawPixel(i, point+1, ST7735_RED);
			ST7735_DrawPixel(i, point, ST7735_RED);
		}
		WaitForInterrupt();
	}
}
Esempio n. 16
0
/**************ST7735_XYplotInit***************
 Specify the X and Y axes for an x-y scatter plot
 Draw the title and clear the plot area
 Inputs:  title  ASCII string to label the plot, null-termination
          minX   smallest X data value allowed, resolution= 0.001
          maxX   largest X data value allowed, resolution= 0.001
          minY   smallest Y data value allowed, resolution= 0.001
          maxY   largest Y data value allowed, resolution= 0.001
 Outputs: none
 assumes minX < maxX, and miny < maxY
*/
void ST7735_XYplotInit(char *title, int32_t minX, int32_t maxX, int32_t minY, int32_t maxY){
	ST7735_FillScreen(ST7735_BLACK);  // set screen to black
  ST7735_SetCursor(0,0);
	printf("%s\n", title);
	
	gi.xMax = maxX;
	gi.xMin = minX;
	gi.yMax = maxY;
	gi.yMin	= minY;
	gi.xRange = maxX - minX;
	gi.yRange = maxY - minY;
	
	if(ST7735_TFTWIDTH<=ST7735_TFTHEIGHT)
		gi.smallDem = ST7735_TFTWIDTH;
	else
		gi.smallDem = ST7735_TFTHEIGHT;
	
	ST7735_DrawFastVLine((ST7735_TFTWIDTH)/2, 0, ST7735_TFTHEIGHT, ST7735_WHITE);
	ST7735_DrawFastHLine(0, ST7735_TFTHEIGHT/2, ST7735_TFTWIDTH, ST7735_WHITE);
	
	ST7735_DrawChar((ST7735_TFTWIDTH)/2 + 1,  0, 'y', ST7735_WHITE, ST7735_BLACK, 1);
	ST7735_DrawChar(0, (ST7735_TFTHEIGHT)/2 + 1, 'x', ST7735_WHITE, ST7735_BLACK, 1);
	
	return;
}
Esempio n. 17
0
//------------HotPotato_DrawStatus------------
// Draws p1 status elements on the top of the screen
// Input: none
// Output: none
void HotPotato_DrawStatus(void){
	ST7735_SetCursor(16, 1);
	LCD_OutDec(Characters[0].hp/2);					// Write hp status
	if(Characters[0].hp == 0){							// Write death status
		ST7735_SetCursor(6, 5);
		ST7735_OutString("You Dead.");
	}
	if(Characters[0].potato){								// Write "it" status
		ST7735_SetCursor(16, 2);
		ST7735_OutString("It!");
		ST7735_DrawBitmap(110, 16, Sprite[smallPotato].array, 8,8);
	}
	else{																		// Write "not-it" status
		ST7735_SetCursor(14, 2);
		ST7735_OutString("Not it");
	}
}
Esempio n. 18
0
int main(void){
  TExaS_Init();
	ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	SysTick_Init();			// This makes things work
  // your Lab 8
  while(1){
		while(ADCStatus == 0){}
		Data = ADCMail;
		Position = Convert(Data); 
		ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
		ADCStatus = 0;
  }
}
int main3(void){ 
  TExaS_Init();         // Bus clock is 80 MHz 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB); 
  while(1){  
    PF2 ^= 0x04;      // Heartbeat
    Data = ADC_In();  // sample 12-bit channel 1
    PF3 = 0x08;       // Profile Convert
    Position = Convert(Data); 
    PF3 = 0;          // end of Convert Profile
    PF1 = 0x02;       // Profile LCD
    ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
    PF1 = 0;          // end of LCD Profile
  }
}
Esempio n. 20
0
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 
    }
}
Esempio n. 21
0
File: Lab1.c Progetto: herettic/445L
//------------Fixed_uBinOut8_test------------
// Test case for Fixed_sDecOut3 function. Unigned 32-bit binary fixed-point with a resolution of 1/256.
void Fixed_uBinOut8_test(void){
	Output_Clear();
	ST7735_SetCursor(0,0);
	printf("Fixed_uBinOut8_test\n");
	for(int i = 0; i < ARRAY_SIZE; i++){
		Fixed_uBinOut8(BinCases[i]);
		SysTick_Wait10ms(10);
	}
	printf("Press SW2 to cont.");
}
int main(void){
  TExaS_Init();         // Bus clock is 80 MHz 
  ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
  SysTick_Init();			//Initialize SysTick
  for(;;){
	  while(ADCStatus == 0){}	//Poll ADCStatus flag 
	  uint32_t x = ADCMail;		//read ADCMail (input)
	  ADCStatus = 0;			//clear flag
	  x = Convert(x);			//convert the input
	  ST7735_SetCursor(1,7);		
    ST7735_OutString("D = "); 	//print "D = "
    ST7735_SetCursor(5,7);
    LCD_OutFix(x);				// print the fixed point value 
		ST7735_SetCursor(10,7);	
		ST7735_OutString(" cm");	// print " cm"
		/////////////////////
		ST7735_SetCursor(1,2);
			ST7735_OutString("Lab 8:");	
		ST7735_SetCursor(1,3);
		ST7735_OutString("Measurment of");
		ST7735_SetCursor(1,4);
		ST7735_OutString("Distance :)");
		
			
	}
	
}
int main(void){
	uint32_t DataTaken;
	uint32_t ConvData;
	TExaS_Init();         // Bus clock is 80 MHz 
  PortF_Init();
	ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB); 
	SysTick_Init();
  while(1){
		if (ADCStatus == 1){
			DataTaken = ADCMail;
			ADCStatus = 0;
			ConvData = Convert(DataTaken);
			ST7735_SetCursor(0,0);
			LCD_OutDec(DataTaken);
			ST7735_OutString("    ");
			ST7735_SetCursor(6,0);
			LCD_OutFix(ConvData);
			ST7735_OutString(" cm");
			
		}
  }
}
Esempio n. 24
0
void ST7735_XYplotInit(char *title, int32_t minX, int32_t maxX, int32_t minY, int32_t maxY)
{
  MinX = minX;
  MaxX = maxX;
  MinY = minY;
  MaxY = maxY;
	//assert(minX < maxX);
	//assert(minY < maxY);
	
  //ST7735_FillScreen(0);  
  ST7735_SetCursor(0, 0);
  ST7735_SetTextColor(ST7735_WHITE); // arbitrary color
  ST7735_OutString(title);
}
Esempio n. 25
0
int main(void){
  PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  //ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  
  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
	DisableInterrupts();
	Timer0A_Init60HzInt();  //updates time every second
	Timer1_Init();	//sound
	Timer2_Init();
	//Switch_Init();					//interrupts on switch press
	ST7735_InitR(INITR_REDTAB);
	ST7735_PlotClear(0,160);
		play = 0;
		TIMER1_CTL_R = 0x00000000;
	EnableInterrupts();	
	ST7735_Circle(ST7735_BLACK);
	//drawClockHands(hour, minute, 1);
	drawDigTime(hour, minute, AMPM);
	ST7735_SetCursor(2, 14);
	printf("<");
	ST7735_SetCursor(18, 14);
	printf(">");
	drawClockHands(2,30,1);
		play = 1;
		TIMER1_CTL_R = 0x00000001;
	while(1){
		
	}
}
int main2(void){
  TExaS_Init();       // Bus clock is 80 MHz 
  ADC_Init();         // turn on ADC, set channel to 1
  PortF_Init();
	ST7735_InitR(INITR_REDTAB); 
  while(1){           // use scope to measure execution time for ADC_In and LCD_OutDec           
    PF2 = 0x04;       // Profile ADC
    Data = ADC_In();  // sample 12-bit channel 1
    PF2 = 0x00;       // end of ADC Profile
    ST7735_SetCursor(0,0);
    PF1 = 0x02;       // Profile LCD
    LCD_OutDec(Data); 
    ST7735_OutString("    ");  // these spaces are used to coverup characters from last output
    PF1 = 0;          // end of LCD Profile
  }
}
Esempio n. 27
0
//------------ST7735_InitR------------
// Initialization for ST7735R screens (green or red tabs).
// Input: option one of the enumerated options depending on tabs
// Output: none
void ST7735_InitR(enum initRFlags option) {
  commonInit(Rcmd1);
  if(option == INITR_GREENTAB) {
    commandList(Rcmd2green);
    ColStart = 2;
    RowStart = 1;
  } else {
    // colstart, rowstart left at default '0' values
    commandList(Rcmd2red);
  }
  commandList(Rcmd3);

  // if black, change MADCTL color filter
  if (option == INITR_BLACKTAB) {
    writecommand(ST7735_MADCTL);
    writedata(0xC0);
  }
  TabColor = option;
  ST7735_SetCursor(0,0);
  StTextColor = ST7735_YELLOW;
  ST7735_FillScreen(0);                 // set screen to black
}
Esempio n. 28
0
int main(void){
	TExaS_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB);
	PortF_Init();
	SysTick_Init();			// This makes things work
	UART1_Init();

	FIFO_Init();
	unsigned char data;
	while(1){
			while(data != 0x02){
					FIFO_Get(&data);					// Look for new data byte
			}
			ST7735_SetCursor(0,0);
			for(int i = 0; i<5; i++){			// Print next 5 elements
					FIFO_Get(&data);
					ST7735_OutChar(data);
			}
			ST7735_OutString(" cm");			// Print units
	}
}
Esempio n. 29
0
int ParseHeadline(char* resp){
	char* sub_str;
	uint32_t offs;
	int i;
	int j = 0;
	int k = 4;
	
	sub_str = strstr(ResponseJson, "headline:");
	offs = (int) ((int) sub_str - (int)ResponseJson );
	
	for(int i = offs; ResponseJson[i] != '\n'; i++){
		ST7735_SetCursor(j,k);
		ST7735_OutChar(ResponseJson[i]);
		j++;
		if(j>=20){
			j = 0;
			k++;
		}
	}
	
	return 0;
}
Esempio n. 30
0
void ST7735_DecOut2(int32_t n){
	char thousands_c = '0';
	char hundreds_c = '0'; 
	char tens_c = '0';
	char units_c = '0';
	
	int thousands;
	int hundreds;
	int tens;
	int units;
	int negative = 0;
	
	
	
//	if(n>999 || n < -999){
//		printf(" *.**");
//		return;
//	}
//	if(n<0){ n = n*(-1);
//		negative = 1;
//	}
	thousands = n/1000;
	hundreds = (n%1000)/100;
	tens = (n%100)/10;
	units = n%10;
	thousands_c = ((char) (thousands)) + 0x30;
	hundreds_c = ((char) (hundreds)) + 0x30;
	tens_c = ((char) (tens)) + 0x30;
	units_c = ((char) (units)) + 0x30;
	
	ST7735_SetCursor(2,2); ST7735_OutChar(thousands_c);
	ST7735_SetCursor(3,2); ST7735_OutChar(hundreds_c);
	ST7735_SetCursor(4,2); ST7735_OutChar('.');
	ST7735_SetCursor(5,2); ST7735_OutChar(tens_c);
	ST7735_SetCursor(6,2); ST7735_OutChar(units_c);
	ST7735_SetCursor(7,2); ST7735_OutChar(' ');
	ST7735_SetCursor(8,2); ST7735_OutChar('C');
	
	return;
}