hadif azli / Mbed 2 deprecated TEST123

Dependencies:   mbed Blynk

Committer:
lixianyu
Date:
Mon Jun 13 02:21:11 2016 +0000
Revision:
1:0e75de2a5d21
Parent:
0:d8f4c441e032
u8glib???????????????????????????Adafruit_GFX????OLED????????bitmap??????

Who changed what in which revision?

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