My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. u8g_bitmap.c
  3. Universal 8bit Graphics Library
  4. Copyright (c) 2011, olikraus@gmail.com
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice, this list
  9. of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice, this
  11. list of conditions and the following disclaimer in the documentation and/or other
  12. materials provided with the distribution.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  14. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  15. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "u8g.h"
  28. void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
  29. {
  30. while( cnt > 0 )
  31. {
  32. u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
  33. bitmap++;
  34. cnt--;
  35. x+=8;
  36. }
  37. }
  38. void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
  39. {
  40. if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
  41. return;
  42. while( h > 0 )
  43. {
  44. u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
  45. bitmap += cnt;
  46. y++;
  47. h--;
  48. }
  49. }
  50. void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
  51. {
  52. while( cnt > 0 )
  53. {
  54. u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
  55. bitmap++;
  56. cnt--;
  57. x+=8;
  58. }
  59. }
  60. void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
  61. {
  62. if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
  63. return;
  64. while( h > 0 )
  65. {
  66. u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
  67. bitmap += cnt;
  68. y++;
  69. h--;
  70. }
  71. }
  72. /*=========================================================================*/
  73. static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
  74. {
  75. uint8_t d;
  76. x+=7;
  77. while( w >= 8 )
  78. {
  79. u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
  80. bitmap++;
  81. w-= 8;
  82. x+=8;
  83. }
  84. if ( w > 0 )
  85. {
  86. d = *bitmap;
  87. x -= 7;
  88. do
  89. {
  90. if ( d & 1 )
  91. u8g_DrawPixel(u8g, x, y);
  92. x++;
  93. w--;
  94. d >>= 1;
  95. } while ( w > 0 );
  96. }
  97. }
  98. void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
  99. {
  100. u8g_uint_t b;
  101. b = w;
  102. b += 7;
  103. b >>= 3;
  104. if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
  105. return;
  106. while( h > 0 )
  107. {
  108. u8g_DrawHXBM(u8g, x, y, w, bitmap);
  109. bitmap += b;
  110. y++;
  111. h--;
  112. }
  113. }
  114. static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
  115. {
  116. uint8_t d;
  117. x+=7;
  118. while( w >= 8 )
  119. {
  120. u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
  121. bitmap++;
  122. w-= 8;
  123. x+=8;
  124. }
  125. if ( w > 0 )
  126. {
  127. d = u8g_pgm_read(bitmap);
  128. x -= 7;
  129. do
  130. {
  131. if ( d & 1 )
  132. u8g_DrawPixel(u8g, x, y);
  133. x++;
  134. w--;
  135. d >>= 1;
  136. } while ( w > 0 );
  137. }
  138. }
  139. void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
  140. {
  141. u8g_uint_t b;
  142. b = w;
  143. b += 7;
  144. b >>= 3;
  145. if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
  146. return;
  147. while( h > 0 )
  148. {
  149. u8g_DrawHXBMP(u8g, x, y, w, bitmap);
  150. bitmap += b;
  151. y++;
  152. h--;
  153. }
  154. }