This is the same idea in @Koepel's simulation, see #9 and the link there to the simuklation
I am not sure why the array is 10 and the 8 meaningful bytes used are from indices 2..9.
I had hacked something but was waylaid by the Raspberry Pi somehow, eventually I arrived at the same thing
#define _SERIAL Serial1
const int vals[10] = {
0x00C6, 0x006B, 0x0080, 0x00E8, 0x0069, 0x00F5, 0x00B0, 0x003F,
};
byte byteMe[8];
double f;
void setup() {
_SERIAL.begin(9600);
_SERIAL.println("Hello World!\n");
for (uint8_t ii = 0; ii < 8; ii++)
byteMe[ii] = vals[ii];
memcpy(&f, byteMe, 8);
_SERIAL.print("using byteMe ");
_SERIAL.println(f, 10);
_SERIAL.println("That's All, Folks!");
}
void loop() {
// no code here, to run repeatedly doing nothing
}
So you could use that (copy the int array to a byte array, then convert) until you ever get around to fixing the transmission format.
@Koepel why the extra two entries jkust to skip them?
@ Anyone, is this
byteMe[ii] = vals[ii];
OK to copy from an array of ints to an array of bytes? Just getting the last byte?
I used & 0xff, worked OPK and of course it seems the cast is OK, just wondering about the simple expression in this case.
Hello World!
using byteMe 0.0662447159
That's All, Folks!
Third vote for ~0.066 :=|
You can also use a
double *f;
instead, then you don't need to copy the byte array at all.
double *f;
f = (double *) byteMe;
_SERIAL.print("using byteMe ");
_SERIAL.println(*f, 10);
Old school.
a7