[vc_row][vc_column width=”1/1″][vc_column_text]Electronic paper, e-paper and electronic ink are display technologies which are designed to mimic the appearance of ordinary ink on paper. Unlike conventional backlit flat panel displays which emit light, electronic paper displays reflect light like ordinary paper, theoretically making it more comfortable to read, and giving the surface a wider viewing angle compared to conventional displays. The contrast ratio in available displays as of 2008 might be described as similar to that of newspaper, though newly developed displays are slightly better. An ideal e-paper display can be read in direct sunlight without the image appearing to fade.
This experiment is to show how to drive Electronic paper by pcDuino. And how to use software Image2Lcd.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Parts List” tab_id=”1389668704-1-54″][vc_column_text]
- 1 x pcDuino
- 1 x Electronic paper
- 1 x 3.3V power supply module
When electronic paper needs refreshing, it will need a high power assumption. pcDuino cannot provide the power. So we need to add a 3.3V power supply module. Pay attention, pcDuino should connect the same GND with 3.3V power supply module.[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1389668704-2-60″][vc_column_text]We use Arduino’s 3.3V to supply the power for electronic paper shield, the circuit diagram is as follows:
[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1389671498729-2-4″][vc_column_text]
#include ”core.h”//pcDuino contains Core header file #include ”ls.h”//Containing images to be displayed #define STATUS_PIN 9//Define electronic paper 's state pin #define CS_PIN 10//Define electronic paper 's chip select pin #define MISO_PIN 11//Master input and slave output pin #define MOSI_PIN 12//Master output and slave input pin #define SCK_PIN 13//Defined clock pin #define FRAME_END_LEN 11//Define the refresh frequency (I used 11, it's free to modify) unsigned char SoftSpiTransfer(unsigned char data)//Simulating SPI timing { unsigned char cnt; unsigned char rst; rst = 0; for(cnt = 0;cnt < 8 ;cnt ++) { rst <<= 1; if(data & 0×80) digitalWrite(MOSI_PIN,HIGH); else digitalWrite(MOSI_PIN,LOW); digitalWrite(SCK_PIN,HIGH); digitalWrite(SCK_PIN,LOW); rst |= digitalRead(MISO_PIN); data <<= 1; } return rst; } void ClearScring(void)//Clear function { bool DeviceStatus;//Defined a quantity of state DeviceStatus = digitalRead(STATUS_PIN); digitalWrite(CS_PIN,LOW); SoftSpiTransfer(3); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”);//Embedded a delay assembler instruction, the same below } digitalWrite(CS_PIN,HIGH); } void SetImageWide(unsigned int wide)//Image width setting function { bool DeviceStatus; DeviceStatus = digitalRead(STATUS_PIN); digitalWrite(CS_PIN,LOW); SoftSpiTransfer(1); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } DeviceStatus = !DeviceStatus; SoftSpiTransfer(wide >> 8); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } DeviceStatus = !DeviceStatus; SoftSpiTransfer(wide & 0xff); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } digitalWrite(CS_PIN,HIGH); } void SetImageHigh(unsigned int high)//Image Height setting function { bool DeviceStatus; DeviceStatus = digitalRead(STATUS_PIN); digitalWrite(CS_PIN,LOW); SoftSpiTransfer(2); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } DeviceStatus = !DeviceStatus; SoftSpiTransfer(high >> 8); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } DeviceStatus = !DeviceStatus; SoftSpiTransfer(high & 0xff); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } digitalWrite(CS_PIN,HIGH); } void SendImage(const unsigned char * pic)//Function of displays pictures { bool DeviceStatus; unsigned char data; unsigned char cnt0; unsigned int cnt1; unsigned long time; DeviceStatus = digitalRead(STATUS_PIN); digitalWrite(CS_PIN,LOW); SoftSpiTransfer(4); while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); } DeviceStatus = !DeviceStatus; for(cnt0 = 0;cnt0 < FRAME_END_LEN; cnt0 ++) { Serial.println(“New Line”); for(cnt1 = 0; cnt1 < 120000; cnt1 ++) { data = gImage[cnt1]; SoftSpiTransfer(data); time = 0; while(digitalRead(STATUS_PIN) == DeviceStatus) { asm(“nop”); time ++; if(time > 1000000) { Serial.println(“Error”);//When timeout serial prompt an error digitalWrite(CS_PIN,HIGH); return; } } DeviceStatus = !DeviceStatus; } } digitalWrite(CS_PIN,HIGH); } void setup() { Serial.begin(9600); pinMode(STATUS_PIN, INPUT); pinMode(CS_PIN, OUTPUT); pinMode(MOSI_PIN, OUTPUT); pinMode(MISO_PIN, INPUT); pinMode(SCK_PIN, OUTPUT); digitalWrite(CS_PIN,HIGH); digitalWrite(STATUS_PIN,HIGH); digitalWrite(SCK_PIN,LOW); } void loop() { char cmd; if(Serial.available())//If serial port received a data { cmd = Serial.parseInt(); switch(cmd) { case 1: SetImageWide(600); Serial.println(“Set Image Wide Complete !”); break; case 2: SetImageHigh(800); Serial.println(“Set Image High Complete !”); break; case 3: Serial.println(“Start Clear Scring !”); ClearScring(); Serial.println(“Clear Scring Complete !”); break; case 4: Serial.println(“Start Send Image Data!”); SendImage(gImage); Serial.println(“Send Image Data Complete !”); break; default: Serial.println(“Unknow instruction !”); break; } } }
[/vc_column_text][/vc_tab][vc_tab title=”User Manual of Software” tab_id=”1389676995754-3-5″][vc_column_text]There are many tools can translate image into binary. We will introduce you how to use Image2Lcd under Windows simply.
Step 1 Clink “Open”, choose “Image”
Step 2 Clink “output data type TAB”, choose “C language array”, save the image as a header file ls.h for output ls.h
Step 3 Clink”Scan mode”, choose horizontal scan. The electronic paper’s scan mode is from top to bottom and left to right, like the picture shows
Step 4 Click the “Output gray” tab, select four gray, which is due to the used electronic paper’s display mode is four gray
Step 5 Input maximum width: 800, maximum high: 600, and clink the triangle on right, save as default
Step 6 Choose “Scan from right to left”
Step 7 Clink “Save”, input ***.h to save.(***is your file name, it should be the same as in the code, mine is ls.h)
Due to the larger data show on 800 * 600, pcDuino display refresh for a long time, so you need to wait patiently[/vc_column_text][/vc_tab][vc_tab title=”Summary” tab_id=”1389678660459-4-10″][vc_column_text]The display mode is 4 gray which we used in this experiment, so each pixel using two binary number. The resolution of the screen is 800*600, so the effective data is 800 * 600/4 = 120000, the ls.h file has 120000 bytes.
You can modify the corresponding parameters and header files in code to display other image.
The serial port(Baud rate 9600) send ASCII 1, 2, 3, 4 to control electronic paper’s display. First you need to set the display width and height to 800 * 600 (instruction 1 and 2), and then clear the screen (command 3), and finally send image data (instruction 4)[/vc_column_text][/vc_tab][vc_tab title=”Appendix” tab_id=”1389679758185-5-9″][vc_column_text]1. Ls.h header file, the file is pcDuino’s logo.
2. Archlinux pcDuino logo
Leave a Reply
You must be logged in to post a comment.