Renamed the variable c that was used for saving the i2c offset that a computer wants to read. Additionally, a 4bit dip-switch can be read in using the Pins A0-A3.
131 lines
5.5 KiB
C++
131 lines
5.5 KiB
C++
#include <Arduino.h>
|
|
//#include <SoftWire.h>
|
|
//#include <AsyncDelay.h>
|
|
#include <Wire.h> //Patch wire.h: BUFFER_LENGTH = 256 TWI_BUFFER_LENGTH 256
|
|
// ToDo: Eigene Wire.h einbinden mit vorgepatchen Werten
|
|
|
|
/*const uint8_t edid[256] = {
|
|
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0xF4, 0x0C, 0x45, 0x52, 0x46, 0x31, 0x15, 0x19, 0x01, 0x03, 0x80, 0x3C, 0x22, 0x78, 0x2A, 0x52, 0x95, 0xA5, 0x56, 0x54, 0x9D, 0x25, 0x0E, 0x50, 0x54, 0xBF, 0xEF, 0x80, 0x71, 0x4F, 0x81, 0xC0, 0x81, 0x00, 0x81, 0x80, 0x95, 0x00, 0xA9, 0xC0, 0xB3, 0x00, 0x01, 0x01, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E, 0x28, 0x55, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x32, 0x4B, 0x1E, 0x51, 0x11, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x53, 0x32, 0x37, 0x45, 0x33, 0x37, 0x30, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x62, 0x02, 0x03, 0x1B, 0xF1, 0x46, 0x90, 0x04, 0x1F, 0x13, 0x03, 0x12, 0x67, 0x03, 0x0C, 0x00, 0x10, 0x00, 0x80, 0x22, 0x23, 0x09, 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x01, 0x1D, 0x00, 0xBC, 0x52, 0xD0, 0x1E, 0x20, 0xB8, 0x28, 0x55, 0x40, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x8C, 0x0A, 0xD0, 0x90, 0x20, 0x40, 0x31, 0x20, 0x0C, 0x40, 0x55, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x18, 0x8C, 0x0A, 0xD0, 0x8A, 0x20, 0xE0, 0x2D, 0x10, 0x10, 0x3E, 0x96, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D
|
|
};*/
|
|
|
|
#define EDID_LENGTH 128
|
|
|
|
// 800x600
|
|
const uint8_t edid[EDID_LENGTH] = {
|
|
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x1E, 0x6D, 0x7D, 0x58, 0xC1, 0x90, 0x02, 0x00,
|
|
0x08, 0x16, 0x01, 0x03, 0x80, 0x33, 0x1D, 0x78, 0xEA, 0x5E, 0xA5, 0xA2, 0x55, 0x4D, 0xA0, 0x26,
|
|
0x11, 0x50, 0x54, 0x27, 0x4B, 0x00, 0xB3, 0x00, 0x81, 0x80, 0x81, 0x40, 0x71, 0x4F, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xE8, 0x0D, 0x20, 0xA0, 0x30, 0x58, 0x12, 0x20, 0x30, 0x20,
|
|
0x34, 0x00, 0xC8, 0x96, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x49, 0x50, 0x53,
|
|
0x32, 0x33, 0x35, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB7};
|
|
|
|
// IPS235 1920x1080
|
|
/*const uint8_t edid[128] = {
|
|
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x1E, 0x6D, 0x7E, 0x58, 0xC1, 0x90, 0x02, 0x00,
|
|
0x08, 0x16, 0x01, 0x03, 0x80, 0x33, 0x1D, 0x78, 0xEA, 0x5E, 0xA5, 0xA2, 0x55, 0x4D, 0xA0, 0x26,
|
|
0x11, 0x50, 0x54, 0x21, 0x08, 0x00, 0xB3, 0x00, 0x81, 0x80, 0x81, 0x40, 0x71, 0x40, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C,
|
|
0x45, 0x00, 0xE0, 0x0E, 0x11, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x49, 0x50, 0x53,
|
|
0x32, 0x33, 0x35, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA8
|
|
};*/
|
|
|
|
unsigned int edid_offset;
|
|
uint8_t edid_select;
|
|
//SoftWire sw(A2, A3);
|
|
|
|
void read_dip_switches()
|
|
{
|
|
|
|
if (digitalRead(A0) == 1)
|
|
edid_select |= 0b10000000;
|
|
if (digitalRead(A1) == 1)
|
|
edid_select |= 0b01000000;
|
|
if (digitalRead(A2) == 1)
|
|
edid_select |= 0b00100000;
|
|
if (digitalRead(A3) == 1)
|
|
edid_select |= 0b00010000;
|
|
}
|
|
|
|
void receiveEvent(int receivedByte)
|
|
{
|
|
while (0 < Wire.available())
|
|
{
|
|
edid_offset = Wire.read(); /* receive start position */
|
|
//Serial.print(c, HEX); /* print the requested position */
|
|
}
|
|
//Serial.println(); /* to newline */
|
|
return;
|
|
}
|
|
|
|
void requestEvent()
|
|
{
|
|
// Send virtual EEPROM in full length from start position
|
|
Wire.write(edid + edid_offset, EDID_LENGTH - edid_offset);
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(9600);
|
|
Serial.println("**** HDMI ****");
|
|
pinMode(4, OUTPUT); //Hot plug detection
|
|
|
|
// Input for DIP switches for selecting from edids
|
|
pinMode(A0, INPUT);
|
|
pinMode(A1, INPUT);
|
|
pinMode(A2, INPUT);
|
|
pinMode(A3, INPUT);
|
|
|
|
read_dip_switches();
|
|
Wire.begin(0x50); // EDID Register
|
|
digitalWrite(4, LOW);
|
|
delay(20);
|
|
|
|
Wire.onReceive(receiveEvent);
|
|
Wire.onRequest(requestEvent);
|
|
|
|
digitalWrite(4, HIGH); //Source knows that a screen is attached and want to read the edid of the screen
|
|
|
|
/*sw.setTimeout_ms(40);
|
|
sw.begin();
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
digitalWrite(LED_BUILTIN, LOW);
|
|
|
|
// Set how long we are willing to wait for a device to respond
|
|
sw.setTimeout_ms(200);
|
|
|
|
const uint8_t firstAddr = 1;
|
|
const uint8_t lastAddr = 0x7F;
|
|
Serial.println();
|
|
Serial.print("Interrogating all addresses in range 0x");
|
|
Serial.print(firstAddr, HEX);
|
|
Serial.print(" - 0x");
|
|
Serial.print(lastAddr, HEX);
|
|
Serial.println(" (inclusive) ...");
|
|
|
|
for (uint8_t addr = firstAddr; addr <= lastAddr; addr++) {
|
|
digitalWrite(LED_BUILTIN, HIGH);
|
|
delayMicroseconds(50);
|
|
|
|
uint8_t startResult = sw.llStart((addr << 1) + 1); // Signal a read
|
|
sw.stop();
|
|
|
|
if (startResult == 0) {
|
|
Serial.print("\rDevice found at 0x");
|
|
Serial.println(addr, HEX);
|
|
Serial.flush();
|
|
}
|
|
digitalWrite(LED_BUILTIN, LOW);
|
|
|
|
delay(50);
|
|
}
|
|
Serial.println("Finished");*/
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
}
|