聚豐項目 > 無線充電卡通鬧鐘
將普通的指針式卡通鬧鐘,改造成電子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: 可否提供一下原理圖參考參考下呢
回復