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_bitmap.c
iforce2d 0:972874f31c98 4
iforce2d 0:972874f31c98 5 Universal 8bit Graphics Library
iforce2d 0:972874f31c98 6
iforce2d 0:972874f31c98 7 Copyright (c) 2011, olikraus@gmail.com
iforce2d 0:972874f31c98 8 All rights reserved.
iforce2d 0:972874f31c98 9
iforce2d 0:972874f31c98 10 Redistribution and use in source and binary forms, with or without modification,
iforce2d 0:972874f31c98 11 are permitted provided that the following conditions are met:
iforce2d 0:972874f31c98 12
iforce2d 0:972874f31c98 13 * Redistributions of source code must retain the above copyright notice, this list
iforce2d 0:972874f31c98 14 of conditions and the following disclaimer.
iforce2d 0:972874f31c98 15
iforce2d 0:972874f31c98 16 * Redistributions in binary form must reproduce the above copyright notice, this
iforce2d 0:972874f31c98 17 list of conditions and the following disclaimer in the documentation and/or other
iforce2d 0:972874f31c98 18 materials provided with the distribution.
iforce2d 0:972874f31c98 19
iforce2d 0:972874f31c98 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
iforce2d 0:972874f31c98 21 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
iforce2d 0:972874f31c98 22 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iforce2d 0:972874f31c98 23 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
iforce2d 0:972874f31c98 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
iforce2d 0:972874f31c98 25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
iforce2d 0:972874f31c98 26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iforce2d 0:972874f31c98 27 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
iforce2d 0:972874f31c98 28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
iforce2d 0:972874f31c98 29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
iforce2d 0:972874f31c98 30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
iforce2d 0:972874f31c98 31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
iforce2d 0:972874f31c98 32 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iforce2d 0:972874f31c98 33
iforce2d 0:972874f31c98 34
iforce2d 0:972874f31c98 35 */
iforce2d 0:972874f31c98 36
iforce2d 0:972874f31c98 37 #include "u8g.h"
iforce2d 0:972874f31c98 38
iforce2d 0:972874f31c98 39 void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
iforce2d 0:972874f31c98 40 {
iforce2d 0:972874f31c98 41 while( cnt > 0 )
iforce2d 0:972874f31c98 42 {
iforce2d 0:972874f31c98 43 u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
iforce2d 0:972874f31c98 44 bitmap++;
iforce2d 0:972874f31c98 45 cnt--;
iforce2d 0:972874f31c98 46 x+=8;
iforce2d 0:972874f31c98 47 }
iforce2d 0:972874f31c98 48 }
iforce2d 0:972874f31c98 49
iforce2d 0:972874f31c98 50 void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
iforce2d 0:972874f31c98 51 {
iforce2d 0:972874f31c98 52 if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
iforce2d 0:972874f31c98 53 return;
iforce2d 0:972874f31c98 54 while( h > 0 )
iforce2d 0:972874f31c98 55 {
iforce2d 0:972874f31c98 56 u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
iforce2d 0:972874f31c98 57 bitmap += cnt;
iforce2d 0:972874f31c98 58 y++;
iforce2d 0:972874f31c98 59 h--;
iforce2d 0:972874f31c98 60 }
iforce2d 0:972874f31c98 61 }
iforce2d 0:972874f31c98 62
iforce2d 0:972874f31c98 63
iforce2d 0:972874f31c98 64 void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
iforce2d 0:972874f31c98 65 {
iforce2d 0:972874f31c98 66 while( cnt > 0 )
iforce2d 0:972874f31c98 67 {
iforce2d 0:972874f31c98 68 u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
iforce2d 0:972874f31c98 69 bitmap++;
iforce2d 0:972874f31c98 70 cnt--;
iforce2d 0:972874f31c98 71 x+=8;
iforce2d 0:972874f31c98 72 }
iforce2d 0:972874f31c98 73 }
iforce2d 0:972874f31c98 74
iforce2d 0:972874f31c98 75 void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
iforce2d 0:972874f31c98 76 {
iforce2d 0:972874f31c98 77 if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
iforce2d 0:972874f31c98 78 return;
iforce2d 0:972874f31c98 79 while( h > 0 )
iforce2d 0:972874f31c98 80 {
iforce2d 0:972874f31c98 81 u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
iforce2d 0:972874f31c98 82 bitmap += cnt;
iforce2d 0:972874f31c98 83 y++;
iforce2d 0:972874f31c98 84 h--;
iforce2d 0:972874f31c98 85 }
iforce2d 0:972874f31c98 86 }
iforce2d 0:972874f31c98 87
iforce2d 0:972874f31c98 88 /*=========================================================================*/
iforce2d 0:972874f31c98 89
iforce2d 0:972874f31c98 90 static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
iforce2d 0:972874f31c98 91 {
iforce2d 0:972874f31c98 92 uint8_t d;
iforce2d 0:972874f31c98 93 x+=7;
iforce2d 0:972874f31c98 94 while( w >= 8 )
iforce2d 0:972874f31c98 95 {
iforce2d 0:972874f31c98 96 u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
iforce2d 0:972874f31c98 97 bitmap++;
iforce2d 0:972874f31c98 98 w-= 8;
iforce2d 0:972874f31c98 99 x+=8;
iforce2d 0:972874f31c98 100 }
iforce2d 0:972874f31c98 101 if ( w > 0 )
iforce2d 0:972874f31c98 102 {
iforce2d 0:972874f31c98 103 d = *bitmap;
iforce2d 0:972874f31c98 104 x -= 7;
iforce2d 0:972874f31c98 105 do
iforce2d 0:972874f31c98 106 {
iforce2d 0:972874f31c98 107 if ( d & 1 )
iforce2d 0:972874f31c98 108 u8g_DrawPixel(u8g, x, y);
iforce2d 0:972874f31c98 109 x++;
iforce2d 0:972874f31c98 110 w--;
iforce2d 0:972874f31c98 111 d >>= 1;
iforce2d 0:972874f31c98 112 } while ( w > 0 );
iforce2d 0:972874f31c98 113 }
iforce2d 0:972874f31c98 114 }
iforce2d 0:972874f31c98 115
iforce2d 0:972874f31c98 116 void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
iforce2d 0:972874f31c98 117 {
iforce2d 0:972874f31c98 118 u8g_uint_t b;
iforce2d 0:972874f31c98 119 b = w;
iforce2d 0:972874f31c98 120 b += 7;
iforce2d 0:972874f31c98 121 b >>= 3;
iforce2d 0:972874f31c98 122
iforce2d 0:972874f31c98 123 if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
iforce2d 0:972874f31c98 124 return;
iforce2d 0:972874f31c98 125
iforce2d 0:972874f31c98 126 while( h > 0 )
iforce2d 0:972874f31c98 127 {
iforce2d 0:972874f31c98 128 u8g_DrawHXBM(u8g, x, y, w, bitmap);
iforce2d 0:972874f31c98 129 bitmap += b;
iforce2d 0:972874f31c98 130 y++;
iforce2d 0:972874f31c98 131 h--;
iforce2d 0:972874f31c98 132 }
iforce2d 0:972874f31c98 133 }
iforce2d 0:972874f31c98 134
iforce2d 0:972874f31c98 135 static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
iforce2d 0:972874f31c98 136 {
iforce2d 0:972874f31c98 137 uint8_t d;
iforce2d 0:972874f31c98 138 x+=7;
iforce2d 0:972874f31c98 139 while( w >= 8 )
iforce2d 0:972874f31c98 140 {
iforce2d 0:972874f31c98 141 u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
iforce2d 0:972874f31c98 142 bitmap++;
iforce2d 0:972874f31c98 143 w-= 8;
iforce2d 0:972874f31c98 144 x+=8;
iforce2d 0:972874f31c98 145 }
iforce2d 0:972874f31c98 146 if ( w > 0 )
iforce2d 0:972874f31c98 147 {
iforce2d 0:972874f31c98 148 d = u8g_pgm_read(bitmap);
iforce2d 0:972874f31c98 149 x -= 7;
iforce2d 0:972874f31c98 150 do
iforce2d 0:972874f31c98 151 {
iforce2d 0:972874f31c98 152 if ( d & 1 )
iforce2d 0:972874f31c98 153 u8g_DrawPixel(u8g, x, y);
iforce2d 0:972874f31c98 154 x++;
iforce2d 0:972874f31c98 155 w--;
iforce2d 0:972874f31c98 156 d >>= 1;
iforce2d 0:972874f31c98 157 } while ( w > 0 );
iforce2d 0:972874f31c98 158 }
iforce2d 0:972874f31c98 159 }
iforce2d 0:972874f31c98 160
iforce2d 0:972874f31c98 161 void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
iforce2d 0:972874f31c98 162 {
iforce2d 0:972874f31c98 163 u8g_uint_t b;
iforce2d 0:972874f31c98 164 b = w;
iforce2d 0:972874f31c98 165 b += 7;
iforce2d 0:972874f31c98 166 b >>= 3;
iforce2d 0:972874f31c98 167
iforce2d 0:972874f31c98 168 if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
iforce2d 0:972874f31c98 169 return;
iforce2d 0:972874f31c98 170 while( h > 0 )
iforce2d 0:972874f31c98 171 {
iforce2d 0:972874f31c98 172 u8g_DrawHXBMP(u8g, x, y, w, bitmap);
iforce2d 0:972874f31c98 173 bitmap += b;
iforce2d 0:972874f31c98 174 y++;
iforce2d 0:972874f31c98 175 h--;
iforce2d 0:972874f31c98 176 }
iforce2d 0:972874f31c98 177 }
iforce2d 0:972874f31c98 178