diff --git a/src/TouchDrvFT6X36.hpp b/src/TouchDrvFT6X36.hpp index 81b41e5..1b86aa5 100644 --- a/src/TouchDrvFT6X36.hpp +++ b/src/TouchDrvFT6X36.hpp @@ -327,7 +327,7 @@ class TouchDrvFT6X36 : const char *getModelName() { - switch (chipID) { + switch (__chipID) { case FT6206_CHIPID: return "FT6206"; case FT6236_CHIPID: return "FT6236"; case FT6236U_CHIPID: return "FT6236U"; @@ -345,7 +345,7 @@ class TouchDrvFT6X36 : void reset() { if (__rst != SENSOR_PIN_NONE) { - + this->setGpioMode(__rst, OUTPUT); this->setGpioLevel(__rst, HIGH); delay(10); this->setGpioLevel(__rst, LOW); @@ -368,32 +368,41 @@ class TouchDrvFT6X36 : private: bool initImpl() { - uint8_t vendId = readRegister(FT6X36_REG_VENDOR1_ID); - chipID = readRegister(FT6X36_REG_CHIPID); + if (__irq != SENSOR_PIN_NONE) { + this->setGpioMode(__irq, INPUT); + } - log_i("Vend ID: 0x%X", vendId); - log_i("Chip ID: 0x%X", chipID); - log_i("Firm Version: 0x%X", readRegister(FT6X36_REG_FIRMVERS)); - log_i("Point Rate Hz: %u", readRegister(FT6X36_REG_PERIODACTIVE)); - log_i("Thresh : %u", readRegister(FT6X36_REG_THRESHHOLD)); + reset(); + + uint8_t vendId = readRegister(FT6X36_REG_VENDOR1_ID); - // change threshhold to be higher/lower - writeRegister(FT6X36_REG_THRESHHOLD, 60); if (vendId != FT6X36_VENDID) { - log_e("Vendor id is not match!"); + log_e("Vendor id is 0x%X not match!\n", vendId); return false; } - if ((chipID != FT6206_CHIPID) && - (chipID != FT6236_CHIPID) && - (chipID != FT6236U_CHIPID) && - (chipID != FT3267_CHIPID) + + __chipID = readRegister(FT6X36_REG_CHIPID); + + if ((__chipID != FT6206_CHIPID) && + (__chipID != FT6236_CHIPID) && + (__chipID != FT6236U_CHIPID) && + (__chipID != FT3267_CHIPID) ) { - log_e("Vendor id is not match!"); - log_e("ChipID:0x%x should be 0x06 or 0x36 or 0x64\n", chipID); + log_e("Vendor id is not match!\n"); + log_e("ChipID:0x%lx should be 0x06 or 0x36 or 0x64\n", __chipID); return false; } + log_i("Vend ID: 0x%X\n", vendId); + log_i("Chip ID: 0x%lx\n", __chipID); + log_i("Firm Version: 0x%X\n", readRegister(FT6X36_REG_FIRMVERS)); + log_i("Point Rate Hz: %u\n", readRegister(FT6X36_REG_PERIODACTIVE)); + log_i("Thresh : %u\n", readRegister(FT6X36_REG_THRESHHOLD)); + + // change threshhold to be higher/lower + writeRegister(FT6X36_REG_THRESHHOLD, 60); + log_i("Chip library version : 0x%x\n", getLibraryVersion()); // This register describes period of monitor status, it should not less than 30. @@ -410,8 +419,6 @@ class TouchDrvFT6X36 : return -1; } -protected: - uint8_t chipID; };