iforce2d Chris / Mbed 2 deprecated ubxDistanceMeter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers u8g_cursor.c Source File

u8g_cursor.c

00001 /*
00002 
00003   u8g_cursor.c
00004 
00005   Universal 8bit Graphics Library
00006   
00007   Copyright (c) 2011, olikraus@gmail.com
00008   All rights reserved.
00009 
00010   Redistribution and use in source and binary forms, with or without modification, 
00011   are permitted provided that the following conditions are met:
00012 
00013   * Redistributions of source code must retain the above copyright notice, this list 
00014     of conditions and the following disclaimer.
00015     
00016   * Redistributions in binary form must reproduce the above copyright notice, this 
00017     list of conditions and the following disclaimer in the documentation and/or other 
00018     materials provided with the distribution.
00019 
00020   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00021   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00022   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00023   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00024   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00025   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00026   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
00027   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00028   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00029   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00030   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00031   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00032   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00033   
00034   
00035 */
00036 
00037 #include "u8g.h"
00038 
00039 void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font)
00040 {
00041   u8g->cursor_font = cursor_font;
00042 }
00043 
00044 void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding)
00045 {
00046   u8g->cursor_encoding = encoding;
00047 }
00048 
00049 void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg)
00050 {
00051   u8g->cursor_bg_color = bg;
00052   u8g->cursor_fg_color = fg;
00053 }
00054 
00055 void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y)
00056 {
00057   u8g->cursor_x = cursor_x;
00058   u8g->cursor_y = cursor_y;
00059 }
00060 
00061 void u8g_EnableCursor(u8g_t *u8g)
00062 {
00063     u8g->cursor_fn = u8g_DrawCursor;
00064 }
00065 
00066 void u8g_DisableCursor(u8g_t *u8g)
00067 {
00068     u8g->cursor_fn = (u8g_draw_cursor_fn)0;
00069 }
00070 
00071 void u8g_DrawCursor(u8g_t *u8g)
00072 {
00073   const u8g_pgm_uint8_t *font;
00074   uint8_t color;
00075   uint8_t encoding = u8g->cursor_encoding;
00076   
00077   /* get current values */
00078   color = u8g_GetColorIndex(u8g);
00079   font = u8g->font;
00080   
00081   /* draw cursor */
00082   u8g->font = u8g->cursor_font;  
00083   encoding++;
00084   u8g_SetColorIndex(u8g, u8g->cursor_bg_color); 
00085   /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
00086   /* required, because y adjustment should not happen to the cursor fonts */
00087   u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
00088   encoding--;
00089   u8g_SetColorIndex(u8g, u8g->cursor_fg_color); 
00090   /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
00091   /* required, because y adjustment should not happen to the cursor fonts */
00092   /* u8g_DrawGlyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); */
00093   u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
00094   
00095   /* restore previous values */
00096   u8g->font = font;
00097   u8g_SetColorIndex(u8g, color); 
00098 }
00099 
00100