Пример #1
0
//*************************************************************************
//                         初始化LCD
//*************************************************************************
void LCD_initial()                        
{
    PSB_SET;		  //液晶并口方式
    RST_SET;		  //复位脚RST置高
    
    lcd_write_instruction(FUN_MODE);			//显示模式设置
    delay_ms(5);
    lcd_write_instruction(DISPLAY_ON);			//显示开
    delay_ms(5);
    lcd_write_instruction(CLEAR_SCREEN);		//清屏
    delay_ms(5);
    lcd_write_instruction(CURSE_ADD);
    delay_ms(5);
    
    //配置时钟
    TACTL |= TASSEL_1 + ID_0 + MC_1;
    TACCR0 = 100000;
    CCTL0 = CCIE;
    
    buffer_ptr = lcd_buffer;
    is_show_lcd_screen = 1;
    is_lcd_message = 0;
}
Пример #2
0
//*************************************************************************
//                             显示一行数据
//*************************************************************************
void LCD_displayCgromLine(uchar line, char *hz)
{
    uchar address = 0x80;
    assert(line < 2);
    switch(line)
    {
    case 0:
      address = 0x80;
      break;
    case 1:
      address = 0x90;
      break; 
    }
    lcd_write_instruction(address);
    delay_ms(5);
    while(*hz != '\0')
    {
      LCD_write_data(*hz);
      hz++;
      delay_ms(5);
    }
}
Пример #3
0
//*************************************************************************
//                             LCD清屏
//*************************************************************************
void LCD_cls()          
{
    lcd_write_instruction(0x01);
    delay_ms(5);  
}
Пример #4
0
int main(void)
{
	memset( spectrum, 0, sizeof(spectrum) );
	memset( spectrum_history, 0, sizeof(spectrum) );

	init();

	uint16_t cycles_till_reset_x = LCD_RESET_ADDR_CYCLES;

	while(1)
	{
		if( sleeping )
		{
			sleepcycles++;

			if( backlight_task_scaler++ >= 75 )
			{
				backlight_task(-1);
				backlight_task_scaler = 0;
			}

			if( sleeping == 3 )
				go_to_sleep();
			else if( sleeping == 2 )
				wake_up();
			else // sleeping == 1
			{
				SMCR = _BV(SM0) | _BV(SE);
				asm volatile( "sleep\n\t" );
			}
		}
		else
		{
			backlight_task_scaler = 0;
			backlight_task(-1);

			// Apply window function and store in butterfly array
			fft_input( capture, bfly );

			// Execute forier transform
			fft_execute( bfly );

			// Bit reversal algorithm from butterfly array to output array
			fft_output( bfly, spectrum );

			// Do exponential/FIR filtering with history data
			exp_average( spectrum, spectrum_history );

#ifdef DISPLAY_TEST_PATTERN
			uint8_t *sp = spectrum;
			uint8_t v = 5;
			uint8_t k = sizeof(spectrum)/sizeof(uint8_t);
			while( k-- )
			{
				*sp = v;
				v++;
				if( v > 38 )
					v = 5;
				sp++;
			}

			long t = 100000;
			while(t--)
			{
				asm volatile("nop");
			}

#else

#ifdef BLANK_LEFT_TWO_BARS
			spectrum[0] = spectrum[1] = 0;
#endif
#endif
			avc_task( spectrum );

			if( --cycles_till_reset_x <= 0 )
			{
				cycles_till_reset_x = LCD_RESET_ADDR_CYCLES;
				lcd_write_instruction( LCD_ADDR | 0, CHIP1 );
				lcd_write_instruction( LCD_ADDR | 0, CHIP2 );
			}
			fastlcd( spectrum );
			
			loopnum++;
		}
	}