Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
u8glibARM/u8g_cursor.c@1:0e75de2a5d21, 2016-06-13 (annotated)
- 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?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lixianyu | 0:d8f4c441e032 | 1 | /* |
| lixianyu | 0:d8f4c441e032 | 2 | |
| lixianyu | 0:d8f4c441e032 | 3 | u8g_cursor.c |
| lixianyu | 0:d8f4c441e032 | 4 | |
| lixianyu | 0:d8f4c441e032 | 5 | Universal 8bit Graphics Library |
| lixianyu | 0:d8f4c441e032 | 6 | |
| lixianyu | 0:d8f4c441e032 | 7 | Copyright (c) 2011, olikraus@gmail.com |
| lixianyu | 0:d8f4c441e032 | 8 | All rights reserved. |
| lixianyu | 0:d8f4c441e032 | 9 | |
| lixianyu | 0:d8f4c441e032 | 10 | Redistribution and use in source and binary forms, with or without modification, |
| lixianyu | 0:d8f4c441e032 | 11 | are permitted provided that the following conditions are met: |
| lixianyu | 0:d8f4c441e032 | 12 | |
| lixianyu | 0:d8f4c441e032 | 13 | * Redistributions of source code must retain the above copyright notice, this list |
| lixianyu | 0:d8f4c441e032 | 14 | of conditions and the following disclaimer. |
| lixianyu | 0:d8f4c441e032 | 15 | |
| lixianyu | 0:d8f4c441e032 | 16 | * Redistributions in binary form must reproduce the above copyright notice, this |
| lixianyu | 0:d8f4c441e032 | 17 | list of conditions and the following disclaimer in the documentation and/or other |
| lixianyu | 0:d8f4c441e032 | 18 | materials provided with the distribution. |
| lixianyu | 0:d8f4c441e032 | 19 | |
| lixianyu | 0:d8f4c441e032 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| lixianyu | 0:d8f4c441e032 | 21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| lixianyu | 0:d8f4c441e032 | 22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| lixianyu | 0:d8f4c441e032 | 23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| lixianyu | 0:d8f4c441e032 | 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| lixianyu | 0:d8f4c441e032 | 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| lixianyu | 0:d8f4c441e032 | 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| lixianyu | 0:d8f4c441e032 | 27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| lixianyu | 0:d8f4c441e032 | 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| lixianyu | 0:d8f4c441e032 | 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| lixianyu | 0:d8f4c441e032 | 30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| lixianyu | 0:d8f4c441e032 | 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| lixianyu | 0:d8f4c441e032 | 32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| lixianyu | 0:d8f4c441e032 | 33 | |
| lixianyu | 0:d8f4c441e032 | 34 | |
| lixianyu | 0:d8f4c441e032 | 35 | */ |
| lixianyu | 0:d8f4c441e032 | 36 | |
| lixianyu | 0:d8f4c441e032 | 37 | #include "u8g.h" |
| lixianyu | 0:d8f4c441e032 | 38 | |
| lixianyu | 0:d8f4c441e032 | 39 | void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font) |
| lixianyu | 0:d8f4c441e032 | 40 | { |
| lixianyu | 0:d8f4c441e032 | 41 | u8g->cursor_font = cursor_font; |
| lixianyu | 0:d8f4c441e032 | 42 | } |
| lixianyu | 0:d8f4c441e032 | 43 | |
| lixianyu | 0:d8f4c441e032 | 44 | void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding) |
| lixianyu | 0:d8f4c441e032 | 45 | { |
| lixianyu | 0:d8f4c441e032 | 46 | u8g->cursor_encoding = encoding; |
| lixianyu | 0:d8f4c441e032 | 47 | } |
| lixianyu | 0:d8f4c441e032 | 48 | |
| lixianyu | 0:d8f4c441e032 | 49 | void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg) |
| lixianyu | 0:d8f4c441e032 | 50 | { |
| lixianyu | 0:d8f4c441e032 | 51 | u8g->cursor_bg_color = bg; |
| lixianyu | 0:d8f4c441e032 | 52 | u8g->cursor_fg_color = fg; |
| lixianyu | 0:d8f4c441e032 | 53 | } |
| lixianyu | 0:d8f4c441e032 | 54 | |
| lixianyu | 0:d8f4c441e032 | 55 | void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y) |
| lixianyu | 0:d8f4c441e032 | 56 | { |
| lixianyu | 0:d8f4c441e032 | 57 | u8g->cursor_x = cursor_x; |
| lixianyu | 0:d8f4c441e032 | 58 | u8g->cursor_y = cursor_y; |
| lixianyu | 0:d8f4c441e032 | 59 | } |
| lixianyu | 0:d8f4c441e032 | 60 | |
| lixianyu | 0:d8f4c441e032 | 61 | void u8g_EnableCursor(u8g_t *u8g) |
| lixianyu | 0:d8f4c441e032 | 62 | { |
| lixianyu | 0:d8f4c441e032 | 63 | u8g->cursor_fn = u8g_DrawCursor; |
| lixianyu | 0:d8f4c441e032 | 64 | } |
| lixianyu | 0:d8f4c441e032 | 65 | |
| lixianyu | 0:d8f4c441e032 | 66 | void u8g_DisableCursor(u8g_t *u8g) |
| lixianyu | 0:d8f4c441e032 | 67 | { |
| lixianyu | 0:d8f4c441e032 | 68 | u8g->cursor_fn = (u8g_draw_cursor_fn)0; |
| lixianyu | 0:d8f4c441e032 | 69 | } |
| lixianyu | 0:d8f4c441e032 | 70 | |
| lixianyu | 0:d8f4c441e032 | 71 | void u8g_DrawCursor(u8g_t *u8g) |
| lixianyu | 0:d8f4c441e032 | 72 | { |
| lixianyu | 0:d8f4c441e032 | 73 | const u8g_pgm_uint8_t *font; |
| lixianyu | 0:d8f4c441e032 | 74 | uint8_t color; |
| lixianyu | 0:d8f4c441e032 | 75 | uint8_t encoding = u8g->cursor_encoding; |
| lixianyu | 0:d8f4c441e032 | 76 | |
| lixianyu | 0:d8f4c441e032 | 77 | /* get current values */ |
| lixianyu | 0:d8f4c441e032 | 78 | color = u8g_GetColorIndex(u8g); |
| lixianyu | 0:d8f4c441e032 | 79 | font = u8g->font; |
| lixianyu | 0:d8f4c441e032 | 80 | |
| lixianyu | 0:d8f4c441e032 | 81 | /* draw cursor */ |
| lixianyu | 0:d8f4c441e032 | 82 | u8g->font = u8g->cursor_font; |
| lixianyu | 0:d8f4c441e032 | 83 | encoding++; |
| lixianyu | 0:d8f4c441e032 | 84 | u8g_SetColorIndex(u8g, u8g->cursor_bg_color); |
| lixianyu | 0:d8f4c441e032 | 85 | /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */ |
| lixianyu | 0:d8f4c441e032 | 86 | /* required, because y adjustment should not happen to the cursor fonts */ |
| lixianyu | 0:d8f4c441e032 | 87 | u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); |
| lixianyu | 0:d8f4c441e032 | 88 | encoding--; |
| lixianyu | 0:d8f4c441e032 | 89 | u8g_SetColorIndex(u8g, u8g->cursor_fg_color); |
| lixianyu | 0:d8f4c441e032 | 90 | /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */ |
| lixianyu | 0:d8f4c441e032 | 91 | /* required, because y adjustment should not happen to the cursor fonts */ |
| lixianyu | 0:d8f4c441e032 | 92 | /* u8g_DrawGlyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); */ |
| lixianyu | 0:d8f4c441e032 | 93 | u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); |
| lixianyu | 0:d8f4c441e032 | 94 | |
| lixianyu | 0:d8f4c441e032 | 95 | /* restore previous values */ |
| lixianyu | 0:d8f4c441e032 | 96 | u8g->font = font; |
| lixianyu | 0:d8f4c441e032 | 97 | u8g_SetColorIndex(u8g, color); |
| lixianyu | 0:d8f4c441e032 | 98 | } |
| lixianyu | 0:d8f4c441e032 | 99 | |
| lixianyu | 0:d8f4c441e032 | 100 |