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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. u8g_page.c
  3. page helper functions, only called by the dev handler.
  4. Universal 8bit Graphics Library
  5. Copyright (c) 2011, 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 "u8g.h"
  29. /*
  30. setup page count structure
  31. conditions: page_height <= total_height
  32. */
  33. void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
  34. {
  35. p->page_height = page_height;
  36. p->total_height = total_height;
  37. p->page = 0;
  38. u8g_page_First(p);
  39. }
  40. void u8g_page_First(u8g_page_t *p)
  41. {
  42. p->page_y0 = 0;
  43. p->page_y1 = p->page_height;
  44. p->page_y1--;
  45. p->page = 0;
  46. }
  47. uint8_t u8g_page_Next(u8g_page_t * p)
  48. {
  49. register u8g_uint_t y1;
  50. p->page_y0 += p->page_height;
  51. if ( p->page_y0 >= p->total_height )
  52. return 0;
  53. p->page++;
  54. y1 = p->page_y1;
  55. y1 += p->page_height;
  56. if ( y1 >= p->total_height )
  57. {
  58. y1 = p->total_height;
  59. y1--;
  60. }
  61. p->page_y1 = y1;
  62. return 1;
  63. }