hello / kitsune

RTOS on Morpheus
11 stars 6 forks source link

check status for tvoc #699

Closed zer0page closed 7 years ago

divkam commented 7 years ago

Just curious, why this change?

zer0page commented 7 years ago

suspect updating the offset every sample somehow interferes with the tvoc internal algorithm

mburnshello commented 7 years ago

let's also check the data ready status bit before sampling data. register 0x00 bit 3. pseudocode from manufacturer: u8 *timer_routine_read_data(){ i2c_write(CCS_811_ADDRESS, STATUS_REG, i2c_buff, 0); i2c_read(CCS_811_ADDRESS, i2c_buff, 1); if(i2c_buff & 0x8) // check if data ready { i2c_write(CCS_811_ADDRESS, ALG_RESULT_DATA, i2c_buff, 0); i2c_read(CCS_811_ADDRESS, i2c_buff, 4); } return i2c_buff; }

zer0page commented 7 years ago

@mburnshello @plasticchris

zer0page commented 7 years ago

Didn't see anything in the spec sheet. This number is arbitrary, also don't want to hog the semaphore for too long

On Nov 23, 2016 12:47 PM, "Chris Johnson" notifications@github.com wrote:

@plasticchris commented on this pull request.

In kitsune/i2c_cmd.c https://github.com/hello/kitsune/pull/699#pullrequestreview-9942478:

  • /*
  • * read status
  • */
  • int tries = 3;
  • bool data_is_ready = false;
  • while(tries-- > 0){
  • b[0] = 0;
  • (I2C_IF_Write(0x5a, b, 1, 1));
  • memset(b,0, sizeof(b));
  • I2C_IF_Read(0x5a, b, 1);
  • if(b[0] & 0x08){
  • data_is_ready = true;
  • break;
  • }
  • vTaskDelay(1);

this seems short; is it based on measurements or datasheet info?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hello/kitsune/pull/699#pullrequestreview-9942478, or mute the thread https://github.com/notifications/unsubscribe-auth/AFVvUUkDIvTIrPQzCBRcerJmRXgxiIBGks5rBKZpgaJpZM4K4o4w .