Xinyuan-LilyGO / LilyGo-T-Wristband-NRF52

28 stars 12 forks source link

Screen not working #4

Open Hintravel opened 3 years ago

Hintravel commented 3 years ago

Hello, I have a Mac m1, Big Sur operating system. I have installed Arduino IDE without problems, version 1.8.13. I followed the steps listed to configure T-Wristband-NRF52 by downloading the custom libraries from the repository and placing them in the libraries folder in Documents / Arduino / Libraries. I also downloaded the Board nrf52 version 0.21.0 (latest available).

Restarted the Ide Arduino, connected T-Wristband-NRF52 via usb C. Everything ok, libraries loaded successfully, device visible, I decide to upload the factory test example.

Everything loads, the code is working, but the screen only turns on the backlight. Nothing can be seen. The program below runs smoothly, but the screen remains lit but black.

How can I solve? What can this problem cause?

Thanks in advance for your kind reply.

20201224_094337

alexisicte commented 3 years ago

Hi, Something should be happening with the i2c bus. I suppose they do not use sufficient pull up resistors on i2c buses. If i will get access on the schematic i will be more sure about it.

Try this code to ensure that your i2c is not permanently broken.

#include <bluefruit.h>
#include <Arduino.h>
#include <Wire.h>

/** SDA pin for first I2C */
#define SDA0 PIN_WIRE_SDA
/** SCL pin for first I2C */
#define SCL0 PIN_WIRE_SCL
/** SDA pin for second I2C */
#define SDA1 15
/** SCL pin for second I2C */
#define SCL1 16

#define I2C_SPEED_STANDARD        100000
#define I2C_SPEED_FAST            400000

#define TOUCH_PW 29
#define TP_PIN_PIN 5

/** First sensor Wire class */
TwoWire i2cWire1 = TwoWire(NRF_TWIM0, NRF_TWIS0, SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, SDA0, SCL0);
TwoWire i2cWire2 = TwoWire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, SDA1, SCL1);

bool btn_pressed = false;

void setup(void)
{
    Serial.begin(115200);
    pinMode(TOUCH_PW, OUTPUT);
    pinMode(TP_PIN_PIN, INPUT_PULLDOWN);
    digitalWrite(TOUCH_PW, HIGH);

    //NRF_UARTE0->ENABLE = 0; //disable UART
    NRF_SAADC->ENABLE = 0;  //disable ADC
    NRF_PWM0->ENABLE = 0;   //disable all pwm instance
    NRF_PWM1->ENABLE = 0;
    NRF_PWM2->ENABLE = 0;
    NRF_TWIM0->ENABLE = 0; //disable TWI Master
    NRF_TWIS0->ENABLE = 0; //disable TWI Slave
    NRF_TWIM1->ENABLE = 0; //disable TWI Master
    NRF_TWIS1->ENABLE = 0; //disable TWI Slave
    NRF_SPI0->ENABLE = 0;  //disable SPI
    NRF_SPI1->ENABLE = 0;  //disable SPI
    NRF_SPI2->ENABLE = 0;  //disable SPI
    __WFE();
    __WFI();
    //NRF_POWER->SYSTEMOFF = 1;
    Serial.println("Initializing sensors");

}
void loop()
{
    Serial.print(digitalRead(PIN_WIRE_SCL));    //should be HIGH
    Serial.println(digitalRead(PIN_WIRE_SDA));   //should be HIGH, is LOW on stuck I2C bus
    if (digitalRead(TP_PIN_PIN) == HIGH)
    {
        Serial.println("button pressed!");
        btn_pressed = true;
    }
    if(btn_pressed){
        btn_pressed = false;
        i2cWire1.end();
        i2cWire1.begin();

        NRF_TWIM0->ENABLE = 1; 
        NRF_TWIS0->ENABLE = 1; 
        Serial.print(digitalRead(PIN_WIRE_SCL));    //should be HIGH
        Serial.println(digitalRead(PIN_WIRE_SDA));   //should be HIGH, is LOW on stuck I2C bus
        byte error;
        //Serial.println("Start I2C #1");
        i2cWire1.begin();
        i2cWire1.setClock(I2C_SPEED_STANDARD);
        //Serial.println("Scan I2C bus #1");

        //sd_power_system_off();
            for (byte address = 1; address < 127; address++)
            {
                Serial.print("Trying address: 0x");
                Serial.println(address, HEX);
                i2cWire1.beginTransmission(address);
                error = i2cWire1.endTransmission();
                if (error == 0)
                {
                    Serial.print("Found device on I2C #1 on address ");
                    Serial.println(address, HEX);
                }
            }
        i2cWire1.end();
        Serial.print(digitalRead(PIN_WIRE_SCL));    //should be HIGH
        Serial.println(digitalRead(PIN_WIRE_SDA));   //should be HIGH, is LOW on stuck I2C bus

        NRF_TWIM0->ENABLE = 0; //disable TWI Master
        NRF_TWIS0->ENABLE = 0; //disable TWI Slave
    }

    delay(500);
}

Then check on your serial monitor that the i2c peripherals are recognized on specific addresses, when the button is pressed. Mine version recognizes 0x51 and 0x69. Then you should be able to upload the default example, but first add

NRF_TWIM0->ENABLE = 1; NRF_TWIS0->ENABLE = 1; Wire.begin();

before tft.sendCommand(ST77XX_SLPOUT); line, after waking up.