iforce2d Chris
/
ubxDistanceMeter
Displays distance to start location on OLED screen.
u8g_page.c@0:972874f31c98, 2018-03-07 (annotated)
- Committer:
- iforce2d
- Date:
- Wed Mar 07 12:49:14 2018 +0000
- Revision:
- 0:972874f31c98
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iforce2d | 0:972874f31c98 | 1 | /* |
iforce2d | 0:972874f31c98 | 2 | |
iforce2d | 0:972874f31c98 | 3 | u8g_page.c |
iforce2d | 0:972874f31c98 | 4 | |
iforce2d | 0:972874f31c98 | 5 | page helper functions, only called by the dev handler. |
iforce2d | 0:972874f31c98 | 6 | |
iforce2d | 0:972874f31c98 | 7 | Universal 8bit Graphics Library |
iforce2d | 0:972874f31c98 | 8 | |
iforce2d | 0:972874f31c98 | 9 | Copyright (c) 2011, olikraus@gmail.com |
iforce2d | 0:972874f31c98 | 10 | All rights reserved. |
iforce2d | 0:972874f31c98 | 11 | |
iforce2d | 0:972874f31c98 | 12 | Redistribution and use in source and binary forms, with or without modification, |
iforce2d | 0:972874f31c98 | 13 | are permitted provided that the following conditions are met: |
iforce2d | 0:972874f31c98 | 14 | |
iforce2d | 0:972874f31c98 | 15 | * Redistributions of source code must retain the above copyright notice, this list |
iforce2d | 0:972874f31c98 | 16 | of conditions and the following disclaimer. |
iforce2d | 0:972874f31c98 | 17 | |
iforce2d | 0:972874f31c98 | 18 | * Redistributions in binary form must reproduce the above copyright notice, this |
iforce2d | 0:972874f31c98 | 19 | list of conditions and the following disclaimer in the documentation and/or other |
iforce2d | 0:972874f31c98 | 20 | materials provided with the distribution. |
iforce2d | 0:972874f31c98 | 21 | |
iforce2d | 0:972874f31c98 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
iforce2d | 0:972874f31c98 | 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
iforce2d | 0:972874f31c98 | 24 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
iforce2d | 0:972874f31c98 | 25 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
iforce2d | 0:972874f31c98 | 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
iforce2d | 0:972874f31c98 | 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
iforce2d | 0:972874f31c98 | 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
iforce2d | 0:972874f31c98 | 29 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
iforce2d | 0:972874f31c98 | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
iforce2d | 0:972874f31c98 | 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
iforce2d | 0:972874f31c98 | 32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
iforce2d | 0:972874f31c98 | 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
iforce2d | 0:972874f31c98 | 34 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
iforce2d | 0:972874f31c98 | 35 | |
iforce2d | 0:972874f31c98 | 36 | |
iforce2d | 0:972874f31c98 | 37 | */ |
iforce2d | 0:972874f31c98 | 38 | |
iforce2d | 0:972874f31c98 | 39 | #include "u8g.h" |
iforce2d | 0:972874f31c98 | 40 | |
iforce2d | 0:972874f31c98 | 41 | /* |
iforce2d | 0:972874f31c98 | 42 | setup page count structure |
iforce2d | 0:972874f31c98 | 43 | conditions: page_height <= total_height |
iforce2d | 0:972874f31c98 | 44 | */ |
iforce2d | 0:972874f31c98 | 45 | void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height ) |
iforce2d | 0:972874f31c98 | 46 | { |
iforce2d | 0:972874f31c98 | 47 | p->page_height = page_height; |
iforce2d | 0:972874f31c98 | 48 | p->total_height = total_height; |
iforce2d | 0:972874f31c98 | 49 | p->page = 0; |
iforce2d | 0:972874f31c98 | 50 | u8g_page_First(p); |
iforce2d | 0:972874f31c98 | 51 | } |
iforce2d | 0:972874f31c98 | 52 | |
iforce2d | 0:972874f31c98 | 53 | void u8g_page_First(u8g_page_t *p) |
iforce2d | 0:972874f31c98 | 54 | { |
iforce2d | 0:972874f31c98 | 55 | p->page_y0 = 0; |
iforce2d | 0:972874f31c98 | 56 | p->page_y1 = p->page_height; |
iforce2d | 0:972874f31c98 | 57 | p->page_y1--; |
iforce2d | 0:972874f31c98 | 58 | p->page = 0; |
iforce2d | 0:972874f31c98 | 59 | } |
iforce2d | 0:972874f31c98 | 60 | |
iforce2d | 0:972874f31c98 | 61 | uint8_t u8g_page_Next(u8g_page_t * p) |
iforce2d | 0:972874f31c98 | 62 | { |
iforce2d | 0:972874f31c98 | 63 | register u8g_uint_t y1; |
iforce2d | 0:972874f31c98 | 64 | p->page_y0 += p->page_height; |
iforce2d | 0:972874f31c98 | 65 | if ( p->page_y0 >= p->total_height ) |
iforce2d | 0:972874f31c98 | 66 | return 0; |
iforce2d | 0:972874f31c98 | 67 | p->page++; |
iforce2d | 0:972874f31c98 | 68 | y1 = p->page_y1; |
iforce2d | 0:972874f31c98 | 69 | y1 += p->page_height; |
iforce2d | 0:972874f31c98 | 70 | if ( y1 >= p->total_height ) |
iforce2d | 0:972874f31c98 | 71 | { |
iforce2d | 0:972874f31c98 | 72 | y1 = p->total_height; |
iforce2d | 0:972874f31c98 | 73 | y1--; |
iforce2d | 0:972874f31c98 | 74 | } |
iforce2d | 0:972874f31c98 | 75 | p->page_y1 = y1; |
iforce2d | 0:972874f31c98 | 76 | |
iforce2d | 0:972874f31c98 | 77 | return 1; |
iforce2d | 0:972874f31c98 | 78 | } |
iforce2d | 0:972874f31c98 | 79 | |
iforce2d | 0:972874f31c98 | 80 | |
iforce2d | 0:972874f31c98 | 81 | |
iforce2d | 0:972874f31c98 | 82 |