Esempio n. 1
0
int main()
{
	lcd_init();
	init_push_buttons();
	shaft_encoder_init();
	stepper_init();
	
	while (1) {
		char prog;
		
		lcd_clear();
		prog = wait_button("Choose program:");
		switch (prog) {
			case 1:
				part1();
				break;
			case 2:
				part2();
				break;
			case 3:
				part3(); 
				break;
			default:
				;  // do nothing
		}
	}
}
Esempio n. 2
0
int main() {
	
	//initialize all necessary sensors and utilities
	lcd_init();
	timer1_init();
	timer3_init();
	move_servo(90);
 	ADC_init();
	USART_Init(MYUBRR);
	init_push_buttons();
	
	oi_t *sensor_data = oi_alloc();
	oi_init(sensor_data);
	
	audioInit(sensor_data);
	//oi_play_song(1);
	
	while(1) {
		//empty currentObjects before proceeding by setting all stored objects to "invalid" - ignored by later checks
		for (int i = 0; i < 20; i++) {
			currentObjects[i].isValid = 0;
		}
		char received = serial_getc(); //take keyboard input from putty
		takeDirectionInput(received, currentObjects); //translate keyboard input into functionality
	}
	
	return 0;
}
Esempio n. 3
0
int main( void )
{
	char buffer[21] = {'\0'};
	int i = 0;
	USART_Init ( calcUBRR() );
	init_push_buttons();
	lcd_init();
	while(1){
		switch(read_push_buttons())
		{
			case '6': USART_Transmit('Y');
			break;
			
			case '5': USART_Transmit('N');
			break;
			
			case '4': Transmit_String("AHHHH!!!!");
			break;
			
			case '3': Transmit_String("This");
			break;
			
			case '2': Transmit_String("computer is");
			break;
			
			case '1': Transmit_String("broken!");
			break;
					}
					wait_ms(100);
					/*
		unsigned char new_letter = USART_Receive();
		if(new_letter != 13)
		{
			buffer[i++] = new_letter;
			
		}			
		USART_Transmit(new_letter);
		lprintf("%d, %c", i, new_letter);
		if(i == 20 || new_letter == 13)
		{
			if(new_letter == 13)
			{
				USART_Transmit(10);
			}
			i = 0;
			lprintf("%s", buffer);
			for(int j=0;j<20;j++)
			{
				buffer[j] = 0;
			}
		}
		*/
	}	
}
Esempio n. 4
0
void main(void)
{
  int i = 0;
  init_leds();
  init_push_buttons();
  init_EXTI();
  init_NVIC();
  
  for(;;) {
    GPIOB->ODR += 1;
    for(i = 0; i < 65535; i++);
  }
  
}
Esempio n. 5
0
void main(void)
{
	init_leds();
	init_push_buttons();
	
	for(;;) {
		if ((GPIOA->IDR & GPIO_IDR_0) == 0 ) { GPIOB->ODR = 0x03; }
		else if ((GPIOA->IDR & GPIO_IDR_1) == 0) { GPIOB->ODR = 0x0C; }
		else if ((GPIOA->IDR & GPIO_IDR_2) == 0) { GPIOB->ODR = 0x30; }
		else if ((GPIOA->IDR & GPIO_IDR_3) == 0) { GPIOB->ODR = 0xC0; }
		else { GPIOB->ODR = 0x00; }
	}
	
}
Esempio n. 6
0
void send_mesg_test_mode()
{
   	lcd_init();
	init_push_buttons();

	usart_init();
	txq_init();
	usart_drain_rx();

	lcd_puts("Send Mesg Test Mode");
	wait_ms(1000);
	lcd_clear();

	char echo_mesg[] = "foobar";  // Assumed to be less than DATA_FRAME_MAX_LEN.
 
	while (true)
	{
		switch (wait_button("Select Message")) {
		case mesg_ping:

			txq_enqueue(signal_start);
			txq_enqueue(mesg_ping);
			txq_enqueue(signal_stop);
			txq_drain();
			break;

		case mesg_echo:

			txq_enqueue(signal_start);
			txq_enqueue(mesg_echo);

			// Copy the echo message into the `control`:
			strcpy(control.data, echo_mesg);
			control.data_len = strlen(echo_mesg);

			// Enqueue the frame. No more frames coming.
			tx_frame(false);

			txq_enqueue(signal_start);
			txq_drain();
			break;

		default:
			wait_button("Invalid selection.");
			break;
		}
	}
}
Esempio n. 7
0
void readings_stream_mode()
{
	const uint8_t BUF_LENGTH = 100;
	char buf[BUF_LENGTH];

	enum {
		reading_ir = 1,
		reading_sonar = 2,
		reading_sonar_mode = 3
	} reading;

	init_push_buttons();
	lcd_init();

	ir_init();
	sonar_init();

	usart_init();
	usart_drain_rx();

	while (true) {
		switch (wait_button("Readings Stream")) {
		case reading_ir:
			snprintf(buf, BUF_LENGTH, "IR: %u\n", ir_raw_reading());
			break;

		case reading_sonar:
			snprintf(buf, BUF_LENGTH, "Sonar: %u\n", sonar_raw_reading());
			break;

		case reading_sonar_mode:
			while (true) {
				snprintf(buf, BUF_LENGTH, "Sonar: %u\n", sonar_raw_reading());
				usart_tx_buf(buf);
			}
			break;

		default:
			buf[0] = '\0';
		}

		usart_tx_buf(buf);
	}
}