第一步,配置内核参数
Graphicssupport --->
<*>Support for frame buffer devices --->
<*> Samsung S3C framebuffer support
[*]Backlight & LCD device support --->
<*> Lowlevel LCD controls
<*> Samsung LTV350QV LCD Panel
<*> Platform LCD controls
<*> Lowlevel Backlight controls
<*> Generic (aka Sharp Corgi) Backlight Driver
<*> Generic PWM based Backlight Driver
Consoledisplay driver support --->
<*>Framebuffer Console support
第二步,配置资源
1.在板级配置文件中添加以下代码,如果问为什么要添加,答案其实很简单,看驱动,看驱动就会发现以下的参数是需要用户根据具体电路在板级配置文件中自己设置的。 //整个LCD移植最主要要修改的地方主要集中在下面这个结构体, static struct s3c_fb_pd_win smdk6410_fb_win0 = { /* this is to ensure we use win0 */ .win_mode = { .left_margin = 0x03, //从sync信号到显示真正的像素的时钟个数 .right_margin = 0x02, //从真正显示像素到sync信号的时钟个数 .upper_margin = 0x01, .lower_margin = 0x01, .hsync_len = 0x28, //水平sync信号的长度 .vsync_len = 0x01, //垂直sync信号的长度 .xres = 480, //xres,yres决定屏幕可见分辨率 .yres = 272, }, .max_bpp = 32, //最大bpp,bpp 即Bits Per Pixel,就是一个像素点的比特数,一个像素所能表达的颜色//数取决BPP,换句话说bpp越大,色彩度越好 .default_bpp = 16, //默认bpp .virtual_y = 480 * 2, //虚拟屏幕分辨率 .virtual_x = 272, }; static struct s3c_fb_platdata smdk6410_lcd_pdata __initdata = { .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, .win[0] = &smdk6410_fb_win0, //这两个值会在驱动中被用来配置寄存器VIDCON0及VIDCON1,这里是配置为RGB输出模式,配置水平sync脉冲及垂直sync脉冲极性为反向 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, }; 2.添加平台设备 static struct platform_device *smdk6410_devices[] __initdata = { &s3c_device_fb, } 3.在map_io函数中添加以下代码初始化LCD /* set the LCD type */ tmp = __raw_readl(S3C64XX_SPCON); tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK; tmp |= S3C64XX_SPCON_LCD_SEL_RGB; __raw_writel(tmp, S3C64XX_SPCON); /* remove the lcd bypass */ tmp = __raw_readl(S3C64XX_MODEM_MIFPCON); tmp &= ~MIFPCON_LCD_BYPASS; __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
第三步,注册设备
调用s3c_fb_set_platdata(&smdk6410_lcd_pdata);添加LCD私有数据
调用platform_add_devices(smdk6410_devices,ARRAY_SIZE(smdk6410_devices));注册平台设备
第四步,测试
编译下载,重启,在/dev目录下就可以看到LCD设备fb,表明设备启动正常,这时候屏幕可能是花屏,如何看下效果呢,
(1)执行以下命令清屏
dd if=/dev/zero of=/dev/fb0 bs=240count=320
(2)让屏幕显示一张图片(xxee.bmp是图片名称)
cat xxee.bmp >/dev/fb0
移植错误集合:
编译中出现以下错误
drivers/built-in.o:(.data+0x450): undefinedreference to `soft_cursor'
错误原因:配置内核时,没有添加以下选项
<*> Framebuffer Console support
1.获取用户头像。facebook的只要知道用户的ID或name就可以获取了。一般是获取最大的然后resize成需要的。地址如下:
?
http://graph.facebook.com/randy.ran.12327/picture?type=large
//or
http://graph.facebook.com/100000396765290/picture?type=large
2.获取好友列表及查看好友是否已经使用了此的APP,请求地址:
?
https://graph.facebook.com/me/friends?fields=id,name,installed&limit=5000&offset=0
3.API方式分享:
public static BoolMessage Share(string token, string name, string link, string caption, string description, string source, string message)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("name", name);
dic.Add("link", link);
dic.Add("caption", caption);
dic.Add("description", description);
dic.Add("source", source);
dic.Add("privacy", "{\"value\": \"EVERYONE\"}");
dic.Add("message", message);
dic.Add("access_token",token);
string url = "https://graph.facebook.com/me/feed";
return HttpHelper.WebRequest(HttpHelper.Method.POST, url,dic);
}
程序中使用dimension中定义的尺寸大小不对的原因 (2013-02-26 09:18:26)转载▼
When you define a dimension in a resource file you include the measurement unit. If you use sp units they are scaled according to the screen density so text at 15sp should appear roughly the same size on screens of differing density. (The real screen density of the device isn't going to exactly match as Android generalises screen density into 120, 160, 240 and 320 dpi groups.)
When calling getResources().getDimension(R.dimen.textsize) it will return the size in pixels. If using sp it will scaled by the screen density,
Calling setText(float) sets the size in sp units. This is where the issue is ie you have pixels measurements on one hand and sp unit on the other to fix do this:
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.textsize));
Note you can also use
getResources().getDimensionPixelSize(R.dimen.textSize);
instead of getDimension() and it will round and convert to an non fractional value.
dimen 必须设置 px
<dimen name="listview_largetextsize">18px</dimen>
<dimen name="listview_smalltextsize">14px</dimen>