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_u16toa.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_u16toa.c |
| lixianyu | 0:d8f4c441e032 | 4 | |
| lixianyu | 0:d8f4c441e032 | 5 | |
| lixianyu | 0:d8f4c441e032 | 6 | Universal 8bit Graphics Library |
| lixianyu | 0:d8f4c441e032 | 7 | |
| lixianyu | 0:d8f4c441e032 | 8 | Copyright (c) 2012, olikraus@gmail.com |
| lixianyu | 0:d8f4c441e032 | 9 | All rights reserved. |
| lixianyu | 0:d8f4c441e032 | 10 | |
| lixianyu | 0:d8f4c441e032 | 11 | Redistribution and use in source and binary forms, with or without modification, |
| lixianyu | 0:d8f4c441e032 | 12 | are permitted provided that the following conditions are met: |
| lixianyu | 0:d8f4c441e032 | 13 | |
| lixianyu | 0:d8f4c441e032 | 14 | * Redistributions of source code must retain the above copyright notice, this list |
| lixianyu | 0:d8f4c441e032 | 15 | of conditions and the following disclaimer. |
| lixianyu | 0:d8f4c441e032 | 16 | |
| lixianyu | 0:d8f4c441e032 | 17 | * Redistributions in binary form must reproduce the above copyright notice, this |
| lixianyu | 0:d8f4c441e032 | 18 | list of conditions and the following disclaimer in the documentation and/or other |
| lixianyu | 0:d8f4c441e032 | 19 | materials provided with the distribution. |
| lixianyu | 0:d8f4c441e032 | 20 | |
| lixianyu | 0:d8f4c441e032 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| lixianyu | 0:d8f4c441e032 | 22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| lixianyu | 0:d8f4c441e032 | 23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| lixianyu | 0:d8f4c441e032 | 24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| lixianyu | 0:d8f4c441e032 | 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| lixianyu | 0:d8f4c441e032 | 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| lixianyu | 0:d8f4c441e032 | 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| lixianyu | 0:d8f4c441e032 | 28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| lixianyu | 0:d8f4c441e032 | 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| lixianyu | 0:d8f4c441e032 | 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| lixianyu | 0:d8f4c441e032 | 31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| lixianyu | 0:d8f4c441e032 | 32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| lixianyu | 0:d8f4c441e032 | 33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| lixianyu | 0:d8f4c441e032 | 34 | |
| lixianyu | 0:d8f4c441e032 | 35 | */ |
| lixianyu | 0:d8f4c441e032 | 36 | |
| lixianyu | 0:d8f4c441e032 | 37 | |
| lixianyu | 0:d8f4c441e032 | 38 | #include "u8g.h" |
| lixianyu | 0:d8f4c441e032 | 39 | |
| lixianyu | 0:d8f4c441e032 | 40 | const char *u8g_u16toap(char * dest, uint16_t v) |
| lixianyu | 0:d8f4c441e032 | 41 | { |
| lixianyu | 0:d8f4c441e032 | 42 | uint8_t pos; |
| lixianyu | 0:d8f4c441e032 | 43 | uint8_t d; |
| lixianyu | 0:d8f4c441e032 | 44 | uint16_t c; |
| lixianyu | 0:d8f4c441e032 | 45 | c = 10000; |
| lixianyu | 0:d8f4c441e032 | 46 | for( pos = 0; pos < 5; pos++ ) |
| lixianyu | 0:d8f4c441e032 | 47 | { |
| lixianyu | 0:d8f4c441e032 | 48 | d = '0'; |
| lixianyu | 0:d8f4c441e032 | 49 | while( v >= c ) |
| lixianyu | 0:d8f4c441e032 | 50 | { |
| lixianyu | 0:d8f4c441e032 | 51 | v -= c; |
| lixianyu | 0:d8f4c441e032 | 52 | d++; |
| lixianyu | 0:d8f4c441e032 | 53 | } |
| lixianyu | 0:d8f4c441e032 | 54 | dest[pos] = d; |
| lixianyu | 0:d8f4c441e032 | 55 | c /= 10; |
| lixianyu | 0:d8f4c441e032 | 56 | } |
| lixianyu | 0:d8f4c441e032 | 57 | dest[5] = '\0'; |
| lixianyu | 0:d8f4c441e032 | 58 | return dest; |
| lixianyu | 0:d8f4c441e032 | 59 | } |
| lixianyu | 0:d8f4c441e032 | 60 | |
| lixianyu | 0:d8f4c441e032 | 61 | /* v = value, d = number of digits */ |
| lixianyu | 0:d8f4c441e032 | 62 | const char *u8g_u16toa(uint16_t v, uint8_t d) |
| lixianyu | 0:d8f4c441e032 | 63 | { |
| lixianyu | 0:d8f4c441e032 | 64 | static char buf[6]; |
| lixianyu | 0:d8f4c441e032 | 65 | d = 5-d; |
| lixianyu | 0:d8f4c441e032 | 66 | return u8g_u16toap(buf, v) + d; |
| lixianyu | 0:d8f4c441e032 | 67 | } |
| lixianyu | 0:d8f4c441e032 | 68 | |
| lixianyu | 0:d8f4c441e032 | 69 |