首頁 > 評測 > 【CuriosityNano測評報告】+墨水屏的顯示驅(qū)動
【CuriosityNano測評報告】+墨水屏的顯示驅(qū)動
- [導讀]
- #申請原創(chuàng)# AVR64DD32 CuriosityNano是一款小巧的開發(fā)板,為這款開發(fā)板配上一款1.54寸的墨水屏是一個不錯的選擇。目前以PIC的產(chǎn)品對墨水屏的支持并不多,為此決定將它移植到AVR64DD32開發(fā)板。比較有意思的是,與常
- #define EPD_CLK_init() do { PORTD.OUTSET = PIN7_bm; PORTD.DIRSET = PIN7_bm; } while (0)
- #define EPD_MOSI_init() do { PORTD.OUTSET = PIN6_bm; PORTD.DIRSET = PIN6_bm; } while (0)
- #define EPD_RST_init() do { PORTD.OUTSET = PIN3_bm; PORTD.DIRSET = PIN3_bm; } while (0)
- #define EPD_DC_init() do { PORTD.OUTSET = PIN2_bm; PORTD.DIRSET = PIN2_bm; } while (0)
- #define EPD_CS_init() do { PORTD.OUTSET = PIN1_bm; PORTD.DIRSET = PIN1_bm; } while (0)
- #define GetValue() (VPORTF.IN & (0x1 << 4))
- #define SetPullUp() do { PORTF_PIN4CTRL |= PORT_PULLUPEN_bm; } while(0)
- #define SetDigitalInput() do { PORTF_DIRCLR = 0x10; } while(0)
- #define EPD_CLK_0 do { PORTD.OUTCLR = PIN7_bm; } while (0) //CLK
- #define EPD_CLK_1 do { PORTD.OUTSET = PIN7_bm; } while (0)
- #define EPD_MOSI_0 do { PORTD.OUTCLR = PIN6_bm; } while (0) //DIN
- #define EPD_MOSI_1 do { PORTD.OUTSET = PIN6_bm; } while (0)
- #define EPD_RST_0 do { PORTD.OUTCLR = PIN3_bm; } while (0) //RST
- #define EPD_RST_1 do { PORTD.OUTSET = PIN3_bm; } while (0)
- #define EPD_DC_0 do { PORTD.OUTCLR = PIN2_bm; } while (0) //DC
- #define EPD_DC_1 do { PORTD.OUTSET = PIN2_bm; } while (0)
- #define EPD_CS_0 do { PORTD.OUTCLR = PIN1_bm; } while (0) //C S
- #define EPD_CS_1 do { PORTD.OUTSET = PIN1_bm; } while (0)
- void EPD_1IN54_Reset(void)
- {
- EPD_RST_1;
- DEV_Delay_ms(200);
- EPD_RST_0;
- DEV_Delay_ms(20);
- EPD_RST_1;
- DEV_Delay_ms(200);
- }
- void EPD_1IN54_ReadBusy(void)
- {
- while(GetValue()==1) {
- DEV_Delay_ms(100);
- }
- }
- int DEV_Module_Init(void)
- {
- EPD_DC_0;
- EPD_CS_0;
- EPD_RST_1;
- return 0;
- }
- void DEV_Module_Exit(void)
- {
- EPD_DC_0;
- EPD_CS_0;
- EPD_RST_0;
- }
- void DEV_SPI_WriteByte(unsigned char value)
- {
- u8 i;
- for(i=0; i<8;i++)
- {
- EPD_CLK_0;
- if(value & 0x80)
- EPD_MOSI_1;
- else
- EPD_MOSI_0;
- EPD_CLK_1;
- value = (value << 1);
- }
- EPD_CLK_0;
- }
- void EPD_1IN54_SendCommand(u8 Reg)
- {
- EPD_DC_0;
- EPD_CS_0;
- DEV_SPI_WriteByte(Reg);
- EPD_CS_1;
- delay_us(4);
- }
- void EPD_1IN54_SendData(u8 Data)
- {
- EPD_DC_1;
- EPD_CS_0;
- DEV_SPI_WriteByte(Data);
- EPD_CS_1;
- delay_us(4);
- }
- void EPD_1IN54_Init(u8 Mode)
- {
- u16 i;
- EPD_1IN54_Reset();
- EPD_1IN54_SendCommand(0x01);
- EPD_1IN54_SendData((EPD_1IN54_HEIGHT - 1) & 0xFF);
- EPD_1IN54_SendData(((EPD_1IN54_HEIGHT - 1) >> 8) & 0xFF);
- EPD_1IN54_SendData(0x00);
- EPD_1IN54_SendCommand(0x0C);
- EPD_1IN54_SendData(0xD7);
- EPD_1IN54_SendData(0xD6);
- EPD_1IN54_SendData(0x9D);
- EPD_1IN54_SendCommand(0x2C);
- EPD_1IN54_SendData(0xA8);
- EPD_1IN54_SendCommand(0x3A);
- EPD_1IN54_SendData(0x1A);
- EPD_1IN54_SendCommand(0x3B);
- EPD_1IN54_SendData(0x08);
- EPD_1IN54_SendCommand(0x11);
- EPD_1IN54_SendData(0x03);
- EPD_1IN54_SendCommand(0x32);
- if(Mode == EPD_1IN54_FULL){
- for ( i = 0; i < 30; i++) {
- EPD_1IN54_SendData(EPD_1IN54_lut_full_update[i]);
- }
- }else if(Mode == EPD_1IN54_PART){
- for ( i = 0; i < 30; i++) {
- EPD_1IN54_SendData(EPD_1IN54_lut_partial_update[i]);
- }
- }else{
-
- }
- }
- void EPD_1IN54_TurnOnDisplay(void)
- {
- EPD_1IN54_SendCommand(0x22);
- EPD_1IN54_SendData(0xC4);
- EPD_1IN54_SendCommand(0x20);
- EPD_1IN54_SendCommand(0xFF);
- EPD_1IN54_ReadBusy();
- }
- void EPD_1IN54_Clear(void)
- {
- u16 Width, Height,i,j;
- Width = (EPD_1IN54_WIDTH%8== 0)? (EPD_1IN54_WIDTH/8):(EPD_1IN54_WIDTH/8+1);
- Height = EPD_1IN54_HEIGHT;
- EPD_1IN54_SetWindow(0, 0, EPD_1IN54_WIDTH, EPD_1IN54_HEIGHT);
- for (j = 0; j < Height; j++) {
- EPD_1IN54_SetCursor(0, j);
- EPD_1IN54_SendCommand(0x24);
- for (i = 0; i < Width; i++) {
- EPD_1IN54_SendData(0XFE);
- }
- }
- EPD_1IN54_TurnOnDisplay();
- }
- void Paint_SelectImage(u8 *image)
- {
- Paint.Image = image;
- }
- void Paint_DrawBitMap(const unsigned char* image_buffer)
- {
- unsigned short int x, y;
- u32 Addr = 0;
- for (y = 0; y < Paint.HeightByte; y++) {
- for (x = 0; x < Paint.WidthByte; x++) {
- Addr = x + y * Paint.WidthByte;
- Paint.Image[Addr] = (unsigned char)image_buffer[Addr];
- }
- }
- }
- u8 BlackImage[5000];
- int main(void) {
- EPD_CLK_init();
- EPD_MOSI_init();
- EPD_RST_init();
- EPD_DC_init();
- EPD_CS_init();
- SetDigitalInput();
- SetPullUp();
- DEV_Module_Init();
- EPD_1IN54_Init(EPD_1IN54_FULL);
- //EPD_1IN54_Clear();
- Paint_NewImage(BlackImage, EPD_1IN54_WIDTH, EPD_1IN54_HEIGHT, 270, WHITE);
- Paint_SelectImage(BlackImage);
- Paint_DrawBitMap(gImage_1in54);
- EPD_1IN54_Display(BlackImage);
- DEV_Delay_ms(2000);
- EPD_1IN54_Sleep();
- DEV_Delay_ms(2000);
- while(1);
- }
- int main(void) {
- EPD_CLK_init();
- EPD_MOSI_init();
- EPD_RST_init();
- EPD_DC_init();
- EPD_CS_init();
- SetDigitalInput();
- SetPullUp();
- DEV_Module_Init();
- EPD_1IN54_Init(EPD_1IN54_FULL);
- Paint_NewImage(BlackImage, EPD_1IN54_WIDTH, EPD_1IN54_HEIGHT, 270, WHITE);
- Paint_SelectImage(BlackImage);
- Paint_DrawBitMap(gImage_1in54);
- Paint_Clear(WHITE);
- Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
- Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
- Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
- Paint_DrawPoint(5, 55, WHITE, DOT_PIXEL_4X4, DOT_STYLE_DFT);
-
- Paint_DrawLine(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
- Paint_DrawLine(70, 10, 20, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
- Paint_DrawLine(170, 15, 170, 55, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
- Paint_DrawLine(150, 35, 190, 35, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
-
- Paint_DrawRectangle(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
- Paint_DrawRectangle(85, 10, 130, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
- Paint_DrawCircle(170, 35, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
- Paint_DrawCircle(170, 85, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
-
- EPD_1IN54_Display(BlackImage);
- DEV_Delay_ms(2000);
- EPD_1IN54_Sleep();
- DEV_Delay_ms(2000);
- while(1);
- }
- 本文系21ic原創(chuàng),未經(jīng)許可禁止轉(zhuǎn)載!
網(wǎng)友評論
- 聯(lián)系人:巧克力娃娃
- 郵箱:board@21ic.com
- 我要投稿
-
歡迎入駐,開放投稿
-
人均百萬?英偉達中國員工收入曝光! 2024-08-29
-
《黑神話:悟空》玩家硬盤升級攻略:提升游戲體驗,暢享3A大作 2024-08-29
-
數(shù)睿數(shù)據(jù)參加《系統(tǒng)與軟件工程 低代碼開發(fā)平臺通用技術(shù)要求》國家標準編制 2024-08-29
- NRF52810藍牙數(shù)字耳機找人定制
預算:¥30005天前
- 125KW模塊式PCS軟硬件外包開發(fā)
預算:¥1100000015小時前
- 12V汽車啟動電源項目BMS設(shè)計
預算:¥50000023小時前
- 數(shù)據(jù)可視化軟件 開發(fā)
預算:¥5000023小時前
- PLC項目調(diào)試修改
預算:¥100001天前
- 起動電機控制器開發(fā)
預算:¥1100001天前