聚丰项目 > 无线充电卡通闹钟
将普通的指针式卡通闹钟,改造成电子LED矩阵显示无线充电的卡通闹钟。因为矩阵式LED显示屏耗电较大需要经常充电,用普通充电器充要经常插拔电源线很麻烦,用了IDT的15W无线充电套件就不用这么麻烦了,闹钟没电了只要将它放在无线充电底座上就可以方便的充电了,随放随充相当方便,非常便利。这个闹钟还有改进的地方,后续可以将无线充电状态从I2C总线读取并显示在显示屏上,这样就可以直观的了解充电情况。(本项目采用的是IDT 15W无线充电开发套件)
expertss
分享expertss
团队成员
罗鹏 硬件工程师
硬件组成:
IDT 15W 无线充电套件
AVR单片机控制LED显示屏,后续读取15W套件接收板I2C总线数据,并显示。
TI的电源管理芯片,负责锂电池充电,电池和无线电源供电的切换。
软件部分:
开发平台:ICCAVR AVRSTUDIO
部分显示代码:
void initia_gram(unsigned char *ledgram)
{
unsigned char i;
for(i = 0;i < 64;i++)
{
*ledgram = 0xff;
ledgram++;
}
}
void refresh_timeonled(unsigned char *datedata,unsigned char *ledgram,const unsigned char *BufferPoint)
{
const unsigned char *zikubuffertemp;
unsigned char *ledgramtemp;
unsigned char i,j;
zikubuffertemp = BufferPoint;
ledgramtemp = ledgram + 4;
// 显示在第二行开始 +4
datedata += 5;
//指向小时 5 指向分钟 3
for(i = 0;i < 4;i++)
{
zikubuffertemp += *datedata * 8;
ledgramtemp += i;
for(j = 0;j < 8;j++)
{
switch(i)
{
case 0:
if(*datedata == 0)
*(ledgramtemp + j * 4) = 0xFF;
else
*(ledgramtemp + j * 4) = (*zikubuffertemp >> 1) | 0x80;
zikubuffertemp++;
break;
case 1:
if(j == 1)
*(ledgramtemp + j * 4) = *zikubuffertemp & 0xFE;
else if(j == 5)
*(ledgramtemp + j * 4) = *zikubuffertemp & 0xFE;
else
*(ledgramtemp + j * 4) = *zikubuffertemp;
zikubuffertemp++;
break;
case 2:
if(j == 1)
*(ledgramtemp + j * 4) = ((*zikubuffertemp >> 2) | 0xC0) & 0x7F;
else if(j == 5)
*(ledgramtemp + j * 4) = ((*zikubuffertemp >> 2) | 0xC0) & 0x7F;
else
*(ledgramtemp + j * 4) = (*zikubuffertemp >> 2) | 0xC0;
zikubuffertemp++;
break;
case 3:
*(ledgramtemp + j * 4) = (*zikubuffertemp >> 1) | 0x80;
zikubuffertemp++;
break;
default:
break;
}
}
--datedata;
zikubuffertemp = BufferPoint;
ledgramtemp = ledgram + 4;
}
}
//------------------------------------------------------------------------------
//
// 将显示缓冲区内的数据发送到LED点阵上 点阵32 * 16
// 输入: 指向显示缓冲区的指针
// 输出: 无
void ShowPicONLED(unsigned char *BufferPoint,unsigned char x_wide,unsigned char y_high,unsigned char x_pos,unsigned char y_pos,unsigned char roll_switch)
{
unsigned char i = 8;
unsigned int j = 0;
unsigned long cycleposition = 0x80000000;
unsigned char *BufferPointbuffer;
BufferPointbuffer = BufferPoint;
while(j < 16)
{
HC595_DataOut(0xFFFFFFFF,cycleposition);
PORTA = i;
HC595_DataOutPut(BufferPoint,cycleposition);
delayofftimeonus();
i++;
BufferPoint += 4;
if(BufferPoint == BufferPointbuffer + 64)//64
BufferPoint = BufferPointbuffer;
if(i == 16)
i = 0;//8
j++;
if(j == 16)
{
HC595_DataOut(0xFFFFFFFF,cycleposition);
//cycleposition >>= 1;
//if(cycleposition == 0)
// cycleposition = 0x80000000;
//j = 0;
}
}
}
//
// 输出32位的数据到4片74HC595上
// 输入:要输出的32位数据
// 输出:无
void HC595_DataOutPut(unsigned char *GRAMPoint,unsigned long Position)
{
unsigned long cycle = Position;
unsigned long databuffer = 0;
unsigned char i = 0,j = 0;
databuffer |= (unsigned long)*GRAMPoint;
GRAMPoint++;
databuffer <<= 8;
databuffer |= (unsigned long)*GRAMPoint;
GRAMPoint++;
databuffer <<= 8;
databuffer |= (unsigned long)*GRAMPoint;
GRAMPoint++;
databuffer <<= 8;
databuffer |= (unsigned long)*GRAMPoint;
LED_MRH;
LED_OEH;
LED_STCPL;
LED_SHCPL;
for(i = 1;i <= 32;i++)
{
if(cycle & databuffer)
LED_MOSIH;
else
LED_MOSIL;
LED_SHCPH;
cycle >>= 1;
if(cycle == 0)
cycle = 0x80000000;
LED_SHCPL;
}
LED_STCPH;
LED_OEL;
LED_STCPL;
LED_SHCPL;
}
wenhua2020: 可否提供一下原理图参考参考下呢
回复