Example #1
0
int main(void) {
    
    char buffer[8];

    cli();
    LCD_Init();
    DDRB = DDRB | ( 1 << PB5);
    PORTB = PORTB & ( ~ ( 1 << PB5 ) );
    sei();

    uint8_t loop8;
    uint16_t byteIndex;
    uint16_t numBytes = 3431;//HARDCODED
    sprintf(buffer, "difference encoding");
    LCD_puts(buffer,1);
    for(byteIndex = 0 ; byteIndex < numBytes ; byteIndex ++){
	uint8_t currByte = pgm_read_byte(&(mywavdata[byteIndex]));
	for(loop8 = 1 ; loop8 > 0 ; loop8*=2){
                if (loop8 & currByte) 
			PORTB = PORTB | (1 << PB5);
		else
			PORTB = PORTB & ~(1 << PB5);
        	_delay_us(120);
	}
    }
    
    return 0;   /* never reached */
}
Example #2
0
//硬件初始化
void borad_HarwareInit(void)
{
		//OS_ERR err;
		//CPU_SR_ALLOC();
		
		delay_init(168);  //时钟初始化
		NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//中断分组配置
		uart_init(115200);   //串口初始化
		
		INTX_DISABLE();		//关中断,防止滴答定时器对外设初始化的打扰
		
		LED_Init();         //LED初始化	
		LCD_Init();			//LCD初始化	
		
		POINT_COLOR = RED;
		LCD_ShowString(30,10,200,16,16,"HardWare: STM32F4");	
		LCD_ShowString(30,30,200,16,16,"SotfWareSystem:UCOSIII,FATFS");
		LCD_ShowString(30,50,200,16,16,"STM32_NC");
		LCD_ShowString(30,70,200,16,16,"HuBei University of Technology");
		LCD_ShowString(30,90,200,16,16,"2016/1/16");
		
		//SD卡初始化
		SDCard_Init();
		
		INTX_ENABLE();		//开中断
}
Example #3
0
void main(){

	OUTPUT_LOW(LCD_RW); //Che do ghi 
	LCD_Init();        //Khoi tao LCD

	LCD_PutCmd(0x01);  //Xoa man hinh

	ENABLE_INTERRUPTS(INT_TIMER0); //Kich hoat ngat ngoai
	SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_32); //Xung kich noi va chia truoc 32
	ENABLE_INTERRUPTS(GLOBAL); //Cho phep ngat toan cuc
	SET_TIMER0(100); //Bat dau dem tu 100, khi tran Timer0 duoc 1ms

	while (True){ //Duy tri hoat dong cua vi dieu khien

		if (dem > N_max){
			dem = 0;
			LCD_PutCmd(0x01);
		}

		LCD_SetPosition(0x00); //Cot 1 dong 1
		LCD_PutChar("Dem so:");
		LCD_SetPosition(0x07); //Cot 8 dong 1
		printf(LCD_PutChar,"%lu",dem);

	}
}
Example #4
0
void main(void)
{
	uint8_t error_flag;

	LED3=0;
	UART_Init();
	LCD_Init();
	SPI_master_init(400000); // Set clock rate to that speed in Hz
	error_flag = SDcard_init();
	

	while(1)
	{
		LED1 = 0;
		LED4 = 0;
		if(error_flag != NO_ERRORS)
		{
			LED4 = 0;
		}
		else
		{
			LED4 = 1;
		}
		delay_ms(1000);
		LED1 = 1;
		LED4 = 1;
		LCD_Write(COMMAND, LINE1);
		LCD_Print(16, "Coltons and Matt");
		LCD_Write(COMMAND, LINE2);
		LCD_Print(15, "hews LCD Works!");
		delay_ms(3000);
		LCD_Clear();
	}

}
Example #5
0
/**
  * @brief  LCD configuration.
  * @param  None
  * @retval None
  */
static void LCD_Config(void)
{
  /* LCD DSI initialization in mode Video Burst  */
  LCD_Init();
  
  /* Activate foreground and background layers */
  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_BACKGROUND, LCD_BG_LAYER_ADDRESS); 
  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_FOREGROUND, LCD_FG_LAYER_ADDRESS);  
  
  /* Set LCD Background Layer  */
  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_BACKGROUND); 
  /* Clear the Background Layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  
  /* Set LCD Foreground Layer  */
  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_FOREGROUND);
  /* Clear the Foreground Layer */ 
  BSP_LCD_Clear(LCD_COLOR_BLACK); 

  /* Configure and enable the Color Keying feature */
  BSP_LCD_SetColorKeying(1, 0); 

  /* Configure the transparency for foreground: Increase the transparency */
  BSP_LCD_SetTransparency(LTDC_ACTIVE_LAYER_FOREGROUND, 100);
  
}
Example #6
0
int main(void) {

    MCU_Clk_Init();
    Input_Init();
    Output_Init();
    LCD_Init();
    // Cau hinh timer xay ra ngat sau 1s
    Timer0A_Config(40000000);

    Write_Str("Hello World!", 0, 0);

    while (1) {
        if (CuaDong) {
            // Bat den
            door_is_close = true;
            GPIOPinWrite(GPIO_PORTB_BASE, LIGHT_PIN, LIGHT_PIN);
        } else {
            door_is_close = false;
            if (is_active) {
                // Neu dang nuong ma mo cua thi tat ngay lap tuc thiet bi nuong, tat timer va bat loa canh bao
                GPIOPinWrite(GPIO_PORTB_BASE, GRILL_PIN, GRILL_PIN);
                GPIOPinWrite(GPIO_PORTB_BASE, MICRO_PIN, MICRO_PIN);
                TimerDisable(TIMER0_BASE, TIMER_A);
                GPIOPinWrite(GPIO_PORTB_BASE, SPEAKER_PIN, 0);
            } else {
                // Neu da nuong xong va cua mo thi tat loa
                GPIOPinWrite(GPIO_PORTB_BASE, SPEAKER_PIN, 0);
            }

        }
    }
}
Example #7
0
/**
 * Hardware setup peripherals
 */
static void 
setup(void)
{
	wdt_enable(WDTO_1S);

	use_buzzer = 1;

	DDRC |= (1 << RED_PIN) | (1 << YELLOW_PIN) | (1 << GREEN_PIN) | (1 << SPEAKER_PIN);
	PORTC |= 0x0E;

	TCCR1B |= (1 << WGM12);
    TIMSK |= (1 << OCIE1A);
    OCR1A = 65400; // 256 prescaler --> 1 Hz

	TCCR0 |= (1 << WGM01);
	OCR0 = 255; // 1024 prescaler --> 250 Hz
	TIMSK |= (1 << OCIE0);

	LCD_Init(16);
	LCD_Clear();
	LCD_GotoXY(0, 0);

	USB_InitAndConnect();

	// TIMER1: 256 prescaler
	TCCR1B |= (1 << CS12); 

	// TIMER0: 1024 prescaler
	TCCR0 |=  (1 << CS02) | (1 << CS00); 

	RFID_Init();
}
Example #8
0
int main()
{

	unsigned int i, j = 0;

   volatile unsigned int *pLcdDestReg = (volatile unsigned int*)(LCD_DEST_REG_ADDR);
   volatile unsigned int *pLcdWidthReg = (volatile unsigned int*)(LCD_WIDTH_REG_ADDR);
   volatile unsigned int *pLcdHeightReg = (volatile unsigned int*)(LCD_HEIGHT_REG_ADDR);
   volatile unsigned int *pLcdCmdReg = (volatile unsigned int*)(LCD_CMD_REG_ADDR);

   volatile unsigned int *pCam = (volatile unsigned int*)(OV7670_0_BASE | 0x80000000);
   volatile unsigned char pid[2] = {0,0};

  *pLcdCmdReg = 0; // make sure that the DMA is stopped before calling the LCD init functions
  *pCam = 0;
  LCD_Init();
  LCD_Clear(0X00ff);
  //init_lcd_frame();



   printf("%x\n", lcd_frame);

   *pCam = 1; // turns the camera ON. Camera turns on with the next new frame
   Delay_Ms(2000); // add delay to be sure that frames are already in the memory

   *pLcdDestReg = LT24_CONTROLLER_0_BASE + 4;
   *pLcdWidthReg = 240; // LCD width
   *pLcdHeightReg = 320; // LCD height
   *pLcdCmdReg = 0x1f00000; // by default camera throws images starting from here
   *pLcdCmdReg |= 0x80000000; // this commands turns the LCD ON



}
Example #9
0
File: main.c Project: XDeca/LED_POV
static void LCD_Config(void)
{
  /* LCD Initialization */ 
  LCD_Init();

  /* LCD Layers Initialization */ 
  LCD_LayerInit();
  
  /* Enable the LCD */ 
  LCD_DisplayOn();

  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  /* Clear the Background Layer */
  LCD_Clear(LCD_COLOR_WHITE);

  /* Set LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  /* Clear the Foreground Layer */ 
  LCD_Clear(LCD_COLOR_WHITE); 

  /* Configure and enable the Color Keying feature */
  LCD_SetColorKeying(0); 

  /* Configure the transparency for foreground : Increase the transprency */
  LCD_SetTransparency(100);

}
void main()
{	
int i,j;
int a[5] = {34,43,12,56,78}	;
int temp = 0;
LCD_PORT = 0x00;
LCD_Init();
lcd_cmd(0x80);  
delay(2);

for(i=0;i<5;i++)
	{
		for(j=i;j<5;j++) 
			{
			 if(a[i]>a[j])
			 	{
					temp = a[i];
					a[i] = a[j];
					a[j] = temp;
				}	 
  			}
		}
for(i=0;i<5;i++)
{
	converttochar(a[i]);

} 
 while(1); 
}
Example #11
0
void prvLCDTask( void * pvParameters )
{
QueueHandle_t *pxLCDQueue;
xLCDMessage xReceivedMessage;
char *pcString;

	/* To test the parameter passing mechanism, the queue on which messages are
	received is passed in as a parameter even though it is available as a file
	scope variable anyway. */
	pxLCDQueue = ( QueueHandle_t * ) pvParameters;

	LCD_Init();

	for( ;; )
	{
		/* Wait for a message to arrive. */
		if( xQueueReceive( *pxLCDQueue, &xReceivedMessage, portMAX_DELAY ) )
		{
			/* Where is the string we are going to display? */
			pcString = *xReceivedMessage.ppcMessageToDisplay;
  			LCD_DisplayString(xReceivedMessage.xRow, pcString, BlackText);

			/* The delay here is just to ensure the LCD task does not starve
			out lower priority tasks as writing to the LCD can take a long
			time. */
			vTaskDelay( mainLCD_DELAY );
		}
	}
}
Example #12
0
int main(void)
{
	int i = 0, j = 0, m = 0;

	*LED = 0b00000001;

	LCD_Init();
	LCD_Clear(GUI_COLOR_RED);

	while(1){

		for(m = 0; (m <= 12); m++){

			LCD_Clear(colors[m]);

			for(i = 0; i < 7; i++){
				*LED<<=1;
				for(j = 0; j < SPEED; j++);
			}

			for(i = 7; i > 0; i--){
				*LED>>=1;
				for(j = 0; j < SPEED; j++);
			}
		}
	}

	return 0;
}
Example #13
0
/**
  * @brief  主函数
  * @param  无  
  * @retval 无
  */
int main(void)
{	
	/* 系统定时器 1us 定时初始化 */
  SysTick_Init();
  
  LCD_Init();	
  /* GRAM扫描方向为左下脚->右上角 */
  Lcd_GramScan(2);
  LCD_Clear(0, 0, 320, 240, BACKGROUND);
  
/*------------------------------------------------------------------------------------------------------*/
  
  /* 触摸屏IO和中断初始化 */
  Touch_Init();
  
  /* 等待触摸屏校正完毕 */
  while(Touch_Calibrate() !=0);
  
  /* 触摸取色板初始化 */
  Palette_Init();
  
	while( 1 )
  {
    if(touch_flag == 1)			/*如果触笔按下了*/
    {
      /*获取点的坐标*/
      if(Get_touch_point(&display, Read_2046_2(), &touch_para ) !=DISABLE)      
      {					
        Palette_draw_point(display.x,display.y);	 										
      }
    }		
  }
}
Example #14
0
void Init() {
    PWR_Init();
    LED_Init();
    CLOCK_Init();
    UART_Initialize();
    printf("Start\n");
    Initialize_ButtonMatrix();
    STORAGE_Init();  // This must come before LCD_Init() for 7e

#ifdef MEDIA_DRIVE
    MEDIA_Init();
#endif

    LCD_Init();
    CHAN_Init();

    SPITouch_Init();
    SOUND_Init();
    BACKLIGHT_Init();
    BACKLIGHT_Brightness(1);
    AUTODIMMER_Init();
    STORAGE_WriteEnable(1);  // Enable writing to all banks of storage

    PPMin_TIM_Init();
#ifdef ENABLE_MODULAR
    //Force protocol to none to initialize RAM
    Model.protocol = PROTOCOL_NONE;
    PROTOCOL_Init(1);
#endif
#if HAS_RTC
    RTC_Init();        // Watchdog must be running in case something goes wrong (e.g no crystal)
#endif
}
Example #15
0
/**
  * @brief LCD configuration.
  * @note  This function Configure tha LTDC peripheral :
  *        1) Configure the Pixel Clock for the LCD
  *        2) Configure the LTDC Timing and Polarity
  *        3) Configure the LTDC Layer 1 :
  *           - ARGB4444 as pixel format  
  *           - The frame buffer is located at internal RAM : The output of DMA2D transfer
  *           - The Layer size configuration : 150x150  
  * @retval
  *  None
  */
static void LCD_Config(void)
{
  /* Initialize the LCD */
  LCD_Init();
  
  /* Initialize the LCD Layers */
  LCD_LayerInit();
  
  /* Set the Foreground as active Layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  LCD_SetTransparency(0);
  
  /* Set the Background as active Layer */
  LCD_SetLayer(LCD_BACKGROUND_LAYER); 
  
  /* Configure the window size and position */
  LCD_SetDisplayWindow(165, 61, 150, 150);

  /* Configure the LCD Pixel Format */
  LCD_SetPixelFormat(LTDC_Pixelformat_ARGB4444);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&aBufferResult);  
}  
Example #16
0
void main(void)
{
    // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
    // Insert your main routine code here.

    //Start LCD
    LCD_Start();
    LCD_Init();

    value = 0; //0b0000 0000 where last four bits are 0, PRT0DR[3],PRT0DR[2], PRT0DR[1]

    while(1)//Control loop
    {
        mask = PRT0DR;

        //Collect PRT0DR[3] value
        if( (mask & 0b00001000) == 0)
        {
            //PRT0DR[3] is low
            value &= ~0b00000100;
        }
        else
        {
            //PRT0DR[3] is high
            value |= 0b00000100;
        }

        //Collect PRT0DR[2] value
        if( (mask & 0b00000100) == 0)
        {
            //PRT0DR[2] is low
            value &= ~0b00000010;
        }
        else
        {
            //PRT0DR[2] is high
            value |= 0b00000010;
        }

        //Collect PRT0DR[1] value
        if( (mask & 0b00000010) == 0)
        {
            //PRT0DR[1] is low
            value &= ~0b00000001;
        }
        else
        {
            //PRT0DR[1] is high
            value |= 0b00000001;
        }

        //Print to LCD
        LCD_Position(0,0);
        LCD_PrHexByte(value);

    }//End control loop


}
/*
 * 初始化液晶,串口,触摸屏,flash及sd卡 * 
 */
void ISO_Init(void)
{
	uint8_t k;
	
  /* 液晶初始化先于串口,不然会有bug,至于是什么原因我也不知道:( */
  LCD_Init();
	
	LCD_Clear(0,0,240,320,WHITE);
	
	LCD_DispStr(20,150,"board init,please wait... ",RED);
  
  USART1_Config();	
	
	

	/* 初始化sd卡文件系统,因为汉字的字库放在了sd卡里面 */
	Sd_fs_init();	

	#ifdef WORD_MODE
  /* 显示界面图片 */
	Lcd_show_bmp(0, 0,"/boardtest/boardtest.bmp");
	#else
	 /* 显示界面图片 */
	Lcd_show_bmp(0, 0,"/boardtest/ISO/ui_boardtest.bmp");

	#endif
	Lcd_List(1);
	
	/* 初始化外部FLASH */
	SPI_FLASH_Init();
	//SPI_FLASH_SectorErase(0);
  
	/* 触摸屏IO和中断初始化 */
	Touch_Init();		
		
		
		/*-------------------------------------------------------------------------------------------------------*/  
		#if 1
		SPI_FLASH_BufferRead(&cal_flag, 0, 1);
		if( cal_flag == 0x55 )
		{
			SPI_FLASH_BufferRead((void*)cal_p, 1, sizeof(cal_p));
			SPI_FLASH_CS_HIGH();
			for( k=0; k<6; k++ )
						printf("\r\n rx = %LF \r\n",cal_p[k]);
		}
		else
		{
			/* 等待触摸屏校正完毕 */
			while(Touch_Calibrate() !=0);
		}
		#elif 0
		/* 等待触摸屏校正完毕 */
		while(Touch_Calibrate() !=0);
		#endif
	


}
Example #18
0
int main()
{
    char uartBuffer[80];
    char lcdBuffer[16];
    
    UART_1_Start();    
    UART_1_UartPutString("Sequencer Board Test\r\n");
    
    // Sequence Boardをリセット
    Pin_I2C_Reset_Write(0u);
    CyDelay(1);
    Pin_I2C_Reset_Write(1u);
    
    /* Init I2C */
    I2CM_Start();
    CyDelay(1500);
    
    CyGlobalIntEnable;
    
    LCD_Init();
    LCD_Clear();
	LCD_Puts("Sequencer Board");
    
    CyDelay(1000);
        
    for(;;)
    {  
        if (readSequencerBoard() == I2C_TRANSFER_CMPLT) {
            sprintf(uartBuffer, "%d %d %d %d %d %d ",
                sequencerRdBuffer[0],
                sequencerRdBuffer[1],
                sequencerRdBuffer[2],
                sequencerRdBuffer[3],
                sequencerRdBuffer[4],
                sequencerRdBuffer[5]
            );
            UART_1_UartPutString(uartBuffer);
        }
        else {
            UART_1_UartPutString("I2C Master Sequencer Read Error.\r\n");
        }
        
        if (writeSequencerBoard() == I2C_TRANSFER_CMPLT) {
            sprintf(uartBuffer, "%d\r\n", sequencerWrBuffer[0]);
            UART_1_UartPutString(uartBuffer);
        }
        else {
            UART_1_UartPutString("I2C Master Sequencer Write Error.\r\n");
        }
        
        sprintf(lcdBuffer, "%d", sequencerWrBuffer[0]);
        LCD_Clear();
        LCD_Puts(lcdBuffer);
        
        sequencerWrBuffer[0] = inc_within_uint8(sequencerWrBuffer[0], 16, 0);
        
        CyDelay(125);
    }
}
Example #19
0
void main(void)
{
    u16 trigpos;
    u8 keycode;
    
    SystemState = AutoRunMode;
    // 现在还是使用软件触发
	  ADCState = Triggered;       // ADCState = WaitTrigger;

    CLK_Init();                 // 主时钟初始化
    TIM4_Init();                // TIM4 用于产生系统运行需要的定时信号
    KEY_Init();                 // 按键驱动初始化
    KeyParse_Init();            // 按键处理模块初始化
    LCD_Init();                 // LCD驱动初始化
    WDraw_Init();               // 波形显示模块初始化
    TriggerInterruptInit();     // 外部触发中断初始化
    ADC_Init();                 // ADC采样程控模块初始化
    DProc_Init();               // 数据处理模块初始化
  

    enableInterrupts();

    /* Infinite loop */
    while (1)
    {
    
				if(flag_10ms_ok)
        {
            flag_10ms_ok = 0;
            keycode = KEY_Scan();
						switch(GET_KTYPE(keycode))
            {
                case KTYPE_NORMAL:
                    KeyParse(GET_KCODE(keycode));
                default:
                    break;
            }
        }
        switch(SystemState)
        {
            // to do
            case AutoRunMode:
            case ManualMode:
                //  处理数据
                if( ADCState == ADC_Buffer_Full )
                {
                    trigpos = GetTriggerPostion(0, 64);
                    WDraw_DisplayUpdate(&ADC_Buffer[trigpos]);
                    ADCState = Triggered;
                    ADC_Index = 0;
                }
                break;
            default:
                break;
        }
		
		}
  
}
Example #20
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint8_t  lcd_status = LCD_OK;
  
  /* STM32F4xx HAL library initialization:
    - Configure the Flash prefetch, instruction and Data caches
    - Systick timer is configured by default as source of time base, but user 
      can eventually implement his proper time base source (a general purpose 
      timer for example or other time source), keeping in mind that Time base 
      duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
      handled in milliseconds basis.
    - Set NVIC Group Priority to 4
    - Low Level Initialization: global MSP (MCU Support Package) initialization
  */
  HAL_Init();
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Initialize the SDRAM */
  BSP_SDRAM_Init();
  
  /* Initialize the LCD   */
  lcd_status = LCD_Init();
  OnError_Handler(lcd_status != LCD_OK); 

  /* Initialize LTDC layer 0 iused for Hint */
  BSP_LCD_LayerDefaultInit(0, LAYER0_ADDRESS);     
  BSP_LCD_SelectLayer(0); 
    
  /* Display example brief   */
  LCD_BriefDisplay();
  
  /*Draw first image */
  CopyBuffer((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240);
  pending_buffer = 0;
  
  /*Refresh the LCD display*/
  HAL_DSI_Refresh(&hdsi_eval);

  /* Infinite loop */
  while (1)
  {
    if(pending_buffer < 0)
    {
      CopyBuffer((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240);
      
      if(ImageIndex >= 2)
      {
        ImageIndex = 0;
      }
      pending_buffer = 0;
      
      HAL_DSI_Refresh(&hdsi_eval);
    }
    /* Wait some time before switching to next image */
    HAL_Delay(2000);
  }
}
Example #21
0
int main(int argc, const char* argv[])
{
	LCD_Init();
	LCD_Clear();
	LCD_WriteString(20,1,"viewtool");
	LCD_WriteString(0,3,"Ginkgo USB-SPI");
	return 0;
}
Example #22
0
unsigned char LCD_INT(void)
{
    Clr_CS();
    Clr_SID();
    Clr_SCLK();
    LCD_Init();
    return (0);
}
static void prvSetupHardware( void )
{
	/* Initialise the LEDs. */
	vParTestInitialise();

	/* Configure the LCD. */
	LCD_Init( LCD );
}
Example #24
0
 int main(void)
 { 
	u16 i,rxlen;
	u16 lenx;
	u8 key=0XFF;
	u8 upload=0;
	delay_init();	    	 //延时函数初始化	  
	uart_init(38400);	 	//串口初始化为9600
	USART2_Init(38400);	//初始化串口2
	LED_Init();				//初始化与LED连接的硬件接口
	KEY_Init();				//初始化与LED连接的硬件接口
   LCD_Init();				//初始化LCD
 	POINT_COLOR=RED;
	LCD_ShowString(30,20,200,16,16,"ALIENTEK STM32 ^_^");	
	LCD_ShowString(30,40,200,16,16,"NE0-6M GPS TEST");	
	LCD_ShowString(30,60,200,16,16,"ATOM@ALIENTEK");
	LCD_ShowString(30,80,200,16,16,"KEY0:Upload NMEA Data SW");   	 										   	   
   	LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:OFF");   
	if(Ublox_Cfg_Rate(1000,1)!=0)	//设置定位信息更新速度为1000ms,顺便判断GPS模块是否在位. 
	{
   		LCD_ShowString(30,120,200,16,16,"NEO-6M Setting...");
		while((Ublox_Cfg_Rate(1000,1)!=0)&&key)	//持续判断,直到可以检查到NEO-6M,且数据保存成功
		{
			USART2_Init(9600);				//初始化串口2波特率为9600(EEPROM没有保存数据的时候,波特率为9600.)
	  		Ublox_Cfg_Prt(38400);			//重新设置模块的波特率为38400
			USART2_Init(38400);				//初始化串口2波特率为38400 
			Ublox_Cfg_Tp(1000000,100000,1);	//设置PPS为1秒钟输出1次,脉冲宽度为100ms	    
			key=Ublox_Cfg_Cfg_Save();		//保存配置  
		}	  					 
	   	LCD_ShowString(30,120,200,16,16,"NEO-6M Set Done!!");
		delay_ms(500);
		LCD_Fill(30,120,30+200,120+16,WHITE);//清除显示 
	}
	while(1) 
	{		
		delay_ms(1);
		if(USART2_RX_STA&0X8000)		//接收到一次数据了
		{
			rxlen=USART2_RX_STA&0X7FFF;	//得到数据长度
			for(i=0;i<rxlen;i++)USART1_TX_BUF[i]=USART2_RX_BUF[i];	   
 			USART2_RX_STA=0;		   	//启动下一次接收
			USART1_TX_BUF[i]=0;			//自动添加结束符
			GPS_Analysis(&gpsx,(u8*)USART1_TX_BUF);//分析字符串
			Gps_Msg_Show();				//显示信息	
			if(upload)printf("\r\n%s\r\n",USART1_TX_BUF);//发送接收到的数据到串口1
 		}
		key=KEY_Scan(0);
		if(key==KEY0_PRES)
		{
			upload=!upload;
			POINT_COLOR=RED;
			if(upload)LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:ON ");
			else LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:OFF");
 		}
		if((lenx%500)==0)LED0=!LED0; 	    				 
		lenx++;	
	}											    
}	
Example #25
0
int read_lc(struct picture *pict){
  int i,j,zx,zy;
 
  pict->xres=X_RES*zoom;
  pict->yres=Y_RES*zoom;
  pict->bps=1;
  pict->gray=gray;
  pict->buffer=malloc(X_RES*Y_RES*((gray)?1:3)*zoom*zoom);
  unsigned char *lbuf=pict->buffer;

  LCD_Init();

    for(i=0; i<Y_RES; i++)
    {
    	  for(zx=0; zx<zoom; zx++)
  	  {
	  	for(j=0; j<X_RES; j++)
  		{
			if(raw[j][i])
			{	
			  	for(zy=0; zy<zoom; zy++)
			  	{
					if(gray)
					{
			  			*(lbuf++)=0xFF;
					}
					else
					{
			  			*(lbuf++)=pixcolor.red;
						*(lbuf++)=pixcolor.green;
	  					*(lbuf++)=pixcolor.blue;
					}
  				}
  			}
  			else
  			{
  				lbuf+=((gray)?1:3)*zoom;
  			}
  		}
  	}
  }

  LCD_Close();

  pict->colormap=(struct fb_cmap*)malloc(sizeof(struct fb_cmap));
  pict->colormap->red=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps));
  pict->colormap->green=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps));
  pict->colormap->blue=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps));
  pict->colormap->transp=(__u16*)malloc(sizeof(__u16)*(1<<pict->bps));
  pict->colormap->start=0;
  pict->colormap->len=1<<pict->bps;
  pict->colormap->red[1]=0xFF<<8; 
  pict->colormap->green[1]=0xFF<<8; 
  pict->colormap->blue[1]=0xFF<<8; 
  pict->colormap->transp[0]=0xFF<<8; 
  
  return 0;
}
Example #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_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	LCD_Init(2, 20);
	LCD_PrintString(0, 0, "Damogran Labs");
	
	Encoder_Init(&encoder1, ENC1_A_GPIO_Port, ENC1_A_Pin, ENC1_B_GPIO_Port, ENC1_B_Pin);
	Encoder_Init(&encoder2, ENC2_A_GPIO_Port, ENC2_A_Pin, ENC2_B_GPIO_Port, ENC2_B_Pin);
		
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	LCD_PrintNumber(1, 0, encoder1.abs_rot);
	LCD_PrintNumber(1, 6, encoder2.abs_rot);
	
  while (1)
  {
		if(Encoder_GetState(&encoder1)){
			LCD_PrintString(1, 0, "     ");
			LCD_PrintNumber(1, 0, encoder1.abs_rot);
		}	
		if(Encoder_GetState(&encoder2)){
			LCD_PrintString(1, 6, "     ");
			LCD_PrintNumber(1, 6, encoder2.abs_rot);
		}	
		
		if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET){
			Encoder_SetAbsToZero(&encoder1);
			Encoder_SetAbsToZero(&encoder2);
		}
		
		HAL_Delay(100);
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Example #27
0
 int main(void)
 {
	u8 key;
	u16 i=0;
	u8 datatemp[SIZE];
 	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
 	uart_init(9600);
 	LED_Init();
 	KEY_Init();
	LCD_Init();
	AT24CXX_Init();		//IIC初始化 
	POINT_COLOR=RED;//设置字体为蓝色	   
	LCD_ShowString(60,50,"Mini STM32");	
	LCD_ShowString(60,70,"IIC TEST");	
	LCD_ShowString(60,90,"ATOM@ALIENTEK");
	LCD_ShowString(60,110,"2011/1/1");			 
	while(AT24CXX_Check())//检测不到24c02
	{
		LCD_ShowString(60,130,"24C02 Check Failed!");
		delay_ms(500);
		LCD_ShowString(60,130,"Please Check!      ");
		delay_ms(500);
		LED0=!LED0;//DS0闪烁
	}
	LCD_ShowString(60,130,"24C02 Ready!");
	//显示提示信息
	LCD_ShowString(60,150,"KEY0:Write KEY2(WK_UP):Read");

	POINT_COLOR=BLUE;//设置字体为蓝色	  
	while(1)
	{
		key=KEY_Scan();
		if(key==1)//KEY0按下,写入24C02
		{
			LCD_Fill(0,170,239,319,WHITE);//清除半屏    
 			LCD_ShowString(60,170,"Start Write 24C02....");
			AT24CXX_Write(0,(u8*)TEXT_Buffer,SIZE);
			LCD_ShowString(60,170,"24C02 Write Finished!");//提示传送完成
		}
		if(key==3)//KEY_UP按下,读取字符串并显示
		{
 			LCD_ShowString(60,170,"Start Read 24C02.... ");
			AT24CXX_Read(0,datatemp,SIZE);
			LCD_ShowString(60,170,"The Data Readed Is:  ");//提示传送完成
			LCD_ShowString(60,190,datatemp);//显示读到的字符串
		}
		i++;
		delay_ms(10);
		if(i==20)
		{
			LED0=!LED0;//提示系统正在运行	
			i=0;
		}		   
	}
 }
Example #28
0
int main(void)
{
//	unsigned long x, a, b, c, d;
//	char cool[5];
	//int i = 0;
	SysTick_Init();
	ADC_Init(1);
	PORTG_Init(1);
	PORTD_Init();
	PORTA_Init();
	PORTF_Init();
	PORTB_Init();
	PORTE_Init(1);
	PORTH_Init();
	
	LCD_Init();
	Touch_Init();
	Camera_Init();
/*	while(1)
	{
	x = ADC_In();
	a = x/1000;
	x -= a * 1000;
	b = x/100;
	x -= b * 100;
	c = x/10;
	x -= c * 10;
	d = x;

	cool[0] = (char)(a + 48);
	cool[1] = (char)(b + 48);
	cool[2] = (char)(c + 48);
	cool[3] = (char)(d + 48);
	cool[4] = 0;
	
	TFT_Fill(purple);
	TFT_Text(&cool[0], 50, 50, 16, black, purple);
	}
	*/
	
	while(1)
	{
		GPIO_PORTG_DATA_R ^= 0x04;
		if(ADC_In() != 1023)
		{
			TFT_Fill(yellow);
		} else {
			TFT_Fill(purple);
		}
	}
	
	//TFT_H_Line(50,150,50,black);
	
	
	
//	return 1;
}
Example #29
0
void lcd_display_init(void)
{
  
  LCD_Init();			// Init Display
  SetBacklight(1);	// Turn Backlight on 
  View = 0;


}
Example #30
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */  
  
  /* Initialize the LCD */
  LCD_Init(); 
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
   
  /* Displays MESSAGE1 on line 0 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);

  /* RTC configuration */
  RTC_Config();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Red);
  
  /* Displays a rectangle on the LCD */
  LCD_DrawRect(80, 290, 25, 240 );
  
  /* Configure the external interrupt "KEY", "WAKEUP" and "TAMPER" buttons */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI);  
     
  /* Configure RTC alarm A register to generate 8 interrupts per 1 Second */
  RTC_AlarmConfig();
  
  /* set LCD Font */
  LCD_SetFont(&Font12x12);

  /* Set the LCD Back Color */
  LCD_SetBackColor(White); 

  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);

  /* Displays MESSAGE2 and MESSAGE3 on the LCD */
  LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2);  
  LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3);  

  /* Infinite loop */
  while (1)
  {}
}