/* on_off_display(on_off) * Turns on the display if on_off is true and turns it off if on_off = 0 */ void on_off_display(unsigned char on_off) { if(on_off) I2C_write_byte(HT16K33_SLA, HT16K33_DISPLAY_SETUP | HT16K33_DISPLAY_ON); else I2C_write_byte(HT16K33_SLA, HT16K33_DISPLAY_SETUP | HT16K33_DISPLAY_OFF); }
void hts_init() { uint8_t callib_regs[HTS_CALLIB_REGS_NUM]; /* Set PD bits (set device active) and BDU bits (data registers actualization only after previous were read) */ I2C_write_byte(SLA_HTS_WR, HTS_CTRL_REG1, HTS_PD | HTS_BDU); // Measurement precision possibly the best I2C_write_byte(SLA_HTS_WR, HTS_AV_CONF, HTS_SET_HUM_OVRSMPL(HTS_OVRSMPL_H512) | HTS_SET_TEMP_OVRSMPL(HTS_OVRSMPL_T256)); // Callibration registers reading. I2C_read_bytes(SLA_HTS_WR, HTS_CALLIB_REGS | HTS_AUTOINCREMENT, HTS_CALLIB_REGS_NUM, callib_regs); // Mapping callibration registers on variables. H0_rH_x2 = callib_regs[0]; H1_rH_x2 = callib_regs[1]; T0_degC_x8 = callib_regs[2] | ((((uint16_t)callib_regs[5]) & 0x03) << 8); T1_degC_x8 = callib_regs[3] | ((((uint16_t)callib_regs[5]) & 0x0C) << 6); H0_T0_out = callib_regs[6] | (((uint16_t)callib_regs[7]) << 8); H1_T0_out = callib_regs[10] | (((uint16_t)callib_regs[11]) << 8); T0_out = callib_regs[12] | (((uint16_t)callib_regs[13]) << 8); T1_out = callib_regs[14] | (((uint16_t)callib_regs[15]) << 8); }
/* LED_init() * */ void LED_init(void) { // Turn on internal oscillator I2C_write_byte(HT16K33_SLA, HT16K33_OSCILLATOR_ON); // Turn on display I2C_write_byte(HT16K33_SLA, HT16K33_DISPLAY_SETUP | HT16K33_DISPLAY_ON); // Brightness maximum I2C_write_byte(HT16K33_SLA, HT16K33_DIMMING_SET(15)); }
/* blink_display(blink) * Sets the blinking frequency according to the parameter "blink" * 0 -> No blinking * 1 -> 2Hz blinking (2 blinks per second) * 2 -> 1Hz blinking (1 blink per second) * 3 -> .5Hz blinking (1 blink every two seconds) */ void blink_display(unsigned char blink) { if(blink > 3) blink = 3; I2C_write_byte(HT16K33_SLA, HT16K33_DISPLAY_SETUP | HT16K33_DISPLAY_BLINK(blink) | HT16K33_DISPLAY_ON); }
/* dim_display(dimming) * Takes a value (dimming) from 0 to 15 and sets the corresponding brightness * with 0 being the dimmest and 15 the brightest */ void dim_display(unsigned char dimming) { if(dimming > 15) dimming = 15; I2C_write_byte(HT16K33_SLA, HT16K33_DIMMING_SET(dimming)); }
void t_hts_dep_meas() { I2C_write_byte(SLA_HTS_WR, HTS_CTRL_REG2, HTS_ONE_SHOT); }