Hi
I'm a bit new to some of this and have a problem which is really left me scratching my head.
int16_t advtemp = ((int16_t)(cTemp * 100.0));
//
int16_t advhum = ((int16_t)(humidity * 100.0));
sprintf(AdvDataCmd,"AT+LEADDATA=%s%s%04X%04XAABB%s\r",Flags,ManData,advtemp,advhum,Name);
I'm working with a 16 bit temperature/humidity sensor and a Due board and I need to send the result (advtemp and advhum) as a pair of 16 bit hex values (no more no less always 4 characters) in a string. My code works fine when advtemp and advhum are positive and I see answers such as "0BC4". However if ,say, advtemp is negative then the hex representation returned is 32 bit e.g "FFFFF134". I am only interested in the last 4 characters. Is there a way of instructing the Due to only return "F134". My values can never exceed the range of a 16 bit integer.
Thanks
Mike