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_dev_flipdisc_2x7.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_dev_flipdisc.c |
| lixianyu | 0:d8f4c441e032 | 4 | |
| lixianyu | 0:d8f4c441e032 | 5 | 1-Bit (BW) Driver for flip disc matrix |
| lixianyu | 0:d8f4c441e032 | 6 | 2x 7 pixel height |
| 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 | #include "u8g.h" |
| lixianyu | 0:d8f4c441e032 | 40 | |
| lixianyu | 0:d8f4c441e032 | 41 | #define WIDTH 28 |
| lixianyu | 0:d8f4c441e032 | 42 | #define HEIGHT 14 |
| lixianyu | 0:d8f4c441e032 | 43 | #define PAGE_HEIGHT 14 |
| lixianyu | 0:d8f4c441e032 | 44 | |
| lixianyu | 0:d8f4c441e032 | 45 | /* |
| lixianyu | 0:d8f4c441e032 | 46 | Write data to the flip disc matrix. |
| lixianyu | 0:d8f4c441e032 | 47 | This procedure must be implemented by the user. |
| lixianyu | 0:d8f4c441e032 | 48 | Arguments: |
| lixianyu | 0:d8f4c441e032 | 49 | id: Id for the matrix. Currently always 0. |
| lixianyu | 0:d8f4c441e032 | 50 | page: A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0 |
| lixianyu | 0:d8f4c441e032 | 51 | width: The width of the flip disc matrix. Always equal to WIDTH |
| lixianyu | 0:d8f4c441e032 | 52 | row1: first data line (7 pixel per byte) |
| lixianyu | 0:d8f4c441e032 | 53 | row2: first data line (7 pixel per byte) |
| lixianyu | 0:d8f4c441e032 | 54 | */ |
| lixianyu | 0:d8f4c441e032 | 55 | void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2); |
| lixianyu | 0:d8f4c441e032 | 56 | |
| lixianyu | 0:d8f4c441e032 | 57 | |
| lixianyu | 0:d8f4c441e032 | 58 | |
| lixianyu | 0:d8f4c441e032 | 59 | void (*u8g_write_flip_disc_matrix)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2); |
| lixianyu | 0:d8f4c441e032 | 60 | |
| lixianyu | 0:d8f4c441e032 | 61 | void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2)) |
| lixianyu | 0:d8f4c441e032 | 62 | { |
| lixianyu | 0:d8f4c441e032 | 63 | u8g_write_flip_disc_matrix = cb; |
| lixianyu | 0:d8f4c441e032 | 64 | } |
| lixianyu | 0:d8f4c441e032 | 65 | |
| lixianyu | 0:d8f4c441e032 | 66 | uint8_t u8g_dev_flipdisc_2x7_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) |
| lixianyu | 0:d8f4c441e032 | 67 | { |
| lixianyu | 0:d8f4c441e032 | 68 | switch(msg) |
| lixianyu | 0:d8f4c441e032 | 69 | { |
| lixianyu | 0:d8f4c441e032 | 70 | case U8G_DEV_MSG_INIT: |
| lixianyu | 0:d8f4c441e032 | 71 | break; |
| lixianyu | 0:d8f4c441e032 | 72 | case U8G_DEV_MSG_STOP: |
| lixianyu | 0:d8f4c441e032 | 73 | break; |
| lixianyu | 0:d8f4c441e032 | 74 | case U8G_DEV_MSG_PAGE_NEXT: |
| lixianyu | 0:d8f4c441e032 | 75 | { |
| lixianyu | 0:d8f4c441e032 | 76 | u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); |
| lixianyu | 0:d8f4c441e032 | 77 | |
| lixianyu | 0:d8f4c441e032 | 78 | /* current page: pb->p.page */ |
| lixianyu | 0:d8f4c441e032 | 79 | /* ptr to the buffer: pb->buf */ |
| lixianyu | 0:d8f4c441e032 | 80 | |
| lixianyu | 0:d8f4c441e032 | 81 | (*u8g_write_flip_disc_matrix)(0, pb->p.page, WIDTH, pb->buf, (uint8_t *)(pb->buf)+WIDTH); |
| lixianyu | 0:d8f4c441e032 | 82 | } |
| lixianyu | 0:d8f4c441e032 | 83 | break; |
| lixianyu | 0:d8f4c441e032 | 84 | case U8G_DEV_MSG_CONTRAST: |
| lixianyu | 0:d8f4c441e032 | 85 | return 1; |
| lixianyu | 0:d8f4c441e032 | 86 | } |
| lixianyu | 0:d8f4c441e032 | 87 | return u8g_dev_pb14v1_base_fn(u8g, dev, msg, arg); |
| lixianyu | 0:d8f4c441e032 | 88 | } |
| lixianyu | 0:d8f4c441e032 | 89 | |
| lixianyu | 0:d8f4c441e032 | 90 | uint8_t u8g_dev_flipdisc_2x7_bw_buf[WIDTH*2] U8G_NOCOMMON ; |
| lixianyu | 0:d8f4c441e032 | 91 | u8g_pb_t u8g_dev_flipdisc_2x7_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_flipdisc_2x7_bw_buf}; |
| lixianyu | 0:d8f4c441e032 | 92 | u8g_dev_t u8g_dev_flipdisc_2x7 = { u8g_dev_flipdisc_2x7_bw_fn, &u8g_dev_flipdisc_2x7_bw_pb, u8g_com_null_fn }; |
| lixianyu | 0:d8f4c441e032 | 93 |