1 //VGA writer to write eeproms in vga displays
2 //Apr 2011 Kieran Levin kiram9@yahoo.com
3 //If you want to modify some data scroll down and modify the bytes in command 'c'
4 //Then load from display - change custom bytes, generate checksum, write to save values back(r,c,g,w)
5 //See also http://en.wikipedia.org/wiki/Extended_display_identification_data
9 l=load binary from serial(gets 128 bytes of binary data from serial then returns)
11 d=displaybuffer(binary)
15 c=change custom bytes (compiled in)
25 #include <SoftwareWire.h>
26 extern SoftwareWire Wire; // defined in RTC
34 int inByte = 0; // incoming serial byte
40 Wire.setClock(100000L); // 100000-400000
41 Wire.begin(); // join i2c bus (address optional for master)
42 // Serial.begin(115200); // start serial for output
44 //write to vclk pin on pin 2
45 pinMode(LED2, OUTPUT);
46 pinMode(LED18, OUTPUT);
48 //This puts i2c eeproms that are also clocked off the vsync into R/W mode
49 digitalWrite(LED18, HIGH); // set the LED off
50 for(i = 0; i < 20; i++){
51 digitalWrite(LED2, HIGH); // set the LED on
52 delay(10); // wait for a second
53 digitalWrite(LED2, LOW); // set the LED off
56 digitalWrite(LED2, HIGH); // set the LED on
58 digitalWrite(LED18, LOW); // set the LED off
60 digitalWrite(LED2, LOW); // set the LED on
62 for(i = 0; i < 10; i++){
63 digitalWrite(LED2, HIGH); // set the LED on
64 delay(10); // wait for a second
65 digitalWrite(LED2, LOW); // set the LED off
68 //disable writing to eeprom
69 digitalWrite(LED2, LOW); // set the LED off
70 Serial.println("EDID Reader Writer C 2011 Kieran Levin kiram9@yahoo.com");
73 int edidreadbytes(char * array)
76 Wire.beginTransmission(B1010000);
77 Wire.write(byte(mycount));
78 Wire.endTransmission();
79 for(int j = 0; j < 128; j++){
80 Wire.requestFrom(B1010000, 1);
81 if (Wire.available()) // slave may send less than requested
83 array[j] = Wire.read(); // receive a byte as character
90 int edidwritebytes(char * array){
92 digitalWrite(LED2, HIGH); // set the LED off
94 for(byte j =0; j < 128;j++){
95 Wire.beginTransmission(B1010000);
98 Wire.write(byte(array[j]));
99 Wire.endTransmission();
103 digitalWrite(LED2, LOW); // set the LED off
106 void printDetailedinfo(){
107 Serial.println("Detailed Information:");
108 Serial.print("\tManufacture ID \t");
109 Serial.println(*((uint16_t *)(edidarray+8)));
110 Serial.print("\tProduct ID code \t");
111 Serial.println(*((uint16_t *)(edidarray+10)));
112 Serial.print("\tSerial Number \t");
113 Serial.println(*((uint32_t *)(edidarray+12)));
114 Serial.print("\tWeek of Manufacture \t");
115 Serial.println(edidarray[16]);
116 Serial.print("\tYear of manufacture \t");
117 Serial.println(edidarray[17] + 1990);
118 Serial.print("\tEdid Version\t");
119 Serial.println(edidarray[18]);
120 Serial.print("\tEdid Revision \t");
121 Serial.println(edidarray[19]);
122 Serial.print("\tEstablished Timing 1 \t");
123 Serial.println(0x00FF & edidarray[35],BIN);
124 Serial.print("\tEstablished Timing 2 \t");
125 Serial.println(0x00FF & edidarray[36],BIN);
126 for(int i = 38; i < 53; i +=2){
127 Serial.print("Standard Timing ID \t");
129 Serial.print("\tHoriz Res \t");
130 Serial.println(248+8*(0x00FF & edidarray[i]));
131 Serial.print("\tAspect Ratio \t");
132 switch(B11000000 & edidarray[i+1]){
134 if (edidarray[19] < 3)
135 Serial.println("1:1");
137 Serial.println("16:10");
140 Serial.println("4:3");
143 Serial.println("5:4");
146 Serial.println("16:9");
149 Serial.print("\tVertical Freq \t");
150 Serial.println(60+(B00111111 & edidarray[i+1]));
153 byte edidchecksum(char * array){
155 for (int i = 0; i < 128; i++){
156 checksum += array[i];
160 void checkchecksum(){
162 for (int i = 0; i < 128; i++){
163 checksum += edidarray[i];
165 Serial.print("\tChecksum (should = 0) \t");
166 Serial.println(checksum,HEX);
169 void generatechecksum(){
170 Serial.println("Generating Checksum");
172 for (int i = 0; i < 127; i++){
173 checksum += edidarray[i];
175 edidarray[127] = 256 - checksum;
182 if (Serial.available() > 0) {
183 // get incoming byte:
184 inByte = Serial.read();
189 Serial.println("EEPROM:");
190 count = edidreadbytes(edidarray);
191 for (i = 0; i < count; i++){
192 Serial.print(edidarray[i],HEX);
197 Serial.print("Read ");
199 Serial.println(" bytes");
203 Serial.println("EEPROM:");
204 count = edidreadbytes(edidarray);
205 for (i = 0; i < count; i++){
206 Serial.print(edidarray[i],BYTE);
210 Serial.print("Read ");
212 Serial.println(" bytes");
217 if (Serial.available() > 0) {
218 // get incoming byte:
219 edidarray[count] = Serial.read();
223 Serial.println("Done Loading Bytes press W to write to eeprom ");
226 edidwritebytes(edidarray);
227 Serial.println("Wrote 128 Bytes to eeprom ");
230 Serial.println("Contents of buffer");
231 for (i = 0; i < 128; i++){
232 Serial.print(edidarray[i]);
246 /******************************************************/
247 //Change custom bytes here
249 //edidarray[49] = edidarray[49] | B11000000; //change aspect ratio to 16x9
251 edidarray[49] = 0 | B11000000; //change aspect ratio to 16x9 60hz resolution
252 //Add on a few more custom resolutions here
254 edidarray[51] = 12 | B11000000; //change aspect ratio to 16x9 72hz resolution
255 edidarray[52] = 129; // change resolution to 1368
256 edidarray[53] = 0 | B11000000; //change aspect ratio to 16x9 60hz resolution
259 // Serial.println("Help:\n\tr=read hex\n\tb=read binary\n\tl=load binary from serial(gets 128 bytes)\n\tw=write\n\td=displaybuffer(binary)\n\te=print detailed info\n\tg=generatechecksum\n\tt=check checksum\n\tc=change custom bytes (compiled in)");
268 int edid_read(char *a)
272 for(byte i = 0; i < 128; i++)
274 int edid_count = edidreadbytes(edidarray);
275 byte edid_checksum = edidchecksum(edidarray);
276 sprintf(a, "EDID EEPROM:%d CRC=%02x %s\n",
279 edid_checksum == 0 ? "OK" : "FAIL"
281 if ( edid_checksum == 0 ) ret++;