Пример #1
0
int16_t parse_cmd_i2c_ds1631_stop(char *cmd, char *output, uint16_t len)
{
	uint8_t adr;
	sscanf_P(cmd, PSTR("%u"), &adr);
	if (adr > 7)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t temp = i2c_ds1631_start_stop(I2C_SLA_DS1631 + adr,0);
	if (temp == 0xffff)
		return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("ds1631 stop %d ok"),adr));
#else
	return ECMD_FINAL(snprintf_P(output, len, PSTR("ok")));
#endif
}
Пример #2
0
int16_t parse_cmd_i2c_ds1631_set_power_state(char *cmd, char *output, uint16_t len)
{
	uint8_t adr;
	uint8_t state;
	sscanf_P(cmd, PSTR("%u %u"), &adr, &state);
	if (adr > 7)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t temp = i2c_ds1631_start_stop(I2C_SLA_DS1631 + adr,state);
	if (temp == 0xffff)
		return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("ds1631 convert %d %d"),adr,state));
#else
	return ECMD_FINAL_OK;
#endif
}