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.
u8g_ll_api.c
00001 /* 00002 00003 u8g_ll_api.c 00004 00005 low level api 00006 00007 Universal 8bit Graphics Library 00008 00009 Copyright (c) 2011, olikraus@gmail.com 00010 All rights reserved. 00011 00012 Redistribution and use in source and binary forms, with or without modification, 00013 are permitted provided that the following conditions are met: 00014 00015 * Redistributions of source code must retain the above copyright notice, this list 00016 of conditions and the following disclaimer. 00017 00018 * Redistributions in binary form must reproduce the above copyright notice, this 00019 list of conditions and the following disclaimer in the documentation and/or other 00020 materials provided with the distribution. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00023 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00024 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00025 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00026 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00027 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00029 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00032 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00033 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00034 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 00036 00037 */ 00038 00039 #include <stddef.h> 00040 #include "u8g.h" 00041 00042 uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) 00043 { 00044 return dev->dev_fn(u8g, dev, msg, arg); 00045 } 00046 00047 /*====================================================================*/ 00048 00049 uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev) 00050 { 00051 uint8_t r; 00052 u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV); 00053 r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL); 00054 u8g->state_cb(U8G_STATE_MSG_BACKUP_U8G); 00055 u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV); 00056 return r; 00057 } 00058 00059 void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev) 00060 { 00061 u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV); 00062 u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G); 00063 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL); 00064 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page)); 00065 u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV); 00066 } 00067 00068 uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev) 00069 { 00070 uint8_t r; 00071 u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV); 00072 u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G); 00073 r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL); 00074 if ( r != 0 ) 00075 { 00076 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page)); 00077 } 00078 u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV); 00079 return r; 00080 } 00081 00082 uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast) 00083 { 00084 return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast); 00085 } 00086 00087 void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y) 00088 { 00089 u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel); 00090 arg->x = x; 00091 arg->y = y; 00092 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg); 00093 } 00094 00095 void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel) 00096 { 00097 u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel); 00098 arg->x = x; 00099 arg->y = y; 00100 arg->dir = dir; 00101 arg->pixel = pixel; 00102 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg); 00103 } 00104 00105 void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel) 00106 { 00107 u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel); 00108 arg->x = x; 00109 arg->y = y; 00110 arg->dir = dir; 00111 arg->pixel = pixel; 00112 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_4TPIXEL, arg); 00113 } 00114 00115 00116 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION 00117 uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) 00118 { 00119 return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg); 00120 } 00121 #endif 00122 00123 00124 00125 u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev) 00126 { 00127 u8g_uint_t r; 00128 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r); 00129 return r; 00130 } 00131 00132 u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev) 00133 { 00134 u8g_uint_t r; 00135 u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r); 00136 return r; 00137 } 00138 00139 u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev) 00140 { 00141 return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL); 00142 } 00143 00144 00145 00146 /*====================================================================*/ 00147 00148 void u8g_UpdateDimension(u8g_t *u8g) 00149 { 00150 u8g->width = u8g_GetWidthLL(u8g, u8g->dev); 00151 u8g->height = u8g_GetHeightLL(u8g, u8g->dev); 00152 u8g->mode = u8g_GetModeLL(u8g, u8g->dev); 00153 /* 9 Dec 2012: u8g_scale.c requires update of current page */ 00154 u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page)); 00155 } 00156 00157 static void u8g_init_data(u8g_t *u8g) 00158 { 00159 u8g->font = NULL; 00160 u8g->cursor_font = NULL; 00161 u8g->cursor_bg_color = 0; 00162 u8g->cursor_fg_color = 1; 00163 u8g->cursor_encoding = 34; 00164 u8g->cursor_fn = (u8g_draw_cursor_fn)0; 00165 00166 #if defined(U8G_WITH_PINLIST) 00167 { 00168 uint8_t i; 00169 for( i = 0; i < U8G_PIN_LIST_LEN; i++ ) 00170 u8g->pin_list[i] = U8G_PIN_NONE; 00171 } 00172 #endif 00173 00174 u8g_SetColorIndex(u8g, 1); 00175 00176 u8g_SetFontPosBaseline(u8g); 00177 00178 u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT; 00179 u8g->font_ref_ascent = 0; 00180 u8g->font_ref_descent = 0; 00181 u8g->font_line_spacing_factor = 64; /* 64 = 1.0, 77 = 1.2 line spacing factor */ 00182 u8g->line_spacing = 0; 00183 00184 u8g->state_cb = u8g_state_dummy_cb; 00185 00186 } 00187 00188 uint8_t u8g_Begin(u8g_t *u8g) 00189 { 00190 /* call and init low level driver and com device */ 00191 if ( u8g_InitLL(u8g, u8g->dev) == 0 ) 00192 return 0; 00193 /* fetch width and height from the low level */ 00194 u8g_UpdateDimension(u8g); 00195 return 1; 00196 } 00197 00198 uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev) 00199 { 00200 u8g_init_data(u8g); 00201 u8g->dev = dev; 00202 00203 /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */ 00204 /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */ 00205 /* if Arduino call u8g_UpdateDimension else u8g_Begin */ 00206 /* issue 146 */ 00207 return u8g_Begin(u8g); 00208 } 00209 00210 /* special init for pure ARM systems */ 00211 uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn) 00212 { 00213 u8g_init_data(u8g); 00214 00215 #if defined(U8G_WITH_PINLIST) 00216 { 00217 uint8_t i; 00218 for( i = 0; i < U8G_PIN_LIST_LEN; i++ ) 00219 u8g->pin_list[i] = U8G_PIN_DUMMY; 00220 } 00221 #endif 00222 00223 u8g->dev = dev; 00224 00225 /* replace the device procedure with a custom communication procedure */ 00226 u8g->dev->com_fn = com_fn; 00227 00228 /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */ 00229 /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */ 00230 /* if Arduino call u8g_UpdateDimension else u8g_Begin */ 00231 /* issue 146 */ 00232 return u8g_Begin(u8g); 00233 } 00234 00235 00236 #if defined(U8G_WITH_PINLIST) 00237 uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset) 00238 { 00239 00240 /* fill data structure with some suitable values */ 00241 u8g_init_data(u8g); 00242 u8g->dev = dev; 00243 00244 /* assign user pins */ 00245 u8g->pin_list[U8G_PI_SCK] = sck; 00246 u8g->pin_list[U8G_PI_MOSI] = mosi; 00247 u8g->pin_list[U8G_PI_CS] = cs; 00248 u8g->pin_list[U8G_PI_A0] = a0; 00249 u8g->pin_list[U8G_PI_RESET] = reset; 00250 00251 /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */ 00252 /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */ 00253 /* if Arduino call u8g_UpdateDimension else u8g_Begin */ 00254 /* issue 146 */ 00255 return u8g_Begin(u8g); 00256 } 00257 00258 uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset) 00259 { 00260 /* fill data structure with some suitable values */ 00261 u8g_init_data(u8g); 00262 u8g->dev = dev; 00263 00264 00265 /* assign user pins */ 00266 u8g->pin_list[U8G_PI_CS] = cs; 00267 u8g->pin_list[U8G_PI_A0] = a0; 00268 u8g->pin_list[U8G_PI_RESET] = reset; 00269 00270 return u8g_Begin(u8g); 00271 } 00272 00273 uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options) 00274 { 00275 /* fill data structure with some suitable values */ 00276 u8g_init_data(u8g); 00277 u8g->dev = dev; 00278 00279 u8g->pin_list[U8G_PI_I2C_OPTION] = options; 00280 00281 return u8g_Begin(u8g); 00282 } 00283 00284 00285 uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset) 00286 { 00287 00288 /* fill data structure with some suitable values */ 00289 u8g_init_data(u8g); 00290 u8g->dev = dev; 00291 00292 /* assign user pins */ 00293 00294 u8g->pin_list[U8G_PI_EN] = en; 00295 u8g->pin_list[U8G_PI_CS] = cs; 00296 u8g->pin_list[U8G_PI_DI] = di; 00297 u8g->pin_list[U8G_PI_RW] = rw; 00298 u8g->pin_list[U8G_PI_RESET] = reset; 00299 00300 return u8g_Begin(u8g); 00301 } 00302 00303 uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 00304 uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset) 00305 { 00306 00307 /* fill data structure with some suitable values */ 00308 u8g_init_data(u8g); 00309 u8g->dev = dev; 00310 00311 /* assign user pins */ 00312 00313 u8g->pin_list[U8G_PI_D0] = d0; 00314 u8g->pin_list[U8G_PI_D1] = d1; 00315 u8g->pin_list[U8G_PI_D2] = d2; 00316 u8g->pin_list[U8G_PI_D3] = d3; 00317 u8g->pin_list[U8G_PI_D4] = d4; 00318 u8g->pin_list[U8G_PI_D5] = d5; 00319 u8g->pin_list[U8G_PI_D6] = d6; 00320 u8g->pin_list[U8G_PI_D7] = d7; 00321 00322 u8g->pin_list[U8G_PI_EN] = en; 00323 u8g->pin_list[U8G_PI_CS1] = cs1; 00324 u8g->pin_list[U8G_PI_CS2] = cs2; 00325 u8g->pin_list[U8G_PI_DI] = di; 00326 u8g->pin_list[U8G_PI_RW] = rw; 00327 u8g->pin_list[U8G_PI_RESET] = reset; 00328 00329 return u8g_Begin(u8g); 00330 } 00331 00332 /* 00333 00334 PIN_D0 8 00335 PIN_D1 9 00336 PIN_D2 10 00337 PIN_D3 11 00338 PIN_D4 4 00339 PIN_D5 5 00340 PIN_D6 6 00341 PIN_D7 7 00342 00343 PIN_CS 14 00344 PIN_A0 15 00345 PIN_RESET 16 00346 PIN_WR 17 00347 PIN_RD 18 00348 00349 u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset) 00350 u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16) 00351 00352 */ 00353 00354 uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 00355 uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset) 00356 { 00357 00358 /* fill data structure with some suitable values */ 00359 u8g_init_data(u8g); 00360 u8g->dev = dev; 00361 00362 /* assign user pins */ 00363 00364 u8g->pin_list[U8G_PI_D0] = d0; 00365 u8g->pin_list[U8G_PI_D1] = d1; 00366 u8g->pin_list[U8G_PI_D2] = d2; 00367 u8g->pin_list[U8G_PI_D3] = d3; 00368 u8g->pin_list[U8G_PI_D4] = d4; 00369 u8g->pin_list[U8G_PI_D5] = d5; 00370 u8g->pin_list[U8G_PI_D6] = d6; 00371 u8g->pin_list[U8G_PI_D7] = d7; 00372 00373 u8g->pin_list[U8G_PI_CS] = cs; 00374 u8g->pin_list[U8G_PI_A0] = a0; 00375 u8g->pin_list[U8G_PI_WR] = wr; 00376 u8g->pin_list[U8G_PI_RD] = rd; 00377 u8g->pin_list[U8G_PI_RESET] = reset; 00378 00379 return u8g_Begin(u8g); 00380 } 00381 #endif /* defined(U8G_WITH_PINLIST) */ 00382 00383 void u8g_FirstPage(u8g_t *u8g) 00384 { 00385 u8g_FirstPageLL(u8g, u8g->dev); 00386 } 00387 00388 uint8_t u8g_NextPage(u8g_t *u8g) 00389 { 00390 if ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 ) 00391 { 00392 u8g->cursor_fn(u8g); 00393 } 00394 return u8g_NextPageLL(u8g, u8g->dev); 00395 } 00396 00397 uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast) 00398 { 00399 return u8g_SetContrastLL(u8g, u8g->dev, contrast); 00400 } 00401 00402 void u8g_SleepOn(u8g_t *u8g) 00403 { 00404 u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL); 00405 } 00406 00407 void u8g_SleepOff(u8g_t *u8g) 00408 { 00409 u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL); 00410 } 00411 00412 00413 void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y) 00414 { 00415 u8g_DrawPixelLL(u8g, u8g->dev, x, y); 00416 } 00417 00418 void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel) 00419 { 00420 u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel); 00421 } 00422 00423 void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel) 00424 { 00425 u8g_Draw4TPixelLL(u8g, u8g->dev, x, y, dir, pixel); 00426 } 00427 00428 00429 /* u8g_IsBBXIntersection() has been moved to u8g_clip.c */ 00430 #ifdef OBSOLETE_CODE 00431 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) 00432 { 00433 /* new code */ 00434 u8g_dev_arg_bbx_t arg; 00435 arg.x = x; 00436 arg.y = y; 00437 arg.w = w; 00438 arg.h = h; 00439 return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg); 00440 00441 /* old code */ 00442 //return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h); 00443 } 00444 #endif 00445 00446 /* 00447 idx: index for the palette entry (0..255) 00448 r: value for red (0..255) 00449 g: value for green (0..255) 00450 b: value for blue (0..255) 00451 */ 00452 void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b) 00453 { 00454 u8g_dev_arg_irgb_t irgb; 00455 irgb.idx = idx; 00456 irgb.r = r; 00457 irgb.g = g; 00458 irgb.b = b; 00459 u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_COLOR_ENTRY, &irgb); 00460 } 00461 00462 void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx) 00463 { 00464 u8g->arg_pixel.color = idx; 00465 /*u8g->color_index = idx; */ /* must be removed */ 00466 } 00467 00468 void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb) 00469 { 00470 u8g->arg_pixel.color = rgb&255; 00471 u8g->arg_pixel.hi_color = rgb>>8; 00472 /*u8g->color_index = idx; */ /* must be removed */ 00473 } 00474 00475 void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b) 00476 { 00477 00478 r &= ~7; 00479 g >>= 2; 00480 b >>= 3; 00481 u8g->arg_pixel.color = b; 00482 u8g->arg_pixel.color |= (g & 7) << 5; 00483 u8g->arg_pixel.hi_color = r; 00484 u8g->arg_pixel.hi_color |= (g>>3) & 7; 00485 00486 //u8g_SetHiColor(u8g, U8G_GET_HICOLOR_BY_RGB(r,g,b)); 00487 } 00488 00489 void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b) 00490 { 00491 if ( u8g->mode == U8G_MODE_R3G3B2 ) 00492 { 00493 r &= 0x0e0; 00494 g &= 0x0e0; 00495 g >>= 3; 00496 b >>= 6; 00497 u8g->arg_pixel.color = r | g | b; 00498 } 00499 else if ( u8g->mode == U8G_MODE_HICOLOR ) 00500 { 00501 u8g_SetHiColorByRGB(u8g, r,g,b); 00502 } 00503 else 00504 { 00505 u8g->arg_pixel.color = r; 00506 u8g->arg_pixel.hi_color = g; 00507 u8g->arg_pixel.blue = b; 00508 } 00509 } 00510 00511 00512 uint8_t u8g_GetColorIndex(u8g_t *u8g) 00513 { 00514 return u8g->arg_pixel.color; 00515 } 00516 00517 uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g) 00518 { 00519 uint8_t mode; 00520 mode = u8g_GetMode(u8g); 00521 if ( mode == U8G_MODE_R3G3B2 ) 00522 return 255; /* white */ 00523 else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT ) 00524 return 3; /* max intensity */ 00525 else /* if ( u8g.getMode() == U8G_MODE_BW ) */ 00526 return 1; /* pixel on */ 00527 return 1; 00528 } 00529 00530 void u8g_SetDefaultForegroundColor(u8g_t *u8g) 00531 { 00532 if ( u8g->mode == U8G_MODE_HICOLOR ) 00533 { 00534 u8g->arg_pixel.color = 0x0ff; 00535 u8g->arg_pixel.hi_color = 0x0ff; 00536 } 00537 else 00538 { 00539 u8g_SetColorIndex(u8g, u8g_GetDefaultForegroundColor(u8g)); 00540 } 00541 } 00542 00543 uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g) 00544 { 00545 return 0; 00546 } 00547 00548 void u8g_SetDefaultBackgroundColor(u8g_t *u8g) 00549 { 00550 u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g)); /* pixel on / black */ 00551 } 00552 00553 uint8_t u8g_GetDefaultMidColor(u8g_t *u8g) 00554 { 00555 uint8_t mode; 00556 mode = u8g_GetMode(u8g); 00557 if ( mode == U8G_MODE_R3G3B2 ) 00558 return 0x06d; /* gray: 01101101 */ 00559 else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT ) 00560 return 1; /* low mid intensity */ 00561 else /* if ( u8g.getMode() == U8G_MODE_BW ) */ 00562 return 1; /* pixel on */ 00563 return 1; /* default */ 00564 } 00565 00566 void u8g_SetDefaultMidColor(u8g_t *u8g) 00567 { 00568 u8g_SetColorIndex(u8g, u8g_GetDefaultMidColor(u8g)); 00569 } 00570 00571 00572 00573 00574
Generated on Tue Jul 12 2022 17:30:58 by
1.7.2