Example #1
0
int32_t main()
{
	STR_UART_T sParam;

	UNLOCKREG();
  DrvSYS_Open(50000000);
	LOCKREG();
   	
	DrvGPIO_InitFunction(E_FUNC_UART0);	// Set UART pins

	/* UART Setting */
    sParam.u32BaudRate 		  = 9600;
    sParam.u8cDataBits 		  = DRVUART_DATABITS_8;
    sParam.u8cStopBits 		  = DRVUART_STOPBITS_1;
    sParam.u8cParity 		    = DRVUART_PARITY_NONE;
    sParam.u8cRxTriggerLevel= DRVUART_FIFO_1BYTES;

	/* Set UART Configuration */
 	if(DrvUART_Open(UART_PORT0,&sParam) != E_SUCCESS);
	DrvUART_EnableInt(UART_PORT0, DRVUART_RDAINT, UART_INT_HANDLE);
	
	init_LCD();                 // initialize LCD panel
	clear_LCD();                 // clear LCD panel							 	
	print_Line(0, "Smpl_UART0_HC05"); // print title
    		   
	while(1)
	{
	}
	//DrvUART_Close(UART_PORT0);
}
Example #2
0
int main(void)
{
	_delay_ms(1000); //Oszillator powerup


	set_ports();//Ein- und Ausgänge einstellen
	configureTimerAndInterrupts();//Benötigte Interrupts aktivieren, Timer einstellen
	
	lcdInit();
	clear_LCD();
    print_stdDisplay();
	
	sei(); //globale Interrupts aktivieren

	while(1) {
		if(btn_light_pushed == true){
			check_light();
		}
		if(rotary!=0){//Drehen soll hier keine Auswirkung haben
			rotary = 0;
		}
		if(check_TimeUpdate()  ){
			if(!menuOpen) { 
				update_time();
			}
			if((hour == alarm_hour) && (minute == alarm_minute) && (alarm)){
				wakeUp_User();
			}
		}
		if(btn_drehenc_pushed){
			
			//Timer starten zum Zählen
			start_btnPress();
			//warten, solange Taste gedrückt ist
			while((PINB & (1<<PINB2)) && (btn_press_duration<BTN_PRESS_LONG)){_delay_ms(50);}//KANN DELAY WEGGELASSEN WERDEN?
			//Zeitmessung beenden
			stop_btnPress();
			//falls länger als BTN_PRESS_LONG gedrückt wurde, Menü öffnen
			if(btn_press_duration > BTN_PRESS_LONG){ 
				for(int i=0; i<32; i++){
					herzSymb[i] = pgm_read_byte(&herz[0][i]);
				}
				for(int i=0; i<HERZ_KLEIN_WIDTH; i++){
					herzKleinSymb[i] = pgm_read_byte(&herzKlein[0][i]);
					herzKleinOffenSymb[i] = pgm_read_byte(&herzKleinOffen[0][i]);
				}
				for(int i=0; i<HAKEN_WIDTH; i++){//PRÜFEN hakenSymb i<60
					hakenSymb[i] = pgm_read_byte(&haken[0][i]);
				}
				menuOpen = true;
				show_mainMenu(STDDISPLAY);
			} 
			btn_drehenc_pushed = false;
			menuOpen = false;
		}
		goodNight();
	}
	
}
void loop()
{
    int sensor_raw = 1024 - analogRead(P_SENSOR);
    
    String sensor_text = String(sensor_raw);

    clear_LCD();
    write_LCD("Sensor: ");
    write_LCD(sensor_text.c_str());
    delay(T_CLK);
}
void setup()
{
    DDRA = 0xFF;
    DDRC = 0xE0;;
    PORTA = 0x00;
    PORTC = 0x00;
    
    init_LCD();
    clear_LCD();
    write_LCD("Welcome!");
}
Example #5
0
void boombox(){
	boot_amp();
	clear_LCD();
	clear_pixelMatrix();
	uint8_t weckerSymb[72];
	for(int i=0; i<72; i++){
		weckerSymb[i] = pgm_read_byte(&note[0][i]);
	}
	print_symbol(16,9,weckerSymb,55,24);
	print_symbol(16,17, hakenSymb,108,46);
	print_symbol(16,16, herzSymb, 92, 2+3*15);
	update_LCD();
	while(!btn_drehenc_pushed){
		goodNight();
		check_light();
	}
	shutdown_amp();
}
Example #6
0
void set_audio(){
	btn_drehenc_pushed = false;
	int item = 0;
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	int warte_ASCII [strlen("Bitte warten")];
	convertString("Bitte warten", warte_ASCII);
	print_ASCIIString(20,16, warte_ASCII, sizeof(warte_ASCII)/sizeof(warte_ASCII[0]));
	update_LCD();
	mp3Player_onoff();//On
	play_pause();
	_delay_ms(1000);
	boot_amp();
	//Speaker-Symbol aus EEPROM holen
	uint8_t speakerSymb[SPEAKER_WIDTH];
	for(int i=0; i<SPEAKER_WIDTH; i++){
		speakerSymb[i] = pgm_read_byte(&speaker[0][i]);
	}
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	print_symbol(24,31,speakerSymb,(128-31)/2,(64-24)/2);
	rotary = 0;
	while(item!=1){
		while(!btn_drehenc_pushed){
			
			item+=rotary;
			item=item%2;
			if(item<0)
			item+=2;
			rotary = 0;
			if(item == 0){
				//ggf. offenes Herz entfernen
				for(int x = 64-HERZ_KLEIN_WIDTH/2; x<64-HERZ_KLEIN_WIDTH/2+2; x++){
					for(int y = 2; y<11; y++)		
						reset_pixel(x,y);
				}
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,64-4, 2);//kleines Herz über Speaker malen
				for(int x = 92; x<92+16; x++){//Großes Herz am Haken entfernen
					for(int y = 2+3*15; y<64; y++)
					reset_pixel(x,y);
				}
				} else {
				print_symbol(16,16, herzSymb, 92, 2+3*15);//Großes Herz am Haken malen
				for(int x = 64-8; x<64+8; x++){//kleines Herz über Speaker entfernen
					for(int y = 2; y<11; y++)
					reset_pixel(x,y);
				}
			}
			update_LCD();
			goodNight();
			check_light();
		}
		btn_drehenc_pushed = false;
		for(int x = 64-8; x<64+8; x++){
			for(int y = 2; y<11; y++)
			reset_pixel(x,y);
		}
		if(item==0){
			print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,64-HERZ_KLEIN_WIDTH/2, 2);
			update_LCD();
			btn_drehenc_pushed = false;
			while(!btn_drehenc_pushed){
				goodNight();
				if(rotary>0){
					volume(UP);
					rotary = 0;
				} else {
					volume(DOWN);
					rotary = 0;
				}
				check_light();
			}
			btn_drehenc_pushed = false;
		}
	}
	clear_pixelMatrix();
	clear_LCD();
	print_ASCIIString(20,16, warte_ASCII, sizeof(warte_ASCII)/sizeof(warte_ASCII[0]));
	update_LCD();
	shutdown_amp();
	mp3Player_onoff();
}
Example #7
0
void set_snoozeDuration(){
	btn_drehenc_pushed = false;
	int item = 0;
	clear_pixelMatrix();
	clear_LCD();
	print_symbol(16,17, hakenSymb,108,46);
	while(item!=1){
		int width = pgm_read_byte(&bigNumberWidth[snoozeDuration%10]);
		if(snoozeDuration>9){
			width += pgm_read_byte(&bigNumberWidth[snoozeDuration/10]);
		}
		printSnoozetime();
		while(!btn_drehenc_pushed){
			item+=rotary;
			item=item%2;
			if(item<0)
				item+=2;
			rotary = 0;
			if(item == 0){
				print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,64-4, 2); 
				for(int x = 92; x<92+16; x++){
					for(int y = 2+3*15; y<64; y++)
					reset_pixel(x,y);
				}
			} else {
				print_symbol(16,16, herzSymb, 92, 2+3*15);
				for(int x = 64-8; x<64+8; x++){
					for(int y = 2; y<11; y++)
					reset_pixel(x,y);
				}
			}
			update_LCD();
			goodNight();
			check_light();	
		}
		btn_drehenc_pushed = false;
		for(int x = 64-8; x<64+8; x++){
			for(int y = 2; y<11; y++)
			reset_pixel(x,y);
		}
		if(item==0){
			print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,64-HERZ_KLEIN_WIDTH/2, 2);
			update_LCD();
			while(!btn_drehenc_pushed){
				if(rotary!=0){
					for(int x = 64-width/2; x<64+width/2;x++){
						for(int y = timeYPos; y<timeYPos+BIG_NUMBER_HEIGHT; y++)
						reset_pixel(x,y);
					}
					snoozeDuration+=rotary;
					snoozeDuration=snoozeDuration%99;
					if(snoozeDuration<0)
					snoozeDuration+=99;
					rotary = 0;
				}
				printSnoozetime();
				update_LCD();
				goodNight();
				check_light();
			}
			btn_drehenc_pushed = false;
		}
	}
}
Example #8
0
int main(int argc, char *argv[])
{
    char c;
    int status = 0;
    
    printf("Hello World, I'm game!\n");
    
    status = init_display();
    if (status != 0)
    {
        printf("Error: Failed to init display\n");
        return status;
    }
    
    status = init_driver();
    if (status != 0)
    {
        printf("Error: Failed to init driver\n");
        destroy_display();
        return status;
    }
    
    status = setup_handler();
    if (status != 0)
    {
        printf("Error: Failed to init signal handler\n");
        destroy_display();
        close(file_gamepad_driver);
        return status;
    }
    time_handler();
    
    /* Intializes random number generator */
    srand((unsigned) time(&t));
    
    sigset_t myset;
    (void) sigemptyset(&myset);

    while(1)
    {
        clear_LCD();       
        draw_game();
        draw_score(p1_score, p2_score);
        redraw();
        
        waitForButton();      
        printf("start game\n");
        
        while((p1_score < 5) && (p2_score < 5))
        {
            random_timer = (rand() % 3) + 2;
            startTimer(random_timer);
            waitForTimer();
            
            random_button = (rand() % 4);
            
            draw_button(random_button, true, RED);
            redraw();
            
            gettimeofday(&time_button_appears, NULL);

            // start timer
            startTimer(3);
            buf = 0;
            while((playerButtonPressed(random_button) == 0) && (timer_expired == false))
            {
                waitForButton(); 
            }
            
            stopTimer();
            if (timer_expired == false)
            {
                time_elapsed = getGameTime();
                draw_time(time_elapsed, BLUE);
                redraw();
            }
      
            if (playerButtonPressed(random_button) == P1)
            {
                p1_score++;
                p1_time += time_elapsed;
                
            }
            else if (playerButtonPressed(random_button) == P2)
            {
                p2_score++;    
                p2_time += time_elapsed;
            }
                
            draw_score(p1_score, p2_score);    
            reset_button(random_button);
            redraw();
            
        }
        // draw winner
        button_pressed = 0;
        if (p1_score == 5)
        {
            winner = P1;
            winner_time = p1_time;
        }
        else if (p2_score == 5)
        {
            winner = P2;
            winner_time = p2_time;
        }
        
        while(button_pressed == 0)
        {
            startTimer(1);
            winner_blink(winner, winner_time);
            waitForTimer();
        }
               
        // print waiting
        waitForButton();
        p1_score = 0;
        p1_time = 0;
        p2_score = 0;
        p2_time = 0;
    }

}
Example #9
0
//---------------------------------------------------------------------------------------------------------
// Main Function                                                           
//---------------------------------------------------------------------------------------------------------
INT32 main()
{
										
	SYSCLK_INITIATE();				// Configure CPU clock source and operation clock frequency.
									// The configuration functions are in "SysClkConfig.h"
	
	CLK_EnableLDO(CLK_LDOSEL_3_3V);	// Enable ISD9100 interl 3.3 LDO.

	if (! SPIFlash_Initiate())		// Initiate SPI interface and checking flows for accessing SPI flash.
		while(1); 					// loop here for easy debug

	OUTPUTPIN_INITIATE();			// Initiate output pin configuration.
									// The output pins configurations are defined in "ConfigIO.h".
	
	KEYPAD_INITIATE();				// Initiate keypad configurations including direct trigger key and matrix key
									// The keypad configurations are defined in "ConfigIO.h".
	
	ULTRAIO_INITIATE();				// Initiate ultraio output configurations.
									// The ultraio output pin configurations are defined in "ConfigUltraIO.h"
	
	PDMA_INITIATE();				// Initiate PDMA.
									// After initiation, the PDMA engine clock NVIC are enabled.
									// Use PdmaCtrl_Open() to set PDMA service channel for desired IP.
									// Use PdmaCtrl_Start() to trigger PDMA operation.
									// Reference "PdmaCtrl.h" for PDMA related APIs.
									// PDMA_INITIATE() must be call before SPK_INITIATE() and MIC_INITIATE(), if open MIC or speaker.
	
	SPK_INITIATE();					// Initiate speaker including pop-sound canceling.
									// After initiation, the APU is paused.
									// Use SPK_Resume(0) to start APU operation.
									// Reference "MicSpk.h" for speaker related APIs.

	MIC_INITIATE();					// Initiate MIC.
									// After initiation, the ADC is paused.
									// Use ADC_Resume() to start ADC operation.
									// Reference "MicSpk.h" for MIC related APIs.
	
																	
	App_Initiate();					// Initiate application for audio decode.

	i2c_Init(); //need to excute  before #define I2C_IRQ

#ifdef I2C_IRQ
	I2C_EnableInt(I2C0);
	NVIC_EnableIRQ(I2C0_IRQn);
	NVIC_SetPriority(I2C0_IRQn, 0);
#endif
#ifdef OLED_ENABLE
	Init_LCD();
	clear_LCD();

	print_Line(0, "OscarNuLiteExEnc");
//	print_Line(1, "2015.11.12      ");
//	print_Line(2, "Eric Yang      ");
//	print_Line(3, "0.96 OLED 128x64");
#endif

	while (1)
	{
		if ( g_u8AppCtrl&APPCTRL_RECORD )
		{
			if ( App_ProcessRec() == FALSE )
			{
				App_StopRec();
				#ifdef OLED_ENABLE
				print_Line(1, "   REC  Stop  ");	
				#endif
			}
		}
		else if ( g_u8AppCtrl&APPCTRL_PLAY )
		{
			if ( App_ProcessPlay() == FALSE )
			{
				App_StopPlay();
				#ifdef OLED_ENABLE
				print_Line(1, "   PLAY  Stop  ");	
				#endif
			}
		}

		TRIGGER_KEY_CHECK();		// Check and execute direct trigger key actions defined in "InputKeyActions.c"
									// Default trigger key handler is "Default_KeyHandler()"
									// The trigger key configurations are defined in "ConfigIO.h".
		
		MATRIX_KEY_CHECK();			// Check and execute matrix key actions defined in "InputKeyActions.c"
									// Default matrix key handler is "Default_KeyHandler()"
									// The matrix key configurations are defined in "ConfigIO.h".

		TOUCH_KEY_CHECK();        // Check and execute touch key actions defined in "InputKeyActions.c"
									// Default touch key handler is "Default_KeyHandler()"
									// The touch key configurations are defined in "ConfigIO.h".
	}
}