iforce2d Chris / Mbed 2 deprecated ubxDistanceMeter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers u8g_page.c Source File

u8g_page.c

00001 /*
00002 
00003   u8g_page.c
00004   
00005   page helper functions, only called by the dev handler.
00006 
00007   Universal 8bit Graphics Library
00008   
00009   Copyright (c) 2011, olikraus@gmail.com
00010   All rights reserved.
00011 
00012   Redistribution and use in source and binary forms, with or without modification, 
00013   are permitted provided that the following conditions are met:
00014 
00015   * Redistributions of source code must retain the above copyright notice, this list 
00016     of conditions and the following disclaimer.
00017     
00018   * Redistributions in binary form must reproduce the above copyright notice, this 
00019     list of conditions and the following disclaimer in the documentation and/or other 
00020     materials provided with the distribution.
00021 
00022   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00023   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00024   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00025   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00027   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00028   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
00029   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00030   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00031   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00032   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00033   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00034   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00035   
00036   
00037 */
00038 
00039 #include "u8g.h"
00040 
00041 /*
00042   setup page count structure
00043   conditions: page_height <= total_height
00044 */
00045 void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
00046 {
00047   p->page_height = page_height;
00048   p->total_height = total_height;
00049   p->page = 0;
00050   u8g_page_First(p);
00051 }
00052 
00053 void u8g_page_First(u8g_page_t *p)
00054 {
00055   p->page_y0 = 0;
00056   p->page_y1 = p->page_height;
00057   p->page_y1--;
00058   p->page = 0;
00059 }
00060 
00061 uint8_t u8g_page_Next(u8g_page_t * p)
00062 {
00063   register u8g_uint_t y1;
00064   p->page_y0 += p->page_height;
00065   if ( p->page_y0 >= p->total_height )
00066     return 0;
00067   p->page++;
00068   y1 = p->page_y1;
00069   y1 += p->page_height;
00070   if ( y1 >= p->total_height )
00071   {
00072     y1 = p->total_height;
00073     y1--;
00074   }
00075   p->page_y1 = y1;
00076   
00077   return 1;
00078 }
00079 
00080 
00081 
00082