首页 > 评测 > 【CuriosityNano测评报告】+墨水屏的显示驱动
【CuriosityNano测评报告】+墨水屏的显示驱动
- [导读]
- #申请原创# AVR64DD32 CuriosityNano是一款小巧的开发板,为这款开发板配上一款1.54寸的墨水屏是一个不错的选择。目前以PIC的产品对墨水屏的支持并不多,为此决定将它移植到AVR64DD32开发板。比较有意思的是,与常
- #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原创,未经许可禁止转载!
网友评论
- 联系人:巧克力娃娃
- 邮箱:board@21ic.com
- 我要投稿
-
欢迎入驻,开放投稿
-
人均百万?英伟达中国员工收入曝光! 2024-08-29
-
《黑神话:悟空》玩家硬盘升级攻略:提升游戏体验,畅享3A大作 2024-08-29
-
数睿数据参加《系统与软件工程 低代码开发平台通用技术要求》国家标准编制 2024-08-29
- NRF52810蓝牙数字耳机找人定制
预算:¥30005天前
- 125KW模块式PCS软硬件外包开发
预算:¥1100000015小时前
- 12V汽车启动电源项目BMS设计
预算:¥50000023小时前
- 数据可视化软件 开发
预算:¥5000023小时前
- PLC项目调试修改
预算:¥100001天前
- 起动电机控制器开发
预算:¥1100001天前