hadif azli / Mbed 2 deprecated TEST123

Dependencies:   mbed Blynk

Committer:
lixianyu
Date:
Fri Jun 10 15:20:20 2016 +0000
Revision:
0:d8f4c441e032
u8glib???????????i2c???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lixianyu 0:d8f4c441e032 1 /*
lixianyu 0:d8f4c441e032 2
lixianyu 0:d8f4c441e032 3 u8g_dev_gprof.c
lixianyu 0:d8f4c441e032 4
lixianyu 0:d8f4c441e032 5 Device for performance measurement with gprof.
lixianyu 0:d8f4c441e032 6 Does not write any data, but uses a buffer.
lixianyu 0:d8f4c441e032 7
lixianyu 0:d8f4c441e032 8 Universal 8bit Graphics Library
lixianyu 0:d8f4c441e032 9
lixianyu 0:d8f4c441e032 10 Copyright (c) 2011, olikraus@gmail.com
lixianyu 0:d8f4c441e032 11 All rights reserved.
lixianyu 0:d8f4c441e032 12
lixianyu 0:d8f4c441e032 13 Redistribution and use in source and binary forms, with or without modification,
lixianyu 0:d8f4c441e032 14 are permitted provided that the following conditions are met:
lixianyu 0:d8f4c441e032 15
lixianyu 0:d8f4c441e032 16 * Redistributions of source code must retain the above copyright notice, this list
lixianyu 0:d8f4c441e032 17 of conditions and the following disclaimer.
lixianyu 0:d8f4c441e032 18
lixianyu 0:d8f4c441e032 19 * Redistributions in binary form must reproduce the above copyright notice, this
lixianyu 0:d8f4c441e032 20 list of conditions and the following disclaimer in the documentation and/or other
lixianyu 0:d8f4c441e032 21 materials provided with the distribution.
lixianyu 0:d8f4c441e032 22
lixianyu 0:d8f4c441e032 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
lixianyu 0:d8f4c441e032 24 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
lixianyu 0:d8f4c441e032 25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
lixianyu 0:d8f4c441e032 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lixianyu 0:d8f4c441e032 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
lixianyu 0:d8f4c441e032 28 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
lixianyu 0:d8f4c441e032 29 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
lixianyu 0:d8f4c441e032 30 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
lixianyu 0:d8f4c441e032 31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
lixianyu 0:d8f4c441e032 32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
lixianyu 0:d8f4c441e032 33 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
lixianyu 0:d8f4c441e032 34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
lixianyu 0:d8f4c441e032 35 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lixianyu 0:d8f4c441e032 36
lixianyu 0:d8f4c441e032 37
lixianyu 0:d8f4c441e032 38
lixianyu 0:d8f4c441e032 39 */
lixianyu 0:d8f4c441e032 40
lixianyu 0:d8f4c441e032 41 #include "u8g.h"
lixianyu 0:d8f4c441e032 42
lixianyu 0:d8f4c441e032 43
lixianyu 0:d8f4c441e032 44 #define WIDTH 128
lixianyu 0:d8f4c441e032 45 #define HEIGHT 64
lixianyu 0:d8f4c441e032 46 #define PAGE_HEIGHT 8
lixianyu 0:d8f4c441e032 47
lixianyu 0:d8f4c441e032 48 uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
lixianyu 0:d8f4c441e032 49
lixianyu 0:d8f4c441e032 50 uint8_t u8g_pb_dev_gprof_buf[WIDTH];
lixianyu 0:d8f4c441e032 51 u8g_pb_t u8g_pb_dev_gprof = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_pb_dev_gprof_buf };
lixianyu 0:d8f4c441e032 52
lixianyu 0:d8f4c441e032 53 u8g_dev_t u8g_dev_gprof = { u8g_dev_gprof_fn, &u8g_pb_dev_gprof, NULL };
lixianyu 0:d8f4c441e032 54
lixianyu 0:d8f4c441e032 55 uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
lixianyu 0:d8f4c441e032 56 {
lixianyu 0:d8f4c441e032 57 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
lixianyu 0:d8f4c441e032 58
lixianyu 0:d8f4c441e032 59 switch(msg)
lixianyu 0:d8f4c441e032 60 {
lixianyu 0:d8f4c441e032 61 case U8G_DEV_MSG_INIT:
lixianyu 0:d8f4c441e032 62 break;
lixianyu 0:d8f4c441e032 63 case U8G_DEV_MSG_STOP:
lixianyu 0:d8f4c441e032 64 break;
lixianyu 0:d8f4c441e032 65 case U8G_DEV_MSG_PAGE_FIRST:
lixianyu 0:d8f4c441e032 66 u8g_pb_Clear(pb);
lixianyu 0:d8f4c441e032 67 u8g_page_First(&(pb->p));
lixianyu 0:d8f4c441e032 68 break;
lixianyu 0:d8f4c441e032 69 case U8G_DEV_MSG_PAGE_NEXT:
lixianyu 0:d8f4c441e032 70 /*
lixianyu 0:d8f4c441e032 71 {
lixianyu 0:d8f4c441e032 72 uint8_t i, j;
lixianyu 0:d8f4c441e032 73 uint8_t page_height;
lixianyu 0:d8f4c441e032 74 page_height = pb->p.page_y1;
lixianyu 0:d8f4c441e032 75 page_height -= pb->p.page_y0;
lixianyu 0:d8f4c441e032 76 page_height++;
lixianyu 0:d8f4c441e032 77 for( j = 0; j < page_height; j++ )
lixianyu 0:d8f4c441e032 78 {
lixianyu 0:d8f4c441e032 79 printf("%02d ", j);
lixianyu 0:d8f4c441e032 80 for( i = 0; i < WIDTH; i++ )
lixianyu 0:d8f4c441e032 81 {
lixianyu 0:d8f4c441e032 82 if ( (u8g_pb_dev_stdout_buf[i] & (1<<j)) != 0 )
lixianyu 0:d8f4c441e032 83 printf("#");
lixianyu 0:d8f4c441e032 84 else
lixianyu 0:d8f4c441e032 85 printf(".");
lixianyu 0:d8f4c441e032 86 }
lixianyu 0:d8f4c441e032 87 printf("\n");
lixianyu 0:d8f4c441e032 88 }
lixianyu 0:d8f4c441e032 89 }
lixianyu 0:d8f4c441e032 90 */
lixianyu 0:d8f4c441e032 91 if ( u8g_page_Next(&(pb->p)) == 0 )
lixianyu 0:d8f4c441e032 92 {
lixianyu 0:d8f4c441e032 93 //printf("\n");
lixianyu 0:d8f4c441e032 94 return 0;
lixianyu 0:d8f4c441e032 95 }
lixianyu 0:d8f4c441e032 96 u8g_pb_Clear(pb);
lixianyu 0:d8f4c441e032 97 break;
lixianyu 0:d8f4c441e032 98 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
lixianyu 0:d8f4c441e032 99 case U8G_DEV_MSG_IS_BBX_INTERSECTION:
lixianyu 0:d8f4c441e032 100 {
lixianyu 0:d8f4c441e032 101 u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
lixianyu 0:d8f4c441e032 102 u8g_uint_t x2, y2;
lixianyu 0:d8f4c441e032 103
lixianyu 0:d8f4c441e032 104 y2 = bbx->y;
lixianyu 0:d8f4c441e032 105 y2 += bbx->h;
lixianyu 0:d8f4c441e032 106 y2--;
lixianyu 0:d8f4c441e032 107
lixianyu 0:d8f4c441e032 108 if ( u8g_pb_IsYIntersection(pb, bbx->y, y2) == 0 )
lixianyu 0:d8f4c441e032 109 return 0;
lixianyu 0:d8f4c441e032 110
lixianyu 0:d8f4c441e032 111 /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
lixianyu 0:d8f4c441e032 112 x2 = bbx->x;
lixianyu 0:d8f4c441e032 113 x2 += bbx->w;
lixianyu 0:d8f4c441e032 114 x2--;
lixianyu 0:d8f4c441e032 115
lixianyu 0:d8f4c441e032 116 if ( u8g_pb_IsXIntersection(pb, bbx->x, x2) == 0 )
lixianyu 0:d8f4c441e032 117 return 0;
lixianyu 0:d8f4c441e032 118 }
lixianyu 0:d8f4c441e032 119 return 1;
lixianyu 0:d8f4c441e032 120 #endif
lixianyu 0:d8f4c441e032 121 case U8G_DEV_MSG_GET_PAGE_BOX:
lixianyu 0:d8f4c441e032 122 u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
lixianyu 0:d8f4c441e032 123 break;
lixianyu 0:d8f4c441e032 124 case U8G_DEV_MSG_SET_COLOR_ENTRY:
lixianyu 0:d8f4c441e032 125 break;
lixianyu 0:d8f4c441e032 126 case U8G_DEV_MSG_SET_XY_CB:
lixianyu 0:d8f4c441e032 127 break;
lixianyu 0:d8f4c441e032 128 }
lixianyu 0:d8f4c441e032 129 return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
lixianyu 0:d8f4c441e032 130 }
lixianyu 0:d8f4c441e032 131