Guest User

Untitled

a guest
Feb 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /*
  2. * zero_print - print_base<> template example
  3. */
  4. #include "print_t.h"
  5.  
  6. void setup() {
  7. Serial.begin(115200);
  8. delay(2000);
  9. }
  10.  
  11. int indx = 0;
  12.  
  13. void loop() {
  14. #if 0
  15. Serial.write('0'); Serial.write('x');
  16. Serial.println(indx, HEX);
  17. Serial.write('0'); Serial.write('x');
  18. Serial.println(indx, BIN);
  19. #else
  20. Serial.write('0'); Serial.write('x');
  21. print_base<uint8_t, 0>(indx, HEX_, true); // zero pad 2 bytes
  22. Serial.write('0'); Serial.write('b');
  23. print_base<uint8_t, 0>(indx, BIN_, true); // zero pad 8 bytes
  24. #endif
  25. if ( ++indx > 0xff ) {
  26. while (1);
  27. }
  28. }
Add Comment
Please, Sign In to add comment