File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,42 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
110110 return value;
111111}
112112
113+ // / for SEN5X detection
114+ // Note, this code needs to be called before setting the I2C bus speed
115+ // for the screen at high speed. The speed needs to be at 100kHz, otherwise
116+ // detection will not work
117+ String readSEN5xProductName (TwoWire* i2cBus, uint8_t address) {
118+ uint8_t cmd[] = { 0xD0 , 0x14 };
119+ uint8_t response[48 ] = {0 };
120+
121+ i2cBus->beginTransmission (address);
122+ i2cBus->write (cmd, 2 );
123+ if (i2cBus->endTransmission () != 0 ) return " " ;
124+
125+ delay (20 );
126+ if (i2cBus->requestFrom (address, (uint8_t )48 ) != 48 ) return " " ;
127+
128+ for (int i = 0 ; i < 48 && i2cBus->available (); ++i) {
129+ response[i] = i2cBus->read ();
130+ }
131+
132+ char productName[33 ] = {0 };
133+ int j = 0 ;
134+ for (int i = 0 ; i < 48 && j < 32 ; i += 3 ) {
135+ if (response[i] >= 32 && response[i] <= 126 )
136+ productName[j++] = response[i];
137+ else
138+ break ;
139+
140+ if (response[i + 1 ] >= 32 && response[i + 1 ] <= 126 )
141+ productName[j++] = response[i + 1 ];
142+ else
143+ break ;
144+ }
145+
146+ return String (productName);
147+ }
148+
113149#define SCAN_SIMPLE_CASE (ADDR, T, ...) \
114150 case ADDR: \
115151 logFoundDevice (__VA_ARGS__); \
You can’t perform that action at this time.
0 commit comments