mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-17 03:37:55 -06:00
ctr: Encode negative integers in normal hex notation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7d014933ce
commit
ff7be3e026
2 changed files with 6 additions and 15 deletions
|
@ -16,7 +16,8 @@
|
|||
|
||||
// Macro to encode an integer for use with DECL_CTR_INT()
|
||||
#define _CTR_HEX(H) ((H) > 9 ? (H) - 10 + 'A' : (H) + '0')
|
||||
#define _CTR_INT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
|
||||
#define _CTR_SHIFT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
|
||||
#define _CTR_INT(V, S) ((V) < 0 ? _CTR_SHIFT(-(V), (S)) : _CTR_SHIFT((V), (S)))
|
||||
#define CTR_INT(VALUE) { \
|
||||
' ', (VALUE) < 0 ? '-' : '+', '0', 'x', \
|
||||
_CTR_INT((VALUE),28), _CTR_INT((VALUE),24), \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue