예제 #1
0
void LCD_show(char *str_0, char *str_1) {
    LCD_command(LCD_CLEAR, 1);
    LCD_setLocation(0, 0);
    LCD_print(str_0);
    LCD_setLocation(0, 1);
    LCD_print(str_1);
}
예제 #2
0
int main (void)
{
	
	LCD_init();
	LCD_init();
	LCD_print("START");
	
	

	for (;;)
	{
		//_delay_ms(1000);							/* Delay 1000ms for things to settle down */
		
		//if (pf_mount(&Fs)) 
		//{	
		//	continue;	/* Initialize FS */
		//}
		
		
		//if (pf_opendir(&Dir,"music")) break;		/* Open /music folder (for task1) */
		//if (pf_opendir(&Dir,"speech")) break;		/* Open /speech folder (for task2) */
			
		while(1) 
		{
			//task1();
			//task2();
			LCD_print("test");
		}
	}
	
	return 1;
}
예제 #3
0
파일: fileproc.c 프로젝트: yfang1644/DSP55X
void fileProcessing(void)
{
	Int16  key;

	if((taskList & FILEPROCESSING) == 0)	return;

//	key = EZDSP5535_SAR_getKey();
	key = -1;
	if(key == SW1)
	if(FHandle == Not_Open_FILE) {
		LCD_print("RECORDING......", 0);
		FHandle = FileOpen("A:\\VOICE000.TXT", FILE_FLAGS_WRITE);
	}

	if(key == SW2)
	if(FHandle != Not_Open_FILE) {
		LCD_print("SAVE VOICE000.DAT", 0); 
		FileClose(FHandle);
		AllCacheWriteBack();
		FHandle = Not_Open_FILE;
	}

//	if (FHandle != Not_Open_FILE)
//		FileWrite(&RfByte[2], number_of_bytes_per_frame, FHandle);

	taskList &= ~FILEPROCESSING;
}
예제 #4
0
void main () {
    init();
    LCD_print("Welcome !", 0); // top line
    delay_ms(1000);
    LCD_print("BIATCH!!!", 1); // bottom line
    LED = 1;
    delay_ms(500);
    int last_key = 0;
    int key = 0;
    LCD_reset();
    LCD_print("NO KEY", 0);
    while (1) {
        //getNum(15);
        LED = 0;
        delay_ms(10);
        //LED = 1;
        delay_ms(10);
        key = Keypad_get_key();
        if (key != last_key) {
            if (key == 0) {
                LCD_print("NO KEY", 0);
            } else {
                LCD_print("Pressed ", 0);
                LCD_char(Keypad_char_for_key(key));
            }
            last_key = key;
        }

    };
}
예제 #5
0
void displayValues() {
    //LCD_printRomOfs (0, 0, gsRomFuncNames, PickRomString(gsRomFuncNames, gcFuncIndex) );       // PRINT nome Funzione (Freq, Period, +Pulse ...
    //LCD_printRomOfs (0,11, gsTimeBase, pTMR->scaleOffs);                                      // PRINT GATE value
    LCD_print (0, 0, gsRomFuncNames, PickRomString(gsRomFuncNames, gcFuncIndex) );       // PRINT nome Funzione (Freq, Period, +Pulse ...
    LCD_print (0,11, gsTimeBase, pTMR->scaleOffs);                                      // PRINT GATE value
    // LCD_printf(1,11, ":%02X", gcFuncIndex);            //DEBUG
    // LCD_print (1, 0, "Ciao:");            //DEBUG
    
    
    
   // LCD_gotoRC(1, 0);
   // LCD_printRomOfs(gsTimeBase, pTMR->scaleOffs);                                      // PRINT GATE value
    // LCD_printf(0,6, ":%03d ", pTMR->scaleOffs);                    // PRINT numero Pulse
    // LCD_printRom("CiaoRom");                    // PRINT numero Pulse
   // LCD_printRom(1,8, prova);                    // PRINT numero Pulse
   // LCD_printRom(1,11, "Rom");                    // PRINT numero Pulse
    
    
    
    // LCD_print (1, 0, gsRomFuncNames, PickRomString(gsRomFuncNames, gcFuncIndex) );       // PRINT nome Funzione (Freq, Period, +Pulse ...
    
    if ( (gcFuncIndex == nPULSE_POS) || (gcFuncIndex == nPULSE_NEG) )  {
        if (fCONTINUOUS_KEY == true ) 
            LCD_print (0,6, ": C  ");                    // PRINT Continuos character
        else 
            LCD_printf(0,6, ":%03d ", gcPulseNumber);                    // PRINT numero Pulse
    }
    
}
예제 #6
0
void ICACHE_FLASH_ATTR 
display_draw_page(uint8 page)
{
    page--;
    LCD_print(_PageData[page].line1);
    LCD_setCursor(0,1);
    LCD_print(_PageData[page].line2);
    LCD_setCursor(0,2);
    LCD_print(_PageData[page].line3);
    LCD_setCursor(0,3);
    LCD_print(_PageData[page].line4);
}
예제 #7
0
// =======================================================================================
// ----5----0----5----0
// Frequency  100mS                // Function : Scale
// Period     100mS                // Function : Scale
// PosWave    100mS                // +/- Pulse: numeroPulse (decimale 3digit): Scale
// NegWave    100mS                // +/- Pulse: numeroPulse (decimale 3digit): Scale
// +Pulse:xxx 100mS                // +/- Pulse: numeroPulse (decimale 3digit): Scale
// -Pulse:xxx 100mS                // +/- Pulse: numeroPulse (decimale 3digit): Scale
// xxx.xxx.xxx MHz 
// =======================================================================================
void displayValues() {
    LCD_print (0,0, romFuncNames, PickRomString(romFuncNames, gcnFunc) );       // PRINT nome Funzione (Freq, Period, +Pulse ...
    LCD_print (0,11, mSecScaleStr, pTMR->scaleOffs);                            // PRINT scale
    LCD_printf(0,11, ":%02X", gcnFunc);            //DEBUG
    
    if ( (gcnFunc == nPULSE_POS) || (gcnFunc == nPULSE_NEG) )  {
        if (fCONTINUOUS_KEY == true ) 
            LCD_print (0,6, ": C  ");                    // PRINT Continuos character
        else 
            LCD_printf(0,6, ":%03d ", gcnPulse);                    // PRINT numero Pulse
    }
    
}
예제 #8
0
void ICACHE_FLASH_ATTR
display_init(void)
{

    while (!LCD_init())
    {
        os_printf("LCD not found\n\r");
    }
    LCD_setCursor(0,2);
    LCD_print("Home status Display");

    LCD_setCursor(0,3);
    LCD_print("Connecting ");
    LCD_blink();
}
예제 #9
0
파일: main.c 프로젝트: LOGre/fpgaSynths
void loop(void)
{
	LCD_reset();
	LCD_move_to(0,0);
	LCD_print("sing");
	while (1) ;
}
예제 #10
0
//  =======================================================================
//  Overloaded lprintf function to output numbers supported formats:
//  "\n" - goto new line
//  "%d" - decimal
//  "%X" - hex
//  "%b" - binary
//  example: display binary number six digits, '0' as file character.
//  lprintf( "val:%06b", numb );
//  =======================================================================
void LCD_printf( const unsigned char *lcdString, unsigned int val ) {
    //unsigned char len = strlen(lcdString) + 6;
    //unsigned char *outStr = alloc(len)
    unsigned char outStr[20];
    sprintf(outStr, lcdString, val);
    LCD_print(outStr );
}
// Actualiza el valor de Tmax.
void Mot_updatePhase(GLCD *glcd_p, uint8_t phase, float current, float voltage){

    // chequeo de limite
    if (current > 99.9) current = 99.9;
    if (voltage > 99.9) voltage = 99.9;

    char str_current[5];
    char str_voltage[5];
    char str_complete[6];

    // transformamos el valor de un flotante a un string
    read4charfloat(str_current, current);
    read4charfloat(str_voltage, voltage);

    // Copiamos las partes relevantes a un solo string.
    str_complete[0] = str_current[0];
    str_complete[1] = str_current[1];
    str_complete[2] = ' ';
    str_complete[3] = str_voltage[0];
    str_complete[4] = str_voltage[1];

    // lo imprimimos en la pantalla
    switch(phase){

        case 1:
            LCD_print(glcd_p, F1_C_pos_x, F1_C_pos_y, 5, str_complete);
            glcd_p->fase_1c = current;
            glcd_p->fase_1v = voltage;
            break;

        case 2:
            LCD_print(glcd_p, F2_C_pos_x, F2_C_pos_y, 5, str_complete);
            glcd_p->fase_2c = current;
            glcd_p->fase_2v = voltage;
            break;

        case 3:
            LCD_print(glcd_p, F3_C_pos_x, F3_C_pos_y, 5, str_complete);
            glcd_p->fase_3c = current;
            glcd_p->fase_3v = voltage;
            break;

        default:
            break;
    }

}
예제 #12
0
void displayCfgValues() {
    // TMRO_TabEntry = nPSA+mSecScale*(PSA_256+1);
    TMRO_TabEntry = nPSA+mSecScale*9;
    LCD_printf(0,0, "PSA:%02X ", PSAValue[nPSA]);
    LCD_print(0,9, mSecSCALE[mSecScale]);
    LCD_printf(1,0, "TMR0Val:%04X", delayNum);
	LCD_printf("%04X", TMR0_mSec[TMRO_TabEntry]);
}
예제 #13
0
파일: main.c 프로젝트: LOGre/fpgaSynths
void _zpu_interrupt(void)
{
	int knobdir;
	char * lcdBuffer = "        ";

	// Debounce inputs
	knob_debounce();

	// Handle rotary encoder
	knobdir = knob_readEncoder();
	if (knobdir==1)
	{

		if(freq > 10)
		{
			freq -= 10;
					
			lcdBuffer = itoa(freq, lcdBuffer, 10);
			LCD_clear();
			LCD_move_to(0,0);
			LCD_print(lcdBuffer);					

			setChannelFrequency(YM2149_CH_C, freq);
		}
		 
	}
	else if (knobdir==-1)
	{
		if(freq < 4085)
		{
			freq += 10;
					
			lcdBuffer = itoa(freq, lcdBuffer, 10);
			LCD_clear();
			LCD_move_to(0,0);
			LCD_print(lcdBuffer);					

			setChannelFrequency(YM2149_CH_C, freq);
		}
	}

    // Clear Timer0 Interrupt Flag
	TMR0CTL &= ~(BIT(TCTLIF));
}
예제 #14
0
// ============================================
// ===  LCD Display ===
// ----0----1----1----2
// ----5----0----5----0
// TMR0:xxxx PSA:xx
// Dly:xxx    100mS
// ============================================
void displayCfgValues() {

    TMRO_TabEntry = stTMR0.psaValue + mSecScale*9;

    LCD_printf(0,0, "TMR0:%04X",    stTMR0.tmr0Value);
    LCD_printf(     " PSA:%02X",    stTMR0.psaValue );
	LCD_printf(1,0, "%02X",         mSecScale);
	LCD_printf(" %02X",             stTMR0.extraCounter);
	LCD_printf(" %02X",             t0con);
    LCD_print (1,11,                stTMR0.scale);
}
예제 #15
0
파일: keyproc.c 프로젝트: gcysmart123/WATCH
//主界面,显示时间    
void main_menu(void )
{ 
    clear_screen();
    if(!index_tmp)
    {    
        Test_Power_ADC();    //显示电池图标
        Display_Time();
        bSignalSet?LCD_print(7,94,"♀√",0):LCD_print(7,94,"♀×",0);   //信号图标
        MenuTimout(0);
        MenuMode=0;
        index=0;
        repaintMenu=0;
    }
    else
    {
        index=index_tmp;
        Display_Time_Line(1);
        displayRF();
        MenuMode=2;
        repaintMenu=0;
    }
    Light(0);
    LED=1;
}
예제 #16
0
void ICACHE_FLASH_ATTR 
display_redraw(void)
{
    char page_buffer[20];

    //Clear the lcd
    LCD_clear();

    //Draw the page from the buffer
    display_draw_page(display_page);

    //Draw page counter 
    LCD_setCursor(17,3);
    os_sprintf(page_buffer, "%i/%i",display_page,DISPLAY_PAGE_MAX);
    LCD_print(page_buffer);
}
// Actualiza el valor de Tprom.
void Mot_updateRC(GLCD *glcd_p, float RC){

    // chequeo de limite
    if (RC > 9.9) RC = 9.9;

    // Pointer check
    if (glcd_p->rc == RC && glcd_p->rc != 0) return;

    char str_RC[4];

    //transformamos el valor de un flotante a un string
    read3charfloat(str_RC, RC);
    //lo imprimimos en la pantalla
    LCD_print(glcd_p, RC_pos_x, RC_pos_y, 3, str_RC);
    glcd_p->rc = RC;
}
// Actualiza el valor de la Corriente de entrada.
void Mot_updateRF(GLCD *glcd_p, float RF){

    // chequeo de limite
    if (RF > 9.9) RF = 9.9;

    // Pointer check
    if (glcd_p->rf == RF && glcd_p->rf != 0) return;

    char str_RF[4];

    //transformamos el valor de un flotante a un string
    read3charfloat(str_RF, RF);
    //lo imprimimos en la pantalla
    LCD_print(glcd_p, RF_pos_x, RF_pos_y, 3, str_RF);
    glcd_p->rf = RF;
}
// Actualiza el valor de la Corriente de Salida.
void Mot_updateInDC(GLCD *glcd_p, float InDC){

   // chequeo de limite
   if (InDC > 99.9) InDC = 99.9;

   // Pointer check
   if (glcd_p->indc == InDC && glcd_p->indc != 0) return;

   char str_InDC[5];

   //transformamos el valor de un flotante a un string
   read4charfloat(str_InDC, InDC);
   //lo imprimimos en la pantalla
   LCD_print(glcd_p, InDC_pos_x, InDC_pos_y, 4, str_InDC);
   glcd_p->indc = InDC;
}
예제 #20
0
파일: main.c 프로젝트: yfang1644/DSP55X
void displayPeriod( )
{
	char *str = "    ";
	Int16 i;
	Int16 pv = period;

	for(i = 0; (i < 10) && (pv >= 100); i++) {
		pv -= 100;
	}
	str[0] = i + '0';
	for(i = 0; (i < 10) && (pv >= 10); i++) {
		pv -= 10;
	}
	str[1] = i + '0';
	str[2] = pv + '0';

	LCD_print(str, 1);
}
예제 #21
0
void main() {
	
	Init_Registers();
    initPorts();
	LCD_initialize();
    LCD_Clear();

    while (1) {
        TMR0_GATE_LINE  = 0;	            //Turn OFF Gate line
        LCD_print(0,0,    "Line1");      	// LCD_Line1-0
        LCD_printf(0,7,   ":%03d ", 54);    // LCD_Line1-7 
        LCD_printRom(1,0, "Line2");         // LCD_Line2-0
        delay_s(1);
        TMR0_GATE_LINE  = 1;	            //Turn OFF Gate line
        delay_s(1);
    }

}    
예제 #22
0
void task2(void)
{
	unsigned char filename[20];
	
	while (!pf_readdir(&Dir, &Fno) && Fno.fname[0]) /* go through all the files in the current folder */
				/* Filter out directories and hidden files */
				
	{		
		if (!(Fno.fattrib & (AM_DIR|AM_HID)) && strstr(Fno.fname, "WAV")) /* filter out all the folders, hidden files and the files that are not "WAV" */
		{	
			/* display the filename on the LCD */
			LCD_print(Fno.fname);
			
			/* play the WAV file (the play(filename) function needs the full name of the file e.g. music/file.wav) */
			play(strcat("music/",Fno.fname));
			
			
		}
	}
}
예제 #23
0
int main(void)
{
	unsigned char i; 
 
    LCD_init();
	LCD_goto(1,2);
	LCD_print("Temperature is");
 
 
	LCD_CNTRL_PORT = (1<<SET_HOUR | 1<<SET_MINUTE);
 
	DDRA = 0x00;			// Configure PortA as input
 
	ADCSRA = 0x8F;			// Enable the ADC and its interrupt feature
					// and set the ACD clock pre-scalar to clk/128
	ADMUX = 0xE0;			// Select internal 2.56V as Vref, left justify 
					// data registers and select ADC0 as input channel 
 
	sei();				// Enable Global Interrupts
	ADCSRA |= 1<<ADSC;		// Start Conversion
 
	while(1);
}
예제 #24
0
파일: IMU.c 프로젝트: ayang199/ME433
void main(){
    // *************** Initialize pins and chips ****************
    //SYSTEMConfigPerformance(48000000);
    __builtin_disable_interrupts();

    // set the CP0 CONFIG register to indicate that kseg0 is cacheable (0x3)
    __builtin_mtc0(_CP0_CONFIG, _CP0_CONFIG_SELECT, 0xa4210583);

    // 0 data RAM access wait states
    BMXCONbits.BMXWSDRM = 0x0;

    // enable multi vector interrupts
    INTCONbits.MVEC = 0x1;

    // disable JTAG to get pins back
    DDPCONbits.JTAGEN = 0;
    
    // do your TRIS and LAT commands here
    TRISA = 0xFFEF; // set pin 4 as output
    TRISB = 0b0001111001110011;     // set outputs/inputs
    
    // turn off analog pins
    ANSELBbits.ANSB2 = 0;
    ANSELBbits.ANSB3 = 0;
    
    // setup i2c
    i2c_master_setup();
    
    __builtin_enable_interrupts();
    
    // setup accelerometer
    i2c_write(ADDR, 0x10, 0b10000000);
    i2c_write(ADDR, 0x11, 0b10000000);
    i2c_write(ADDR, 0x12, 0b00000100);
    
    // initialize PWM
    RPB7Rbits.RPB7R = 0b0101; //OC1 on pin 16
    RPB8Rbits.RPB8R = 0b0101; //OC2 on pin 17
    T2CONbits.TCKPS = 4;    // Timer2 prescaler N=16 (1:16)
    PR2 = 4999;             // period = (PR2+1) * N * 12.5 ns = 1 ms, 1 kHz
    TMR2 = 0;               // initial TMR2 count is 0
    OC1RS = 2500;           // duty cycle = OC1RS/(PR2+1) = 50%
    OC1R = 2500;            // initialize before turning OC1 on; afterward it is read-only
    OC2RS = 2500;
    OC2R = 2500;
    OC1CONbits.OCTSEL = 0;  // select timer2
    OC2CONbits.OCTSEL = 0;
    OC1CONbits.OCM = 0b110; // PWM mode without fault pin; other OC1CON bits are defaults
    OC2CONbits.OCM = 0b110;
    T2CONbits.ON = 1;       // turn on Timer2
    OC1CONbits.ON = 1;      // turn on OC1
    OC2CONbits.ON = 1;
    
//    RPB13Rbits.RPB13R = 0b0011; //SDO
//    CS = 1;
    
    // initialize SPI
    SPI_init();
    LCD_init();
    LCD_clearScreen(RED);
    
    //***********************************************************
    
    
    
    
    //****************** constants ***************************
    char length = 14;
    unsigned char IMUdata[length];
    
    short temp;
    unsigned short temperature;
    
    short gx;
    short gy;
    short gz;
    
    unsigned short gyrox;
    unsigned short gyroy;
    unsigned short gyroz;
    
    short ax;
    short ay;
    short az;
    
    unsigned short accelx;
    unsigned short accely;
    unsigned short accelz;
    
    char text[100];
    
    //**********************************************************
    
    
    
    while(1){        
        int var = 1337;
        sprintf(text,"Hello World %d!",var);
        LCD_print(28,32,text,WHITE);
        
        
        //************ TEST IF IMU WORKS ***********************
//        unsigned char data = 0;
//        data = i2c_read(ADDR,0x0F);
//        
//        // read output from SPI
//        CS=0;
//        setVoltage(0,data);
//        CS=1;
        
        //************* SHOULD GET 01101001 *******************

        
        //********** READ MULTI REGISTERS FROM IMU ***************
//        i2c_multiread(ADDR,0x20,IMUdata,length);
//        
//        temp = (IMUdata[1]<<8) | IMUdata[0];
//        temperature = temp + 32768;
//        
//        gx = (IMUdata[3]<<8) | IMUdata[2];
//        gyrox = gx + 32768;
//        
//        gy = (IMUdata[5]<<8) | IMUdata[4];
//        gyroy = gy + 32768;
//        
//        gz = (IMUdata[7]<<8) | IMUdata[6];
//        gyroz = gz + 32768;
//        
//        ax = (IMUdata[9]<<8) | IMUdata[8];
//        accelx = ax + 32768;
//        
//        ay = (IMUdata[11]<<8) | IMUdata[10];
//        accely = ay + 32768;
//        
//        az = (IMUdata[13]<<8) | IMUdata[12];
//        accelz = az + 32768;
//        
//        //********************************************************
//        
//        
//        
//        //*********************** PWM ****************************
//        // Calculate OC1RS and OC2RS
//        OC1RS = floor(accelx/6.5535);
//        OC2RS = floor(accely/6.5535);
//        
//        // Set OC1 limits
//        if (OC1RS > 7500){
//            OC1RS = 5000;
//        }
//        else if (OC1RS < 2500){
//            OC1RS = 0;
//        }
//        else {
//            OC1RS = OC1RS-2500;
//        }
//        
//        // Set OC2 limits
//        if (OC2RS > 7500){
//            OC2RS = 5000;
//        }
//        else if (OC2RS < 2500){
//            OC2RS = 0;
//        }
//        else {
//            OC2RS = OC2RS-2500;
//        }
        
        //******************************************************
        
        

        delay(24000); // Delay 1ms
    }
    
}
예제 #25
0
파일: main.c 프로젝트: yfang1644/DSP55X
void main(void)
{
	Int16  temp_cnt;

	ICR = 0xff2e;	/* IDLE Control Register */
					/* mem port, io port and cpu idle active */

	/* Peripheral_Reset  */
	CSL_SYSCTRL_REGS->PSRCR = 0x0020;

	CSL_SYSCTRL_REGS->PCGCR1 = 0x0000;
	CSL_SYSCTRL_REGS->PCGCR2 = 0x0000;
	CSL_SYSCTRL_REGS->PRCR = 0x00bf;

/* VERY IMPORTANT !!! */
/* PPMODE1 (SPI, GPIO, UART, and I2S2):
    7 signals of the SPI module,
    6 GPIO signals(GP[17:12]),
    4 signals of the UART module,
    4 signals of the I2S2 module

   SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6])
   SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0
*/
	CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12)
							|(CSL_SYS_EBSR_SP1MODE_MODE2 << 10)
							|(CSL_SYS_EBSR_SP0MODE_MODE0 << 8);

	asm("	bit(ST1, #ST1_INTM) = #1");

	INTR_init();
	PLL_init(3658);		// system clock set to 120MHz
	TIMER_init();
	EZDSP5535_GPIO_init();
	EZDSP5535_I2C_init();		/* Initialize I2C */

	Audio_init(7);				/* Initialise to bandwidth=7kHz */

	EZDSP5535_LCD_init();
	LCD_print("G722.1 Receiver  ", 17, 0);
	LCD_print("16kbps  ", 8, 1);
	EZDSP5535_SPI_init();
	Si446x_Init();

	EZDSP5535_SAR_init();
	DiskInit();
	FileInit();

	AddFileDriver(SDCammand, NULL);

	asm("	bit(ST1, #ST1_INTM) = #0");

	bApi_Set_Receive();
	while(1) {
		if(gpioIsrStatus == 1) {
			temp_cnt = SPI_recvData(spibuffer);

			gpioIsrStatus = 0;
			CSL_GPIO_REGS->IOINTFLG1 = 0x0800;
		}

		if(spiIsrStatus == 1) {
//			SpiWriteByte(CMD_FIFO_INFO, 0);
			SpiWriteByte(CMD_GET_INT_STATUS, 0);
			bApi_Set_Receive();
			if(audioProcessing())	continue;

			spiIsrStatus = 0;
		}

		fileProcessing();

		asm("	idle");
	}

//	RemoveFileDriver(SDCammand);
}
예제 #26
0
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_FSMC_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  LCD_Init(LCD_ORIENTATION_PORTRAIT);
  LCD_setFont(SmallFont);
  LCD_setBackColor(VGA_BLACK);
  LCD_fillScr(VGA_BLACK);

  TSC2046_Init();
  TSC2046_Calibration();
  LCD_fillScr(VGA_BLACK);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  char buf[100];
  int16_t xpos, ypos;

  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    LCD_setColor(VGA_BLUE);
    LCD_drawRect(0, 0, 10, 10);

    while(!Is_Touhcing());

    while (Is_Touhcing())
    {
      // read
      xpos = TSC2046_Get_Position_X();
      ypos = TSC2046_Get_Position_Y();

      // clear
      if (xpos > LCD_WIDTH - 20 && ypos > LCD_HEIGHT - 20)
      {
        LCD_fillScr(VGA_BLACK);
      }

      // print
      sprintf(buf, "(x,y)=(%04d, %04d)", xpos, ypos);
      LCD_setColor(VGA_RED);
      LCD_setBackColor(VGA_BLACK);
      LCD_print(buf, 20, 300, 0);

      // draw pen
      LCD_setColor(rand() | 0b0111101111101111);
      LCD_fillCircle(xpos, ypos, 3);

      // clear button
      LCD_setColor(VGA_WHITE);
      LCD_fillRect(LCD_WIDTH - 20, LCD_HEIGHT - 20, LCD_WIDTH - 1, LCD_HEIGHT - 1);

      // pen indicator
      LCD_setColor(VGA_GREEN);
      LCD_drawRect(0, 0, 10, 10);
    }

  }
  /* USER CODE END 3 */

}
예제 #27
0
/* Main                                                                  */
int main (void)
{
	// setare pin 5 (difuzor) si pin 6 (CS_SD) al portului A ca pin de iesire
	DDRD |= (1<<PD5) | (1<<PD6);
	
	// setam toti pinii portului C ca pini de iesire
	DDRC = 0xFF;
	
	DDRB &= ~(1<<PB0);
	DDRB &= ~(1<<PB1);
	
	PORTB |= (1<<PB1) | (1<<PB0);
	PORTD &= ~((1<<PD5) | (1<<PD6));
	PORTD &= ~((1<<PD5) | (1<<PD6));
	

	LCD_init();
		
	sei();

	for (;;)
	{
		_delay_ms(1000);							/* Delay 1000ms for things to settle down */
		
		if (pf_mount(&Fs)) 
		{	
			continue;	/* Initialize FS */
		}
		
		if (pf_opendir(&Dir, "wav")) break;		/* Open /wav folder */
		
		int state = STAHPED;
		char* filename, first_wav, last_wav_played;
		
		
		
		if (!pf_readdir(&Dir, &Fno) && Fno.fname[0]) /* go to next file*/
			{		
				if (!(Fno.fattrib & (AM_DIR|AM_HID)) && strstr(Fno.fname, "WAV")) /* filter out all the folders, hidden files and the files that are not "WAV" */
				{	
					/* display the filename on the LCD */
					LCD_print(Fno.fname);
					strcpy(first_wav, Fno.fname);
				}
			}		

		while(1) 
		{
			/* check if button on PA3 (start/stahp) is pressed */
			if (!(PINA & (1 << PA3)))
			{
				if (state == STAHPED)
				{
					state = STARTED;
					LCD_print(Fno.fname);
					play(strcat("wav", Fno.fname)); // play song
				}
				else 
				{
					state = STAHPED;
					LCD_print(Fno.fname);
					FifoCt = 0; // stop melody
				}
			}
			/* check if button on PA2 (next) is pressed */
			if (!(PINA & (1 << PA2)))
			{
				sprintf(last_wav_played, "%s", Fno.fname);
				
				if (state == STARTED)
				{
					if (!pf_readdir(&Dir, &Fno) && Fno.fname[0]) /* go to next file*/
					{		
						if (!(Fno.fattrib & (AM_DIR|AM_HID)) && strstr(Fno.fname, "WAV")) /* filter out all the folders, hidden files and the files that are not "WAV" */
						{	
							/* display the filename on the LCD */
							LCD_print(Fno.fname);
							
							/* play the WAV file */
							play(strcat("wav", Fno.fname));
						}
					}			
				}
				else 
				{
					if (!pf_readdir(&Dir, &Fno) && Fno.fname[0]) /* go to next file*/
					{		
						if (!(Fno.fattrib & (AM_DIR|AM_HID)) && strstr(Fno.fname, "WAV")) /* filter out all the folders, hidden files and the files that are not "WAV" */
						{	
							/* display the filename on the LCD */
							LCD_print(Fno.fname);
						}
					}			
				}
			}
			
			/* check if button on PA1 (previous) is pressed */
			if (!(PINA & (1 << PA1)))
			{
				if (state == STARTED)
				{
					if (strcmp(last_wav_played, first_wav) != 0 )
					{
						/* display the filename on the LCD */
						LCD_print(last_wav_played);
						
						/* play the WAV file */
						play(strcat("wav", last_wav_played));
					}
					else 
						/* display the filename on the LCD */
						LCD_print(first_wav);
				}
				else
					if (strcmp(last_wav_played, first_wav) != 0 )
					/* display the filename on the LCD */
						LCD_print(last_wav_played);
			}
		}
	}
	
	return 1;
}
예제 #28
0
/***************************************************
 * Print String to LCD at Row, Column *
*************************************************** */
void LCD_printA(unsigned char LcdLine, unsigned char LcdColumn, char *str1, char *str2) {
    LCD_gotoRC( LcdLine, LcdColumn);
    LCD_print( str1 );
    LCD_print( str2 );
}
예제 #29
0
/***************************************************
 * Print String to LCD at Row, Column *
*************************************************** */
void LCD_printA(unsigned char LcdRow, unsigned char LcdColumn, unsigned char *str1, unsigned char *str2) {
    LCD_gotoRC( LcdRow, LcdColumn);
    LCD_print( str1 );
    LCD_print( str2 );
}
예제 #30
0
/***************************************************
 * Print String to LCD at Row, Column *
*************************************************** */
void LCD_print(unsigned char LcdRow, unsigned char LcdColumn, unsigned char *text) {
    LCD_gotoRC( LcdRow, LcdColumn);
    LCD_print( text );
}