예제 #1
0
void LCDInit(void)
{
    LCD_CS_TRIS = 0; // set chip select to output
    LCD_CS = 1;  // unselect LCD 
        
    LCD_RST_TRIS = 0;  // Set LCD Reset to output
    LCD_RST = 1;   // 
        
    delay();delay(); delay();  
        
    SpiInit(); 
    PortASpiInit(); 
    PortBSpiInit();
         
    WritePortA(0,0);    
    delay();  
    
    LCDConfigWrite(0x3C); 
    delay(); 
      
    LCDConfigWrite(0x0C); //Display off 
    delay();
        
    LCDConfigWrite(0x01); //Display Clear
    delay();
          
    LCDConfigWrite(0x06); //Entry Mode 
} 
예제 #2
0
/******************************************************************************
 * Function:        void LCDUpdate(void)
 *
 * PreCondition:    LCDInit() must have been called once
 *
 * Input:           LCDText[]
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Copies the contents of the local LCDText[] array into the 
 *                  LCD's internal display buffer.  Null terminators in 
 *                  LCDText[] terminate the current line, so strings may be 
 *                  printed directly to LCDText[].
 *
 * Note:            None
 *****************************************************************************/
 void LCDUpdate(void)
 {
    BYTE i, j;

    // Go home
    LCDConfigWrite(0x02);
    
    //DelayMs(2);
    
    // Output first line
    //while(i< 16)  
    for(i = 0; i < 16u; i++)
    {
        // Erase the rest of the line if a null char is 
        // encountered (good for printing strings directly)
        if(LCDText[i] == 0u)
        {
            for(j=i; j < 16u; j++)
            {
                LCDText[j] = ' ';
            }
        }
        //if (SPIQueuecount == 0)
        //{ 
            LCDDataWrite(LCDText[i]);
            //i++; 
            //if (i == 16)
            //{
                //i=0; 
            //}    
        //}
        //else 
            //break;     
//      Delay10us(5);
    }
    
    // Set the address to the second line
    LCDConfigWrite(0xC0);
//  Delay10us(5);
//
    // Output second line
    for(i = 16; i < 32u; i++)
    {
        // Erase the rest of the line if a null char is 
        // encountered (good for printing strings directly)
        if(LCDText[i] == 0u)
        {
            for(j=i; j < 32u; j++)
            {
                LCDText[j] = ' ';
            }
        }
        LCDDataWrite(LCDText[i]);
//      Delay10us(5);
    }
    //SpiTxService(); 
 }
예제 #3
0
void ReturnHome(void)
{
    LCDConfigWrite(0x02); 
}   
예제 #4
0
void LCDErase(void)
{
    LCDConfigWrite(0x01);
    // Clear local copy
    memset(LCDText, ' ', 32); 
}  
예제 #5
0
void LcdLine_1(void)
{
    LCDConfigWrite(0xC0); 
}    
예제 #6
0
static int set_custom_nv_settings(const struct menu_opt *menu)
{
	int ret = 0;
	nv_lcd_config_t lcd_config;
	nv_lcd_config_data_t *lcd_config_data;
	uint8_t config_index;
	uint32_t temp;
	char ch;

	ret = LCDConfigRead(&lcd_config);
	switch ( ret )
	{
		/* OK */
		case 0:
			break;

		/* LCD configuration read error, try to create it */
		case 1:
			printf("\n***No valid LCD configuration found!\n");

			break;

		/* LCD config has an invalid size, resize it */
		case 2:
			do {
				printf("\n***Invalid LCD configuration! It is necessary to recreate " \
				"the configuration.\nIf you continue, you will lose your existing settings.\n");
				printf("Do you want to continue (y/n)? ");

				ch = read_opt();
				printf("%c\n", ch);
				if ( (ch == USER_CANCEL) || (ch == 'n') ) {
					goto error;
				}

			} while ( ch != 'y' );

			break;

		default:
			goto error;
	}

	if ( ret > 0 ) {
		printf("\nCreating LCD configuration... ");
		LCDConfigAdd();

		/* Try again to read config */
		if ( LCDConfigRead(&lcd_config) > 0 ) {
			printf("*** Couldn't read LCD configuration from NVRAM\n");
			goto error;
		}
		printf("OK\n\n");
	}

	if ( lcd_config.header.version < NV_LCD_CONFIG_VERSION ) {
		printf("\n*** Invalid LCD configuration version (%d instead of %d).\nConfiguration is resetted!\n\n",
		       lcd_config.header.version, NV_LCD_CONFIG_VERSION);
		LCDConfigReset(&lcd_config);
	}

	if ( !strncmp(menu->param, "custom4_nv", 13) ) {
		lcd_config_data = &lcd_config.lcd2;
		config_index = 2;
	}
	else {
		lcd_config_data = &lcd_config.lcd1;
		config_index = 1;
	}

	/* Get refresh rate */
	if ( (ret = get_uint("  Refresh rate (Hz)", &lcd_config_data->video_mode.refresh, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get Xres */
	if ( (ret = get_uint("  X-resolution (pixels)", &lcd_config_data->video_mode.xres, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get Yres */
	if ( (ret = get_uint("  Y-resolution (pixels)", &lcd_config_data->video_mode.yres, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get pixel clock */
	if ( (ret = get_uint("  Pixel clock (picoseconds)", &lcd_config_data->video_mode.pixclock, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get left margin */
	if ( (ret = get_uint("  Left margin (clocks)", &lcd_config_data->video_mode.left_margin, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get right margin */
	if ( (ret = get_uint("  Right margin (clocks)", &lcd_config_data->video_mode.right_margin, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get upper margin */
	if ( (ret = get_uint("  Upper margin (lines)", &lcd_config_data->video_mode.upper_margin, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get lower margin */
	if ( (ret = get_uint("  Lower margin (lines)", &lcd_config_data->video_mode.lower_margin, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get HSync */
	if ( (ret = get_uint("  H-sync (clocks)", &lcd_config_data->video_mode.hsync_len, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get VSync */
	if ( (ret = get_uint("  V-sync (lines)", &lcd_config_data->video_mode.vsync_len, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get sync */
	if ( (ret = get_uint("  Sync", &lcd_config_data->video_mode.sync, 16, 1,
		syncHelpTable, sizeof(syncHelpTable) / sizeof(help_info_t))) != 0 ) {
		goto error;
	}

	/* Get vmode */
	if ( (ret = get_uint("  V-Mode", &lcd_config_data->video_mode.vmode, 10, 1,
		vmodeHelpTable, sizeof(vmodeHelpTable) / sizeof(help_info_t))) != 0 ) {
		goto error;
	}

	/* Get flags */
	if ( (ret = get_uint("  Flags", &lcd_config_data->video_mode.flag, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Backlight function is enabled */
	temp = lcd_config_data->is_bl_enable_func;
	if ( (ret = get_uint("  Backlight function enabled", &temp, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}
	lcd_config_data->is_bl_enable_func = (temp != 0);

	printf("\nWindows CE specific settings:\n");

	/* Get pixel data offset */
	if ( (ret = get_uint("  Pixel Data Offset", &lcd_config_data->pix_cfg.pix_data_offset, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get pixel clock up */
	if ( (ret = get_uint("  Pixel Clock Up", &lcd_config_data->pix_cfg.pix_clk_up, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	/* Get pixel clock down */
	if ( (ret = get_uint("  Pixel Clock Down", &lcd_config_data->pix_cfg.pix_clk_down, 10, 1,
		NULL, 0)) != 0 ) {
		goto error;
	}

	if ( config_index == 1 ) {
		lcd_config.header.lcd1_valid = 1;
	}
	else {
		lcd_config.header.lcd2_valid = 1;
	}

	if ( LCDConfigWrite(&lcd_config) == 0 ) {
		printf("\n***Couldn't write config into the NVRAM!\n");
		ret = 1;
		goto error;
	}

	if ( NvEnvUpdateLCDConfig() == 0 ) {
		printf("\n***Couldn't update shared memory\n");
		ret = 1;
		goto error;
	}

	return set_video_lcd(menu);

error:
	return ret;
}