iforce2d Chris / Mbed 2 deprecated ubxDistanceMeter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers u8g_dev_gprof.c Source File

u8g_dev_gprof.c

00001 /*
00002 
00003   u8g_dev_gprof.c
00004 
00005   Device for performance measurement with gprof.
00006   Does not write any data, but uses a buffer.
00007 
00008   Universal 8bit Graphics Library
00009   
00010   Copyright (c) 2011, olikraus@gmail.com
00011   All rights reserved.
00012 
00013   Redistribution and use in source and binary forms, with or without modification, 
00014   are permitted provided that the following conditions are met:
00015 
00016   * Redistributions of source code must retain the above copyright notice, this list 
00017     of conditions and the following disclaimer.
00018     
00019   * Redistributions in binary form must reproduce the above copyright notice, this 
00020     list of conditions and the following disclaimer in the documentation and/or other 
00021     materials provided with the distribution.
00022 
00023   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00024   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00025   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00026   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00027   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00028   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00029   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
00030   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00031   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00032   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00033   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00034   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00035   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00036   
00037   
00038 
00039 */
00040 
00041 #include "u8g.h"
00042 
00043 
00044 #define WIDTH 128
00045 #define HEIGHT 64
00046 #define PAGE_HEIGHT 8
00047 
00048 uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00049 
00050 uint8_t u8g_pb_dev_gprof_buf[WIDTH];
00051 u8g_pb_t u8g_pb_dev_gprof = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_pb_dev_gprof_buf };
00052 
00053 u8g_dev_t u8g_dev_gprof = { u8g_dev_gprof_fn, &u8g_pb_dev_gprof, NULL };
00054 
00055 uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
00056 {
00057   u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
00058   
00059   switch(msg)
00060   {
00061     case U8G_DEV_MSG_INIT:
00062       break;
00063     case U8G_DEV_MSG_STOP:
00064       break;
00065     case U8G_DEV_MSG_PAGE_FIRST:
00066       u8g_pb_Clear(pb);
00067       u8g_page_First(&(pb->p));
00068       break;
00069     case U8G_DEV_MSG_PAGE_NEXT:
00070       /*
00071       {
00072         uint8_t i, j;
00073         uint8_t page_height;
00074         page_height = pb->p.page_y1;
00075         page_height -= pb->p.page_y0;
00076         page_height++;
00077         for( j = 0; j < page_height; j++ )
00078         {
00079           printf("%02d ", j);
00080           for( i = 0; i < WIDTH; i++ )
00081           {
00082             if ( (u8g_pb_dev_stdout_buf[i] & (1<<j)) != 0 )
00083               printf("#");
00084             else
00085               printf(".");
00086           }
00087           printf("\n");
00088         }
00089       }
00090       */
00091       if ( u8g_page_Next(&(pb->p)) == 0 )
00092       {
00093         //printf("\n");
00094         return 0;
00095       }
00096       u8g_pb_Clear(pb);
00097       break;
00098 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
00099     case U8G_DEV_MSG_IS_BBX_INTERSECTION:
00100        {
00101         u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
00102         u8g_uint_t x2, y2;
00103 
00104         y2 = bbx->y;
00105         y2 += bbx->h;
00106         y2--;
00107         
00108         if ( u8g_pb_IsYIntersection(pb, bbx->y, y2) == 0 )
00109           return 0;
00110         
00111         /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
00112         x2 = bbx->x;
00113         x2 += bbx->w;
00114         x2--;
00115         
00116         if ( u8g_pb_IsXIntersection(pb, bbx->x, x2) == 0 )
00117           return 0;
00118       }
00119       return 1;
00120 #endif
00121     case U8G_DEV_MSG_GET_PAGE_BOX:
00122       u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
00123       break;
00124     case U8G_DEV_MSG_SET_COLOR_ENTRY:
00125       break;
00126     case U8G_DEV_MSG_SET_XY_CB:
00127       break;
00128   }
00129   return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
00130 }
00131