-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArduinoEdid.pde
249 lines (237 loc) · 7.18 KB
/
ArduinoEdid.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//VGA writer to write eeproms in vga displays
//Apr 2011 Kieran Levin [email protected]
//If you want to modify some data scroll down and modify the bytes in command 'c'
//Then load from display - change custom bytes, generate checksum, write to save values back(r,c,g,w)
//See also http://en.wikipedia.org/wiki/Extended_display_identification_data
/*Help Commands:
r=read hex
b=read binary
l=load binary from serial(gets 128 bytes of binary data from serial then returns)
w=write
d=displaybuffer(binary)
e=print detailed info
g=generatechecksum
t=check checksum
c=change custom bytes (compiled in)
Connection
Arduino VGA DVI
Analog 4(Data) 12 7
Analog 5(Clk) 15 6
DIO 2 14
Power5V 9 14
GND 11 15
*/
#include <Wire.h>
int i;
int inByte = 0; // incoming serial byte
int count = 0;
char edidarray[128];
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
//write to vclk pin on pin 2
pinMode(2, OUTPUT);
pinMode(18, OUTPUT);
//This puts i2c eeproms that are also clocked off the vsync into R/W mode
digitalWrite(18, HIGH); // set the LED off
for(i = 0; i < 20; i++){
digitalWrite(2, HIGH); // set the LED on
delay(10); // wait for a second
digitalWrite(2, LOW); // set the LED off
delay(10);
}
digitalWrite(2, HIGH); // set the LED on
delay(10);
digitalWrite(18, LOW); // set the LED off
delay(10);
digitalWrite(2, LOW); // set the LED on
for(i = 0; i < 10; i++){
digitalWrite(2, HIGH); // set the LED on
delay(10); // wait for a second
digitalWrite(2, LOW); // set the LED off
delay(10);
}
//disable writing to eeprom
digitalWrite(2, LOW); // set the LED off
Serial.println("EDID Reader Writer C 2011 Kieran Levin [email protected]");
}
int edidreadbytes(char * array){
byte mycount = 0;
Wire.beginTransmission(B1010000);
Wire.send(mycount);
Wire.endTransmission();
for(int j =0; j < 128; j++){
Wire.requestFrom(B1010000, 1);
if (Wire.available()) // slave may send less than requested
{
array[j] = Wire.receive(); // receive a byte as character
mycount++;
}
delay(10);
}
return mycount;
}
int edidwritebytes(char * array){
byte mycount = 0;
digitalWrite(2, HIGH); // set the LED off
delay(10);
for(byte j =0; j < 128;j++){
Wire.beginTransmission(B1010000);
Wire.send(j);
Wire.send(array[j]);
Wire.endTransmission();
delay(10);
}
digitalWrite(2, LOW); // set the LED off
return mycount;
}
void printDetailedinfo(){
Serial.println("Detailed Information:");
Serial.print("\tManufacture ID \t");
Serial.println(*((uint16_t *)(edidarray+8)));
Serial.print("\tProduct ID code \t");
Serial.println(*((uint16_t *)(edidarray+10)));
Serial.print("\tSerial Number \t");
Serial.println(*((uint32_t *)(edidarray+12)));
Serial.print("\tWeek of Manufacture \t");
Serial.println(edidarray[16]);
Serial.print("\tYear of manufacture \t");
Serial.println(edidarray[17] + 1990);
Serial.print("\tEdid Version\t");
Serial.println(edidarray[18]);
Serial.print("\tEdid Revision \t");
Serial.println(edidarray[19]);
Serial.print("\tEstablished Timing 1 \t");
Serial.println(0x00FF & edidarray[35],BIN);
Serial.print("\tEstablished Timing 2 \t");
Serial.println(0x00FF & edidarray[36],BIN);
for(int i = 38; i < 53; i +=2){
Serial.print("Standard Timing ID \t");
Serial.println(i);
Serial.print("\tHoriz Res \t");
Serial.println(248+8*(0x00FF & edidarray[i]));
Serial.print("\tAspect Ratio \t");
switch(B11000000 & edidarray[i+1]){
case B00000000:
if (edidarray[19] < 3)
Serial.println("1:1");
else
Serial.println("16:10");
break;
case B01000000:
Serial.println("4:3");
break;
case B10000000:
Serial.println("5:4");
break;
case B11000000:
Serial.println("16:9");
break;
}
Serial.print("\tVertical Freq \t");
Serial.println(60+(B00111111 & edidarray[i+1]));
}
}
void checkchecksum(){
byte checksum = 0;
for (int i = 0; i < 128; i++){
checksum += edidarray[i];
}
Serial.print("\tChecksum (should = 0) \t");
Serial.println(checksum,HEX);
}
void generatechecksum(){
Serial.println("Generating Checksum");
byte checksum = 0;
for (int i = 0; i < 127; i++){
checksum += edidarray[i];
}
edidarray[127] = 256 - checksum;
checkchecksum();
}
void loop()
{
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
switch (inByte){
case 'r':
count = 0;
Serial.println("EEPROM:");
count = edidreadbytes(edidarray);
for (i = 0; i < count; i++){
Serial.print(edidarray[i],HEX);
Serial.print(',');
delay(1);
}
Serial.println();
Serial.print("Read ");
Serial.print(count);
Serial.println(" bytes");
break;
case 'b':
count = 0;
Serial.println("EEPROM:");
count = edidreadbytes(edidarray);
for (i = 0; i < count; i++){
Serial.print(edidarray[i],BYTE);
delay(1);
}
Serial.println();
Serial.print("Read ");
Serial.print(count);
Serial.println(" bytes");
break;
case 'l':
count = 0;
while (count < 128){
if (Serial.available() > 0) {
// get incoming byte:
edidarray[count] = Serial.read();
count++;
}
}
Serial.println("Done Loading Bytes press W to write to eeprom ");
break;
case 'w':
edidwritebytes(edidarray);
Serial.println("Wrote 128 Bytes to eeprom ");
break;
case 'd':
Serial.println("Contents of buffer");
for (i = 0; i < 128; i++){
Serial.print(edidarray[i]);
delay(1);
}
break;
case 'e':
printDetailedinfo();
break;
case 'g':
generatechecksum();
break;
case 't':
checkchecksum();
break;
case 'c':
/******************************************************/
//Change custom bytes here
edidarray[0] = 0;
//edidarray[49] = edidarray[49] | B11000000; //change aspect ratio to 16x9
edidarray[48] = 139;
edidarray[49] = 0 | B11000000; //change aspect ratio to 16x9 60hz resolution
//Add on a few more custom resolutions here
edidarray[50] = 129;
edidarray[51] = 12 | B11000000; //change aspect ratio to 16x9 72hz resolution
edidarray[52] = 129; // change resolution to 1368
edidarray[53] = 0 | B11000000; //change aspect ratio to 16x9 60hz resolution
break;
case 'h':
// 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)");
break;
default:
break;
}
}
}