Displays distance to start location on OLED screen.

Dependencies:   mbed

Committer:
iforce2d
Date:
Wed Mar 07 12:49:14 2018 +0000
Revision:
0:972874f31c98
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iforce2d 0:972874f31c98 1 /*
iforce2d 0:972874f31c98 2
iforce2d 0:972874f31c98 3 u8g_dev_flipdisc.c
iforce2d 0:972874f31c98 4
iforce2d 0:972874f31c98 5 1-Bit (BW) Driver for flip disc matrix
iforce2d 0:972874f31c98 6 2x 7 pixel height
iforce2d 0:972874f31c98 7
iforce2d 0:972874f31c98 8 Universal 8bit Graphics Library
iforce2d 0:972874f31c98 9
iforce2d 0:972874f31c98 10 Copyright (c) 2011, olikraus@gmail.com
iforce2d 0:972874f31c98 11 All rights reserved.
iforce2d 0:972874f31c98 12
iforce2d 0:972874f31c98 13 Redistribution and use in source and binary forms, with or without modification,
iforce2d 0:972874f31c98 14 are permitted provided that the following conditions are met:
iforce2d 0:972874f31c98 15
iforce2d 0:972874f31c98 16 * Redistributions of source code must retain the above copyright notice, this list
iforce2d 0:972874f31c98 17 of conditions and the following disclaimer.
iforce2d 0:972874f31c98 18
iforce2d 0:972874f31c98 19 * Redistributions in binary form must reproduce the above copyright notice, this
iforce2d 0:972874f31c98 20 list of conditions and the following disclaimer in the documentation and/or other
iforce2d 0:972874f31c98 21 materials provided with the distribution.
iforce2d 0:972874f31c98 22
iforce2d 0:972874f31c98 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
iforce2d 0:972874f31c98 24 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
iforce2d 0:972874f31c98 25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iforce2d 0:972874f31c98 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
iforce2d 0:972874f31c98 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
iforce2d 0:972874f31c98 28 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
iforce2d 0:972874f31c98 29 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iforce2d 0:972874f31c98 30 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
iforce2d 0:972874f31c98 31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
iforce2d 0:972874f31c98 32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
iforce2d 0:972874f31c98 33 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
iforce2d 0:972874f31c98 34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
iforce2d 0:972874f31c98 35 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iforce2d 0:972874f31c98 36
iforce2d 0:972874f31c98 37 */
iforce2d 0:972874f31c98 38
iforce2d 0:972874f31c98 39 #include "u8g.h"
iforce2d 0:972874f31c98 40
iforce2d 0:972874f31c98 41 #define WIDTH 28
iforce2d 0:972874f31c98 42 #define HEIGHT 14
iforce2d 0:972874f31c98 43 #define PAGE_HEIGHT 14
iforce2d 0:972874f31c98 44
iforce2d 0:972874f31c98 45 /*
iforce2d 0:972874f31c98 46 Write data to the flip disc matrix.
iforce2d 0:972874f31c98 47 This procedure must be implemented by the user.
iforce2d 0:972874f31c98 48 Arguments:
iforce2d 0:972874f31c98 49 id: Id for the matrix. Currently always 0.
iforce2d 0:972874f31c98 50 page: A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
iforce2d 0:972874f31c98 51 width: The width of the flip disc matrix. Always equal to WIDTH
iforce2d 0:972874f31c98 52 row1: first data line (7 pixel per byte)
iforce2d 0:972874f31c98 53 row2: first data line (7 pixel per byte)
iforce2d 0:972874f31c98 54 */
iforce2d 0:972874f31c98 55 void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
iforce2d 0:972874f31c98 56
iforce2d 0:972874f31c98 57
iforce2d 0:972874f31c98 58
iforce2d 0:972874f31c98 59 void (*u8g_write_flip_disc_matrix)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
iforce2d 0:972874f31c98 60
iforce2d 0:972874f31c98 61 void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2))
iforce2d 0:972874f31c98 62 {
iforce2d 0:972874f31c98 63 u8g_write_flip_disc_matrix = cb;
iforce2d 0:972874f31c98 64 }
iforce2d 0:972874f31c98 65
iforce2d 0:972874f31c98 66 uint8_t u8g_dev_flipdisc_2x7_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
iforce2d 0:972874f31c98 67 {
iforce2d 0:972874f31c98 68 switch(msg)
iforce2d 0:972874f31c98 69 {
iforce2d 0:972874f31c98 70 case U8G_DEV_MSG_INIT:
iforce2d 0:972874f31c98 71 break;
iforce2d 0:972874f31c98 72 case U8G_DEV_MSG_STOP:
iforce2d 0:972874f31c98 73 break;
iforce2d 0:972874f31c98 74 case U8G_DEV_MSG_PAGE_NEXT:
iforce2d 0:972874f31c98 75 {
iforce2d 0:972874f31c98 76 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
iforce2d 0:972874f31c98 77
iforce2d 0:972874f31c98 78 /* current page: pb->p.page */
iforce2d 0:972874f31c98 79 /* ptr to the buffer: pb->buf */
iforce2d 0:972874f31c98 80
iforce2d 0:972874f31c98 81 (*u8g_write_flip_disc_matrix)(0, pb->p.page, WIDTH, pb->buf, (uint8_t *)(pb->buf)+WIDTH);
iforce2d 0:972874f31c98 82 }
iforce2d 0:972874f31c98 83 break;
iforce2d 0:972874f31c98 84 case U8G_DEV_MSG_CONTRAST:
iforce2d 0:972874f31c98 85 return 1;
iforce2d 0:972874f31c98 86 }
iforce2d 0:972874f31c98 87 return u8g_dev_pb14v1_base_fn(u8g, dev, msg, arg);
iforce2d 0:972874f31c98 88 }
iforce2d 0:972874f31c98 89
iforce2d 0:972874f31c98 90 uint8_t u8g_dev_flipdisc_2x7_bw_buf[WIDTH*2] U8G_NOCOMMON ;
iforce2d 0:972874f31c98 91 u8g_pb_t u8g_dev_flipdisc_2x7_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_flipdisc_2x7_bw_buf};
iforce2d 0:972874f31c98 92 u8g_dev_t u8g_dev_flipdisc_2x7 = { u8g_dev_flipdisc_2x7_bw_fn, &u8g_dev_flipdisc_2x7_bw_pb, u8g_com_null_fn };
iforce2d 0:972874f31c98 93