Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ Please see example code.
* [Shell](./examples/Shell/Shell.ino)
* [Send illminance (CdS)](./examples/CdS/CdS.ino)

# Notes

* On the Uno and other ATMEGA based boards, Values ​​of type double are sent as float type. (Please see [Arduino Reference]( https://www.arduino.cc/reference/en/language/variables/data-types/double/).)

# License

Expand Down
12 changes: 12 additions & 0 deletions src/SakuraIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ uint8_t SakuraIO::enqueueTx(uint8_t ch, float value, uint64_t offset){
}

uint8_t SakuraIO::enqueueTx(uint8_t ch, double value, uint64_t offset){

// check sizeof(double)
//
// On the Uno and other ATMEGA based boards,
// this occupies 4 bytes. That is, the double
// implementation is exactly the same as the float,
// with no gain in precision.
// https://www.arduino.cc/reference/en/language/variables/data-types/double/
if (sizeof(double) == 4){
return enqueueTx(ch, (float)value, offset);
}

return enqueueTxRaw(ch, 'd', 8, (uint8_t *)&value, offset);
}

Expand Down