U8g2lib.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. U8g2lib.cpp
  3. Arduino specific functions
  4. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  5. Copyright (c) 2016, olikraus@gmail.com
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without modification,
  8. are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright notice, this list
  10. of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright notice, this
  12. list of conditions and the following disclaimer in the documentation and/or other
  13. materials provided with the distribution.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  15. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  16. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  19. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  24. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #include "U8g2lib.h"
  29. #ifdef ARDUINO
  30. static Print *u8g2_print_for_screenshot;
  31. void u8g2_print_callback(const char *s)
  32. {
  33. yield();
  34. u8g2_print_for_screenshot->print(s);
  35. }
  36. void U8G2::writeBufferPBM(Print &p)
  37. {
  38. u8g2_print_for_screenshot = &p;
  39. u8g2_WriteBufferPBM(getU8g2(), u8g2_print_callback);
  40. }
  41. void U8G2::writeBufferXBM(Print &p)
  42. {
  43. u8g2_print_for_screenshot = &p;
  44. u8g2_WriteBufferXBM(getU8g2(), u8g2_print_callback);
  45. }
  46. void U8G2::writeBufferPBM2(Print &p)
  47. {
  48. u8g2_print_for_screenshot = &p;
  49. u8g2_WriteBufferPBM2(getU8g2(), u8g2_print_callback);
  50. }
  51. void U8G2::writeBufferXBM2(Print &p)
  52. {
  53. u8g2_print_for_screenshot = &p;
  54. u8g2_WriteBufferXBM2(getU8g2(), u8g2_print_callback);
  55. }
  56. #endif