ARM裸机开发之基于S3C2451的电子相册开发

该项目的制作是用的友善之臂的Mini2451开发板。

简单先介绍一下该电子相册的主要功能即操作:

开发板上一共有4个按键,K1是进入选择界面,选择界面中K2为手动切换,K3为自动切换,在自动切换模式中K1可以暂停,手动模式下K2、K3分别为上一张和下一张。K4则是关闭相册回到主界面。

在PC端可以使用上位机进行操作,可以开启关闭相册,切换图片,同步标准时钟,设置时钟,设置闹钟、LED灯闪烁等。主要用到了时钟中断、定时器中断、串口中断等。

首先先来看一看时钟显示模块:

在显示时钟之前先得把传入的unsigned int型数转换为string,用LCD显示函数显示出来。

void u32tostr(U32 dat,char *str)    //将unsigned int转换为字符串型
{
	char temp[20];
	unsigned int i=0,j=0;
	while(dat)
	{
		temp[i]=dat%16+0x30;
		i++;
		dat/=16;
	}
	j=i;
	if(i == 1)
	{
		str[0] = 48;
		str[1] = temp[0];
		str[2] = 0;
	}
	else
	{
	for(i=0;i<j;i++)
	{
		str[i]=temp[j-i-1];
	}
	if (!i) { str[i++] = 48;str[i++] = 48;}
	str[i] = '\0';
	}
}
接下来为时钟中断中,将转换完的数显示出来:

void __irq TICK_IRQ()                   //RTC中断
{
	int i;
	char s[10];
	RTC_Time_get(&rtc_struct_init);
	LCD_clear1(0,0,16,162,0xffffff);    //局部清屏,保证显示的时钟不被覆盖
	u32tostr(rtc_struct_init.year,s);
	LCD_Display_char1(10,0,0xff,s);
	LCD_Display_char(42,0,0xff,'-');
	u32tostr(rtc_struct_init.month,s);
	LCD_Display_char1(50,0,0xff,s);
	LCD_Display_char(66,0,0xff,'-');
	u32tostr(rtc_struct_init.day,s);
	LCD_Display_char1(74,0,0xff,s);
	LCD_Display_char(90,0,0xff,' ');
	u32tostr(rtc_struct_init.hour,s);
	LCD_Display_char1(98,0,0xff,s);
	LCD_Display_char(114,0,0xff,':');
	u32tostr(rtc_struct_init.minute,s);
	LCD_Display_char1(122,0,0xff,s);
	LCD_Display_char(138,0,0xff,':');
	u32tostr(rtc_struct_init.second,s);
	LCD_Display_char1(146,0,0xff,s);
 	IRQ_CleaSRCPND(INT_TICK);
}
局部清屏的函数原型:自定义开始位置和清屏范围

void LCD_clear1(U16 x0,U16 y0,U16 m,U16 n,U32 c)   //局部清屏
{
	 U16 x,y;
   for(y=y0;y<y0+m;y++)
	{
     for(x=x0;x<x0+n;x++)
		 LCD_BUFFER[y][x]=c;
  }
}


其他功能和完整代码,可以到我的下载频道查看。
闹钟功能上位机无法实现,需要在串口发送:FE 07 F1 年 月 日 时 分 秒 EF



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值