From 863ff46105a30aa1bc92a7b67df2378a4ac55009 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Tue, 26 Jun 2018 13:39:09 +0200 Subject: [PATCH] dynamic changes, rsen working, still no t1 --- app/application.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/app/application.cpp b/app/application.cpp index 63b7b7d..677da19 100644 --- a/app/application.cpp +++ b/app/application.cpp @@ -176,6 +176,13 @@ void select_output(char output) } uint8_t matrixInit() { + + debugf("Logic reset..."); + i2cWrite(0x64, 0x40, 0x08); + delay(500); + debugf("Reset, clearing..."); + i2cWrite(0x64, 0x40, 0x00); + setEDID(0, edidbuf); setEDID(1, edidbuf); setEDID(2, edidbuf); @@ -191,10 +198,10 @@ uint8_t matrixInit() { i2cWrite(0x64, 0x46, 0xe4); i2cWrite(0x64, 0x47, 0x80); i2cWrite(0x64, 0x48, 0x04); - i2cWrite(0x64, 0x49, 0b10110100); - i2cWrite(0x64, 0x4a, 0xff); + i2cWrite(0x64, 0x49, 0b01110000); + i2cWrite(0x64, 0x4a, 0xcf); // 0xff //i2cWrite(0x64, 0x49, 0xc0); - i2cWrite(0x64, 0x4b, 0x24); + i2cWrite(0x64, 0x4b, 0b111111); uint8_t err; uint8_t physettings[4] = {0x4c, 0x02, 0x50, 0x00}; @@ -205,7 +212,15 @@ uint8_t matrixInit() { physettings[0] = 0x4d; physettings[1] = 0x16; - physettings[2] = 0x21; + physettings[2] = 0x41; + + if ((err = twi_writeTo(0x64, physettings, 3, true)) != 0) { + Serial.printf("txphy write failed: %d\r\n", err); + } + Serial.printf("discharging txphy..."); + delay(1000); + + physettings[2] = 0x01; if ((err = twi_writeTo(0x64, physettings, 3, true)) != 0) { Serial.printf("txphy write failed: %d\r\n", err); @@ -249,7 +264,13 @@ void init() { Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(true); // Disable debug output - + Serial.setCallback(*[](Stream& src, char arrived, uint16_t available) { + debugf("arrived: %02x", arrived); + input_a = (arrived - 0x31) & 0x3; + input_b = (arrived - 0x31) & 0x3; + debugf("setting: %d", input_a); + i2cWrite(0x64, 0x49, (0b01010000 | 0) | (input_b << 2)); + }); WDT.enable(false); // First (but not the best) option: fully disable watch dog timer // Default I2C pins (SDA: 2, SCL:0) @@ -338,6 +359,9 @@ void init() if (status4 & 0x02) Serial.printf("ri_rdy "); if (status4 & 0x10) Serial.printf("rptr "); + uint8_t status5 = i2cRead(0x65, 0x0e); + if (status5 & 0x01) Serial.printf("hdmi "); + Serial.printf("[%02x ", i2cRead(0x65, 0x07)); Serial.printf("%02x ", i2cRead(0x65, 0x08)); Serial.printf("%02x ", i2cRead(0x65, 0x09));