Repetier-Firmware  0.91
src/ArduinoAVR/Repetier/u8glib_ex.h
Go to the documentation of this file.
00001 /*
00002 
00003   U8glib.cpp
00004 
00005   C++ Interface
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 The U8glib code (http://code.google.com/p/u8glib/) is licensed under the terms of
00038 the new-bsd license (two-clause bsd license).
00039 See also: http://www.opensource.org/licenses/bsd-license.php
00040 
00041 The repository and optionally the releases contain icons, which are
00042 derived from the WPZOOM Developer Icon Set:
00043 http://www.wpzoom.com/wpzoom/new-freebie-wpzoom-developer-icon-set-154-free-icons/
00044 WPZOOM Developer Icon Set by WPZOOM is licensed under a Creative Commons
00045 Attribution-ShareAlike 3.0 Unported License.
00046 
00047 Fonts are licensed under different conditions.
00048 See http://code.google.com/p/u8glib/wiki/fontgroup for
00049 detailed information on the licensing conditions for each font.
00050 
00051 ============ X11 Fonts COUR, HELV, NCEN, TIM, SYMB ============
00052 
00053 For fonts derived from the following files, the license below applies.
00054 COURB08.BDF COURB10.BDF COURB12.BDF COURB14.BDF COURB18.BDF
00055 COURB24.BDF COURR08.BDF COURR10.BDF COURR12.BDF COURR14.BDF
00056 COURR18.BDF COURR24.BDF HELVB08.BDF HELVB10.BDF HELVB12.BDF HELVB14.BDF
00057 HELVB18.BDF HELVB24.BDF HELVR08.BDF HELVR10.BDF HELVR12.BDF HELVR14.BDF
00058 HELVR18.BDF HELVR24.BDF NCENB08.BDF NCENB10.BDF NCENB12.BDF
00059 NCENB14.BDF NCENB18.BDF NCENB24.BDF NCENR08.BDF NCENR10.BDF
00060 NCENR12.BDF NCENR14.BDF NCENR18.BDF NCENR24.BDF SYMB08.BDF SYMB10.BDF
00061 SYMB12.BDF SYMB14.BDF SYMB18.BDF SYMB24.BDF TIMB08.BDF TIMB10.BDF
00062 TIMB12.BDF TIMB14.BDF TIMB18.BDF TIMB24.BDF TIMR08.BDF TIMR10.BDF
00063 TIMR12.BDF TIMR14.BDF TIMR18.BDF TIMR24.BDF
00064 
00065 Copyright 1984-1989, 1994 Adobe Systems Incorporated.
00066 Copyright 1988, 1994 Digital Equipment Corporation.
00067 
00068 Adobe is a trademark of Adobe Systems Incorporated which may be
00069 registered in certain jurisdictions.
00070 Permission to use these trademarks is hereby granted only in
00071 association with the images described in this file.
00072 
00073 Permission to use, copy, modify, distribute and sell this software
00074 and its documentation for any purpose and without fee is hereby
00075 granted, provided that the above copyright notices appear in all
00076 copies and that both those copyright notices and this permission
00077 notice appear in supporting documentation, and that the names of
00078 Adobe Systems and Digital Equipment Corporation not be used in
00079 advertising or publicity pertaining to distribution of the software
00080 without specific, written prior permission.  Adobe Systems and
00081 Digital Equipment Corporation make no representations about the
00082 suitability of this software for any purpose.  It is provided "as
00083 is" without express or implied warranty.
00084 
00085 
00086 ============ BSD License for U8glib Code ============
00087 
00088 Universal 8bit Graphics Library (http://code.google.com/p/u8glib/)
00089 
00090 Copyright (c) 2011, olikraus@gmail.com
00091 All rights reserved.
00092 
00093 Redistribution and use in source and binary forms, with or without modification,
00094 are permitted provided that the following conditions are met:
00095 
00096 * Redistributions of source code must retain the above copyright notice, this list
00097   of conditions and the following disclaimer.
00098 
00099 * Redistributions in binary form must reproduce the above copyright notice, this
00100   list of conditions and the following disclaimer in the documentation and/or other
00101   materials provided with the distribution.
00102 
00103 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
00104 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
00105 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00106 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00107 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00108 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00109 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00110 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00111 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00112 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00113 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00114 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00115 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00116 
00117 */
00118 
00119 // ============= u8g.h ====================
00120 
00121 /*
00122 
00123   u8g.h
00124 
00125   Universal 8bit Graphics Library
00126 
00127   Copyright (c) 2011, olikraus@gmail.com
00128   All rights reserved.
00129 
00130   Redistribution and use in source and binary forms, with or without modification,
00131   are permitted provided that the following conditions are met:
00132 
00133   * Redistributions of source code must retain the above copyright notice, this list
00134     of conditions and the following disclaimer.
00135 
00136   * Redistributions in binary form must reproduce the above copyright notice, this
00137     list of conditions and the following disclaimer in the documentation and/or other
00138     materials provided with the distribution.
00139 
00140   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
00141   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
00142   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00143   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00144   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00145   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00146   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00147   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00148   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00149   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00150   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00151   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00152   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00153 
00154 */
00155 
00156 #ifndef _U8G_H
00157 #define _U8G_H
00158 
00159 /* uncomment the following line to support displays larger than 240x240 */
00160 //#define U8G_16BIT 1
00161 
00162 /* comment the following line to generate more compact but interrupt unsafe code */
00163 #define U8G_INTERRUPT_SAFE 1
00164 
00165 
00166 #include <stddef.h>
00167 
00168 #ifdef __18CXX
00169 typedef unsigned char uint8_t;
00170 typedef signed char int8_t;
00171 typedef unsigned short uint16_t;
00172 typedef signed short int16_t;
00173 #else
00174 #include <stdint.h>
00175 #endif
00176 
00177 #if defined(__AVR__)
00178 #include <avr/pgmspace.h>
00179 #endif
00180 
00181 /*
00182   use the com interface directly on any systems which are not AVR or ARDUINO
00183 */
00184 #if defined(__AVR__) || defined(ARDUINO)
00185 #define U8G_WITH_PINLIST
00186 #endif
00187 
00188 
00189 #ifdef __cplusplus
00190 extern "C" {
00191 #endif
00192 
00193 
00194 /*===============================================================*/
00195 #ifdef __GNUC__
00196 #  define U8G_NOINLINE __attribute__((noinline))
00197 #  define U8G_PURE  __attribute__ ((pure))
00198 #  define U8G_NOCOMMON __attribute__ ((nocommon))
00199 #  define U8G_SECTION(name) __attribute__ ((section (name)))
00200 #  if defined(__MSPGCC__)
00201 /* mspgcc does not have .progmem sections. Use -fdata-sections. */
00202 #    define U8G_FONT_SECTION(name)
00203 #  endif
00204 #  if defined(__AVR__)
00205 #    define U8G_FONT_SECTION(name) U8G_SECTION(".progmem." name)
00206 #  endif
00207 #else
00208 #  define U8G_NOINLINE
00209 #  define U8G_PURE
00210 #  define U8G_NOCOMMON
00211 #  define U8G_SECTION(name)
00212 #endif
00213 
00214 #ifndef U8G_FONT_SECTION
00215 #  define U8G_FONT_SECTION(name)
00216 #endif
00217 
00218 
00219 /*===============================================================*/
00220 /* flash memory access */
00221 
00222 #if defined(__AVR__)
00223 /* U8G_PROGMEM is used by the XBM example */
00224 #define U8G_PROGMEM U8G_SECTION(".progmem.data")
00225 typedef uint8_t PROGMEM u8g_pgm_uint8_t;
00226 typedef uint8_t u8g_fntpgm_uint8_t;
00227 #define u8g_pgm_read(adr) pgm_read_byte_near(adr)
00228 #define U8G_PSTR(s) ((u8g_pgm_uint8_t *)PSTR(s))
00229 
00230 #else
00231 
00232 #define U8G_PROGMEM
00233 #define PROGMEM
00234 typedef uint8_t u8g_pgm_uint8_t;
00235 typedef uint8_t u8g_fntpgm_uint8_t;
00236 #define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
00237 #define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
00238 
00239 #endif
00240 
00241 /*===============================================================*/
00242 /* interrupt safe code */
00243 #if defined(U8G_INTERRUPT_SAFE)
00244 #  if defined(__AVR__)
00245 extern uint8_t global_SREG_backup;      /* u8g_state.c */
00246 #    define U8G_ATOMIC_START()          do { global_SREG_backup = SREG; cli(); } while(0)
00247 #    define U8G_ATOMIC_END()                    SREG = global_SREG_backup
00248 #    define U8G_ATOMIC_OR(ptr, val)     do { uint8_t tmpSREG = SREG; cli(); (*(ptr) |= (val)); SREG = tmpSREG; } while(0)
00249 #    define U8G_ATOMIC_AND(ptr, val)    do { uint8_t tmpSREG = SREG; cli(); (*(ptr) &= (val)); SREG = tmpSREG; } while(0)
00250 #  else
00251 #    define U8G_ATOMIC_OR(ptr, val) (*(ptr) |= (val))
00252 #    define U8G_ATOMIC_AND(ptr, val) (*(ptr) &= (val))
00253 #    define U8G_ATOMIC_START()
00254 #    define U8G_ATOMIC_END()
00255 #  endif /* __AVR__ */
00256 #else
00257 #  define U8G_ATOMIC_OR(ptr, val) (*(ptr) |= (val))
00258 #  define U8G_ATOMIC_AND(ptr, val) (*(ptr) &= (val))
00259 #  define U8G_ATOMIC_START()
00260 #  define U8G_ATOMIC_END()
00261 #endif /* U8G_INTERRUPT_SAFE */
00262 
00263 
00264 /*===============================================================*/
00265 /* forward */
00266 typedef struct _u8g_t u8g_t;
00267 typedef struct _u8g_dev_t u8g_dev_t;
00268 
00269 typedef struct _u8g_dev_arg_pixel_t u8g_dev_arg_pixel_t;
00270 typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t;
00271 typedef struct _u8g_box_t u8g_box_t;
00272 typedef struct _u8g_dev_arg_irgb_t u8g_dev_arg_irgb_t;
00273 
00274 
00275 /*===============================================================*/
00276 /* generic */
00277 #if defined(U8G_16BIT)
00278 typedef uint16_t u8g_uint_t;
00279 typedef int16_t u8g_int_t;
00280 #else
00281 typedef uint8_t u8g_uint_t;
00282 typedef int8_t u8g_int_t;
00283 #endif
00284 
00285 #ifdef OBSOLETE
00286 struct _u8g_box_t
00287 {
00288   u8g_uint_t x0, y0, x1, y1;
00289 };
00290 typedef struct _u8g_box_t u8g_box_t;
00291 #endif /* OBSOLETE */
00292 
00293 
00294 /*===============================================================*/
00295 /* device structure */
00296 
00297 #ifdef __XC8
00298 /* device prototype */
00299 typedef uint8_t (*u8g_dev_fnptr)(void *u8g, void *dev, uint8_t msg, void *arg);
00300 
00301 /* com prototype */
00302 typedef uint8_t (*u8g_com_fnptr)(void *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
00303 #else
00304 /* device prototype */
00305 typedef uint8_t (*u8g_dev_fnptr)(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00306 
00307 /* com prototype */
00308 typedef uint8_t (*u8g_com_fnptr)(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
00309 #endif
00310 
00311 
00312 
00313 struct _u8g_dev_t
00314 {
00315   u8g_dev_fnptr dev_fn;         /* device procedure */
00316   void *dev_mem;                /* device memory */
00317   u8g_com_fnptr com_fn;         /* communication procedure */
00318 };
00319 
00320 
00321 /*===============================================================*/
00322 /* device list */
00323 
00324 /* Size: 128x64 SDL, u8g_dev_sdl.c */
00325 extern u8g_dev_t u8g_dev_sdl_1bit;
00326 extern u8g_dev_t u8g_dev_sdl_1bit_h;
00327 extern u8g_dev_t u8g_dev_sdl_2bit;
00328 extern u8g_dev_t u8g_dev_sdl_2bit_double_mem;
00329 extern u8g_dev_t u8g_dev_sdl_8bit;
00330 extern u8g_dev_t u8g_dev_sdl_hicolor;
00331 extern u8g_dev_t u8g_dev_sdl_fullcolor;
00332 int u8g_sdl_get_key(void);
00333 
00334 /* Size: 70x30 monochrom, stdout */
00335 extern u8g_dev_t u8g_dev_stdout;
00336 
00337 /* Size: monochrom, writes "u8g.pbm" */
00338 extern u8g_dev_t u8g_dev_pbm;
00339 extern u8g_dev_t u8g_dev_pbm_8h1;
00340 extern u8g_dev_t u8g_dev_pbm_8h2;       /* grayscale simulation */
00341 
00342 /* Size: 128x64 monochrom, no output, used for performance measure */
00343 extern u8g_dev_t u8g_dev_gprof;
00344 
00345 /* Display: EA DOGS102, Size: 102x64 monochrom */
00346 extern u8g_dev_t u8g_dev_uc1701_dogs102_sw_spi;
00347 extern u8g_dev_t u8g_dev_uc1701_dogs102_hw_spi;
00348 
00349 extern u8g_dev_t u8g_dev_uc1701_dogs102_2x_sw_spi;
00350 extern u8g_dev_t u8g_dev_uc1701_dogs102_2x_hw_spi;
00351 
00352 /* Display: Mini12864 (dealextreme), Size: 128x64 monochrom */
00353 extern u8g_dev_t u8g_dev_uc1701_mini12864_sw_spi;
00354 extern u8g_dev_t u8g_dev_uc1701_mini12864_hw_spi;
00355 
00356 extern u8g_dev_t u8g_dev_uc1701_mini12864_2x_sw_spi;
00357 extern u8g_dev_t u8g_dev_uc1701_mini12864_2x_hw_spi;
00358 
00359 /* Display: EA DOGM132, Size: 128x32 monochrom */
00360 extern u8g_dev_t u8g_dev_st7565_dogm132_sw_spi;
00361 extern u8g_dev_t u8g_dev_st7565_dogm132_hw_spi;
00362 
00363 /* Display: EA DOGM128, Size: 128x64 monochrom */
00364 extern u8g_dev_t u8g_dev_st7565_dogm128_sw_spi;
00365 extern u8g_dev_t u8g_dev_st7565_dogm128_hw_spi;
00366 extern u8g_dev_t u8g_dev_st7565_dogm128_parallel;
00367 
00368 extern u8g_dev_t u8g_dev_st7565_dogm128_2x_sw_spi;
00369 extern u8g_dev_t u8g_dev_st7565_dogm128_2x_hw_spi;
00370 extern u8g_dev_t u8g_dev_st7565_dogm128_2x_parallel;
00371 
00372 /* Display: Topway LM6059 128x64 (Adafruit) */
00373 extern u8g_dev_t u8g_dev_st7565_lm6059_sw_spi;
00374 extern u8g_dev_t u8g_dev_st7565_lm6059_hw_spi;
00375 extern u8g_dev_t u8g_dev_st7565_lm6059_2x_sw_spi;
00376 extern u8g_dev_t u8g_dev_st7565_lm6059_2x_hw_spi;
00377 /* Display: Topway LM6063 128x64 */
00378 extern u8g_dev_t u8g_dev_st7565_lm6063_sw_spi;
00379 extern u8g_dev_t u8g_dev_st7565_lm6063_hw_spi;
00380 extern u8g_dev_t u8g_dev_st7565_lm6063_2x_sw_spi;
00381 extern u8g_dev_t u8g_dev_st7565_lm6063_2x_hw_spi;
00382 /* Display: Newhaven NHD-C12864 */
00383 extern u8g_dev_t u8g_dev_st7565_nhd_c12864_sw_spi;
00384 extern u8g_dev_t u8g_dev_st7565_nhd_c12864_hw_spi;
00385 extern u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_sw_spi;
00386 extern u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_hw_spi;
00387 
00388 /* Display: Newhaven NHD-C12832 */
00389 extern u8g_dev_t u8g_dev_st7565_nhd_c12832_sw_spi;
00390 extern u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_spi;
00391 extern u8g_dev_t u8g_dev_st7565_nhd_c12832_parallel;
00392 extern u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_usart_spi;
00393 
00394 /* Display: Displaytech 64128N */
00395 extern u8g_dev_t u8g_dev_st7565_64128n_sw_spi;
00396 extern u8g_dev_t u8g_dev_st7565_64128n_hw_spi;
00397 extern u8g_dev_t u8g_dev_st7565_64128n_parallel;
00398 
00399 extern u8g_dev_t u8g_dev_st7565_64128n_2x_sw_spi;
00400 extern u8g_dev_t u8g_dev_st7565_64128n_2x_hw_spi;
00401 extern u8g_dev_t u8g_dev_st7565_64128n_2x_parallel;
00402 
00403 /* Display: LCD-AG-C128032R-DIW W/KK E6 PBF */
00404 extern u8g_dev_t u8g_dev_uc1601_c128032_sw_spi;
00405 extern u8g_dev_t u8g_dev_uc1601_c128032_hw_spi;
00406 
00407 extern u8g_dev_t u8g_dev_uc1601_c128032_2x_sw_spi;
00408 extern u8g_dev_t u8g_dev_uc1601_c128032_2x_hw_spi;
00409 
00410 /* dfrobot 128x64 Graphic LCD (SKU:FIT0021) */
00411 extern u8g_dev_t u8g_dev_st7920_128x64_sw_spi;
00412 extern u8g_dev_t u8g_dev_st7920_128x64_hw_spi;
00413 extern u8g_dev_t u8g_dev_st7920_128x64_8bit;
00414 extern u8g_dev_t u8g_dev_st7920_128x64_custom;
00415 
00416 extern u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi;
00417 extern u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi;
00418 extern u8g_dev_t u8g_dev_st7920_128x64_4x_8bit;
00419 extern u8g_dev_t u8g_dev_st7920_128x64_4x_custom;
00420 
00421 /* NHD-19232WG */
00422 extern u8g_dev_t u8g_dev_st7920_192x32_sw_spi;
00423 extern u8g_dev_t u8g_dev_st7920_192x32_hw_spi;
00424 extern u8g_dev_t u8g_dev_st7920_192x32_8bit;
00425 
00426 extern u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi;
00427 extern u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi;
00428 extern u8g_dev_t u8g_dev_st7920_192x32_4x_8bit;
00429 
00430 /* CrystalFontz CFAG20232 */
00431 extern u8g_dev_t u8g_dev_st7920_202x32_sw_spi;
00432 extern u8g_dev_t u8g_dev_st7920_202x32_hw_spi;
00433 extern u8g_dev_t u8g_dev_st7920_202x32_8bit;
00434 
00435 extern u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi;
00436 extern u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi;
00437 extern u8g_dev_t u8g_dev_st7920_202x32_4x_8bit;
00438 
00439 /* LC7981 160x80 display */
00440 extern u8g_dev_t u8g_dev_lc7981_160x80_8bit;
00441 /* LC7981 240x64 display */
00442 extern u8g_dev_t u8g_dev_lc7981_240x64_8bit;
00443 /* LC7981 240x128 display */
00444 extern u8g_dev_t u8g_dev_lc7981_240x128_8bit;
00445 /* LC7981 320x64 display */
00446 extern u8g_dev_t u8g_dev_lc7981_320x64_8bit;
00447 
00448 /* T6963, all t6963 devices have double page (2x) */
00449 extern u8g_dev_t u8g_dev_t6963_240x128_8bit;
00450 extern u8g_dev_t u8g_dev_t6963_240x64_8bit;
00451 extern u8g_dev_t u8g_dev_t6963_128x64_8bit;
00452 
00453 /* Display: EA DOGXL160, Size: 160x104 monochrom & gray level */
00454 extern u8g_dev_t u8g_dev_uc1610_dogxl160_bw_sw_spi;
00455 extern u8g_dev_t u8g_dev_uc1610_dogxl160_bw_hw_spi;
00456 extern u8g_dev_t u8g_dev_uc1610_dogxl160_gr_sw_spi;
00457 extern u8g_dev_t u8g_dev_uc1610_dogxl160_gr_hw_spi;
00458 
00459 extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi;
00460 extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi;
00461 extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi;
00462 extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi;
00463 
00464 /* Display: Generic KS0108b, Size: 128x64 monochrom */
00465 extern u8g_dev_t u8g_dev_ks0108_128x64;         /* official Arduino Library interface */
00466 extern u8g_dev_t u8g_dev_ks0108_128x64_fast;    /* faster, but uses private tables from the Arduino Library */
00467 
00468 /* Nokia 84x48 Display with PCD8544 */
00469 extern u8g_dev_t u8g_dev_pcd8544_84x48_sw_spi;
00470 extern u8g_dev_t u8g_dev_pcd8544_84x48_hw_spi;
00471 extern u8g_dev_t u8g_dev_tls8204_84x48_sw_spi;
00472 
00473 /* Nokia 96x65 Display with PCF8812 */
00474 extern u8g_dev_t u8g_dev_pcf8812_96x65_sw_spi;
00475 extern u8g_dev_t u8g_dev_pcf8812_96x65_hw_spi;
00476 
00477 /* NHD-2.7-12864UCY3 OLED Display with SSD1325 Controller */
00478 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_sw_spi;
00479 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_hw_spi;
00480 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_parallel;
00481 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_sw_spi;
00482 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_hw_spi;
00483 
00484 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi;
00485 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi;
00486 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel;
00487 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi;
00488 extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi;
00489 
00490 /* LY120 OLED with SSD1327 Controller (tested with Seeedstudio module) */
00491 extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_sw_spi;
00492 extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_hw_spi;
00493 extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_i2c;
00494 
00495 extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi;
00496 extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi;
00497 extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c;
00498 
00499 /* NHD-3.12-25664 OLED Display with SSD1322 Controller */
00500 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_sw_spi;
00501 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_hw_spi;
00502 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_parallel;
00503 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi;
00504 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi;
00505 
00506 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_sw_spi;
00507 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_hw_spi;
00508 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_parallel;
00509 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi;
00510 extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi;
00511 
00512 /* OLED 128x64 Display with SSD1306 Controller */
00513 extern u8g_dev_t u8g_dev_ssd1306_128x64_sw_spi;
00514 extern u8g_dev_t u8g_dev_ssd1306_128x64_hw_spi;
00515 extern u8g_dev_t u8g_dev_ssd1306_128x64_i2c;
00516 
00517 extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi;
00518 extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi;
00519 extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c;
00520 
00521 /* OLED 128x64 Display with SSD1309 Controller */
00522 extern u8g_dev_t u8g_dev_ssd1309_128x64_sw_spi;
00523 extern u8g_dev_t u8g_dev_ssd1309_128x64_hw_spi;
00524 extern u8g_dev_t u8g_dev_ssd1309_128x64_i2c;
00525 
00526 /* OLED 128x32 Display with SSD1306 Controller */
00527 extern u8g_dev_t u8g_dev_ssd1306_128x32_sw_spi;
00528 extern u8g_dev_t u8g_dev_ssd1306_128x32_hw_spi;
00529 extern u8g_dev_t u8g_dev_ssd1306_128x32_i2c;
00530 
00531 extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_sw_spi;
00532 extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_hw_spi;
00533 extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_i2c;
00534 
00535 /* experimental 65K TFT with st7687 controller */
00536 extern u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi;
00537 extern u8g_dev_t u8g_dev_st7687_c144mvgd_8bit;
00538 
00539 /* SBN1661/SED1520 display with 122x32 */
00540 extern u8g_dev_t u8g_dev_sbn1661_122x32;
00541 
00542 /* flip disc matrix */
00543 extern u8g_dev_t u8g_dev_flipdisc_2x7;
00544 void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2));
00545 
00546 /* ILI9325D based TFT */
00547 extern u8g_dev_t u8g_dev_ili9325d_320x240_8bit;
00548 
00549 
00550 /* SSD1351 OLED (breakout board from http://www.kickstarter.com/projects/ilsoftltd/colour-oled-breakout-board) */
00551 extern u8g_dev_t u8g_dev_ssd1351_128x128_332_sw_spi;
00552 extern u8g_dev_t u8g_dev_ssd1351_128x128_332_hw_spi;
00553 extern u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_sw_spi;
00554 extern u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_hw_spi;
00555 extern u8g_dev_t u8g_dev_ssd1351_128x128_idx_sw_spi;
00556 extern u8g_dev_t u8g_dev_ssd1351_128x128_idx_hw_spi;
00557 extern u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_sw_spi;
00558 extern u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_hw_spi;
00559 extern u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_sw_spi;
00560 extern u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi;
00561 
00562 /* SSD1351 OLED (Freetronics, GPIOs set to high level) */
00563 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_332_sw_spi;
00564 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_332_hw_spi;
00565 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_sw_spi;
00566 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_hw_spi;
00567 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_sw_spi;
00568 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_hw_spi;
00569 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi;
00570 extern u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi;
00571 
00572 /* HT1632 */
00573 extern u8g_dev_t u8g_dev_ht1632_24x16;
00574 
00575 /* A2 Micro Printer */
00576 extern u8g_dev_t u8g_dev_a2_micro_printer_384x240;
00577 extern u8g_dev_t u8g_dev_a2_micro_printer_192x120_ds;
00578 
00579 /* u8g_virtual_screen.c  */
00580 extern u8g_dev_t u8g_dev_vs;
00581 
00582 
00583 /*===============================================================*/
00584 /* device messages */
00585 
00586 struct _u8g_dev_arg_pixel_t
00587 {
00588   u8g_uint_t x, y;              /* will be modified */
00589   uint8_t pixel;                  /* will be modified, pixel sequence or transparency value */
00590   uint8_t dir;
00591   uint8_t color;                        /* color or index value, red value for true color mode */
00592   uint8_t hi_color;             /* high byte for 64K color mode, low byte is in "color", green value for true color mode */
00593   uint8_t blue;                 /* blue value in true color mode */
00594 };
00595 /* typedef struct _u8g_dev_arg_pixel_t u8g_dev_arg_pixel_t; */ /* forward decl */
00596 
00597 /* range for r,g,b: 0..255 */
00598 #define U8G_GET_HICOLOR_BY_RGB(r,g,b) (((uint16_t)((r)&0x0f8))<<8)|(((uint16_t)((g)&0x0fc))<<3)|(((uint16_t)((b)>>3)))
00599 
00600 struct _u8g_dev_arg_bbx_t
00601 {
00602   u8g_uint_t x, y, w, h;
00603 };
00604 /* typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t; */ /* forward decl */
00605 
00606 struct _u8g_box_t
00607 {
00608   u8g_uint_t x0, y0, x1, y1;
00609 };
00610 /* typedef struct _u8g_box_t u8g_box_t; */ /* forward decl */
00611 
00612 struct _u8g_dev_arg_irgb_t
00613 {
00614   u8g_uint_t idx, r, g, b;              /* index with rgb value */
00615 };
00616 /* typedef struct _u8g_dev_arg_irgb_t u8g_dev_arg_irgb_t; */ /* forward decl */
00617 
00618 
00619 
00620 #define U8G_DEV_MSG_INIT                10
00621 #define U8G_DEV_MSG_STOP                  11
00622 
00623 /* arg: pointer to uint8_t, contranst value between 0 and 255 */
00624 #define U8G_DEV_MSG_CONTRAST            15
00625 
00626 #define U8G_DEV_MSG_SLEEP_ON            16
00627 #define U8G_DEV_MSG_SLEEP_OFF            17
00628 
00629 #define U8G_DEV_MSG_PAGE_FIRST                  20
00630 #define U8G_DEV_MSG_PAGE_NEXT                    21
00631 
00632 /* arg: u8g_dev_arg_bbx_t * */
00633 /* new algorithm with U8G_DEV_MSG_GET_PAGE_BOX makes this msg obsolete */
00634 /* #define U8G_DEV_MSG_IS_BBX_INTERSECTION 22 */
00635 
00636 /* arg: u8g_box_t *, fill structure with current page properties */
00637 #define U8G_DEV_MSG_GET_PAGE_BOX 23
00638 
00639 /*
00640 #define U8G_DEV_MSG_PRIMITIVE_START             30
00641 #define U8G_DEV_MSG_PRIMITIVE_END               31
00642 */
00643 
00644 /* arg: u8g_dev_arg_pixel_t * */
00645 #define U8G_DEV_MSG_SET_TPIXEL                          44
00646 #define U8G_DEV_MSG_SET_4TPIXEL                 45
00647 
00648 #define U8G_DEV_MSG_SET_PIXEL                           50
00649 #define U8G_DEV_MSG_SET_8PIXEL                          59
00650 
00651 #define U8G_DEV_MSG_SET_COLOR_ENTRY                60
00652 
00653 #define U8G_DEV_MSG_SET_XY_CB                           61
00654 
00655 #define U8G_DEV_MSG_GET_WIDTH                           70
00656 #define U8G_DEV_MSG_GET_HEIGHT                           71
00657 #define U8G_DEV_MSG_GET_MODE                  72
00658 
00659 /*===============================================================*/
00660 /* device modes */
00661 #define U8G_MODE(is_index_mode, is_color, bits_per_pixel) (((is_index_mode)<<6) | ((is_color)<<5)|(bits_per_pixel))
00662 
00663 #define U8G_MODE_UNKNOWN     0
00664 #define U8G_MODE_BW     U8G_MODE(0, 0, 1)
00665 #define U8G_MODE_GRAY2BIT     U8G_MODE(0, 0, 2)
00666 #define U8G_MODE_R3G3B2  U8G_MODE(0, 1, 8)
00667 #define U8G_MODE_INDEX  U8G_MODE(1, 1, 8)
00668 /* hicolor is R5G6B5 */
00669 #define U8G_MODE_HICOLOR  U8G_MODE(0, 1, 16)
00670 /* truecolor  */
00671 #define U8G_MODE_TRUECOLOR  U8G_MODE(0, 1, 24)
00672 
00673 
00674 #define U8G_MODE_GET_BITS_PER_PIXEL(mode) ((mode)&31)
00675 #define U8G_MODE_IS_COLOR(mode) (((mode)&32)==0?0:1)
00676 #define U8G_MODE_IS_INDEX_MODE(mode) (((mode)&64)==0?0:1)
00677 
00678 
00679 /*===============================================================*/
00680 /* com options */
00681 
00682 /* uncomment the following line for Atmega HW SPI double speed, issue 89 */
00683 /* #define U8G_HW_SPI_2X 1 */
00684 
00685 /* com messages */
00686 
00687 #define U8G_COM_MSG_STOP        0
00688 #define U8G_COM_MSG_INIT        1
00689 
00690 #define U8G_COM_MSG_ADDRESS 2
00691 
00692 /* CHIP_SELECT argument: number of the chip which needs to be activated, so this is more like high active */
00693 #define U8G_COM_MSG_CHIP_SELECT 3
00694 
00695 #define U8G_COM_MSG_RESET 4
00696 
00697 #define U8G_COM_MSG_WRITE_BYTE 5
00698 #define U8G_COM_MSG_WRITE_SEQ 6
00699 #define U8G_COM_MSG_WRITE_SEQ_P 7
00700 
00701 
00702 /* com driver */
00703 uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);               /* u8g_com_null.c */
00704 uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);        /* u8g_com_arduino_std_sw_spi.c */
00705 uint8_t u8g_com_arduino_hw_usart_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);      /* u8g_com_atmega_hw_usart_spi.c */
00706 uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);        /* u8g_com_arduino_sw_spi.c */
00707 uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);          /* u8g_com_arduino_hw_spi.c */
00708 uint8_t u8g_com_arduino_ATtiny85_std_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);          /* u8g_arduino_ATTiny85_std_hw_spi.c */
00709 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);  /* u8g_com_arduino_st7920_spi.c */
00710 uint8_t u8g_com_arduino_st7920_custom_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_custom.c */
00711 uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);  /* u8g_com_arduino_st7920_hw_spi.c */
00712 uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);           /* u8g_com_arduino_parallel.c */
00713 uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);      /* u8g_com_arduino_fast_parallel.c */
00714 uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);       /* u8g_com_arduino_port_d_wr.c */
00715 uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);     /* u8g_com_arduino_no_en_parallel.c */
00716 uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);            /* u8g_com_arduino_ssd_i2c.c */
00717 uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);                      /* u8g_com_arduino_t6963.c */
00718 
00719 
00720 uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);      /* u8g_com_atmega_hw_spi.c */
00721 uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);      /* u8g_com_atmega_sw_spi.c */
00722 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);       /* u8g_com_atmega_st7920_spi.c */
00723 uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
00724 uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);    /* u8g_com_atmega_parallel.c */
00725 
00726 
00727 /*
00728   Translation of system specific com drives to generic com names
00729   At the moment, the following generic com drives are available
00730   U8G_COM_HW_SPI
00731   U8G_COM_SW_SPI
00732   U8G_COM_PARALLEL
00733   U8G_COM_T6963
00734   U8G_COM_FAST_PARALLEL
00735   U8G_COM_SSD_I2C
00736 
00737 defined(__18CXX) || defined(__PIC32MX)
00738 
00739 */
00740 /* ==== HW SPI, Arduino ====*/
00741 #if defined(ARDUINO)
00742 #if defined(__AVR__)
00743 
00744 #if defined(__AVR_ATtiny85__)
00745 #define U8G_COM_HW_SPI u8g_com_arduino_ATtiny85_std_hw_spi_fn
00746 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
00747 #else
00748 
00749 #define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
00750 #if defined(__AVR_ATmega32U4__)
00751 #define U8G_COM_HW_USART_SPI u8g_com_arduino_hw_usart_spi_fn
00752 #endif /* __AVR_ATmega32U4__ */
00753 #define U8G_COM_ST7920_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
00754 #endif /* __AVR_ATtiny85__ */
00755 
00756 #elif defined(__18CXX) || defined(__PIC32MX)
00757 #define U8G_COM_HW_SPI u8g_com_null_fn
00758 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
00759 #elif defined(__arm__)   /* Arduino Due */
00760 #define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
00761 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
00762 #endif
00763 #endif
00764 /* ==== HW SPI, not Arduino ====*/
00765 #ifndef U8G_COM_HW_SPI
00766 #if defined(__AVR__)
00767 #define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
00768 #define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
00769 #endif
00770 #endif
00771 #ifndef U8G_COM_HW_SPI
00772 #define U8G_COM_HW_SPI u8g_com_null_fn
00773 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
00774 #endif
00775 
00776 #ifndef U8G_COM_HW_USART_SPI
00777 #define U8G_COM_HW_USART_SPI u8g_com_null_fn
00778 #endif
00779 
00780 
00781 /* ==== SW SPI, Arduino ====*/
00782 #if defined(ARDUINO)
00783 #if defined(__AVR__)
00784 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
00785 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
00786 #elif defined(__18CXX) || defined(__PIC32MX)
00787 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
00788 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
00789 #elif defined(__arm__)   /* Arduino Due */
00790 //#define U8G_COM_SW_SPI u8g_com_arduino_std_sw_spi_fn
00791 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
00792 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
00793 #endif
00794 #endif
00795 
00796 #ifndef U8G_COM_SW_SPI
00797 /* ==== SW SPI, not Arduino ====*/
00798 #if defined(__AVR__)
00799 #define U8G_COM_SW_SPI u8g_com_atmega_sw_spi_fn
00800 #define U8G_COM_ST7920_SW_SPI u8g_com_atmega_st7920_sw_spi_fn
00801 #endif
00802 #endif
00803 #ifndef U8G_COM_SW_SPI
00804 #define U8G_COM_SW_SPI u8g_com_null_fn
00805 #define U8G_COM_ST7920_SW_SPI u8g_com_null_fn
00806 #endif
00807 
00808 /* ==== Parallel iinterface, Arduino ====*/
00809 #if defined(ARDUINO)
00810 #if defined(__AVR__)
00811 #define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
00812 #define U8G_COM_FAST_PARALLEL u8g_com_arduino_fast_parallel_fn
00813 #define U8G_COM_T6963  u8g_com_arduino_t6963_fn
00814 #else /* Arduino Due, Chipkit PIC32 */
00815 #define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
00816 #define U8G_COM_FAST_PARALLEL u8g_com_arduino_parallel_fn
00817 #define U8G_COM_T6963  u8g_com_null_fn
00818 #endif
00819 #endif
00820 #ifndef U8G_COM_PARALLEL
00821 #if defined(__AVR__)
00822 #define U8G_COM_PARALLEL u8g_com_atmega_parallel_fn
00823 #define U8G_COM_FAST_PARALLEL u8g_com_atmega_parallel_fn
00824 #define U8G_COM_T6963  u8g_com_null_fn
00825 #endif
00826 #endif
00827 #ifndef U8G_COM_PARALLEL
00828 #define U8G_COM_PARALLEL u8g_com_null_fn
00829 #define U8G_COM_FAST_PARALLEL u8g_com_null_fn
00830 #define U8G_COM_T6963  u8g_com_null_fn
00831 #endif
00832 
00833 #if defined(ARDUINO)
00834 #if defined(__AVR__)
00835 #define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
00836 #endif
00837 #endif
00838 
00839 #ifndef U8G_COM_SSD_I2C
00840 #if defined(__AVR__)
00841 /* AVR variant can use the arduino version at the moment */
00842 #define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
00843 #endif
00844 #endif
00845 #ifndef U8G_COM_SSD_I2C
00846 #define U8G_COM_SSD_I2C u8g_com_null_fn
00847 #endif
00848 
00849 
00850 
00851 /*===============================================================*/
00852 /* com api */
00853 
00854 #define U8G_SPI_CLK_CYCLE_50NS 1
00855 #define U8G_SPI_CLK_CYCLE_300NS 2
00856 #define U8G_SPI_CLK_CYCLE_400NS 3
00857 #define U8G_SPI_CLK_CYCLE_NONE 255
00858 
00859 uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time);
00860 void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev);
00861 void u8g_EnableCom(u8g_t *u8g, u8g_dev_t *dev);         /* obsolete */
00862 void u8g_DisableCom(u8g_t *u8g, u8g_dev_t *dev);        /* obsolete */
00863 void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs);
00864 void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev);
00865 void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev);
00866 void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address);
00867 uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val);
00868 uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq);
00869 uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq);
00870 
00871 
00872 
00873 #define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
00874 #define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
00875 #define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
00876 #define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
00877 #define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
00878 #define U8G_ESC_END 255, 254
00879 #define U8G_ESC_255 255, 255
00880 //uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, u8g_pgm_uint8_t *esc_seq);
00881 uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq);
00882 
00883 
00884 /* u8g_com_api_16gr.c */
00885 uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
00886 uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
00887 uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
00888 uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
00889 
00890 
00891 /*===============================================================*/
00892 /* u8g_arduino_common.c */
00893 void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value);
00894 void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g);
00895 
00896 /*===============================================================*/
00897 /* u8g_com_io.c */
00898 
00899 /* create internal number from port and pin */
00900 uint8_t u8g_Pin(uint8_t port, uint8_t bitpos);
00901 #define PN(port,bitpos) u8g_Pin(port,bitpos)
00902 
00903 /* low level procedures */
00904 void u8g_SetPinOutput(uint8_t internal_pin_number);
00905 void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level);
00906 void u8g_SetPinInput(uint8_t internal_pin_number);
00907 uint8_t u8g_GetPinLevel(uint8_t internal_pin_number);
00908 
00909 /* u8g level procedures, expect U8G_PI_xxx macro */
00910 void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi);
00911 void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level);
00912 
00913 
00914 /*===============================================================*/
00915 /* page */
00916 struct _u8g_page_t
00917 {
00918   u8g_uint_t page_height;
00919   u8g_uint_t total_height;
00920   u8g_uint_t page_y0;
00921   u8g_uint_t page_y1;
00922   uint8_t page;
00923 };
00924 typedef struct _u8g_page_t u8g_page_t;
00925 
00926 void u8g_page_First(u8g_page_t *p) U8G_NOINLINE;                                                                                        /* u8g_page.c */
00927 void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height ) U8G_NOINLINE;            /* u8g_page.c */
00928 uint8_t u8g_page_Next(u8g_page_t *p) U8G_NOINLINE;                                                                                   /* u8g_page.c */
00929 
00930 /*===============================================================*/
00931 /* page buffer (pb) */
00932 
00933 struct _u8g_pb_t
00934 {
00935   u8g_page_t p;
00936   u8g_uint_t width;             /* pixel width */
00937   void *buf;
00938 };
00939 typedef struct _u8g_pb_t u8g_pb_t;
00940 
00941 
00942 /* u8g_pb.c */
00943 void u8g_pb_Clear(u8g_pb_t *b);
00944 uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1);
00945 uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
00946 uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx);
00947 void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box);
00948 uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel);
00949 uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
00950 
00951 /*
00952   note on __attribute__ ((nocommon))
00953     AVR scripts often use  --gc-sections on the linker to remove unused section.
00954     This works fine for initialed data and text sections. In principle .bss is also
00955     handled, but the name##_pb definition is not removed. Reason is, that
00956     array definitions are placed in the COMMON section, by default
00957     The attribute "nocommon" removes this automatic assignment to the
00958     COMMON section and directly puts it into .bss. As a result, if more
00959     than one buffer is defined in one file, then it will be removed with --gc-sections
00960 
00961     .. not sure if Arduino IDE uses -fno-common... if yes, then the attribute is
00962     redundant.
00963 */
00964 #define U8G_PB_DEV(name, width, height, page_height, dev_fn, com_fn) \
00965 uint8_t name##_buf[width] U8G_NOCOMMON ; \
00966 u8g_pb_t name##_pb = { {page_height, height, 0, 0, 0},  width, name##_buf}; \
00967 u8g_dev_t name = { dev_fn, &name##_pb, com_fn }
00968 
00969 
00970 void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)   U8G_NOINLINE;
00971 void u8g_pb8v1_Clear(u8g_pb_t *b) U8G_NOINLINE;
00972 
00973 uint8_t u8g_pb8v1_IsYIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
00974 uint8_t u8g_pb8v1_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
00975 uint8_t u8g_pb8v1_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
00976 
00977 uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00978 
00979 /* u8g_pb16v1.c */
00980 uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00981 
00982 /* u8g_pb14v1.c */
00983 uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00984 
00985 /* u8g_pb8v2.c */
00986 uint8_t u8g_dev_pb8v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00987 
00988 /* u8g_pb16v2.c (double memory of pb8v2) */
00989 uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00990 
00991 
00992 /* u8g_pb8h1.c */
00993 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00994 
00995 /* u8g_pb16h1.c */
00996 uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
00997 
00998 /* u8g_pb32h1.c */
00999 uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01000 
01001 
01002 /* u8g_pb8h2.c 8 pixel rows, byte has horzontal orientation */
01003 uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01004 
01005 /* u8g_pb16h2.c */
01006 uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01007 
01008 
01009 
01010 /* u8g_pb8h1f.c */
01011 uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01012 
01013 /* u8g_pb8h8.c */
01014 uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01015 
01016 /* u8g_pbxh16.c */
01017 uint8_t u8g_dev_pbxh16_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01018 
01019 /* u8g_pbxh24.c */
01020 uint8_t u8g_dev_pbxh24_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01021 
01022 
01023 /*===============================================================*/
01024 /* u8g_ll_api.c */
01025 
01026 /* cursor draw callback */
01027 typedef void (*u8g_draw_cursor_fn)(u8g_t *u8g);
01028 
01029 /* vertical reference point calculation callback */
01030 typedef u8g_uint_t (*u8g_font_calc_vref_fnptr)(u8g_t *u8g);
01031 
01032 /* state backup and restore procedure */
01033 typedef void (*u8g_state_cb)(uint8_t msg);
01034 
01035 
01036 /* PI = Pin Index */
01037 
01038 /* reset pin, usually optional */
01039 #define U8G_PI_RESET 0
01040 
01041 /* address / data or instruction */
01042 #define U8G_PI_A0 1
01043 #define U8G_PI_DI 1
01044 
01045 /* chip select line */
01046 #define U8G_PI_CS 2
01047 #define U8G_PI_CS1 2
01048 #define U8G_PI_CS2 3
01049 /* Feb 2013: A0 state moved from 7 to 3 for t6963 controller*/
01050 #define U8G_PI_A0_STATE 3
01051 
01052 /* enable / clock signal */
01053 #define U8G_PI_EN 4
01054 #define U8G_PI_CS_STATE 4
01055 #define U8G_PI_SCK 4
01056 #define U8G_PI_SCL 4
01057 #define U8G_PI_RD 4
01058 
01059 
01060 /* data pins, shared with SPI and I2C pins */
01061 #define U8G_PI_D0 5
01062 #define U8G_PI_MOSI 5
01063 #define U8G_PI_SDA 5
01064 #define U8G_PI_D1 6
01065 #define U8G_PI_MISO 6
01066 #define U8G_PI_D2 7
01067 #define U8G_PI_D3 8
01068 #define U8G_PI_SET_A0 8
01069 #define U8G_PI_D4 9
01070 #define U8G_PI_D5 10
01071 #define U8G_PI_I2C_OPTION 11
01072 #define U8G_PI_D6 11
01073 #define U8G_PI_D7 12
01074 
01075 /* read/write pin, must be the last pin in the list, this means U8G_PIN_LIST_LEN =  U8G_PI_RW + 1*/
01076 #define U8G_PI_WR 13
01077 #define U8G_PI_RW 13
01078 
01079 #define U8G_PIN_LIST_LEN 14
01080 
01081 
01082 #define U8G_PIN_DUMMY 254
01083 #define U8G_PIN_NONE 255
01084 
01085 #define U8G_FONT_HEIGHT_MODE_TEXT 0
01086 #define U8G_FONT_HEIGHT_MODE_XTEXT 1
01087 #define U8G_FONT_HEIGHT_MODE_ALL 2
01088 
01089 struct _u8g_t
01090 {
01091   u8g_uint_t width;
01092   u8g_uint_t height;
01093 
01094 
01095   u8g_dev_t *dev;               /* first device in the device chain */
01096   const u8g_pgm_uint8_t *font;             /* regular font for all text procedures */
01097   const u8g_pgm_uint8_t *cursor_font;  /* special font for cursor procedures */
01098   uint8_t cursor_fg_color, cursor_bg_color;
01099   uint8_t cursor_encoding;
01100   uint8_t mode;                         /* display mode, one of U8G_MODE_xxx */
01101   u8g_uint_t cursor_x;
01102   u8g_uint_t cursor_y;
01103   u8g_draw_cursor_fn cursor_fn;
01104 
01105   int8_t glyph_dx;
01106   int8_t glyph_x;
01107   int8_t glyph_y;
01108   uint8_t glyph_width;
01109   uint8_t glyph_height;
01110 
01111   u8g_font_calc_vref_fnptr font_calc_vref;
01112   uint8_t font_height_mode;
01113   int8_t font_ref_ascent;
01114   int8_t font_ref_descent;
01115   uint8_t font_line_spacing_factor;     /* line_spacing = factor * (ascent - descent) / 64 */
01116   uint8_t line_spacing;
01117 
01118   u8g_dev_arg_pixel_t arg_pixel;
01119   /* uint8_t color_index; */
01120 
01121 #ifdef U8G_WITH_PINLIST
01122   uint8_t pin_list[U8G_PIN_LIST_LEN];
01123 #endif
01124 
01125   u8g_state_cb state_cb;
01126 
01127   u8g_box_t current_page;               /* current box of the visible page */
01128 
01129 };
01130 
01131 #define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
01132 #define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
01133 #define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
01134 
01135 uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
01136 
01137 uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev);
01138 void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev);
01139 uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev);
01140 uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast);
01141 void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y);
01142 void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
01143 void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
01144 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);    /* obsolete */
01145 u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev);
01146 u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev);
01147 
01148 void u8g_UpdateDimension(u8g_t *u8g);
01149 uint8_t u8g_Begin(u8g_t *u8g);                          /* reset device, put it into default state and call u8g_UpdateDimension() */
01150 uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev);   /* only usefull if the device only as hardcoded ports */
01151 uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn);        /* Init procedure for anything which is not Arduino or AVR (e.g. ARM, but not Due, which is Arduino) */
01152 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);
01153 uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset);
01154 uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options);       /* use U8G_I2C_OPT_NONE as options */
01155 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);
01156 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,
01157   uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset);
01158 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,
01159   uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
01160 void u8g_FirstPage(u8g_t *u8g);
01161 uint8_t u8g_NextPage(u8g_t *u8g);
01162 uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast);
01163 void u8g_SleepOn(u8g_t *u8g);
01164 void u8g_SleepOff(u8g_t *u8g);
01165 void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y);
01166 void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
01167 void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
01168 
01169 uint8_t u8g_Stop(u8g_t *u8g);
01170 void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
01171 void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx);
01172 void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb);
01173 void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b);
01174 void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b);
01175 uint8_t u8g_GetColorIndex(u8g_t *u8g);
01176 
01177 uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g);
01178 void u8g_SetDefaultForegroundColor(u8g_t *u8g);
01179 
01180 uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g);
01181 void u8g_SetDefaultBackgroundColor(u8g_t *u8g);
01182 
01183 uint8_t u8g_GetDefaultMidColor(u8g_t *u8g);
01184 void u8g_SetDefaultMidColor(u8g_t *u8g);
01185 
01186 #define u8g_GetWidth(u8g) ((u8g)->width)
01187 #define u8g_GetHeight(u8g) ((u8g)->height)
01188 #define u8g_GetMode(u8g) ((u8g)->mode)
01189 /*
01190   U8G_MODE_GET_BITS_PER_PIXEL(u8g_GetMode(u8g))
01191   U8G_MODE_IS_COLOR(u8g_GetMode(u8g))
01192 */
01193 
01194 /* u8g_state.c */
01195 #define U8G_STATE_ENV_IDX 0
01196 #define U8G_STATE_U8G_IDX 1
01197 #define U8G_STATE_RESTORE 0
01198 #define U8G_STATE_BACKUP 1
01199 #define U8G_STATE_MSG_COMPOSE(cmd,idx) (((cmd)<<1) | (idx))
01200 
01201 #define U8G_STATE_MSG_RESTORE_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_ENV_IDX)
01202 #define U8G_STATE_MSG_BACKUP_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_ENV_IDX)
01203 #define U8G_STATE_MSG_RESTORE_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_U8G_IDX)
01204 #define U8G_STATE_MSG_BACKUP_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_U8G_IDX)
01205 
01206 #define U8G_STATE_MSG_GET_IDX(msg) ((msg)&1)
01207 #define U8G_STATE_MSG_IS_BACKUP(msg) ((msg)&2)
01208 
01209 
01210 
01211 void u8g_state_dummy_cb(uint8_t msg);
01212 void u8g_backup_spi(uint8_t msg);               /* backup SPI state controller */
01213 /* backward compatible definition */
01214 #define u8g_backup_avr_spi u8g_backup_spi
01215 
01216 void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb);
01217 
01218 /* u8g_clip.c */
01219 
01220 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
01221 
01222 
01223 /* u8g_rot.c */
01224 
01225 void u8g_UndoRotation(u8g_t *u8g);
01226 void u8g_SetRot90(u8g_t *u8g);
01227 void u8g_SetRot180(u8g_t *u8g);
01228 void u8g_SetRot270(u8g_t *u8g);
01229 
01230 /* u8g_scale.c */
01231 
01232 void u8g_UndoScale(u8g_t *u8g);
01233 void u8g_SetScale2x2(u8g_t *u8g);
01234 
01235 
01236 /* u8g_font.c */
01237 
01238 size_t u8g_font_GetSize(const void *font);
01239 uint8_t u8g_font_GetFontStartEncoding(const void *font) U8G_NOINLINE;
01240 uint8_t u8g_font_GetFontEndEncoding(const void *font) U8G_NOINLINE;
01241 
01242 void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font);
01243 
01244 uint8_t u8g_GetFontBBXWidth(u8g_t *u8g);
01245 uint8_t u8g_GetFontBBXHeight(u8g_t *u8g);
01246 int8_t u8g_GetFontBBXOffX(u8g_t *u8g);
01247 int8_t u8g_GetFontBBXOffY(u8g_t *u8g);
01248 uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g);
01249 
01250 uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding);
01251 int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding);
01252 
01253 int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding); /* used by u8g_cursor.c */
01254 
01255 int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
01256 int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
01257 int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
01258 int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
01259 int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
01260 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
01261 
01262 u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
01263 u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
01264 u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
01265 u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
01266 
01267 u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
01268 
01269 
01270 u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
01271 u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
01272 u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
01273 u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
01274 
01275 
01276 void u8g_SetFontRefHeightText(u8g_t *u8g);
01277 void u8g_SetFontRefHeightExtendedText(u8g_t *u8g);
01278 void u8g_SetFontRefHeightAll(u8g_t *u8g);
01279 void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor);
01280 
01281 u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g);
01282 u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g);
01283 u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g);
01284 u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g);
01285 
01286 void u8g_SetFontPosBaseline(u8g_t *u8g);
01287 void u8g_SetFontPosBottom(u8g_t *u8g);
01288 void u8g_SetFontPosCenter(u8g_t *u8g);
01289 void u8g_SetFontPosTop(u8g_t *u8g);
01290 
01291 
01292 u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s);
01293 u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
01294 int8_t u8g_GetStrX(u8g_t *u8g, const char *s);
01295 int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
01296 u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s);
01297 u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
01298 
01299 u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
01300 
01301 void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
01302 void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
01303 
01304 
01305 u8g_uint_t u8g_DrawAAStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
01306 
01307 /* u8g_rect.c */
01308 
01309 void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) U8G_NOINLINE;
01310 
01311 void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
01312 void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
01313 void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
01314 void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
01315 
01316 void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
01317 void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
01318 
01319 /* u8g_bitmap.c */
01320 
01321 void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap);
01322 void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap);
01323 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);
01324 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);
01325 
01326 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);
01327 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);
01328 
01329 
01330 /* u8g_line.c */
01331 void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2);
01332 
01333 
01334 /* u8g_circle.c */
01335 
01336 /* the following, commented code has been rewritten or is not yet finished
01337 #define U8G_CIRC_UPPER_RIGHT 0x01
01338 #define U8G_CIRC_UPPER_LEFT  0x02
01339 #define U8G_CIRC_LOWER_LEFT 0x04
01340 #define U8G_CIRC_LOWER_RIGHT  0x08
01341 #define U8G_CIRC_ALL (U8G_CIRC_UPPER_RIGHT|U8G_CIRC_UPPER_LEFT|U8G_CIRC_LOWER_RIGHT|U8G_CIRC_LOWER_LEFT)
01342 void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
01343 void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
01344 void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1);
01345 */
01346 
01347 #define U8G_DRAW_UPPER_RIGHT 0x01
01348 #define U8G_DRAW_UPPER_LEFT  0x02
01349 #define U8G_DRAW_LOWER_LEFT 0x04
01350 #define U8G_DRAW_LOWER_RIGHT  0x08
01351 #define U8G_DRAW_ALL (U8G_DRAW_UPPER_RIGHT|U8G_DRAW_UPPER_LEFT|U8G_DRAW_LOWER_RIGHT|U8G_DRAW_LOWER_LEFT)
01352 
01353 void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
01354 void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
01355 
01356 void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
01357 void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
01358 
01359 /* u8g_ellipse.c */
01360 void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option);
01361 void u8g_DrawFilledEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option);
01362 
01363 /* u8g_clip.c */
01364 uint8_t u8g_is_box_bbx_intersection(u8g_box_t *box, u8g_dev_arg_bbx_t *bbx);
01365 
01366 
01367 /* u8g_cursor.c */
01368 void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font);
01369 void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding);
01370 void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y);
01371 void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg);
01372 void u8g_EnableCursor(u8g_t *u8g);
01373 void u8g_DisableCursor(u8g_t *u8g);
01374 void u8g_DrawCursor(u8g_t *u8g);
01375 
01376 
01377 
01378 /*===============================================================*/
01379 /* u8g_virtual_screen.c */
01380 void u8g_SetVirtualScreenDimension(u8g_t *vs_u8g, u8g_uint_t width, u8g_uint_t height);
01381 uint8_t u8g_AddToVirtualScreen(u8g_t *vs_u8g, u8g_uint_t x, u8g_uint_t y, u8g_t *child_u8g);
01382 
01383 /*===============================================================*/
01384 void st_Draw(uint8_t fps);
01385 void st_Step(uint8_t player_pos, uint8_t is_auto_fire, uint8_t is_fire);
01386 
01387 /*===============================================================*/
01388 /* u8g_com_i2c.c */
01389 
01390 /* options for u8g_i2c_init() */
01391 #define U8G_I2C_OPT_NONE 0
01392 
01393 /* retrun values from u8g_twi_get_error() */
01394 #define U8G_I2C_ERR_NONE 0x00
01395 /* the following values are bit masks */
01396 #define U8G_I2C_ERR_TIMEOUT 0x01
01397 #define U8G_I2C_ERR_BUS 0x02
01398 
01399 void u8g_i2c_clear_error(void) U8G_NOINLINE;
01400 uint8_t  u8g_i2c_get_error(void) U8G_NOINLINE;
01401 uint8_t u8g_i2c_get_err_pos(void) U8G_NOINLINE;
01402 void u8g_i2c_init(uint8_t options) U8G_NOINLINE;                /* use U8G_I2C_OPT_NONE as options */
01403 uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) U8G_NOINLINE;
01404 uint8_t u8g_i2c_start(uint8_t sla) U8G_NOINLINE;
01405 uint8_t u8g_i2c_send_byte(uint8_t data) U8G_NOINLINE;
01406 void u8g_i2c_stop(void) U8G_NOINLINE;
01407 
01408 
01409 /*===============================================================*/
01410 /* u8g_u8toa.c */
01411 /* v = value, d = number of digits */
01412 const char *u8g_u8toa(uint8_t v, uint8_t d);
01413 
01414 /* u8g_u8toa.c */
01415 /* v = value, d = number of digits */
01416 const char *u8g_u16toa(uint16_t v, uint8_t d);
01417 
01418 /*===============================================================*/
01419 /* u8g_delay.c */
01420 
01421 /* delay by the specified number of milliseconds */
01422 void u8g_Delay(uint16_t val);
01423 
01424 /* delay by one microsecond */
01425 void u8g_MicroDelay(void);
01426 
01427 /* delay by 10 microseconds */
01428 void u8g_10MicroDelay(void);
01429 
01430 /*===============================================================*/
01431 /* chessengine.c */
01432 #define CHESS_KEY_NONE 0
01433 #define CHESS_KEY_NEXT 1
01434 #define CHESS_KEY_PREV 2
01435 #define CHESS_KEY_SELECT 3
01436 #define CHESS_KEY_BACK 4
01437 
01438 void chess_Init(u8g_t *u8g, uint8_t empty_body_color);
01439 void chess_Draw(void);
01440 void chess_Step(uint8_t keycode);
01441 
01442 /*===============================================================*/
01443 /* font definitions */
01444 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_FONT_SECTION("u8g_font_m2icon_5");
01445 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_7[] U8G_FONT_SECTION("u8g_font_m2icon_7");
01446 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_9[] U8G_FONT_SECTION("u8g_font_m2icon_9");
01447 
01448 extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4[] U8G_FONT_SECTION("u8g_font_u8glib_4");
01449 extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4r[] U8G_FONT_SECTION("u8g_font_u8glib_4r");
01450 
01451 
01452 extern const u8g_fntpgm_uint8_t u8g_font_6x12_75r[] U8G_FONT_SECTION("u8g_font_6x12_75r");
01453 extern const u8g_fntpgm_uint8_t u8g_font_6x13_75r[] U8G_FONT_SECTION("u8g_font_6x13_75r");
01454 extern const u8g_fntpgm_uint8_t u8g_font_7x13_75r[] U8G_FONT_SECTION("u8g_font_7x13_75r");
01455 extern const u8g_fntpgm_uint8_t u8g_font_8x13_75r[] U8G_FONT_SECTION("u8g_font_8x13_75r");
01456 extern const u8g_fntpgm_uint8_t u8g_font_9x15_75r[] U8G_FONT_SECTION("u8g_font_9x15_75r");
01457 extern const u8g_fntpgm_uint8_t u8g_font_9x18_75r[] U8G_FONT_SECTION("u8g_font_9x18_75r");
01458 extern const u8g_fntpgm_uint8_t u8g_font_cu12_75r[] U8G_FONT_SECTION("u8g_font_cu12_75r");
01459 extern const u8g_fntpgm_uint8_t u8g_font_unifont_75r[] U8G_FONT_SECTION("u8g_font_unifont_75r");
01460 extern const u8g_fntpgm_uint8_t u8g_font_10x20_75r[] U8G_FONT_SECTION("u8g_font_10x20_75r");
01461 
01462 extern const u8g_fntpgm_uint8_t u8g_font_10x20_67_75[] U8G_FONT_SECTION("u8g_font_10x20_67_75");
01463 extern const u8g_fntpgm_uint8_t u8g_font_10x20_78_79[] U8G_FONT_SECTION("u8g_font_10x20_78_79");
01464 extern const u8g_fntpgm_uint8_t u8g_font_10x20[] U8G_FONT_SECTION("u8g_font_10x20");
01465 extern const u8g_fntpgm_uint8_t u8g_font_10x20r[] U8G_FONT_SECTION("u8g_font_10x20r");
01466 extern const u8g_fntpgm_uint8_t u8g_font_4x6[] U8G_FONT_SECTION("u8g_font_4x6");
01467 extern const u8g_fntpgm_uint8_t u8g_font_4x6r[] U8G_FONT_SECTION("u8g_font_4x6r");
01468 //extern const u8g_fntpgm_uint8_t u8g_font_4x6n[] U8G_FONT_SECTION("u8g_font_4x6n");
01469 extern const u8g_fntpgm_uint8_t u8g_font_5x7[] U8G_FONT_SECTION("u8g_font_5x7");
01470 extern const u8g_fntpgm_uint8_t u8g_font_5x7r[] U8G_FONT_SECTION("u8g_font_5x7r");
01471 extern const u8g_fntpgm_uint8_t u8g_font_5x8[] U8G_FONT_SECTION("u8g_font_5x8");
01472 extern const u8g_fntpgm_uint8_t u8g_font_5x8r[] U8G_FONT_SECTION("u8g_font_5x8r");
01473 extern const u8g_fntpgm_uint8_t u8g_font_6x10[] U8G_FONT_SECTION("u8g_font_6x10");
01474 extern const u8g_fntpgm_uint8_t u8g_font_6x10r[] U8G_FONT_SECTION("u8g_font_6x10r");
01475 extern const u8g_fntpgm_uint8_t u8g_font_6x12_67_75[] U8G_FONT_SECTION("u8g_font_6x12_67_75");
01476 extern const u8g_fntpgm_uint8_t u8g_font_6x12_78_79[] U8G_FONT_SECTION("u8g_font_6x12_78_79");
01477 extern const u8g_fntpgm_uint8_t u8g_font_6x12[] U8G_FONT_SECTION("u8g_font_6x12");
01478 extern const u8g_fntpgm_uint8_t u8g_font_6x12r[] U8G_FONT_SECTION("u8g_font_6x12r");
01479 extern const u8g_fntpgm_uint8_t u8g_font_6x13_67_75[] U8G_FONT_SECTION("u8g_font_6x13_67_75");
01480 extern const u8g_fntpgm_uint8_t u8g_font_6x13_78_79[] U8G_FONT_SECTION("u8g_font_6x13_78_79");
01481 extern const u8g_fntpgm_uint8_t u8g_font_6x13B[] U8G_FONT_SECTION("u8g_font_6x13B");
01482 extern const u8g_fntpgm_uint8_t u8g_font_6x13Br[] U8G_FONT_SECTION("u8g_font_6x13Br");
01483 extern const u8g_fntpgm_uint8_t u8g_font_6x13[] U8G_FONT_SECTION("u8g_font_6x13");
01484 extern const u8g_fntpgm_uint8_t u8g_font_6x13r[] U8G_FONT_SECTION("u8g_font_6x13r");
01485 extern const u8g_fntpgm_uint8_t u8g_font_6x13O[] U8G_FONT_SECTION("u8g_font_6x13O");
01486 extern const u8g_fntpgm_uint8_t u8g_font_6x13Or[] U8G_FONT_SECTION("u8g_font_6x13Or");
01487 extern const u8g_fntpgm_uint8_t u8g_font_7x13_67_75[] U8G_FONT_SECTION("u8g_font_7x13_67_75");
01488 extern const u8g_fntpgm_uint8_t u8g_font_7x13_78_79[] U8G_FONT_SECTION("u8g_font_7x13_78_79");
01489 extern const u8g_fntpgm_uint8_t u8g_font_7x13B[] U8G_FONT_SECTION("u8g_font_7x13B");
01490 extern const u8g_fntpgm_uint8_t u8g_font_7x13Br[] U8G_FONT_SECTION("u8g_font_7x13Br");
01491 extern const u8g_fntpgm_uint8_t u8g_font_7x13[] U8G_FONT_SECTION("u8g_font_7x13");
01492 extern const u8g_fntpgm_uint8_t u8g_font_7x13r[] U8G_FONT_SECTION("u8g_font_7x13r");
01493 extern const u8g_fntpgm_uint8_t u8g_font_7x13O[] U8G_FONT_SECTION("u8g_font_7x13O");
01494 extern const u8g_fntpgm_uint8_t u8g_font_7x13Or[] U8G_FONT_SECTION("u8g_font_7x13Or");
01495 extern const u8g_fntpgm_uint8_t u8g_font_7x14B[] U8G_FONT_SECTION("u8g_font_7x14B");
01496 extern const u8g_fntpgm_uint8_t u8g_font_7x14Br[] U8G_FONT_SECTION("u8g_font_7x14Br");
01497 extern const u8g_fntpgm_uint8_t u8g_font_7x14[] U8G_FONT_SECTION("u8g_font_7x14");
01498 extern const u8g_fntpgm_uint8_t u8g_font_7x14r[] U8G_FONT_SECTION("u8g_font_7x14r");
01499 extern const u8g_fntpgm_uint8_t u8g_font_8x13_67_75[] U8G_FONT_SECTION("u8g_font_8x13_67_75");
01500 extern const u8g_fntpgm_uint8_t u8g_font_8x13B[] U8G_FONT_SECTION("u8g_font_8x13B");
01501 extern const u8g_fntpgm_uint8_t u8g_font_8x13Br[] U8G_FONT_SECTION("u8g_font_8x13Br");
01502 extern const u8g_fntpgm_uint8_t u8g_font_8x13[] U8G_FONT_SECTION("u8g_font_8x13");
01503 extern const u8g_fntpgm_uint8_t u8g_font_8x13r[] U8G_FONT_SECTION("u8g_font_8x13r");
01504 extern const u8g_fntpgm_uint8_t u8g_font_8x13O[] U8G_FONT_SECTION("u8g_font_8x13O");
01505 extern const u8g_fntpgm_uint8_t u8g_font_8x13Or[] U8G_FONT_SECTION("u8g_font_8x13Or");
01506 
01507 extern const u8g_fntpgm_uint8_t u8g_font_9x15_67_75[] U8G_FONT_SECTION("u8g_font_9x15_67_75");
01508 extern const u8g_fntpgm_uint8_t u8g_font_9x15_78_79[] U8G_FONT_SECTION("u8g_font_9x15_78_79");
01509 extern const u8g_fntpgm_uint8_t u8g_font_9x15B[] U8G_FONT_SECTION("u8g_font_9x15B");
01510 extern const u8g_fntpgm_uint8_t u8g_font_9x15Br[] U8G_FONT_SECTION("u8g_font_9x15Br");
01511 extern const u8g_fntpgm_uint8_t u8g_font_9x15[] U8G_FONT_SECTION("u8g_font_9x15");
01512 extern const u8g_fntpgm_uint8_t u8g_font_9x15r[] U8G_FONT_SECTION("u8g_font_9x15r");
01513 
01514 extern const u8g_fntpgm_uint8_t u8g_font_9x18_67_75[] U8G_FONT_SECTION("u8g_font_9x18_67_75");
01515 extern const u8g_fntpgm_uint8_t u8g_font_9x18_78_79[] U8G_FONT_SECTION("u8g_font_9x18_78_79");
01516 extern const u8g_fntpgm_uint8_t u8g_font_9x18B[] U8G_FONT_SECTION("u8g_font_9x18B");
01517 extern const u8g_fntpgm_uint8_t u8g_font_9x18[] U8G_FONT_SECTION("u8g_font_9x18");
01518 extern const u8g_fntpgm_uint8_t u8g_font_9x18Br[] U8G_FONT_SECTION("u8g_font_9x18Br");
01519 extern const u8g_fntpgm_uint8_t u8g_font_9x18r[] U8G_FONT_SECTION("u8g_font_9x18r");
01520 
01521 extern const u8g_fntpgm_uint8_t u8g_font_cursor[] U8G_FONT_SECTION("u8g_font_cursor");
01522 extern const u8g_fntpgm_uint8_t u8g_font_cursorr[] U8G_FONT_SECTION("u8g_font_cursorr");
01523 extern const u8g_fntpgm_uint8_t u8g_font_micro[] U8G_FONT_SECTION("u8g_font_micro");
01524 
01525 extern const u8g_fntpgm_uint8_t u8g_font_cu12_67_75[] U8G_FONT_SECTION("u8g_font_cu12_67_75");
01526 extern const u8g_fntpgm_uint8_t u8g_font_cu12_78_79[] U8G_FONT_SECTION("u8g_font_cu12_78_79");
01527 extern const u8g_fntpgm_uint8_t u8g_font_cu12[] U8G_FONT_SECTION("u8g_font_cu12");
01528 
01529 /*
01530   Free-Universal Bold
01531   r: Reduced char set (codes 32 - 128)
01532   n: Numbers (codes 42 - 57)
01533   no char: Full set (codes 32 - 255)
01534 */
01535 
01536 extern const u8g_fntpgm_uint8_t u8g_font_fub11[] U8G_FONT_SECTION("u8g_font_fub11");
01537 extern const u8g_fntpgm_uint8_t u8g_font_fub11r[] U8G_FONT_SECTION("u8g_font_fub11r");
01538 extern const u8g_fntpgm_uint8_t u8g_font_fub11n[] U8G_FONT_SECTION("u8g_font_fub11n");
01539 extern const u8g_fntpgm_uint8_t u8g_font_fub14[] U8G_FONT_SECTION("u8g_font_fub14");
01540 extern const u8g_fntpgm_uint8_t u8g_font_fub14r[] U8G_FONT_SECTION("u8g_font_fub14r");
01541 extern const u8g_fntpgm_uint8_t u8g_font_fub14n[] U8G_FONT_SECTION("u8g_font_fub14n");
01542 extern const u8g_fntpgm_uint8_t u8g_font_fub17[] U8G_FONT_SECTION("u8g_font_fub17");
01543 extern const u8g_fntpgm_uint8_t u8g_font_fub17r[] U8G_FONT_SECTION("u8g_font_fub17r");
01544 extern const u8g_fntpgm_uint8_t u8g_font_fub17n[] U8G_FONT_SECTION("u8g_font_fub17n");
01545 extern const u8g_fntpgm_uint8_t u8g_font_fub20[] U8G_FONT_SECTION("u8g_font_fub20");
01546 extern const u8g_fntpgm_uint8_t u8g_font_fub20r[] U8G_FONT_SECTION("u8g_font_fub20r");
01547 extern const u8g_fntpgm_uint8_t u8g_font_fub20n[] U8G_FONT_SECTION("u8g_font_fub20n");
01548 extern const u8g_fntpgm_uint8_t u8g_font_fub25[] U8G_FONT_SECTION("u8g_font_fub25");
01549 extern const u8g_fntpgm_uint8_t u8g_font_fub25r[] U8G_FONT_SECTION("u8g_font_fub25r");
01550 extern const u8g_fntpgm_uint8_t u8g_font_fub25n[] U8G_FONT_SECTION("u8g_font_fub25n");
01551 extern const u8g_fntpgm_uint8_t u8g_font_fub30[] U8G_FONT_SECTION("u8g_font_fub30");
01552 extern const u8g_fntpgm_uint8_t u8g_font_fub30r[] U8G_FONT_SECTION("u8g_font_fub30r");
01553 extern const u8g_fntpgm_uint8_t u8g_font_fub30n[] U8G_FONT_SECTION("u8g_font_fub30n");
01554 extern const u8g_fntpgm_uint8_t u8g_font_fub35n[] U8G_FONT_SECTION("u8g_font_fub35n");
01555 extern const u8g_fntpgm_uint8_t u8g_font_fub42n[] U8G_FONT_SECTION("u8g_font_fub42n");
01556 extern const u8g_fntpgm_uint8_t u8g_font_fub49n[] U8G_FONT_SECTION("u8g_font_fub49n");
01557 
01558 /*
01559   Free-Universal Regular
01560   r: Reduced char set (codes 32 - 128)
01561   n: Numbers (codes 42 - 57)
01562   no char: Full set (codes 32 - 255)
01563 */
01564 
01565 extern const u8g_fntpgm_uint8_t u8g_font_fur11[] U8G_FONT_SECTION("u8g_font_fur11");
01566 extern const u8g_fntpgm_uint8_t u8g_font_fur11r[] U8G_FONT_SECTION("u8g_font_fur11r");
01567 extern const u8g_fntpgm_uint8_t u8g_font_fur11n[] U8G_FONT_SECTION("u8g_font_fur11n");
01568 extern const u8g_fntpgm_uint8_t u8g_font_fur14[] U8G_FONT_SECTION("u8g_font_fur14");
01569 extern const u8g_fntpgm_uint8_t u8g_font_fur14r[] U8G_FONT_SECTION("u8g_font_fur14r");
01570 extern const u8g_fntpgm_uint8_t u8g_font_fur14n[] U8G_FONT_SECTION("u8g_font_fur14n");
01571 extern const u8g_fntpgm_uint8_t u8g_font_fur17[] U8G_FONT_SECTION("u8g_font_fur17");
01572 extern const u8g_fntpgm_uint8_t u8g_font_fur17r[] U8G_FONT_SECTION("u8g_font_fur17r");
01573 extern const u8g_fntpgm_uint8_t u8g_font_fur17n[] U8G_FONT_SECTION("u8g_font_fur17n");
01574 extern const u8g_fntpgm_uint8_t u8g_font_fur20[] U8G_FONT_SECTION("u8g_font_fur20");
01575 extern const u8g_fntpgm_uint8_t u8g_font_fur20r[] U8G_FONT_SECTION("u8g_font_fur20r");
01576 extern const u8g_fntpgm_uint8_t u8g_font_fur20n[] U8G_FONT_SECTION("u8g_font_fur20n");
01577 extern const u8g_fntpgm_uint8_t u8g_font_fur25[] U8G_FONT_SECTION("u8g_font_fur25");
01578 extern const u8g_fntpgm_uint8_t u8g_font_fur25r[] U8G_FONT_SECTION("u8g_font_fur25r");
01579 extern const u8g_fntpgm_uint8_t u8g_font_fur25n[] U8G_FONT_SECTION("u8g_font_fur25n");
01580 extern const u8g_fntpgm_uint8_t u8g_font_fur30[] U8G_FONT_SECTION("u8g_font_fur30");
01581 extern const u8g_fntpgm_uint8_t u8g_font_fur30r[] U8G_FONT_SECTION("u8g_font_fur30r");
01582 extern const u8g_fntpgm_uint8_t u8g_font_fur30n[] U8G_FONT_SECTION("u8g_font_fur30n");
01583 extern const u8g_fntpgm_uint8_t u8g_font_fur35n[] U8G_FONT_SECTION("u8g_font_fur35n");
01584 extern const u8g_fntpgm_uint8_t u8g_font_fur42n[] U8G_FONT_SECTION("u8g_font_fur42n");
01585 extern const u8g_fntpgm_uint8_t u8g_font_fur49n[] U8G_FONT_SECTION("u8g_font_fur49n");
01586 
01587 /*
01588   Gentium Bold
01589   r: Reduced char set (codes 32 - 128)
01590   n: Numbers (codes 42 - 57)
01591   no char: Full set (codes 32 - 255)
01592 */
01593 
01594 extern const u8g_fntpgm_uint8_t u8g_font_gdb11[] U8G_FONT_SECTION("u8g_font_gdb11");
01595 extern const u8g_fntpgm_uint8_t u8g_font_gdb12[] U8G_FONT_SECTION("u8g_font_gdb12");
01596 extern const u8g_fntpgm_uint8_t u8g_font_gdb14[] U8G_FONT_SECTION("u8g_font_gdb14");
01597 extern const u8g_fntpgm_uint8_t u8g_font_gdb17[] U8G_FONT_SECTION("u8g_font_gdb17");
01598 extern const u8g_fntpgm_uint8_t u8g_font_gdb20[] U8G_FONT_SECTION("u8g_font_gdb20");
01599 extern const u8g_fntpgm_uint8_t u8g_font_gdb25[] U8G_FONT_SECTION("u8g_font_gdb25");
01600 extern const u8g_fntpgm_uint8_t u8g_font_gdb30[] U8G_FONT_SECTION("u8g_font_gdb30");
01601 
01602 extern const u8g_fntpgm_uint8_t u8g_font_gdb11r[] U8G_FONT_SECTION("u8g_font_gdb11r");
01603 extern const u8g_fntpgm_uint8_t u8g_font_gdb12r[] U8G_FONT_SECTION("u8g_font_gdb12r");
01604 extern const u8g_fntpgm_uint8_t u8g_font_gdb14r[] U8G_FONT_SECTION("u8g_font_gdb14r");
01605 extern const u8g_fntpgm_uint8_t u8g_font_gdb17r[] U8G_FONT_SECTION("u8g_font_gdb17r");
01606 extern const u8g_fntpgm_uint8_t u8g_font_gdb20r[] U8G_FONT_SECTION("u8g_font_gdb20r");
01607 extern const u8g_fntpgm_uint8_t u8g_font_gdb25r[] U8G_FONT_SECTION("u8g_font_gdb25r");
01608 extern const u8g_fntpgm_uint8_t u8g_font_gdb30r[] U8G_FONT_SECTION("u8g_font_gdb30r");
01609 
01610 extern const u8g_fntpgm_uint8_t u8g_font_gdb11n[] U8G_FONT_SECTION("u8g_font_gdb11n");
01611 extern const u8g_fntpgm_uint8_t u8g_font_gdb12n[] U8G_FONT_SECTION("u8g_font_gdb12n");
01612 extern const u8g_fntpgm_uint8_t u8g_font_gdb14n[] U8G_FONT_SECTION("u8g_font_gdb14n");
01613 extern const u8g_fntpgm_uint8_t u8g_font_gdb17n[] U8G_FONT_SECTION("u8g_font_gdb17n");
01614 extern const u8g_fntpgm_uint8_t u8g_font_gdb20n[] U8G_FONT_SECTION("u8g_font_gdb20n");
01615 extern const u8g_fntpgm_uint8_t u8g_font_gdb25n[] U8G_FONT_SECTION("u8g_font_gdb25n");
01616 extern const u8g_fntpgm_uint8_t u8g_font_gdb30n[] U8G_FONT_SECTION("u8g_font_gdb30n");
01617 
01618 /*
01619   Gentium Regular
01620   r: Reduced char set (codes 32 - 128)
01621   n: Numbers (codes 42 - 57)
01622   no char: Full set (codes 32 - 255)
01623 */
01624 
01625 extern const u8g_fntpgm_uint8_t u8g_font_gdr9[] U8G_FONT_SECTION("u8g_font_gdr9");
01626 extern const u8g_fntpgm_uint8_t u8g_font_gdr10[] U8G_FONT_SECTION("u8g_font_gdr10");
01627 extern const u8g_fntpgm_uint8_t u8g_font_gdr11[] U8G_FONT_SECTION("u8g_font_gdr11");
01628 extern const u8g_fntpgm_uint8_t u8g_font_gdr12[] U8G_FONT_SECTION("u8g_font_gdr12");
01629 extern const u8g_fntpgm_uint8_t u8g_font_gdr14[] U8G_FONT_SECTION("u8g_font_gdr14");
01630 extern const u8g_fntpgm_uint8_t u8g_font_gdr17[] U8G_FONT_SECTION("u8g_font_gdr17");
01631 extern const u8g_fntpgm_uint8_t u8g_font_gdr20[] U8G_FONT_SECTION("u8g_font_gdr20");
01632 extern const u8g_fntpgm_uint8_t u8g_font_gdr25[] U8G_FONT_SECTION("u8g_font_gdr25");
01633 extern const u8g_fntpgm_uint8_t u8g_font_gdr30[] U8G_FONT_SECTION("u8g_font_gdr30");
01634 
01635 extern const u8g_fntpgm_uint8_t u8g_font_gdr9r[] U8G_FONT_SECTION("u8g_font_gdr9r");
01636 extern const u8g_fntpgm_uint8_t u8g_font_gdr10r[] U8G_FONT_SECTION("u8g_font_gdr10r");
01637 extern const u8g_fntpgm_uint8_t u8g_font_gdr11r[] U8G_FONT_SECTION("u8g_font_gdr11r");
01638 extern const u8g_fntpgm_uint8_t u8g_font_gdr12r[] U8G_FONT_SECTION("u8g_font_gdr12r");
01639 extern const u8g_fntpgm_uint8_t u8g_font_gdr14r[] U8G_FONT_SECTION("u8g_font_gdr14r");
01640 extern const u8g_fntpgm_uint8_t u8g_font_gdr17r[] U8G_FONT_SECTION("u8g_font_gdr17r");
01641 extern const u8g_fntpgm_uint8_t u8g_font_gdr20r[] U8G_FONT_SECTION("u8g_font_gdr20r");
01642 extern const u8g_fntpgm_uint8_t u8g_font_gdr25r[] U8G_FONT_SECTION("u8g_font_gdr25r");
01643 extern const u8g_fntpgm_uint8_t u8g_font_gdr30r[] U8G_FONT_SECTION("u8g_font_gdr30r");
01644 
01645 extern const u8g_fntpgm_uint8_t u8g_font_gdr9n[] U8G_FONT_SECTION("u8g_font_gdr9n");
01646 extern const u8g_fntpgm_uint8_t u8g_font_gdr10n[] U8G_FONT_SECTION("u8g_font_gdr10n");
01647 extern const u8g_fntpgm_uint8_t u8g_font_gdr11n[] U8G_FONT_SECTION("u8g_font_gdr11n");
01648 extern const u8g_fntpgm_uint8_t u8g_font_gdr12n[] U8G_FONT_SECTION("u8g_font_gdr12n");
01649 extern const u8g_fntpgm_uint8_t u8g_font_gdr14n[] U8G_FONT_SECTION("u8g_font_gdr14n");
01650 extern const u8g_fntpgm_uint8_t u8g_font_gdr17n[] U8G_FONT_SECTION("u8g_font_gdr17n");
01651 extern const u8g_fntpgm_uint8_t u8g_font_gdr20n[] U8G_FONT_SECTION("u8g_font_gdr20n");
01652 extern const u8g_fntpgm_uint8_t u8g_font_gdr25n[] U8G_FONT_SECTION("u8g_font_gdr25n");
01653 extern const u8g_fntpgm_uint8_t u8g_font_gdr30n[] U8G_FONT_SECTION("u8g_font_gdr30n");
01654 
01655 /*
01656   Old-Standard Bold
01657   r: Reduced char set (codes 32 - 128)
01658   n: Numbers (codes 42 - 57)
01659   no char: Full set (codes 32 - 255)
01660 */
01661 
01662 extern const u8g_fntpgm_uint8_t u8g_font_osb18[] U8G_FONT_SECTION("u8g_font_osb18");
01663 extern const u8g_fntpgm_uint8_t u8g_font_osb21[] U8G_FONT_SECTION("u8g_font_osb21");
01664 extern const u8g_fntpgm_uint8_t u8g_font_osb26[] U8G_FONT_SECTION("u8g_font_osb26");
01665 extern const u8g_fntpgm_uint8_t u8g_font_osb29[] U8G_FONT_SECTION("u8g_font_osb29");
01666 extern const u8g_fntpgm_uint8_t u8g_font_osb35[] U8G_FONT_SECTION("u8g_font_osb35");
01667 
01668 extern const u8g_fntpgm_uint8_t u8g_font_osb18r[] U8G_FONT_SECTION("u8g_font_osb18r");
01669 extern const u8g_fntpgm_uint8_t u8g_font_osb21r[] U8G_FONT_SECTION("u8g_font_osb21r");
01670 extern const u8g_fntpgm_uint8_t u8g_font_osb26r[] U8G_FONT_SECTION("u8g_font_osb26r");
01671 extern const u8g_fntpgm_uint8_t u8g_font_osb29r[] U8G_FONT_SECTION("u8g_font_osb29r");
01672 extern const u8g_fntpgm_uint8_t u8g_font_osb35r[] U8G_FONT_SECTION("u8g_font_osb35r");
01673 
01674 extern const u8g_fntpgm_uint8_t u8g_font_osb18n[] U8G_FONT_SECTION("u8g_font_osb18n");
01675 extern const u8g_fntpgm_uint8_t u8g_font_osb21n[] U8G_FONT_SECTION("u8g_font_osb21n");
01676 extern const u8g_fntpgm_uint8_t u8g_font_osb26n[] U8G_FONT_SECTION("u8g_font_osb26n");
01677 extern const u8g_fntpgm_uint8_t u8g_font_osb29n[] U8G_FONT_SECTION("u8g_font_osb29n");
01678 extern const u8g_fntpgm_uint8_t u8g_font_osb35n[] U8G_FONT_SECTION("u8g_font_osb35n");
01679 
01680 /*
01681   Old-Standard Regular
01682   r: Reduced char set (codes 32 - 128)
01683   n: Numbers (codes 42 - 57)
01684   no char: Full set (codes 32 - 255)
01685 */
01686 
01687 extern const u8g_fntpgm_uint8_t u8g_font_osr18[] U8G_FONT_SECTION("u8g_font_osr18");
01688 extern const u8g_fntpgm_uint8_t u8g_font_osr21[] U8G_FONT_SECTION("u8g_font_osr21");
01689 extern const u8g_fntpgm_uint8_t u8g_font_osr26[] U8G_FONT_SECTION("u8g_font_osr26");
01690 extern const u8g_fntpgm_uint8_t u8g_font_osr29[] U8G_FONT_SECTION("u8g_font_osr29");
01691 extern const u8g_fntpgm_uint8_t u8g_font_osr35[] U8G_FONT_SECTION("u8g_font_osr35");
01692 
01693 extern const u8g_fntpgm_uint8_t u8g_font_osr18r[] U8G_FONT_SECTION("u8g_font_osr18r");
01694 extern const u8g_fntpgm_uint8_t u8g_font_osr21r[] U8G_FONT_SECTION("u8g_font_osr21r");
01695 extern const u8g_fntpgm_uint8_t u8g_font_osr26r[] U8G_FONT_SECTION("u8g_font_osr26r");
01696 extern const u8g_fntpgm_uint8_t u8g_font_osr29r[] U8G_FONT_SECTION("u8g_font_osr29r");
01697 extern const u8g_fntpgm_uint8_t u8g_font_osr35r[] U8G_FONT_SECTION("u8g_font_osr35r");
01698 
01699 extern const u8g_fntpgm_uint8_t u8g_font_osr18n[] U8G_FONT_SECTION("u8g_font_osr18n");
01700 extern const u8g_fntpgm_uint8_t u8g_font_osr21n[] U8G_FONT_SECTION("u8g_font_osr21n");
01701 extern const u8g_fntpgm_uint8_t u8g_font_osr26n[] U8G_FONT_SECTION("u8g_font_osr26n");
01702 extern const u8g_fntpgm_uint8_t u8g_font_osr29n[] U8G_FONT_SECTION("u8g_font_osr29n");
01703 extern const u8g_fntpgm_uint8_t u8g_font_osr35n[] U8G_FONT_SECTION("u8g_font_osr35n");
01704 
01705 //extern const u8g_fntpgm_uint8_t u8g_font_osr41[] U8G_FONT_SECTION("u8g_font_osr41");
01706 
01707 /* GNU unifont */
01708 
01709 extern const u8g_fntpgm_uint8_t u8g_font_unifont_18_19[] U8G_FONT_SECTION("u8g_font_unifont_18_19");
01710 extern const u8g_fntpgm_uint8_t u8g_font_unifont_72_73[] U8G_FONT_SECTION("u8g_font_unifont_72_73");
01711 extern const u8g_fntpgm_uint8_t u8g_font_unifont_67_75[] U8G_FONT_SECTION("u8g_font_unifont_67_75");
01712 extern const u8g_fntpgm_uint8_t u8g_font_unifont_76[] U8G_FONT_SECTION("u8g_font_unifont_76");
01713 extern const u8g_fntpgm_uint8_t u8g_font_unifont_77[] U8G_FONT_SECTION("u8g_font_unifont_77");
01714 extern const u8g_fntpgm_uint8_t u8g_font_unifont_78_79[] U8G_FONT_SECTION("u8g_font_unifont_78_79");
01715 extern const u8g_fntpgm_uint8_t u8g_font_unifont_86[] U8G_FONT_SECTION("u8g_font_unifont_86");
01716 extern const u8g_fntpgm_uint8_t u8g_font_unifont[] U8G_FONT_SECTION("u8g_font_unifont");
01717 extern const u8g_fntpgm_uint8_t u8g_font_unifontr[] U8G_FONT_SECTION("u8g_font_unifontr");
01718 extern const u8g_fntpgm_uint8_t u8g_font_unifont_0_8[] U8G_FONT_SECTION("u8g_font_unifont_0_8");
01719 extern const u8g_fntpgm_uint8_t u8g_font_unifont_2_3[] U8G_FONT_SECTION("u8g_font_unifont_2_3");
01720 extern const u8g_fntpgm_uint8_t u8g_font_unifont_4_5[] U8G_FONT_SECTION("u8g_font_unifont_4_5");
01721 extern const u8g_fntpgm_uint8_t u8g_font_unifont_8_9[] U8G_FONT_SECTION("u8g_font_unifont_8_9");
01722 extern const u8g_fntpgm_uint8_t u8g_font_unifont_12_13[] U8G_FONT_SECTION("u8g_font_unifont_12_13");
01723 
01724 
01725 /* 04b fonts */
01726 
01727 extern const u8g_fntpgm_uint8_t u8g_font_04b_03b[] U8G_FONT_SECTION("u8g_font_04b_03b");
01728 extern const u8g_fntpgm_uint8_t u8g_font_04b_03bn[] U8G_FONT_SECTION("u8g_font_04b_03bn");
01729 extern const u8g_fntpgm_uint8_t u8g_font_04b_03br[] U8G_FONT_SECTION("u8g_font_04b_03br");
01730 extern const u8g_fntpgm_uint8_t u8g_font_04b_03[] U8G_FONT_SECTION("u8g_font_04b_03");
01731 extern const u8g_fntpgm_uint8_t u8g_font_04b_03n[] U8G_FONT_SECTION("u8g_font_04b_03n");
01732 extern const u8g_fntpgm_uint8_t u8g_font_04b_03r[] U8G_FONT_SECTION("u8g_font_04b_03r");
01733 extern const u8g_fntpgm_uint8_t u8g_font_04b_24[] U8G_FONT_SECTION("u8g_font_04b_24");
01734 extern const u8g_fntpgm_uint8_t u8g_font_04b_24n[] U8G_FONT_SECTION("u8g_font_04b_24n");
01735 extern const u8g_fntpgm_uint8_t u8g_font_04b_24r[] U8G_FONT_SECTION("u8g_font_04b_24r");
01736 
01737 /* orgdot fonts */
01738 
01739 extern const u8g_fntpgm_uint8_t u8g_font_orgv01[] U8G_FONT_SECTION("u8g_font_orgv01");
01740 extern const u8g_fntpgm_uint8_t u8g_font_orgv01r[] U8G_FONT_SECTION("u8g_font_orgv01r");
01741 extern const u8g_fntpgm_uint8_t u8g_font_orgv01n[] U8G_FONT_SECTION("u8g_font_orgv01n");
01742 
01743 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0[] U8G_FONT_SECTION("u8g_font_fixed_v0");
01744 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0r[] U8G_FONT_SECTION("u8g_font_fixed_v0r");
01745 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0n[] U8G_FONT_SECTION("u8g_font_fixed_v0n");
01746 
01747 extern const u8g_fntpgm_uint8_t u8g_font_tpssb[] U8G_FONT_SECTION("u8g_font_tpssb");
01748 extern const u8g_fntpgm_uint8_t u8g_font_tpssbr[] U8G_FONT_SECTION("u8g_font_tpssbr");
01749 extern const u8g_fntpgm_uint8_t u8g_font_tpssbn[] U8G_FONT_SECTION("u8g_font_tpssbn");
01750 
01751 extern const u8g_fntpgm_uint8_t u8g_font_tpss[] U8G_FONT_SECTION("u8g_font_tpss");
01752 extern const u8g_fntpgm_uint8_t u8g_font_tpssr[] U8G_FONT_SECTION("u8g_font_tpssr");
01753 extern const u8g_fntpgm_uint8_t u8g_font_tpssn[] U8G_FONT_SECTION("u8g_font_tpssn");
01754 
01755 /* contributed */
01756 
01757 extern const u8g_fntpgm_uint8_t u8g_font_freedoomr25n[] U8G_FONT_SECTION("u8g_font_freedoomr25n");
01758 extern const u8g_fntpgm_uint8_t u8g_font_freedoomr10r[] U8G_FONT_SECTION("u8g_font_freedoomr10r");
01759 
01760 /* adobe X11 */
01761 extern const u8g_fntpgm_uint8_t u8g_font_courB08[] U8G_FONT_SECTION("u8g_font_courB08");
01762 extern const u8g_fntpgm_uint8_t u8g_font_courB08r[] U8G_FONT_SECTION("u8g_font_courB08r");
01763 extern const u8g_fntpgm_uint8_t u8g_font_courB10[] U8G_FONT_SECTION("u8g_font_courB10");
01764 extern const u8g_fntpgm_uint8_t u8g_font_courB10r[] U8G_FONT_SECTION("u8g_font_courB10r");
01765 extern const u8g_fntpgm_uint8_t u8g_font_courB12[] U8G_FONT_SECTION("u8g_font_courB12");
01766 extern const u8g_fntpgm_uint8_t u8g_font_courB12r[] U8G_FONT_SECTION("u8g_font_courB12r");
01767 extern const u8g_fntpgm_uint8_t u8g_font_courB14[] U8G_FONT_SECTION("u8g_font_courB14");
01768 extern const u8g_fntpgm_uint8_t u8g_font_courB14r[] U8G_FONT_SECTION("u8g_font_courB14r");
01769 extern const u8g_fntpgm_uint8_t u8g_font_courB18[] U8G_FONT_SECTION("u8g_font_courB18");
01770 extern const u8g_fntpgm_uint8_t u8g_font_courB18r[] U8G_FONT_SECTION("u8g_font_courB18r");
01771 extern const u8g_fntpgm_uint8_t u8g_font_courB24[] U8G_FONT_SECTION("u8g_font_courB24");
01772 extern const u8g_fntpgm_uint8_t u8g_font_courB24r[] U8G_FONT_SECTION("u8g_font_courB24r");
01773 extern const u8g_fntpgm_uint8_t u8g_font_courB24n[] U8G_FONT_SECTION("u8g_font_courB24n");
01774 
01775 extern const u8g_fntpgm_uint8_t u8g_font_courR08[] U8G_FONT_SECTION("u8g_font_courR08");
01776 extern const u8g_fntpgm_uint8_t u8g_font_courR08r[] U8G_FONT_SECTION("u8g_font_courR08r");
01777 extern const u8g_fntpgm_uint8_t u8g_font_courR10[] U8G_FONT_SECTION("u8g_font_courR10");
01778 extern const u8g_fntpgm_uint8_t u8g_font_courR10r[] U8G_FONT_SECTION("u8g_font_courR10r");
01779 extern const u8g_fntpgm_uint8_t u8g_font_courR12[] U8G_FONT_SECTION("u8g_font_courR12");
01780 extern const u8g_fntpgm_uint8_t u8g_font_courR12r[] U8G_FONT_SECTION("u8g_font_courR12r");
01781 extern const u8g_fntpgm_uint8_t u8g_font_courR14[] U8G_FONT_SECTION("u8g_font_courR14");
01782 extern const u8g_fntpgm_uint8_t u8g_font_courR14r[] U8G_FONT_SECTION("u8g_font_courR14r");
01783 extern const u8g_fntpgm_uint8_t u8g_font_courR18[] U8G_FONT_SECTION("u8g_font_courR18");
01784 extern const u8g_fntpgm_uint8_t u8g_font_courR18r[] U8G_FONT_SECTION("u8g_font_courR18r");
01785 extern const u8g_fntpgm_uint8_t u8g_font_courR24[] U8G_FONT_SECTION("u8g_font_courR24");
01786 extern const u8g_fntpgm_uint8_t u8g_font_courR24r[] U8G_FONT_SECTION("u8g_font_courR24r");
01787 extern const u8g_fntpgm_uint8_t u8g_font_courR24n[] U8G_FONT_SECTION("u8g_font_courR24n");
01788 
01789 extern const u8g_fntpgm_uint8_t u8g_font_helvB08[] U8G_FONT_SECTION("u8g_font_helvB08");
01790 extern const u8g_fntpgm_uint8_t u8g_font_helvB08r[] U8G_FONT_SECTION("u8g_font_helvB08r");
01791 extern const u8g_fntpgm_uint8_t u8g_font_helvB10[] U8G_FONT_SECTION("u8g_font_helvB10");
01792 extern const u8g_fntpgm_uint8_t u8g_font_helvB10r[] U8G_FONT_SECTION("u8g_font_helvB10r");
01793 extern const u8g_fntpgm_uint8_t u8g_font_helvB12[] U8G_FONT_SECTION("u8g_font_helvB12");
01794 extern const u8g_fntpgm_uint8_t u8g_font_helvB12r[] U8G_FONT_SECTION("u8g_font_helvB12r");
01795 extern const u8g_fntpgm_uint8_t u8g_font_helvB14[] U8G_FONT_SECTION("u8g_font_helvB14");
01796 extern const u8g_fntpgm_uint8_t u8g_font_helvB14r[] U8G_FONT_SECTION("u8g_font_helvB14r");
01797 extern const u8g_fntpgm_uint8_t u8g_font_helvB18[] U8G_FONT_SECTION("u8g_font_helvB18");
01798 extern const u8g_fntpgm_uint8_t u8g_font_helvB18r[] U8G_FONT_SECTION("u8g_font_helvB18r");
01799 extern const u8g_fntpgm_uint8_t u8g_font_helvB24[] U8G_FONT_SECTION("u8g_font_helvB24");
01800 extern const u8g_fntpgm_uint8_t u8g_font_helvB24r[] U8G_FONT_SECTION("u8g_font_helvB24r");
01801 extern const u8g_fntpgm_uint8_t u8g_font_helvB24n[] U8G_FONT_SECTION("u8g_font_helvB24n");
01802 
01803 extern const u8g_fntpgm_uint8_t u8g_font_helvR08[] U8G_FONT_SECTION("u8g_font_helvR08");
01804 extern const u8g_fntpgm_uint8_t u8g_font_helvR08r[] U8G_FONT_SECTION("u8g_font_helvR08r");
01805 extern const u8g_fntpgm_uint8_t u8g_font_helvR10[] U8G_FONT_SECTION("u8g_font_helvR10");
01806 extern const u8g_fntpgm_uint8_t u8g_font_helvR10r[] U8G_FONT_SECTION("u8g_font_helvR10r");
01807 extern const u8g_fntpgm_uint8_t u8g_font_helvR12[] U8G_FONT_SECTION("u8g_font_helvR12");
01808 extern const u8g_fntpgm_uint8_t u8g_font_helvR12r[] U8G_FONT_SECTION("u8g_font_helvR12r");
01809 extern const u8g_fntpgm_uint8_t u8g_font_helvR14[] U8G_FONT_SECTION("u8g_font_helvR14");
01810 extern const u8g_fntpgm_uint8_t u8g_font_helvR14r[] U8G_FONT_SECTION("u8g_font_helvR14r");
01811 extern const u8g_fntpgm_uint8_t u8g_font_helvR18[] U8G_FONT_SECTION("u8g_font_helvR18");
01812 extern const u8g_fntpgm_uint8_t u8g_font_helvR18r[] U8G_FONT_SECTION("u8g_font_helvR18r");
01813 extern const u8g_fntpgm_uint8_t u8g_font_helvR24[] U8G_FONT_SECTION("u8g_font_helvR24");
01814 extern const u8g_fntpgm_uint8_t u8g_font_helvR24r[] U8G_FONT_SECTION("u8g_font_helvR24r");
01815 extern const u8g_fntpgm_uint8_t u8g_font_helvR24n[] U8G_FONT_SECTION("u8g_font_helvR24n");
01816 
01817 extern const u8g_fntpgm_uint8_t u8g_font_ncenB08[] U8G_FONT_SECTION("u8g_font_ncenB08");
01818 extern const u8g_fntpgm_uint8_t u8g_font_ncenB08r[] U8G_FONT_SECTION("u8g_font_ncenB08r");
01819 extern const u8g_fntpgm_uint8_t u8g_font_ncenB10[] U8G_FONT_SECTION("u8g_font_ncenB10");
01820 extern const u8g_fntpgm_uint8_t u8g_font_ncenB10r[] U8G_FONT_SECTION("u8g_font_ncenB10r");
01821 extern const u8g_fntpgm_uint8_t u8g_font_ncenB12[] U8G_FONT_SECTION("u8g_font_ncenB12");
01822 extern const u8g_fntpgm_uint8_t u8g_font_ncenB12r[] U8G_FONT_SECTION("u8g_font_ncenB12r");
01823 extern const u8g_fntpgm_uint8_t u8g_font_ncenB14[] U8G_FONT_SECTION("u8g_font_ncenB14");
01824 extern const u8g_fntpgm_uint8_t u8g_font_ncenB14r[] U8G_FONT_SECTION("u8g_font_ncenB14r");
01825 extern const u8g_fntpgm_uint8_t u8g_font_ncenB18[] U8G_FONT_SECTION("u8g_font_ncenB18");
01826 extern const u8g_fntpgm_uint8_t u8g_font_ncenB18r[] U8G_FONT_SECTION("u8g_font_ncenB18r");
01827 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24[] U8G_FONT_SECTION("u8g_font_ncenB24");
01828 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24r[] U8G_FONT_SECTION("u8g_font_ncenB24r");
01829 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24n[] U8G_FONT_SECTION("u8g_font_ncenB24n");
01830 
01831 extern const u8g_fntpgm_uint8_t u8g_font_ncenR08[] U8G_FONT_SECTION("u8g_font_ncenR08");
01832 extern const u8g_fntpgm_uint8_t u8g_font_ncenR08r[] U8G_FONT_SECTION("u8g_font_ncenR08r");
01833 extern const u8g_fntpgm_uint8_t u8g_font_ncenR10[] U8G_FONT_SECTION("u8g_font_ncenR10");
01834 extern const u8g_fntpgm_uint8_t u8g_font_ncenR10r[] U8G_FONT_SECTION("u8g_font_ncenR10r");
01835 extern const u8g_fntpgm_uint8_t u8g_font_ncenR12[] U8G_FONT_SECTION("u8g_font_ncenR12");
01836 extern const u8g_fntpgm_uint8_t u8g_font_ncenR12r[] U8G_FONT_SECTION("u8g_font_ncenR12r");
01837 extern const u8g_fntpgm_uint8_t u8g_font_ncenR14[] U8G_FONT_SECTION("u8g_font_ncenR14");
01838 extern const u8g_fntpgm_uint8_t u8g_font_ncenR14r[] U8G_FONT_SECTION("u8g_font_ncenR14r");
01839 extern const u8g_fntpgm_uint8_t u8g_font_ncenR18[] U8G_FONT_SECTION("u8g_font_ncenR18");
01840 extern const u8g_fntpgm_uint8_t u8g_font_ncenR18r[] U8G_FONT_SECTION("u8g_font_ncenR18r");
01841 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24[] U8G_FONT_SECTION("u8g_font_ncenR24");
01842 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24r[] U8G_FONT_SECTION("u8g_font_ncenR24r");
01843 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24n[] U8G_FONT_SECTION("u8g_font_ncenR24n");
01844 
01845 extern const u8g_fntpgm_uint8_t u8g_font_symb08[] U8G_FONT_SECTION("u8g_font_symb08");
01846 extern const u8g_fntpgm_uint8_t u8g_font_symb08r[] U8G_FONT_SECTION("u8g_font_symb08r");
01847 extern const u8g_fntpgm_uint8_t u8g_font_symb10[] U8G_FONT_SECTION("u8g_font_symb10");
01848 extern const u8g_fntpgm_uint8_t u8g_font_symb10r[] U8G_FONT_SECTION("u8g_font_symb10r");
01849 extern const u8g_fntpgm_uint8_t u8g_font_symb12[] U8G_FONT_SECTION("u8g_font_symb12");
01850 extern const u8g_fntpgm_uint8_t u8g_font_symb12r[] U8G_FONT_SECTION("u8g_font_symb12r");
01851 extern const u8g_fntpgm_uint8_t u8g_font_symb14[] U8G_FONT_SECTION("u8g_font_symb14");
01852 extern const u8g_fntpgm_uint8_t u8g_font_symb14r[] U8G_FONT_SECTION("u8g_font_symb14r");
01853 extern const u8g_fntpgm_uint8_t u8g_font_symb18[] U8G_FONT_SECTION("u8g_font_symb18");
01854 extern const u8g_fntpgm_uint8_t u8g_font_symb18r[] U8G_FONT_SECTION("u8g_font_symb18r");
01855 extern const u8g_fntpgm_uint8_t u8g_font_symb24[] U8G_FONT_SECTION("u8g_font_symb24");
01856 extern const u8g_fntpgm_uint8_t u8g_font_symb24r[] U8G_FONT_SECTION("u8g_font_symb24r");
01857 
01858 extern const u8g_fntpgm_uint8_t u8g_font_timB08[] U8G_FONT_SECTION("u8g_font_timB08");
01859 extern const u8g_fntpgm_uint8_t u8g_font_timB08r[] U8G_FONT_SECTION("u8g_font_timB08r");
01860 extern const u8g_fntpgm_uint8_t u8g_font_timB10[] U8G_FONT_SECTION("u8g_font_timB10");
01861 extern const u8g_fntpgm_uint8_t u8g_font_timB10r[] U8G_FONT_SECTION("u8g_font_timB10r");
01862 extern const u8g_fntpgm_uint8_t u8g_font_timB12[] U8G_FONT_SECTION("u8g_font_timB12");
01863 extern const u8g_fntpgm_uint8_t u8g_font_timB12r[] U8G_FONT_SECTION("u8g_font_timB12r");
01864 extern const u8g_fntpgm_uint8_t u8g_font_timB14[] U8G_FONT_SECTION("u8g_font_timB14");
01865 extern const u8g_fntpgm_uint8_t u8g_font_timB14r[] U8G_FONT_SECTION("u8g_font_timB14r");
01866 extern const u8g_fntpgm_uint8_t u8g_font_timB18[] U8G_FONT_SECTION("u8g_font_timB18");
01867 extern const u8g_fntpgm_uint8_t u8g_font_timB18r[] U8G_FONT_SECTION("u8g_font_timB18r");
01868 extern const u8g_fntpgm_uint8_t u8g_font_timB24[] U8G_FONT_SECTION("u8g_font_timB24");
01869 extern const u8g_fntpgm_uint8_t u8g_font_timB24r[] U8G_FONT_SECTION("u8g_font_timB24r");
01870 extern const u8g_fntpgm_uint8_t u8g_font_timB24n[] U8G_FONT_SECTION("u8g_font_timB24n");
01871 
01872 extern const u8g_fntpgm_uint8_t u8g_font_timR08[] U8G_FONT_SECTION("u8g_font_timR08");
01873 extern const u8g_fntpgm_uint8_t u8g_font_timR08r[] U8G_FONT_SECTION("u8g_font_timR08r");
01874 extern const u8g_fntpgm_uint8_t u8g_font_timR10[] U8G_FONT_SECTION("u8g_font_timR10");
01875 extern const u8g_fntpgm_uint8_t u8g_font_timR10r[] U8G_FONT_SECTION("u8g_font_timR10r");
01876 extern const u8g_fntpgm_uint8_t u8g_font_timR12[] U8G_FONT_SECTION("u8g_font_timR12");
01877 extern const u8g_fntpgm_uint8_t u8g_font_timR12r[] U8G_FONT_SECTION("u8g_font_timR12r");
01878 extern const u8g_fntpgm_uint8_t u8g_font_timR14[] U8G_FONT_SECTION("u8g_font_timR14");
01879 extern const u8g_fntpgm_uint8_t u8g_font_timR14r[] U8G_FONT_SECTION("u8g_font_timR14r");
01880 extern const u8g_fntpgm_uint8_t u8g_font_timR18[] U8G_FONT_SECTION("u8g_font_timR18");
01881 extern const u8g_fntpgm_uint8_t u8g_font_timR18r[] U8G_FONT_SECTION("u8g_font_timR18r");
01882 extern const u8g_fntpgm_uint8_t u8g_font_timR24[] U8G_FONT_SECTION("u8g_font_timR24");
01883 extern const u8g_fntpgm_uint8_t u8g_font_timR24r[] U8G_FONT_SECTION("u8g_font_timR24r");
01884 extern const u8g_fntpgm_uint8_t u8g_font_timR24n[] U8G_FONT_SECTION("u8g_font_timR24n");
01885 
01886 /* fontstruct */
01887 
01888 extern const u8g_fntpgm_uint8_t u8g_font_p01type[] U8G_FONT_SECTION("u8g_font_p01type");
01889 extern const u8g_fntpgm_uint8_t u8g_font_p01typer[] U8G_FONT_SECTION("u8g_font_p01typer");
01890 extern const u8g_fntpgm_uint8_t u8g_font_p01typen[] U8G_FONT_SECTION("u8g_font_p01typen");
01891 
01892 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternate[] U8G_FONT_SECTION("u8g_font_lucasfont_alternate");
01893 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternater[] U8G_FONT_SECTION("u8g_font_lucasfont_alternater");
01894 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternaten[] U8G_FONT_SECTION("u8g_font_lucasfont_alternaten");
01895 
01896 extern const u8g_fntpgm_uint8_t u8g_font_chikita[] U8G_FONT_SECTION("u8g_font_chikita");
01897 extern const u8g_fntpgm_uint8_t u8g_font_chikitar[] U8G_FONT_SECTION("u8g_font_chikitar");
01898 extern const u8g_fntpgm_uint8_t u8g_font_chikitan[] U8G_FONT_SECTION("u8g_font_chikitan");
01899 
01900 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micro[] U8G_FONT_SECTION("u8g_font_pixelle_micro");
01901 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micror[] U8G_FONT_SECTION("u8g_font_pixelle_micror");
01902 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micron[] U8G_FONT_SECTION("u8g_font_pixelle_micron");
01903 
01904 extern const u8g_fntpgm_uint8_t u8g_font_trixel_square[] U8G_FONT_SECTION("u8g_font_trixel_square");
01905 extern const u8g_fntpgm_uint8_t u8g_font_trixel_squarer[] U8G_FONT_SECTION("u8g_font_trixel_squarer");
01906 extern const u8g_fntpgm_uint8_t u8g_font_trixel_squaren[] U8G_FONT_SECTION("u8g_font_trixel_squaren");
01907 
01908 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niro[] U8G_FONT_SECTION("u8g_font_robot_de_niro");
01909 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niror[] U8G_FONT_SECTION("u8g_font_robot_de_niror");
01910 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niron[] U8G_FONT_SECTION("u8g_font_robot_de_niron");
01911 
01912 extern const u8g_fntpgm_uint8_t u8g_font_baby[] U8G_FONT_SECTION("u8g_font_baby");
01913 extern const u8g_fntpgm_uint8_t u8g_font_babyr[] U8G_FONT_SECTION("u8g_font_babyr");
01914 extern const u8g_fntpgm_uint8_t u8g_font_babyn[] U8G_FONT_SECTION("u8g_font_babyn");
01915 
01916 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07[] U8G_FONT_SECTION("u8g_font_blipfest_07");
01917 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07r[] U8G_FONT_SECTION("u8g_font_blipfest_07r");
01918 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07n[] U8G_FONT_SECTION("u8g_font_blipfest_07n");
01919 
01920 
01921 
01922 #ifdef __cplusplus
01923 }
01924 #endif
01925 
01926 #endif /* _U8G_H */
01927 
01928 /*
01929   Fontname: -Misc-Fixed-Medium-R-Normal--7-70-75-75-C-50-ISO10646-1
01930   Copyright: Public domain font.  Share and enjoy.
01931   Capital A Height: 6, '1' Height: 6
01932   Calculated Max Values w= 7 h= 8 x= 4 y= 5 dx= 9 dy= 0 ascent= 8 len= 8
01933   Font Bounding box     w= 5 h= 7 x= 0 y=-1
01934   Calculated Min Values           x= 0 y=-1 dx= 0 dy= 0
01935   Pure Font   ascent = 6 descent=-1
01936   X Font      ascent = 6 descent=-1
01937   Max Font    ascent = 8 descent=-1
01938 */
01939 const u8g_fntpgm_uint8_t repetier_5x7[2405] U8G_FONT_SECTION("repetier_5x7") = {
01940   0,5,7,0,255,6,2,72,3,186,0,255,255,8,255,6,
01941   255,5,5,5,5,0,0,168,0,136,0,168,5,8,8,6,
01942   0,0,8,8,8,40,72,248,64,32,3,3,3,6,1,4,
01943   64,160,64,5,5,5,6,0,0,248,248,248,248,248,5,5,
01944   5,6,0,0,248,136,136,136,248,5,8,8,6,0,0,32,
01945   80,80,80,112,248,248,112,7,5,5,9,0,0,28,254,130,
01946   130,254,5,8,8,6,0,0,136,80,32,136,32,80,136,136,
01947   6,8,8,6,0,0,72,144,72,252,252,120,48,48,6,8,
01948   8,6,0,0,36,72,36,252,252,120,48,48,6,5,5,6,
01949   0,0,252,252,120,48,48,6,2,2,6,0,0,252,252,6,
01950   6,6,6,0,0,72,144,72,144,252,252,6,6,6,6,0,
01951   0,36,72,36,72,252,252,7,7,7,7,0,0,130,68,56,
01952   40,56,68,130,7,7,7,7,0,0,16,16,56,238,56,16,
01953   16,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
01954   255,0,0,0,5,4,0,1,6,6,5,2,0,128,128,128,
01955   128,0,128,3,3,3,5,1,3,160,160,160,5,5,5,5,
01956   0,0,80,248,80,248,80,5,5,5,5,0,0,112,160,112,
01957   40,112,4,6,6,5,0,0,128,144,32,64,144,16,4,5,
01958   5,5,0,0,64,160,64,160,80,1,3,3,5,2,3,128,
01959   128,128,2,6,6,5,1,0,64,128,128,128,128,64,2,6,
01960   6,5,1,0,128,64,64,64,64,128,3,5,5,5,1,0,
01961   160,64,224,64,160,5,5,5,5,0,0,32,32,248,32,32,
01962   3,3,3,5,1,255,96,64,128,4,1,1,5,0,2,240,
01963   2,2,2,5,1,0,192,192,4,4,4,5,0,1,16,32,
01964   64,128,3,6,6,5,1,0,64,160,160,160,160,64,3,6,
01965   6,5,1,0,64,192,64,64,64,224,4,6,6,5,0,0,
01966   96,144,16,32,64,240,4,6,6,5,0,0,240,16,96,16,
01967   144,96,4,6,6,5,0,0,32,96,160,240,32,32,4,6,
01968   6,5,0,0,240,128,224,16,144,96,4,6,6,5,0,0,
01969   96,128,224,144,144,96,4,6,6,5,0,0,240,16,32,32,
01970   64,64,4,6,6,5,0,0,96,144,96,144,144,96,4,6,
01971   6,5,0,0,96,144,144,112,16,96,2,5,5,5,1,0,
01972   192,192,0,192,192,3,6,6,5,0,255,96,96,0,96,64,
01973   128,3,5,5,5,1,0,32,64,128,64,32,4,3,3,5,
01974   0,1,240,0,240,3,5,5,5,1,0,128,64,32,64,128,
01975   3,6,6,5,1,0,64,160,32,64,0,64,4,6,6,5,
01976   0,0,96,144,176,176,128,96,4,6,6,5,0,0,96,144,
01977   144,240,144,144,4,6,6,5,0,0,224,144,224,144,144,224,
01978   4,6,6,5,0,0,96,144,128,128,144,96,4,6,6,5,
01979   0,0,224,144,144,144,144,224,4,6,6,5,0,0,240,128,
01980   224,128,128,240,4,6,6,5,0,0,240,128,224,128,128,128,
01981   4,6,6,5,0,0,96,144,128,176,144,112,4,6,6,5,
01982   0,0,144,144,240,144,144,144,3,6,6,5,1,0,224,64,
01983   64,64,64,224,4,6,6,5,0,0,16,16,16,16,144,96,
01984   4,6,6,5,0,0,144,160,192,192,160,144,4,6,6,5,
01985   0,0,128,128,128,128,128,240,4,6,6,5,0,0,144,240,
01986   240,144,144,144,4,6,6,5,0,0,144,208,208,176,176,144,
01987   4,6,6,5,0,0,96,144,144,144,144,96,4,6,6,5,
01988   0,0,224,144,144,224,128,128,4,7,7,5,0,255,96,144,
01989   144,144,208,96,16,4,6,6,5,0,0,224,144,144,224,160,
01990   144,4,6,6,5,0,0,96,144,64,32,144,96,3,6,6,
01991   5,1,0,224,64,64,64,64,64,4,6,6,5,0,0,144,
01992   144,144,144,144,96,4,6,6,5,0,0,144,144,144,144,96,
01993   96,4,6,6,5,0,0,144,144,144,240,240,144,4,6,6,
01994   5,0,0,144,144,96,96,144,144,3,6,6,5,1,0,160,
01995   160,160,64,64,64,4,6,6,5,0,0,240,16,32,64,128,
01996   240,3,6,6,5,1,0,224,128,128,128,128,224,4,4,4,
01997   5,0,1,128,64,32,16,3,6,6,5,1,0,224,32,32,
01998   32,32,224,3,2,2,5,1,4,64,160,4,1,1,5,0,
01999   0,240,2,2,2,5,1,4,128,64,4,4,4,5,0,0,
02000   112,144,176,80,4,6,6,5,0,0,128,128,224,144,144,224,
02001   3,4,4,5,0,0,96,128,128,96,4,6,6,5,0,0,
02002   16,16,112,144,144,112,4,4,4,5,0,0,96,176,192,96,
02003   4,6,6,5,0,0,32,80,64,224,64,64,4,5,5,5,
02004   0,255,112,144,96,128,112,4,6,6,5,0,0,128,128,224,
02005   144,144,144,3,6,6,5,1,0,64,0,192,64,64,224,3,
02006   7,7,5,1,255,32,0,32,32,32,160,64,4,6,6,5,
02007   0,0,128,128,160,192,160,144,3,6,6,5,1,0,192,64,
02008   64,64,64,224,4,4,4,5,0,0,160,240,144,144,4,4,
02009   4,5,0,0,224,144,144,144,4,4,4,5,0,0,96,144,
02010   144,96,4,5,5,5,0,255,224,144,144,224,128,4,5,5,
02011   5,0,255,112,144,144,112,16,4,4,4,5,0,0,224,144,
02012   128,128,4,4,4,5,0,0,112,192,48,224,4,6,6,5,
02013   0,0,64,64,224,64,64,48,4,4,4,5,0,0,144,144,
02014   144,112,3,4,4,5,1,0,160,160,160,64,4,4,4,5,
02015   0,0,144,144,240,240,4,4,4,5,0,0,144,96,96,144,
02016   4,5,5,5,0,255,144,144,80,32,64,4,4,4,5,0,
02017   0,240,32,64,240,3,6,6,5,1,0,32,64,192,64,64,
02018   32,1,6,6,5,2,0,128,128,128,128,128,128,3,6,6,
02019   5,1,0,128,64,96,64,64,128,4,2,2,5,0,4,80,
02020   160,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
02021   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
02022   255,255,0,0,0,5,4,0,1,6,6,5,2,0,128,0,
02023   128,128,128,128,4,6,6,5,0,255,32,112,160,160,112,32,
02024   4,5,5,5,0,0,48,64,224,64,176,5,5,5,5,0,
02025   0,136,112,80,112,136,3,6,6,5,1,0,160,160,64,224,
02026   64,64,1,5,5,5,2,0,128,128,0,128,128,3,7,7,
02027   5,1,255,96,128,192,160,96,32,192,3,1,1,5,1,5,
02028   160,5,7,7,5,0,255,112,136,168,200,168,136,112,3,3,
02029   3,5,0,3,96,160,96,5,3,3,5,0,1,72,144,72,
02030   4,2,2,5,0,1,240,16,3,1,1,5,1,2,224,5,
02031   7,7,5,0,255,112,136,232,200,200,136,112,4,1,1,5,
02032   0,5,240,3,3,3,5,1,3,64,160,64,5,6,6,5,
02033   0,0,32,32,248,32,32,248,2,4,4,5,1,2,192,64,
02034   128,192,2,4,4,5,1,2,192,192,64,192,2,2,2,5,
02035   1,4,64,128,4,5,5,5,0,255,144,144,144,224,128,4,
02036   6,6,5,0,0,112,208,208,80,80,80,2,2,2,5,1,
02037   2,192,192,2,2,2,5,1,255,64,128,3,4,4,5,1,
02038   2,64,192,64,224,3,3,3,5,0,3,64,160,64,5,3,
02039   3,5,0,1,144,72,144,4,7,7,5,0,255,128,128,128,
02040   144,48,112,16,4,7,7,5,0,255,128,128,128,176,16,32,
02041   48,4,7,7,5,0,255,192,192,64,208,48,112,16,3,6,
02042   6,5,1,0,64,0,64,128,160,64,4,6,6,5,0,0,
02043   96,144,144,240,144,144,4,6,6,5,0,0,96,144,144,240,
02044   144,144,4,6,6,5,0,0,96,144,144,240,144,144,4,6,
02045   6,5,0,0,96,144,144,240,144,144,4,6,6,5,0,0,
02046   144,96,144,240,144,144,4,6,6,5,0,0,96,96,144,240,
02047   144,144,4,6,6,5,0,0,112,160,176,224,160,176,4,7,
02048   7,5,0,255,96,144,128,128,144,96,64,4,6,6,5,0,
02049   0,240,128,224,128,128,240,4,6,6,5,0,0,240,128,224,
02050   128,128,240,4,6,6,5,0,0,240,128,224,128,128,240,4,
02051   6,6,5,0,0,240,128,224,128,128,240,3,6,6,5,1,
02052   0,224,64,64,64,64,224,3,6,6,5,1,0,224,64,64,
02053   64,64,224,3,6,6,5,1,0,224,64,64,64,64,224,3,
02054   6,6,5,1,0,224,64,64,64,64,224,4,6,6,5,0,
02055   0,224,80,208,80,80,224,4,6,6,5,0,0,176,144,208,
02056   176,176,144,4,6,6,5,0,0,96,144,144,144,144,96,4,
02057   6,6,5,0,0,96,144,144,144,144,96,4,6,6,5,0,
02058   0,96,144,144,144,144,96,4,6,6,5,0,0,96,144,144,
02059   144,144,96,4,6,6,5,0,0,144,96,144,144,144,96,4,
02060   4,4,5,0,0,144,96,96,144,4,6,6,5,0,0,112,
02061   176,176,208,208,224,4,6,6,5,0,0,144,144,144,144,144,
02062   96,4,6,6,5,0,0,144,144,144,144,144,96,4,6,6,
02063   5,0,0,144,144,144,144,144,96,4,6,6,5,0,0,144,
02064   0,144,144,144,96,3,6,6,5,1,0,160,160,160,64,64,
02065   64,4,6,6,5,0,0,128,224,144,224,128,128,4,6,6,
02066   5,0,0,96,144,160,144,144,160,4,6,6,5,0,0,64,
02067   32,112,144,176,80,4,6,6,5,0,0,32,64,112,144,176,
02068   80,4,6,6,5,0,0,32,80,112,144,176,80,4,6,6,
02069   5,0,0,80,160,112,144,176,80,4,6,6,5,0,0,80,
02070   0,112,144,176,80,4,6,6,5,0,0,96,96,112,144,176,
02071   80,4,4,4,5,0,0,112,176,160,112,3,5,5,5,1,
02072   255,96,128,128,96,64,4,6,6,5,0,0,64,32,96,176,
02073   192,96,4,6,6,5,0,0,32,64,96,176,192,96,4,6,
02074   6,5,0,0,64,160,96,176,192,96,4,6,6,5,0,0,
02075   160,0,96,176,192,96,3,6,6,5,1,0,128,64,192,64,
02076   64,224,3,6,6,5,1,0,64,128,192,64,64,224,3,6,
02077   6,5,1,0,64,160,192,64,64,224,3,6,6,5,1,0,
02078   160,0,192,64,64,224,4,6,6,5,0,0,64,48,96,144,
02079   144,96,4,6,6,5,0,0,80,160,224,144,144,144,4,6,
02080   6,5,0,0,64,32,96,144,144,96,4,6,6,5,0,0,
02081   32,64,96,144,144,96,4,6,6,5,0,0,96,0,96,144,
02082   144,96,4,6,6,5,0,0,80,160,96,144,144,96,4,6,
02083   6,5,0,0,80,0,96,144,144,96,4,5,5,5,0,0,
02084   96,0,240,0,96,4,4,4,5,0,0,112,176,208,224,4,
02085   6,6,5,0,0,64,32,144,144,144,112,4,6,6,5,0,
02086   0,32,64,144,144,144,112,4,6,6,5,0,0,96,0,144,
02087   144,144,112,4,6,6,5,0,0,80,0,144,144,144,112,4,
02088   7,7,5,0,255,32,64,144,144,80,32,64,4,6,6,5,
02089   0,255,128,224,144,144,224,128,4,7,7,5,0,255,80,0,
02090   144,144,80,32,64};
02091 
02092 /*
02093   Fontname: -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1
02094   Copyright: Public domain terminal emulator font.  Share and enjoy.
02095   Capital A Height: 7, '1' Height: 7
02096   Calculated Max Values w= 7 h= 9 x= 5 y= 7 dx= 9 dy= 0 ascent= 8 len= 9
02097   Font Bounding box     w= 7 h=10 x= 0 y=-2
02098   Calculated Min Values           x= 0 y=-2 dx= 0 dy= 0
02099   Pure Font   ascent = 7 descent=-2
02100   X Font      ascent = 7 descent=-2
02101   Max Font    ascent = 8 descent=-2
02102 */
02103 const u8g_fntpgm_uint8_t repetier_6x10[2625] U8G_FONT_SECTION("repetier_6x10") = {
02104   0,7,10,0,254,7,2,105,3,251,0,255,254,8,254,7,
02105   254,5,7,7,6,0,0,168,0,136,0,136,0,168,5,8,
02106   8,6,0,0,8,8,8,40,72,248,64,32,3,3,3,6,
02107   1,4,64,160,64,5,5,5,6,0,0,248,248,248,248,248,
02108   5,5,5,6,0,0,248,136,136,136,248,5,8,8,6,0,
02109   0,32,80,80,80,112,248,248,112,7,5,5,9,0,0,28,
02110   254,130,130,254,5,8,8,6,0,0,136,80,32,136,32,80,
02111   136,136,6,8,8,6,0,0,72,144,72,252,252,120,48,48,
02112   6,8,8,6,0,0,36,72,36,252,252,120,48,48,6,5,
02113   5,6,0,0,252,252,120,48,48,6,2,2,6,0,0,252,
02114   252,6,6,6,6,0,0,72,144,72,144,252,252,6,6,6,
02115   6,0,0,36,72,36,72,252,252,7,7,7,7,0,0,130,
02116   68,56,40,56,68,130,7,7,7,7,0,0,16,16,56,238,
02117   56,16,16,255,255,255,255,255,255,255,255,255,255,255,255,255,
02118   255,255,255,0,0,0,6,5,255,1,7,7,6,2,0,128,
02119   128,128,128,128,0,128,3,3,3,6,1,4,160,160,160,5,
02120   7,7,6,0,0,80,80,248,80,248,80,80,5,7,7,6,
02121   0,0,32,112,160,112,40,112,32,6,8,8,6,0,0,68,
02122   164,72,16,32,72,148,136,5,7,7,6,0,0,64,160,160,
02123   64,168,144,104,1,3,3,6,2,4,128,128,128,3,7,7,
02124   6,1,0,32,64,128,128,128,64,32,3,7,7,6,1,0,
02125   128,64,32,32,32,64,128,5,5,5,6,0,1,136,80,248,
02126   80,136,5,5,5,6,0,1,32,32,248,32,32,3,3,3,
02127   6,1,255,96,64,128,4,1,1,6,1,3,240,2,2,2,
02128   6,1,255,192,192,5,7,7,6,0,0,8,8,16,32,64,
02129   128,128,5,7,7,6,0,0,32,80,136,136,136,80,32,5,
02130   7,7,6,0,0,32,96,160,32,32,32,248,5,7,7,6,
02131   0,0,112,136,8,48,64,128,248,5,7,7,6,0,0,248,
02132   8,16,48,8,136,112,5,7,7,6,0,0,16,48,80,144,
02133   248,16,16,5,7,7,6,0,0,248,128,176,200,8,136,112,
02134   5,7,7,6,0,0,48,64,128,176,200,136,112,5,7,7,
02135   6,0,0,248,8,16,16,32,64,64,5,7,7,6,0,0,
02136   112,136,136,112,136,136,112,5,7,7,6,0,0,112,136,152,
02137   104,8,16,96,2,5,5,6,2,1,192,192,0,192,192,3,
02138   7,7,6,1,255,64,224,64,0,96,64,128,4,7,7,6,
02139   1,0,16,32,64,128,64,32,16,5,3,3,6,0,2,248,
02140   0,248,4,7,7,6,1,0,128,64,32,16,32,64,128,5,
02141   7,7,6,0,0,112,136,16,32,32,0,32,5,7,7,6,
02142   0,0,112,136,152,168,176,128,112,5,7,7,6,0,0,32,
02143   80,136,136,248,136,136,5,7,7,6,0,0,240,72,72,112,
02144   72,72,240,5,7,7,6,0,0,112,136,128,128,128,136,112,
02145   5,7,7,6,0,0,240,72,72,72,72,72,240,5,7,7,
02146   6,0,0,248,128,128,240,128,128,248,5,7,7,6,0,0,
02147   248,128,128,240,128,128,128,5,7,7,6,0,0,112,136,128,
02148   128,152,136,112,5,7,7,6,0,0,136,136,136,248,136,136,
02149   136,3,7,7,6,1,0,224,64,64,64,64,64,224,5,7,
02150   7,6,0,0,56,16,16,16,16,144,96,5,7,7,6,0,
02151   0,136,144,160,192,160,144,136,5,7,7,6,0,0,128,128,
02152   128,128,128,128,248,5,7,7,6,0,0,136,136,216,168,136,
02153   136,136,5,7,7,6,0,0,136,136,200,168,152,136,136,5,
02154   7,7,6,0,0,112,136,136,136,136,136,112,5,7,7,6,
02155   0,0,240,136,136,240,128,128,128,5,8,8,6,0,255,112,
02156   136,136,136,136,168,112,8,5,7,7,6,0,0,240,136,136,
02157   240,160,144,136,5,7,7,6,0,0,112,136,128,112,8,136,
02158   112,5,7,7,6,0,0,248,32,32,32,32,32,32,5,7,
02159   7,6,0,0,136,136,136,136,136,136,112,5,7,7,6,0,
02160   0,136,136,136,80,80,80,32,5,7,7,6,0,0,136,136,
02161   136,168,168,216,136,5,7,7,6,0,0,136,136,80,32,80,
02162   136,136,5,7,7,6,0,0,136,136,80,32,32,32,32,5,
02163   7,7,6,0,0,248,8,16,32,64,128,248,3,7,7,6,
02164   1,0,224,128,128,128,128,128,224,5,7,7,6,0,0,128,
02165   128,64,32,16,8,8,3,7,7,6,1,0,224,32,32,32,
02166   32,32,224,5,3,3,6,0,4,32,80,136,5,1,1,6,
02167   0,255,248,2,2,2,6,2,6,128,64,5,5,5,6,0,
02168   0,112,8,120,136,120,5,7,7,6,0,0,128,128,176,200,
02169   136,200,176,5,5,5,6,0,0,112,136,128,136,112,5,7,
02170   7,6,0,0,8,8,104,152,136,152,104,5,5,5,6,0,
02171   0,112,136,248,128,112,5,7,7,6,0,0,48,72,64,240,
02172   64,64,64,5,7,7,6,0,254,120,136,136,120,8,136,112,
02173   5,7,7,6,0,0,128,128,176,200,136,136,136,3,7,7,
02174   6,1,0,64,0,192,64,64,64,224,4,9,9,6,1,254,
02175   16,0,48,16,16,16,144,144,96,5,7,7,6,0,0,128,
02176   128,136,144,224,144,136,3,7,7,6,1,0,192,64,64,64,
02177   64,64,224,5,5,5,6,0,0,208,168,168,168,136,5,5,
02178   5,6,0,0,176,200,136,136,136,5,5,5,6,0,0,112,
02179   136,136,136,112,5,7,7,6,0,254,176,200,136,200,176,128,
02180   128,5,7,7,6,0,254,104,152,136,152,104,8,8,5,5,
02181   5,6,0,0,176,200,128,128,128,5,5,5,6,0,0,112,
02182   128,112,8,240,5,7,7,6,0,0,64,64,240,64,64,72,
02183   48,5,5,5,6,0,0,136,136,136,152,104,5,5,5,6,
02184   0,0,136,136,80,80,32,5,5,5,6,0,0,136,136,168,
02185   168,80,5,5,5,6,0,0,136,80,32,80,136,5,7,7,
02186   6,0,254,136,136,152,104,8,136,112,5,5,5,6,0,0,
02187   248,16,32,64,248,4,7,7,6,1,0,48,64,32,192,32,
02188   64,48,1,7,7,6,2,0,128,128,128,128,128,128,128,4,
02189   7,7,6,1,0,192,32,64,48,64,32,192,5,3,3,6,
02190   0,4,72,168,144,255,255,255,255,255,255,255,255,255,255,255,
02191   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
02192   255,255,255,255,255,255,255,1,7,7,6,2,0,128,0,128,
02193   128,128,128,128,5,7,7,6,0,255,32,120,160,160,160,120,
02194   32,5,7,7,6,0,0,48,72,64,224,64,72,176,5,5,
02195   5,6,0,0,136,112,80,112,136,5,8,8,6,0,255,136,
02196   136,80,32,248,32,32,32,1,7,7,6,2,0,128,128,128,
02197   0,128,128,128,5,8,8,6,0,255,112,128,224,144,72,56,
02198   8,112,3,1,1,6,1,7,160,5,7,7,6,0,0,112,
02199   136,168,200,168,136,112,4,6,6,6,1,1,112,144,176,80,
02200   0,240,6,5,5,6,0,0,36,72,144,72,36,4,2,2,
02201   6,1,2,240,16,255,5,7,7,6,0,0,112,136,232,200,
02202   200,136,112,5,1,1,6,0,7,248,3,3,3,6,1,4,
02203   64,160,64,5,6,6,6,0,0,32,32,248,32,32,248,4,
02204   5,5,6,1,3,96,144,32,64,240,4,5,5,6,1,3,
02205   224,16,96,16,224,2,2,2,6,2,6,64,128,255,5,7,
02206   7,6,0,0,120,232,232,104,40,40,40,1,1,1,6,2,
02207   3,128,2,2,2,6,2,254,64,128,3,5,5,6,1,3,
02208   64,192,64,64,224,4,6,6,6,1,1,96,144,144,96,0,
02209   240,6,5,5,6,0,0,144,72,36,72,144,6,9,9,6,
02210   0,255,64,192,64,64,228,12,20,60,4,6,9,9,6,0,
02211   255,64,192,64,64,232,20,4,8,28,5,9,9,6,0,255,
02212   192,32,64,32,200,24,40,120,8,5,7,7,6,0,0,32,
02213   0,32,32,64,136,112,5,8,8,6,0,0,64,32,112,136,
02214   136,248,136,136,5,8,8,6,0,0,16,32,112,136,136,248,
02215   136,136,5,8,8,6,0,0,32,80,112,136,136,248,136,136,
02216   5,8,8,6,0,0,72,176,112,136,136,248,136,136,5,8,
02217   8,6,0,0,80,0,112,136,136,248,136,136,5,8,8,6,
02218   0,0,32,80,112,136,136,248,136,136,6,7,7,6,0,0,
02219   60,80,144,156,240,144,156,5,9,9,6,0,254,112,136,128,
02220   128,128,136,112,32,64,5,8,8,6,0,0,64,248,128,128,
02221   240,128,128,248,5,8,8,6,0,0,16,248,128,128,240,128,
02222   128,248,5,8,8,6,0,0,32,248,128,128,240,128,128,248,
02223   5,8,8,6,0,0,80,248,128,128,240,128,128,248,3,8,
02224   8,6,1,0,128,64,224,64,64,64,64,224,3,8,8,6,
02225   1,0,32,64,224,64,64,64,64,224,3,8,8,6,1,0,
02226   64,160,224,64,64,64,64,224,3,8,8,6,1,0,160,0,
02227   224,64,64,64,64,224,5,7,7,6,0,0,240,72,72,232,
02228   72,72,240,5,8,8,6,0,0,40,80,136,200,168,152,136,
02229   136,5,8,8,6,0,0,64,32,112,136,136,136,136,112,5,
02230   8,8,6,0,0,16,32,112,136,136,136,136,112,5,8,8,
02231   6,0,0,32,80,112,136,136,136,136,112,5,8,8,6,0,
02232   0,40,80,112,136,136,136,136,112,5,8,8,6,0,0,80,
02233   0,112,136,136,136,136,112,5,5,5,6,0,0,136,80,32,
02234   80,136,5,7,7,6,0,0,112,152,152,168,200,200,112,5,
02235   8,8,6,0,0,64,32,136,136,136,136,136,112,5,8,8,
02236   6,0,0,16,32,136,136,136,136,136,112,5,8,8,6,0,
02237   0,32,80,0,136,136,136,136,112,5,8,8,6,0,0,80,
02238   0,136,136,136,136,136,112,5,8,8,6,0,0,16,32,136,
02239   136,80,32,32,32,5,7,7,6,0,0,128,240,136,240,128,
02240   128,128,5,7,7,6,0,0,112,136,144,160,144,136,176,5,
02241   8,8,6,0,0,64,32,0,112,8,120,136,120,5,8,8,
02242   6,0,0,16,32,0,112,8,120,136,120,5,8,8,6,0,
02243   0,32,80,0,112,8,120,136,120,5,8,8,6,0,0,40,
02244   80,0,112,8,120,136,120,5,7,7,6,0,0,80,0,112,
02245   8,120,136,120,5,8,8,6,0,0,32,80,32,112,8,120,
02246   136,120,6,5,5,6,0,0,120,20,124,144,124,5,7,7,
02247   6,0,254,112,136,128,136,112,32,64,5,8,8,6,0,0,
02248   64,32,0,112,136,248,128,112,5,8,8,6,0,0,16,32,
02249   0,112,136,248,128,112,5,8,8,6,0,0,32,80,0,112,
02250   136,248,128,112,5,7,7,6,0,0,80,0,112,136,248,128,
02251   112,3,8,8,6,1,0,128,64,0,192,64,64,64,224,3,
02252   8,8,6,1,0,64,128,0,192,64,64,64,224,3,8,8,
02253   6,1,0,64,160,0,192,64,64,64,224,3,7,7,6,1,
02254   0,160,0,192,64,64,64,224,5,7,7,6,0,0,192,48,
02255   112,136,136,136,112,5,8,8,6,0,0,40,80,0,176,200,
02256   136,136,136,5,8,8,6,0,0,64,32,0,112,136,136,136,
02257   112,5,8,8,6,0,0,16,32,0,112,136,136,136,112,5,
02258   8,8,6,0,0,32,80,0,112,136,136,136,112,5,8,8,
02259   6,0,0,40,80,0,112,136,136,136,112,5,7,7,6,0,
02260   0,80,0,112,136,136,136,112,5,5,5,6,0,1,32,0,
02261   248,0,32,5,5,5,6,0,0,120,152,168,200,240,5,8,
02262   8,6,0,0,64,32,0,136,136,136,152,104,5,8,8,6,
02263   0,0,16,32,0,136,136,136,152,104,5,8,8,6,0,0,
02264   32,80,0,136,136,136,152,104,5,7,7,6,0,0,80,0,
02265   136,136,136,152,104,5,9,9,6,0,254,16,32,136,136,152,
02266   104,8,136,112,5,8,8,6,0,254,128,240,136,136,136,240,
02267   128,128,5,9,9,6,0,254,80,0,136,136,152,104,8,136,
02268   112};
02269 /*
02270   Fontname: -Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1
02271   Copyright: Public domain terminal emulator font.  Share and enjoy.
02272   Capital A Height: 3, '1' Height: 8
02273   Calculated Max Values w= 6 h=12 x= 5 y= 8 dx= 6 dy= 0 ascent=10 len=12
02274   Font Bounding box     w= 6 h=12 x= 0 y=-2
02275   Calculated Min Values           x= 0 y=-2 dx= 0 dy= 0
02276   Pure Font   ascent = 3 descent= 0
02277   X Font      ascent = 8 descent= 0
02278   Max Font    ascent =10 descent=-2
02279 */
02280 const u8g_fntpgm_uint8_t u8g_font_6x12_67_75[2382] U8G_FONT_SECTION("u8g_font_6x12_67_75") = {
02281   1,6,12,0,254,3,2,41,3,99,0,255,0,10,254,8,
02282   0,2,87,103,168,0,136,0,136,0,168,2,87,103,240,136,
02283   232,168,232,136,240,2,87,103,112,168,248,168,248,168,112,2,
02284   87,103,112,136,8,8,8,136,112,18,69,101,96,144,16,144,
02285   96,1,88,104,112,136,128,128,136,120,8,8,2,87,103,32,
02286   32,32,32,168,112,32,2,103,103,248,252,252,156,252,252,248,
02287   2,87,103,112,248,248,168,248,248,112,255,255,255,255,255,255,
02288   255,3,85,101,32,64,248,64,32,2,87,103,32,112,168,32,
02289   32,32,32,3,85,101,32,16,248,16,32,2,87,103,32,32,
02290   32,32,168,112,32,4,83,99,80,248,80,2,87,103,32,112,
02291   168,32,168,112,32,2,89,105,192,240,224,160,32,16,16,8,
02292   8,2,89,105,24,120,56,40,32,64,64,128,128,2,89,105,
02293   128,128,64,64,32,40,56,120,24,2,89,105,8,8,16,16,
02294   32,160,224,240,192,3,101,101,40,72,252,80,48,3,101,101,
02295   48,40,252,72,80,4,99,99,192,216,100,4,99,99,12,108,
02296   152,3,101,101,40,80,252,80,40,2,88,104,32,112,168,112,
02297   168,32,32,32,3,101,101,80,40,252,40,80,2,88,104,32,
02298   32,32,168,112,168,112,32,3,101,101,36,72,240,72,36,3,
02299   101,101,144,72,60,72,144,3,85,101,40,72,248,72,40,2,
02300   87,103,32,112,168,32,32,32,248,3,85,101,160,144,248,144,
02301   160,2,87,103,248,32,32,32,168,112,32,2,87,103,32,112,
02302   168,32,168,112,248,3,101,101,40,68,248,64,32,3,101,101,
02303   80,136,124,8,16,3,101,101,32,76,252,72,40,3,101,101,
02304   16,200,252,72,80,3,100,100,72,220,236,72,3,101,101,8,
02305   88,252,104,64,2,87,103,128,144,176,208,144,56,16,2,88,
02306   104,32,64,248,72,40,8,8,8,2,88,104,32,16,248,144,
02307   160,128,128,128,2,88,104,8,8,8,40,72,248,64,32,2,
02308   87,103,128,128,160,144,248,16,32,3,84,100,240,16,56,16,
02309   3,85,101,8,8,72,248,64,3,85,101,48,72,72,232,72,
02310   3,85,101,96,144,144,184,16,2,88,104,248,128,224,192,160,
02311   32,16,16,2,89,105,160,192,248,192,168,24,248,24,40,2,
02312   86,102,56,48,168,136,136,112,2,86,102,224,96,168,136,136,
02313   112,5,83,99,32,64,248,3,83,99,248,64,32,34,56,104,
02314   128,192,160,128,128,128,128,128,2,56,104,32,96,160,32,32,
02315   32,32,32,5,83,99,32,16,248,3,83,99,248,16,32,34,
02316   56,104,128,128,128,128,128,160,192,128,2,56,104,32,32,32,
02317   32,32,160,96,32,2,89,105,32,16,248,16,32,64,248,64,
02318   32,2,88,104,80,240,80,80,80,80,120,80,2,89,105,32,
02319   64,248,64,32,16,248,16,32,2,89,105,32,64,248,64,32,
02320   64,248,64,32,2,88,104,80,248,80,80,80,80,80,80,2,
02321   89,105,32,16,248,16,32,16,248,16,32,2,88,104,80,80,
02322   80,80,80,80,248,80,2,87,103,32,64,248,0,248,16,32,
02323   2,87,103,32,16,248,0,248,64,32,2,103,103,20,40,124,
02324   144,124,32,80,2,103,103,8,88,252,164,252,104,64,2,103,
02325   103,160,80,248,36,248,16,40,3,85,101,32,120,128,120,32,
02326   2,87,103,32,80,216,80,80,80,80,3,85,101,32,240,8,
02327   240,32,2,87,103,80,80,80,80,216,80,32,3,101,101,72,
02328   252,132,252,72,2,88,104,32,80,216,80,80,216,80,32,2,
02329   102,102,248,160,208,168,148,8,2,102,102,124,20,44,84,164,
02330   64,2,102,102,64,164,84,44,20,124,2,102,102,8,148,168,
02331   208,160,248,2,103,103,16,60,64,252,64,60,16,2,103,103,
02332   32,240,8,252,8,240,32,3,100,100,64,232,212,64,3,100,
02333   100,8,92,172,8,2,88,104,32,112,168,32,112,32,112,32,
02334   2,88,104,32,112,32,112,32,168,112,32,3,101,101,32,64,
02335   212,64,32,2,88,104,32,112,136,32,0,32,0,32,3,101,
02336   101,16,8,172,8,16,2,88,104,32,0,32,0,32,136,112,
02337   32,3,85,101,160,192,248,192,160,3,85,101,40,24,248,24,
02338   40,3,85,101,32,120,136,120,32,2,88,104,32,80,216,80,
02339   80,80,80,112,3,85,101,32,240,136,240,32,2,88,104,112,
02340   80,80,80,80,216,80,32,2,89,105,32,80,216,80,112,0,
02341   112,80,112,2,89,105,32,80,216,80,80,80,216,136,248,2,
02342   89,105,32,80,248,136,80,80,216,136,248,2,89,105,32,112,
02343   248,112,112,112,248,168,248,2,89,105,32,80,216,80,216,80,
02344   80,80,112,2,89,105,32,80,216,80,216,80,216,136,248,3,
02345   85,101,160,240,136,240,160,2,88,104,248,128,176,160,144,16,
02346   8,8,2,88,104,128,128,64,72,40,104,8,248,2,88,104,
02347   32,80,216,80,80,216,80,32,3,101,101,16,104,252,104,16,
02348   2,88,104,80,120,80,80,80,80,240,80,2,89,105,16,248,
02349   16,16,248,16,16,248,16,3,101,101,40,72,252,72,40,3,
02350   101,101,80,72,252,72,80,3,101,101,48,120,252,120,48,3,
02351   101,101,56,88,252,88,56,3,101,101,112,104,252,104,112,3,
02352   101,101,48,120,252,120,48,3,85,101,32,96,184,96,32,3,
02353   85,101,32,48,232,48,32,3,101,101,48,120,180,120,48,6,
02354   102,102,252,252,252,252,252,252,0,98,98,252,252,0,99,99,
02355   252,252,252,0,101,101,252,252,252,252,252,0,102,102,252,252,
02356   252,252,252,252,0,104,104,252,252,252,252,252,252,252,252,0,
02357   105,105,252,252,252,252,252,252,252,252,252,0,107,107,252,252,
02358   252,252,252,252,252,252,252,252,252,0,108,108,252,252,252,252,
02359   252,252,252,252,252,252,252,252,0,92,108,248,248,248,248,248,
02360   248,248,248,248,248,248,248,0,76,108,240,240,240,240,240,240,
02361   240,240,240,240,240,240,0,76,108,240,240,240,240,240,240,240,
02362   240,240,240,240,240,0,60,108,224,224,224,224,224,224,224,224,
02363   224,224,224,224,0,44,108,192,192,192,192,192,192,192,192,192,
02364   192,192,192,0,44,108,192,192,192,192,192,192,192,192,192,192,
02365   192,192,0,28,108,128,128,128,128,128,128,128,128,128,128,128,
02366   128,48,60,108,224,224,224,224,224,224,224,224,224,224,224,224,
02367   1,107,107,168,0,84,0,168,0,84,0,168,0,84,0,108,
02368   108,168,84,168,84,168,84,168,84,168,84,168,84,0,108,108,
02369   84,252,168,252,84,252,168,252,84,252,168,252,10,98,98,252,
02370   252,80,28,108,128,128,128,128,128,128,128,128,128,128,128,128,
02371   0,54,102,224,224,224,224,224,224,48,54,102,224,224,224,224,
02372   224,224,6,54,102,224,224,224,224,224,224,0,108,108,224,224,
02373   224,224,224,224,252,252,252,252,252,252,0,108,108,224,224,224,
02374   224,224,224,28,28,28,28,28,28,0,108,108,252,252,252,252,
02375   252,252,224,224,224,224,224,224,0,108,108,252,252,252,252,252,
02376   252,28,28,28,28,28,28,54,54,102,224,224,224,224,224,224,
02377   0,108,108,28,28,28,28,28,28,224,224,224,224,224,224,0,
02378   108,108,28,28,28,28,28,28,252,252,252,252,252,252,2,85,
02379   101,248,248,248,248,248,2,85,101,248,136,136,136,248,2,85,
02380   101,112,136,136,136,112,2,85,101,248,136,168,136,248,2,85,
02381   101,248,136,248,136,248,2,85,101,248,168,168,168,248,2,85,
02382   101,248,168,248,168,248,2,85,101,248,200,168,152,248,2,85,
02383   101,248,152,168,200,248,2,85,101,248,216,168,216,248,20,51,
02384   99,224,224,224,20,51,99,224,160,224,3,101,101,252,252,252,
02385   252,252,3,101,101,252,132,132,132,252,17,74,106,240,240,240,
02386   240,240,240,240,240,240,240,17,74,106,240,144,144,144,144,144,
02387   144,144,144,240,4,99,99,60,120,240,4,99,99,60,72,240,
02388   2,87,103,32,32,112,112,248,248,248,2,87,103,32,32,80,
02389   80,136,136,248,3,85,101,32,32,112,112,248,3,85,101,32,
02390   32,80,80,248,18,71,103,128,192,224,240,224,192,128,18,71,
02391   103,128,192,160,144,160,192,128,19,53,101,128,192,224,192,128,
02392   19,53,101,128,192,160,192,128,3,101,101,192,240,252,240,192,
02393   3,101,101,192,176,140,176,192,2,87,103,248,248,248,112,112,
02394   32,32,2,87,103,248,136,136,80,80,32,32,2,85,101,248,
02395   112,112,32,32,2,85,101,248,80,80,32,32,18,71,103,16,
02396   48,112,240,112,48,16,18,71,103,16,48,80,144,80,48,16,
02397   19,53,101,32,96,224,96,32,19,53,101,32,96,160,96,32,
02398   3,101,101,12,60,252,60,12,3,101,101,12,52,196,52,12,
02399   3,85,101,32,112,248,112,32,3,85,101,32,80,136,80,32,
02400   3,85,101,32,80,168,80,32,2,102,102,48,72,180,180,72,
02401   48,2,87,103,32,80,80,136,80,80,32,2,102,102,48,72,
02402   132,132,72,48,2,102,102,32,8,128,4,64,16,2,85,101,
02403   112,168,168,168,112,2,87,103,112,136,168,216,168,136,112,2,
02404   102,102,48,120,252,252,120,48,2,102,102,48,104,228,228,104,
02405   48,2,102,102,48,88,156,156,88,48,2,102,102,48,72,132,
02406   252,120,48,2,102,102,48,120,252,132,72,48,2,102,102,48,
02407   88,156,132,72,48,2,102,102,48,104,228,132,72,48,18,89,
02408   105,8,56,120,120,248,120,120,56,8,2,89,105,128,224,240,
02409   240,248,240,240,224,128,0,108,108,252,252,252,252,204,132,132,
02410   204,252,252,252,252,0,108,108,252,252,252,204,180,120,120,180,
02411   204,252,252,252,6,102,102,252,252,252,204,180,120,0,102,102,
02412   120,180,204,252,252,252,5,51,99,32,64,128,53,51,99,128,
02413   64,32,50,51,99,32,64,128,2,51,99,128,64,32,5,99,
02414   99,48,72,132,2,99,99,132,72,48,2,85,101,8,24,56,
02415   120,248,2,85,101,128,192,224,240,248,2,85,101,248,240,224,
02416   192,128,2,85,101,248,120,56,24,8,2,85,101,112,136,136,
02417   136,112,2,85,101,248,232,232,232,248,2,85,101,248,184,184,
02418   184,248,2,85,101,248,248,232,200,248,2,85,101,248,152,184,
02419   248,248,2,85,101,248,168,168,168,248,2,87,103,32,32,80,
02420   112,168,136,248,2,87,103,32,32,112,112,232,232,248,2,87,
02421   103,32,32,112,112,184,184,248,2,103,103,48,72,132,132,132,
02422   72,48,2,85,101,248,168,232,136,248,2,85,101,248,136,232,
02423   168,248,2,85,101,248,136,184,168,248,2,85,101,248,168,184,
02424   136,248,2,85,101,112,168,232,136,112,2,85,101,112,136,232,
02425   168,112,2,85,101,112,136,184,168,112,2,85,101,112,168,184,
02426   136,112,3,85,101,248,144,160,192,128,3,85,101,248,72,40,
02427   24,8,3,85,101,128,192,160,144,248,20,68,100,240,144,144,
02428   240,19,68,100,240,240,240,240,20,68,100,240,144,144,240,20,
02429   68,100,240,240,240,240,3,85,101,8,24,40,72,248};
02430 // ======== u8g_dev_st7920_128x64.c ==============
02431 
02432 /*
02433 
02434   u8g_dev_st7920_128x64.c
02435 
02436   Universal 8bit Graphics Library
02437 
02438   Copyright (c) 2011, olikraus@gmail.com
02439   All rights reserved.
02440 
02441   Redistribution and use in source and binary forms, with or without modification,
02442   are permitted provided that the following conditions are met:
02443 
02444   * Redistributions of source code must retain the above copyright notice, this list
02445     of conditions and the following disclaimer.
02446 
02447   * Redistributions in binary form must reproduce the above copyright notice, this
02448     list of conditions and the following disclaimer in the documentation and/or other
02449     materials provided with the distribution.
02450 
02451   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
02452   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
02453   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
02454   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
02455   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
02456   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
02457   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
02458   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
02459   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
02460   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
02461   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
02462   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
02463   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
02464 
02465 
02466 */
02467 
02468 
02469 #define WIDTH 128
02470 #define HEIGHT 64
02471 #define PAGE_HEIGHT 8
02472 
02473 
02474 /* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
02475 static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = {
02476   U8G_ESC_CS(0),             /* disable chip */
02477   U8G_ESC_ADR(0),           /* instruction mode */
02478   U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
02479   U8G_ESC_DLY(100),         /* 8 Dez 2012: additional delay 100 ms because of reset*/
02480   U8G_ESC_CS(1),             /* enable chip */
02481   U8G_ESC_DLY(50),         /* delay 50 ms */
02482 
02483   0x038,                                /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
02484   0x00c,                                /* display on, cursor & blink off; 0x08: all off */
02485   0x006,                                /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
02486   0x002,                                /* disable scroll, enable CGRAM adress */
02487   0x001,                                /* clear RAM, needs 1.6 ms */
02488   U8G_ESC_DLY(100),               /* delay 100 ms */
02489 
02490   U8G_ESC_CS(0),             /* disable chip */
02491   U8G_ESC_END                /* end of sequence */
02492 };
02493 
02494 uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
02495 {
02496   switch(msg)
02497   {
02498     case U8G_DEV_MSG_INIT:
02499       u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
02500       u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
02501       break;
02502     case U8G_DEV_MSG_STOP:
02503       break;
02504     case U8G_DEV_MSG_PAGE_NEXT:
02505       {
02506         uint8_t y, i;
02507         uint8_t *ptr;
02508         u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
02509 
02510         u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
02511         u8g_SetChipSelect(u8g, dev, 1);
02512         y = pb->p.page_y0;
02513         ptr = (uint8_t*)pb->buf;
02514         for( i = 0; i < 8; i ++ )
02515         {
02516           u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
02517           u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
02518 
02519           if ( y < 32 )
02520           {
02521                   u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
02522                   u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
02523           }
02524           else
02525           {
02526                   u8g_WriteByte(u8g, dev, 0x080 | (y-32) );      /* y pos  */
02527                   u8g_WriteByte(u8g, dev, 0x080 | 8);      /* set x pos to 64*/
02528           }
02529 
02530           u8g_SetAddress(u8g, dev, 1);                  /* data mode */
02531           u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
02532           ptr += WIDTH/8;
02533           y++;
02534         }
02535         u8g_SetChipSelect(u8g, dev, 0);
02536       }
02537       break;
02538   }
02539   return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
02540 }
02541 
02542 uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
02543 {
02544   switch(msg)
02545   {
02546     case U8G_DEV_MSG_INIT:
02547       u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
02548       u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
02549       break;
02550     case U8G_DEV_MSG_STOP:
02551       break;
02552     case U8G_DEV_MSG_PAGE_NEXT:
02553       {
02554         uint8_t y, i;
02555         uint8_t *ptr;
02556         u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
02557 
02558         u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
02559         u8g_SetChipSelect(u8g, dev, 1);
02560         y = pb->p.page_y0;
02561         ptr = (uint8_t*)pb->buf;
02562         for( i = 0; i < 32; i ++ )
02563         {
02564           u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
02565           u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
02566 
02567           if ( y < 32 )
02568           {
02569                   u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
02570                   u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
02571           }
02572           else
02573           {
02574                   u8g_WriteByte(u8g, dev, 0x080 | (y-32) );      /* y pos  */
02575                   u8g_WriteByte(u8g, dev, 0x080 | 8);      /* set x pos to 64*/
02576           }
02577 
02578           u8g_SetAddress(u8g, dev, 1);                  /* data mode */
02579           u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
02580           ptr += WIDTH/8;
02581           y++;
02582         }
02583         u8g_SetChipSelect(u8g, dev, 0);
02584       }
02585       break;
02586   }
02587   return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
02588 }
02589 
02590 U8G_PB_DEV(u8g_dev_st7920_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_SW_SPI);
02591 U8G_PB_DEV(u8g_dev_st7920_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_HW_SPI);
02592 U8G_PB_DEV(u8g_dev_st7920_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_FAST_PARALLEL);
02593 U8G_PB_DEV(u8g_dev_st7920_128x64_custom, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, u8g_com_arduino_st7920_custom_fn);
02594 
02595 
02596 
02597 #define QWIDTH (WIDTH*4)
02598 uint8_t u8g_dev_st7920_128x64_4x_buf[QWIDTH] U8G_NOCOMMON ;
02599 u8g_pb_t u8g_dev_st7920_128x64_4x_pb = { {32, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_st7920_128x64_4x_buf};
02600 u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_SW_SPI };
02601 u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_HW_SPI };
02602 u8g_dev_t u8g_dev_st7920_128x64_4x_8bit = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_FAST_PARALLEL };
02603 u8g_dev_t u8g_dev_st7920_128x64_4x_custom = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, u8g_com_arduino_st7920_custom_fn };
02604 
02605 
02606 // ================ u8g_font.c ===================
02607 
02608 /*
02609 
02610   u8g_font.c
02611 
02612   U8G Font High Level Interface
02613 
02614   Universal 8bit Graphics Library
02615 
02616   Copyright (c) 2011, olikraus@gmail.com
02617   All rights reserved.
02618 
02619   Redistribution and use in source and binary forms, with or without modification,
02620   are permitted provided that the following conditions are met:
02621 
02622   * Redistributions of source code must retain the above copyright notice, this list
02623     of conditions and the following disclaimer.
02624 
02625   * Redistributions in binary form must reproduce the above copyright notice, this
02626     list of conditions and the following disclaimer in the documentation and/or other
02627     materials provided with the distribution.
02628 
02629   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
02630   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
02631   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
02632   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
02633   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
02634   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
02635   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
02636   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
02637   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
02638   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
02639   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
02640   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
02641   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
02642 
02643 
02644 */
02645 
02646 
02647 /* font api */
02648 
02649 /* pointer to the start adress of the glyph, points to progmem area */
02650 typedef void * u8g_glyph_t;
02651 
02652 /* size of the font data structure, there is no struct or class... */
02653 #define U8G_FONT_DATA_STRUCT_SIZE 17
02654 
02655 /*
02656   ... instead the fields of the font data structure are accessed directly by offset
02657   font information
02658   offset
02659   0             font format
02660   1             FONTBOUNDINGBOX width           unsigned
02661   2             FONTBOUNDINGBOX height          unsigned
02662   3             FONTBOUNDINGBOX x-offset         signed
02663   4             FONTBOUNDINGBOX y-offset        signed
02664   5             capital A height                                unsigned
02665   6             start 'A'
02666   8             start 'a'
02667   10            encoding start
02668   11            encoding end
02669   12            descent 'g'                     negative: below baseline
02670   13            font max ascent
02671   14            font min decent             negative: below baseline
02672   15            font xascent
02673   16            font xdecent             negative: below baseline
02674 
02675 */
02676 
02677 /* use case: What is the width and the height of the minimal box into which string s fints? */
02678 void u8g_font_GetStrSize(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
02679 void u8g_font_GetStrSizeP(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
02680 
02681 /* use case: lower left edge of a minimal box is known, what is the correct x, y position for the string draw procedure */
02682 void u8g_font_AdjustXYToDraw(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
02683 void u8g_font_AdjustXYToDrawP(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
02684 
02685 /* use case: Baseline origin known, return minimal box */
02686 void u8g_font_GetStrMinBox(u8g_t *u8g, const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
02687 
02688 /* procedures */
02689 
02690 /*========================================================================*/
02691 /* low level byte and word access */
02692 
02693 /* removed NOINLINE, because it leads to smaller code, might also be faster */
02694 //static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
02695 static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset)
02696 {
02697   font += offset;
02698   return u8g_pgm_read( (u8g_pgm_uint8_t *)font );
02699 }
02700 
02701 static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
02702 static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset)
02703 {
02704     uint16_t pos;
02705     font += offset;
02706     pos = u8g_pgm_read( (u8g_pgm_uint8_t *)font );
02707     font++;
02708     pos <<= 8;
02709     pos += u8g_pgm_read( (u8g_pgm_uint8_t *)font);
02710     return pos;
02711 }
02712 
02713 /*========================================================================*/
02714 /* direct access on the font */
02715 
02716 static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
02717 static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font)
02718 {
02719   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 0);
02720 }
02721 
02722 static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
02723 static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font)
02724 {
02725   switch(u8g_font_GetFormat((const u8g_fntpgm_uint8_t*)font))
02726   {
02727     case 0: return 6;
02728     case 1: return 3;
02729     case 2: return 6;
02730   }
02731   return 3;
02732 }
02733 
02734 static uint8_t u8g_font_GetBBXWidth(const void *font)
02735 {
02736   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 1);
02737 }
02738 
02739 static uint8_t u8g_font_GetBBXHeight(const void *font)
02740 {
02741   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 2);
02742 }
02743 
02744 static int8_t u8g_font_GetBBXOffX(const void *font)
02745 {
02746   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 3);
02747 }
02748 
02749 static int8_t u8g_font_GetBBXOffY(const void *font)
02750 {
02751   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 4);
02752 }
02753 
02754 uint8_t u8g_font_GetCapitalAHeight(const void *font)
02755 {
02756   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 5);
02757 }
02758 
02759 uint16_t u8g_font_GetEncoding65Pos(const void *font) U8G_NOINLINE;
02760 uint16_t u8g_font_GetEncoding65Pos(const void *font)
02761 {
02762     return u8g_font_get_word((const u8g_fntpgm_uint8_t*)font, 6);
02763 }
02764 
02765 uint16_t u8g_font_GetEncoding97Pos(const void *font) U8G_NOINLINE;
02766 uint16_t u8g_font_GetEncoding97Pos(const void *font)
02767 {
02768     return u8g_font_get_word((const u8g_fntpgm_uint8_t*)font, 8);
02769 }
02770 
02771 uint8_t u8g_font_GetFontStartEncoding(const void *font)
02772 {
02773   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 10);
02774 }
02775 
02776 uint8_t u8g_font_GetFontEndEncoding(const void *font)
02777 {
02778   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 11);
02779 }
02780 
02781 int8_t u8g_font_GetLowerGDescent(const void *font)
02782 {
02783   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 12);
02784 }
02785 
02786 int8_t u8g_font_GetFontAscent(const void *font)
02787 {
02788   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 13);
02789 }
02790 
02791 int8_t u8g_font_GetFontDescent(const void *font)
02792 {
02793   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 14);
02794 }
02795 
02796 int8_t u8g_font_GetFontXAscent(const void *font)
02797 {
02798   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 15);
02799 }
02800 
02801 int8_t u8g_font_GetFontXDescent(const void *font)
02802 {
02803   return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 16);
02804 }
02805 
02806 
02807 /* return the data start for a font and the glyph pointer */
02808 static uint8_t *u8g_font_GetGlyphDataStart(const void *font, u8g_glyph_t g)
02809 {
02810   return ((u8g_fntpgm_uint8_t *)g) + u8g_font_GetFontGlyphStructureSize((const u8g_fntpgm_uint8_t*)font);
02811 }
02812 
02813 /* calculate the overall length of the font, only used to create the picture for the google wiki */
02814 size_t u8g_font_GetSize(const void *font)
02815 {
02816   uint8_t *p = (uint8_t *)(font);
02817   uint8_t font_format = u8g_font_GetFormat((const u8g_fntpgm_uint8_t*)font);
02818   uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize((const u8g_fntpgm_uint8_t*)font);
02819   uint8_t start, end;
02820   uint8_t i;
02821   uint8_t mask = 255;
02822 
02823   start = u8g_font_GetFontStartEncoding(font);
02824   end = u8g_font_GetFontEndEncoding(font);
02825 
02826   if ( font_format == 1 )
02827     mask = 15;
02828 
02829   p += U8G_FONT_DATA_STRUCT_SIZE;       /* skip font general information */
02830 
02831   i = start;
02832   for(;;)
02833   {
02834     if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
02835     {
02836       p += 1;
02837     }
02838     else
02839     {
02840       p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
02841       p += data_structure_size;
02842     }
02843     if ( i == end )
02844       break;
02845     i++;
02846   }
02847 
02848   return p - (uint8_t *)font;
02849 }
02850 
02851 /*========================================================================*/
02852 /* u8g interface, font access */
02853 
02854 uint8_t u8g_GetFontBBXWidth(u8g_t *u8g)
02855 {
02856   return u8g_font_GetBBXWidth(u8g->font);
02857 }
02858 
02859 uint8_t u8g_GetFontBBXHeight(u8g_t *u8g)
02860 {
02861   return u8g_font_GetBBXHeight(u8g->font);
02862 }
02863 
02864 int8_t u8g_GetFontBBXOffX(u8g_t *u8g) U8G_NOINLINE;
02865 int8_t u8g_GetFontBBXOffX(u8g_t *u8g)
02866 {
02867   return u8g_font_GetBBXOffX(u8g->font);
02868 }
02869 
02870 int8_t u8g_GetFontBBXOffY(u8g_t *u8g) U8G_NOINLINE;
02871 int8_t u8g_GetFontBBXOffY(u8g_t *u8g)
02872 {
02873   return u8g_font_GetBBXOffY(u8g->font);
02874 }
02875 
02876 uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g) U8G_NOINLINE;
02877 uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g)
02878 {
02879   return u8g_font_GetCapitalAHeight(u8g->font);
02880 }
02881 
02882 /*========================================================================*/
02883 /* glyph handling */
02884 
02885 static void u8g_CopyGlyphDataToCache(u8g_t *u8g, u8g_glyph_t g)
02886 {
02887   uint8_t tmp;
02888   switch( u8g_font_GetFormat(u8g->font) )
02889   {
02890     case 0:
02891     case 2:
02892   /*
02893     format 0
02894     glyph information
02895     offset
02896     0             BBX width                                       unsigned
02897     1             BBX height                                      unsigned
02898     2             data size                                          unsigned    (BBX width + 7)/8 * BBX height
02899     3             DWIDTH                                          signed
02900     4             BBX xoffset                                    signed
02901     5             BBX yoffset                                    signed
02902   byte 0 == 255 indicates empty glyph
02903   */
02904       u8g->glyph_width =  u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
02905       u8g->glyph_height =  u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
02906       u8g->glyph_dx =  u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 3 );
02907       u8g->glyph_x =  u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 4 );
02908       u8g->glyph_y =  u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 5 );
02909       break;
02910     case 1:
02911     default:
02912       /*
02913 format 1
02914   0             BBX xoffset                                    signed   --> upper 4 Bit
02915   0             BBX yoffset                                    signed --> lower 4 Bit
02916   1             BBX width                                       unsigned --> upper 4 Bit
02917   1             BBX height                                      unsigned --> lower 4 Bit
02918   2             data size                                           unsigned -(BBX width + 7)/8 * BBX height  --> lower 4 Bit
02919   2             DWIDTH                                          signed --> upper  4 Bit
02920   byte 0 == 255 indicates empty glyph
02921       */
02922 
02923       tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
02924       u8g->glyph_y =  tmp & 15;
02925       u8g->glyph_y-=2;
02926       tmp >>= 4;
02927       u8g->glyph_x =  tmp;
02928 
02929       tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
02930       u8g->glyph_height =  tmp & 15;
02931       tmp >>= 4;
02932       u8g->glyph_width =  tmp;
02933 
02934       tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 2 );
02935       tmp >>= 4;
02936       u8g->glyph_dx = tmp;
02937 
02938 
02939       break;
02940   }
02941 }
02942 
02943 //void u8g_FillEmptyGlyphCache(u8g_t *u8g) U8G_NOINLINE;
02944 static void u8g_FillEmptyGlyphCache(u8g_t *u8g)
02945 {
02946   u8g->glyph_dx = 0;
02947   u8g->glyph_width = 0;
02948   u8g->glyph_height = 0;
02949   u8g->glyph_x = 0;
02950   u8g->glyph_y = 0;
02951 }
02952 
02953 /*
02954   Find (with some speed optimization) and return a pointer to the glyph data structure
02955   Also uncompress (format 1) and copy the content of the data structure to the u8g structure
02956 */
02957 u8g_glyph_t u8g_GetGlyph(u8g_t *u8g, uint8_t requested_encoding)
02958 {
02959   uint8_t *p = (uint8_t *)(u8g->font);
02960   uint8_t font_format = u8g_font_GetFormat(u8g->font);
02961   uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize(u8g->font);
02962   uint8_t start, end;
02963   uint16_t pos;
02964   uint8_t i;
02965   uint8_t mask = 255;
02966 
02967   if ( font_format == 1 )
02968     mask = 15;
02969 
02970   start = u8g_font_GetFontStartEncoding(u8g->font);
02971   end = u8g_font_GetFontEndEncoding(u8g->font);
02972 
02973   pos = u8g_font_GetEncoding97Pos(u8g->font);
02974   if ( requested_encoding >= 97 && pos > 0 )
02975   {
02976     p+= pos;
02977     start = 97;
02978   }
02979   else
02980   {
02981     pos = u8g_font_GetEncoding65Pos(u8g->font);
02982     if ( requested_encoding >= 65 && pos > 0 )
02983     {
02984       p+= pos;
02985       start = 65;
02986     }
02987     else
02988       p += U8G_FONT_DATA_STRUCT_SIZE;       /* skip font general information */
02989   }
02990 
02991   if ( requested_encoding > end )
02992   {
02993     u8g_FillEmptyGlyphCache(u8g);
02994     return NULL;                      /* not found */
02995   }
02996 
02997   i = start;
02998   if ( i <= end )
02999   {
03000     for(;;)
03001     {
03002       if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
03003       {
03004         p += 1;
03005       }
03006       else
03007       {
03008         if ( i == requested_encoding )
03009         {
03010           u8g_CopyGlyphDataToCache(u8g, p);
03011           return p;
03012         }
03013         p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
03014         p += data_structure_size;
03015       }
03016       if ( i == end )
03017         break;
03018       i++;
03019     }
03020   }
03021 
03022   u8g_FillEmptyGlyphCache(u8g);
03023 
03024   return NULL;
03025 }
03026 
03027 uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding)
03028 {
03029   if ( u8g_GetGlyph(u8g, requested_encoding) != NULL )
03030     return 1;
03031   return 0;
03032 }
03033 
03034 int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding)
03035 {
03036   if ( u8g_GetGlyph(u8g, requested_encoding) == NULL )
03037     return 0;  /* should never happen, so return something */
03038   return u8g->glyph_dx;
03039 }
03040 
03041 
03042 /*========================================================================*/
03043 /* glyph drawing procedures */
03044 
03045 #ifdef OBSOLETE
03046 /*
03047   Draw a glyph
03048   x,y: left baseline position of the glyph
03049 */
03050 int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
03051 {
03052   u8g_glyph_t g;
03053   uint8_t w, h, i, j;
03054   const u8g_pgm_uint8_t *data;
03055   uint8_t bytes_per_line;
03056   u8g_uint_t ix, iy;
03057 
03058   g = u8g_GetGlyph(u8g, encoding);
03059   if ( g == NULL  )
03060     return 0;
03061   w = u8g->glyph_width;
03062   h = u8g->glyph_height;
03063 
03064   bytes_per_line = w;
03065   bytes_per_line += 7;
03066   bytes_per_line /= 8;
03067 
03068   data = u8g_font_GetGlyphDataStart(u8g->font, g);
03069 
03070   switch(dir)
03071   {
03072     case 0:
03073       x += u8g->glyph_x;
03074       y -= u8g->glyph_y;
03075       y--;
03076       //u8g_DrawFrame(u8g, x, y-h+1, w, h);
03077       if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
03078         return u8g->glyph_dx;
03079 
03080       iy = y;
03081       iy -= h;
03082       iy++;
03083 
03084       for( j = 0; j < h; j++ )
03085       {
03086         ix = x;
03087         for( i = 0; i < bytes_per_line; i++ )
03088         {
03089           u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
03090           data++;
03091           ix+=8;
03092         }
03093         iy++;
03094       }
03095       break;
03096     case 1:
03097       x += u8g->glyph_y;
03098       x++;
03099       y += u8g->glyph_x;
03100       //printf("enc %d, dir %d, x %d, y %d, w %d, h %d\n", encoding, dir, x, y, w, h);
03101       //u8g_DrawFrame(u8g, x, y, h, w);
03102       if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
03103         return u8g->glyph_dx;
03104 
03105       ix = x;
03106       ix += h;
03107       ix--;
03108       for( j = 0; j < h; j++ )
03109       {
03110         iy = y;
03111         for( i = 0; i < bytes_per_line; i++ )
03112         {
03113           u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
03114           data++;
03115           iy+=8;
03116         }
03117         ix--;
03118       }
03119       break;
03120     case 2:
03121       x -= u8g->glyph_x;
03122       y += u8g->glyph_y;
03123       y++;
03124       if ( u8g_IsBBXIntersection(u8g, x-w-1, y, w, h) == 0 )
03125         return u8g->glyph_dx;
03126 
03127       iy = y;
03128       iy += h;
03129       iy--;
03130       for( j = 0; j < h; j++ )
03131       {
03132         ix = x;
03133         for( i = 0; i < bytes_per_line; i++ )
03134         {
03135           u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
03136           data++;
03137           ix-=8;
03138         }
03139         iy--;
03140       }
03141       break;
03142     case 3:
03143       x -= u8g->glyph_y;
03144       x--;
03145       y -= u8g->glyph_x;
03146 
03147       if ( u8g_IsBBXIntersection(u8g, x-h-1, y-w-1, h, w) == 0 )
03148         return u8g->glyph_dx;
03149 
03150       ix = x;
03151       ix -= h;
03152       ix++;
03153 
03154       for( j = 0; j < h; j++ )
03155       {
03156         iy = y;
03157         for( i = 0; i < bytes_per_line; i++ )
03158         {
03159           u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
03160           data++;
03161           iy-=8;
03162         }
03163         ix++;
03164       }
03165       break;
03166   }
03167   return u8g->glyph_dx;
03168 }
03169 #endif
03170 
03171 int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03172 {
03173   const u8g_pgm_uint8_t *data;
03174   uint8_t w, h;
03175   uint8_t i, j;
03176   u8g_uint_t ix, iy;
03177 
03178   {
03179     u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
03180     if ( g == NULL  )
03181       return 0;
03182     data = u8g_font_GetGlyphDataStart(u8g->font, g);
03183   }
03184 
03185   w = u8g->glyph_width;
03186   h = u8g->glyph_height;
03187 
03188   x += u8g->glyph_x;
03189   y -= u8g->glyph_y;
03190   y--;
03191 
03192   if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
03193     return u8g->glyph_dx;
03194 
03195   /* now, w is reused as bytes per line */
03196   w += 7;
03197   w /= 8;
03198 
03199   iy = y;
03200   iy -= h;
03201   iy++;
03202 
03203   for( j = 0; j < h; j++ )
03204   {
03205     ix = x;
03206     for( i = 0; i < w; i++ )
03207     {
03208       u8g_Draw8Pixel(u8g, ix, iy, 0, u8g_pgm_read(data));
03209       data++;
03210       ix+=8;
03211     }
03212     iy++;
03213   }
03214   return u8g->glyph_dx;
03215 }
03216 
03217 int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03218 {
03219   y += u8g->font_calc_vref(u8g);
03220   return u8g_draw_glyph(u8g, x, y, encoding);
03221 }
03222 
03223 int8_t u8g_draw_glyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03224 {
03225   const u8g_pgm_uint8_t *data;
03226   uint8_t w, h;
03227   uint8_t i, j;
03228   u8g_uint_t ix, iy;
03229 
03230   {
03231     u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
03232     if ( g == NULL  )
03233       return 0;
03234     data = u8g_font_GetGlyphDataStart(u8g->font, g);
03235   }
03236 
03237   w = u8g->glyph_width;
03238   h = u8g->glyph_height;
03239 
03240   x += u8g->glyph_y;
03241   x++;
03242   y += u8g->glyph_x;
03243 
03244   if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
03245     return u8g->glyph_dx;
03246 
03247   /* now, w is reused as bytes per line */
03248   w += 7;
03249   w /= 8;
03250 
03251   ix = x;
03252   ix += h;
03253   ix--;
03254   for( j = 0; j < h; j++ )
03255   {
03256     iy = y;
03257     for( i = 0; i < w; i++ )
03258     {
03259       u8g_Draw8Pixel(u8g, ix, iy, 1, u8g_pgm_read(data));
03260       data++;
03261       iy+=8;
03262     }
03263     ix--;
03264   }
03265   return u8g->glyph_dx;
03266 }
03267 
03268 int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03269 {
03270   x -= u8g->font_calc_vref(u8g);
03271   return u8g_draw_glyph90(u8g, x, y, encoding);
03272 }
03273 
03274 
03275 int8_t u8g_draw_glyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03276 {
03277   const u8g_pgm_uint8_t *data;
03278   uint8_t w, h;
03279   uint8_t i, j;
03280   u8g_uint_t ix, iy;
03281 
03282   {
03283     u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
03284     if ( g == NULL  )
03285       return 0;
03286     data = u8g_font_GetGlyphDataStart(u8g->font, g);
03287   }
03288 
03289   w = u8g->glyph_width;
03290   h = u8g->glyph_height;
03291 
03292   x -= u8g->glyph_x;
03293   y += u8g->glyph_y;
03294   y++;
03295 
03296   if ( u8g_IsBBXIntersection(u8g, x-(w-1), y, w, h) == 0 )
03297     return u8g->glyph_dx;
03298 
03299   /* now, w is reused as bytes per line */
03300   w += 7;
03301   w /= 8;
03302 
03303   iy = y;
03304   iy += h;
03305   iy--;
03306   for( j = 0; j < h; j++ )
03307   {
03308     ix = x;
03309     for( i = 0; i < w; i++ )
03310     {
03311       u8g_Draw8Pixel(u8g, ix, iy, 2, u8g_pgm_read(data));
03312       data++;
03313       ix-=8;
03314     }
03315     iy--;
03316   }
03317   return u8g->glyph_dx;
03318 }
03319 
03320 int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03321 {
03322   y -= u8g->font_calc_vref(u8g);
03323   return u8g_draw_glyph180(u8g, x, y, encoding);
03324 }
03325 
03326 
03327 int8_t u8g_draw_glyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03328 {
03329   const u8g_pgm_uint8_t *data;
03330   uint8_t w, h;
03331   uint8_t i, j;
03332   u8g_uint_t ix, iy;
03333 
03334   {
03335     u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
03336     if ( g == NULL  )
03337       return 0;
03338     data = u8g_font_GetGlyphDataStart(u8g->font, g);
03339   }
03340 
03341   w = u8g->glyph_width;
03342   h = u8g->glyph_height;
03343 
03344   x -= u8g->glyph_y;
03345   x--;
03346   y -= u8g->glyph_x;
03347 
03348   if ( u8g_IsBBXIntersection(u8g, x-(h-1), y-(w-1), h, w) == 0 )
03349     return u8g->glyph_dx;
03350 
03351 
03352   /* now, w is reused as bytes per line */
03353   w += 7;
03354   w /= 8;
03355 
03356   ix = x;
03357   ix -= h;
03358   ix++;
03359 
03360   for( j = 0; j < h; j++ )
03361   {
03362     iy = y;
03363     for( i = 0; i < w; i++ )
03364     {
03365       u8g_Draw8Pixel(u8g, ix, iy, 3, u8g_pgm_read(data));
03366       data++;
03367       iy-=8;
03368     }
03369     ix++;
03370   }
03371   return u8g->glyph_dx;
03372 }
03373 
03374 int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
03375 {
03376   x += u8g->font_calc_vref(u8g);
03377   return u8g_draw_glyph270(u8g, x, y, encoding);
03378 }
03379 
03380 
03381 
03382 #ifdef OBSOLETE
03383 /*
03384   Draw a glyph
03385   x,y: lower left corner of the font bounding box
03386 */
03387 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
03388 {
03389   /* TODO: apply "dir" */
03390   x -= u8g_GetFontBBXOffX(u8g);
03391   y += u8g_GetFontBBXOffY(u8g);
03392   return u8g_DrawGlyphDir(u8g, x, y, dir, encoding);
03393 }
03394 #endif
03395 
03396 /*========================================================================*/
03397 /* string drawing procedures */
03398 
03399 
03400 u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
03401 {
03402   u8g_uint_t t = 0;
03403   int8_t d;
03404 
03405   //u8g_uint_t u8g_GetStrWidth(u8g, s);
03406   //u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
03407 
03408   y += u8g->font_calc_vref(u8g);
03409 
03410   while( *s != '\0' )
03411   {
03412     d = u8g_draw_glyph(u8g, x, y, *s);
03413     x += d;
03414     t += d;
03415     s++;
03416   }
03417   return t;
03418 }
03419 
03420 u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
03421 {
03422   u8g_uint_t t = 0;
03423   int8_t d;
03424 
03425   x -= u8g->font_calc_vref(u8g);
03426 
03427   while( *s != '\0' )
03428   {
03429     d = u8g_draw_glyph90(u8g, x, y, *s);
03430     y += d;
03431     t += d;
03432     s++;
03433   }
03434   return t;
03435 }
03436 
03437 u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
03438 {
03439   u8g_uint_t t = 0;
03440   int8_t d;
03441 
03442   y -= u8g->font_calc_vref(u8g);
03443 
03444   while( *s != '\0' )
03445   {
03446     d = u8g_draw_glyph180(u8g, x, y, *s);
03447     x -= d;
03448     t += d;
03449     s++;
03450   }
03451   return t;
03452 }
03453 
03454 u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
03455 {
03456   u8g_uint_t t = 0;
03457   int8_t d;
03458 
03459   x += u8g->font_calc_vref(u8g);
03460 
03461   while( *s != '\0' )
03462   {
03463     d = u8g_draw_glyph270(u8g, x, y, *s);
03464     y -= d;
03465     t += d;
03466     s++;
03467   }
03468   return t;
03469 }
03470 
03471 u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
03472 {
03473   switch(dir)
03474   {
03475     case 0:
03476       return u8g_DrawStr(u8g, x, y, s);
03477     case 1:
03478       return u8g_DrawStr90(u8g, x, y, s);
03479     case 2:
03480       return u8g_DrawStr180(u8g, x, y, s);
03481     case 3:
03482       return u8g_DrawStr270(u8g, x, y, s);
03483   }
03484   return 0;
03485 }
03486 
03487 u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
03488 {
03489   u8g_uint_t t = 0;
03490   int8_t d;
03491   uint8_t c;
03492 
03493   y += u8g->font_calc_vref(u8g);
03494 
03495   for(;;)
03496   {
03497     c = u8g_pgm_read(s);
03498     if ( c == '\0' )
03499       break;
03500     d = u8g_draw_glyph(u8g, x, y, c);
03501     x += d;
03502     t += d;
03503     s++;
03504   }
03505   return t;
03506 }
03507 
03508 u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
03509 {
03510   u8g_uint_t t = 0;
03511   int8_t d;
03512 
03513   x -= u8g->font_calc_vref(u8g);
03514 
03515   while( *s != '\0' )
03516   {
03517     d = u8g_DrawGlyph90(u8g, x, y, u8g_pgm_read(s));
03518     y += d;
03519     t += d;
03520     s++;
03521   }
03522   return t;
03523 }
03524 
03525 u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
03526 {
03527   u8g_uint_t t = 0;
03528   int8_t d;
03529 
03530   y -= u8g->font_calc_vref(u8g);
03531 
03532   while( *s != '\0' )
03533   {
03534     d = u8g_DrawGlyph180(u8g, x, y, u8g_pgm_read(s));
03535     x -= d;
03536     t += d;
03537     s++;
03538   }
03539   return t;
03540 }
03541 
03542 u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
03543 {
03544   u8g_uint_t t = 0;
03545   int8_t d;
03546 
03547   x += u8g->font_calc_vref(u8g);
03548 
03549   while( *s != '\0' )
03550   {
03551     d = u8g_DrawGlyph270(u8g, x, y, u8g_pgm_read(s));
03552     y -= d;
03553     t += d;
03554     s++;
03555   }
03556   return t;
03557 }
03558 
03559 u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
03560 {
03561   x -= u8g_GetFontBBXOffX(u8g);
03562   y += u8g_GetFontBBXOffY(u8g);
03563   return u8g_DrawStrDir(u8g, x, y, dir, s);
03564 }
03565 
03566 /* still used by picgen.c, dir argument is ignored */
03567 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
03568 {
03569   x -= u8g_GetFontBBXOffX(u8g);
03570   y += u8g_GetFontBBXOffY(u8g);
03571   u8g_draw_glyph(u8g, x, y, encoding);
03572   return 0;
03573 }
03574 
03575 
03576 /*========================================================================*/
03577 /* set ascent/descent for reference point calculation */
03578 
03579 void u8g_UpdateRefHeight(u8g_t *u8g)
03580 {
03581   uint16_t ls;
03582   if ( u8g->font == NULL )
03583     return;
03584   if ( u8g->font_height_mode == U8G_FONT_HEIGHT_MODE_TEXT )
03585   {
03586     u8g->font_ref_ascent = u8g_font_GetCapitalAHeight(u8g->font);
03587     u8g->font_ref_descent = u8g_font_GetLowerGDescent(u8g->font);
03588   }
03589   else if ( u8g->font_height_mode == U8G_FONT_HEIGHT_MODE_XTEXT )
03590   {
03591     u8g->font_ref_ascent = u8g_font_GetFontXAscent(u8g->font);
03592     u8g->font_ref_descent = u8g_font_GetFontXDescent(u8g->font);
03593   }
03594   else
03595   {
03596     u8g->font_ref_ascent = u8g_font_GetFontAscent(u8g->font);
03597     u8g->font_ref_descent = u8g_font_GetFontDescent(u8g->font);
03598   }
03599 
03600   ls = u8g->font_ref_ascent - u8g->font_ref_descent;
03601   if ( u8g->font_line_spacing_factor != 64 )
03602   {
03603     ls &= 255;
03604     ls *= u8g->font_line_spacing_factor;
03605     ls >>= 6;
03606   }
03607   u8g->line_spacing = ls;
03608 }
03609 
03610 void u8g_SetFontRefHeightText(u8g_t *u8g)
03611 {
03612   u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_TEXT;
03613   u8g_UpdateRefHeight(u8g);
03614 }
03615 
03616 void u8g_SetFontRefHeightExtendedText(u8g_t *u8g)
03617 {
03618   u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
03619   u8g_UpdateRefHeight(u8g);
03620 }
03621 
03622 
03623 void u8g_SetFontRefHeightAll(u8g_t *u8g)
03624 {
03625   u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_ALL;
03626   u8g_UpdateRefHeight(u8g);
03627 }
03628 
03629 /* factor = 64: linespaceing == ascent and descent */
03630 void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t  factor)
03631 {
03632   u8g->font_line_spacing_factor = factor;
03633   u8g_UpdateRefHeight(u8g);
03634 }
03635 
03636 
03637 
03638 /*========================================================================*/
03639 /* callback procedures to correct the y position */
03640 
03641 u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g)
03642 {
03643   return 0;
03644 }
03645 
03646 void u8g_SetFontPosBaseline(u8g_t *u8g)
03647 {
03648   u8g->font_calc_vref = u8g_font_calc_vref_font;
03649 }
03650 
03651 
03652 u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g)
03653 {
03654   /* y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent); */
03655   return (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent);
03656 }
03657 
03658 void u8g_SetFontPosBottom(u8g_t *u8g)
03659 {
03660   u8g->font_calc_vref = u8g_font_calc_vref_bottom;
03661 }
03662 
03663 u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g)
03664 {
03665   u8g_uint_t tmp;
03666   /* reference pos is one pixel above the upper edge of the reference glyph */
03667 
03668   /*
03669   y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
03670   y++;
03671   */
03672   tmp = (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
03673   tmp++;
03674   return tmp;
03675 }
03676 
03677 void u8g_SetFontPosTop(u8g_t *u8g)
03678 {
03679   u8g->font_calc_vref = u8g_font_calc_vref_top;
03680 }
03681 
03682 u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g)
03683 {
03684   int8_t tmp;
03685   tmp = u8g->font_ref_ascent;
03686   tmp -= u8g->font_ref_descent;
03687   tmp /= 2;
03688   tmp += u8g->font_ref_descent;
03689   /* y += (u8g_uint_t)(u8g_int_t)(tmp); */
03690   return tmp;
03691 }
03692 
03693 void u8g_SetFontPosCenter(u8g_t *u8g)
03694 {
03695   u8g->font_calc_vref = u8g_font_calc_vref_center;
03696 }
03697 
03698 /*========================================================================*/
03699 /* string pixel width calculation */
03700 
03701 char u8g_font_get_char(const void *s)
03702 {
03703   return *(const char *)(s);
03704 }
03705 
03706 char u8g_font_get_charP(const void *s)
03707 {
03708   return u8g_pgm_read(s);
03709 }
03710 
03711 typedef char (*u8g_font_get_char_fn)(const void *s);
03712 
03713 
03714 u8g_uint_t u8g_font_calc_str_pixel_width(u8g_t *u8g, const char *s, u8g_font_get_char_fn get_char )
03715 {
03716   u8g_uint_t  w;
03717   uint8_t enc;
03718 
03719   /* reset the total minimal width to zero, this will be expanded during calculation */
03720   w = 0;
03721 
03722   enc = get_char(s);
03723 
03724   /* check for empty string, width is already 0 */
03725   if ( enc == '\0' )
03726   {
03727     return w;
03728   }
03729 
03730   /* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
03731   /* if *s is not inside the font, then the cached parameters of the glyph are all zero */
03732   u8g_GetGlyph(u8g, enc);
03733 
03734   /* strlen(s) == 1:       width = width(s[0]) */
03735   /* strlen(s) == 2:       width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
03736   /* strlen(s) == 3:       width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
03737 
03738   /* assume that the string has size 2 or more, than start with negative offset-x */
03739   /* for string with size 1, this will be nullified after the loop */
03740   w = -u8g->glyph_x;
03741   for(;;)
03742   {
03743 
03744     /* check and stop if the end of the string is reached */
03745     s++;
03746     if ( get_char(s) == '\0' )
03747       break;
03748 
03749     /* if there are still more characters, add the delta to the next glyph */
03750     w += u8g->glyph_dx;
03751 
03752     /* store the encoding in a local variable, used also after the for(;;) loop */
03753     enc = get_char(s);
03754 
03755     /* load the next glyph information */
03756     u8g_GetGlyph(u8g, enc);
03757   }
03758 
03759   /* finally calculate the width of the last char */
03760   /* here is another exception, if the last char is a black, use the dx value instead */
03761   if ( enc != ' ' )
03762   {
03763     /* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
03764     w += u8g->glyph_width;
03765     w += u8g->glyph_x;
03766   }
03767   else
03768   {
03769     w += u8g->glyph_dx;
03770   }
03771 
03772 
03773   return w;
03774 }
03775 
03776 u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s)
03777 {
03778   return u8g_font_calc_str_pixel_width(u8g, s, u8g_font_get_char);
03779 }
03780 
03781 u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
03782 {
03783   return u8g_font_calc_str_pixel_width(u8g, (const char *)s, u8g_font_get_charP);
03784 }
03785 
03786 int8_t u8g_GetStrX(u8g_t *u8g, const char *s)
03787 {
03788   u8g_GetGlyph(u8g, *s);
03789   return u8g->glyph_x;
03790 }
03791 
03792 int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
03793 {
03794   u8g_GetGlyph(u8g, u8g_pgm_read(s));
03795   return u8g->glyph_x;
03796 }
03797 
03798 /*========================================================================*/
03799 /* string width calculation */
03800 
03801 u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s)
03802 {
03803   u8g_uint_t  w;
03804   uint8_t encoding;
03805 
03806   /* reset the total width to zero, this will be expanded during calculation */
03807   w = 0;
03808 
03809   for(;;)
03810   {
03811     encoding = *s;
03812     if ( encoding == 0 )
03813       break;
03814 
03815     /* load glyph information */
03816     u8g_GetGlyph(u8g, encoding);
03817     w += u8g->glyph_dx;
03818 
03819     /* goto next char */
03820     s++;
03821   }
03822 
03823   return w;
03824 }
03825 
03826 
03827 u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
03828 {
03829   u8g_uint_t  w;
03830   uint8_t encoding;
03831 
03832   /* reset the total width to zero, this will be expanded during calculation */
03833   w = 0;
03834 
03835   for(;;)
03836   {
03837     encoding = u8g_pgm_read(s);
03838     if ( encoding == 0 )
03839       break;
03840 
03841     /* load glyph information */
03842     u8g_GetGlyph(u8g, encoding);
03843     w += u8g->glyph_dx;
03844 
03845     /* goto next char */
03846     s++;
03847   }
03848 
03849   return w;
03850 }
03851 
03852 
03853 /*========================================================================*/
03854 /* calculation of font/glyph/string characteristics */
03855 
03856 
03857 /*
03858   Description:
03859     Calculate parameter for the minimal bounding box on a given string
03860   Output
03861     buf->y_min          extend of the lower left edge if the string below (y_min<0) or above (y_min>0) baseline (descent)
03862     buf->y_max          extend of the upper left edge if the string below (y_min<0) or above (y_min>0) baseline (ascent)
03863     buf->w                 the width of the string
03864 */
03865 struct u8g_str_size_struct
03866 {
03867   int8_t y_min;         /* descent */
03868   int8_t y_max;         /* ascent */
03869   int8_t x, y;             /* the reference point of the font (negated!) */
03870   u8g_uint_t w;         /* width of the overall string */
03871 };
03872 typedef struct u8g_str_size_struct u8g_str_size_t;
03873 
03874 static void u8g_font_calc_str_min_box(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
03875 {
03876   /* u8g_glyph_t g; */
03877   int8_t tmp;
03878 
03879   /* reset the total minimal width to zero, this will be expanded during calculation */
03880   buf->w = 0;
03881 
03882   /* check for empty string, width is already 0, but also reset y_min and y_max to 0 */
03883   if ( *s == '\0' )
03884   {
03885     buf->y_min = 0;
03886     buf->y_max = 0;
03887     buf->x = 0;
03888     buf->y = 0;
03889     return;
03890   }
03891 
03892   /* reset y_min to the largest possible value. Later we search for the smallest value */
03893   /* y_min contains the position [pixel] of the lower left edge of the glyph above (y_min>0) or below (y_min<0) baseline  */
03894   buf->y_min = 127;
03895   /* reset y_max to the smallest possible value. Later we search for the highest value */
03896   /* y_max contains the position [pixel] of the upper left edge of the glyph above (y_max>0) or below (y_max<0) baseline  */
03897   buf->y_max = -128;
03898 
03899   /* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
03900   u8g_GetGlyph(u8g, *s);
03901 
03902   /* strlen(s) == 1:       width = width(s[0]) */
03903   /* strlen(s) == 2:       width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
03904   /* strlen(s) == 3:       width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
03905 
03906   /* assume that the string has size 2 or more, than start with negative offset-x */
03907   /* for string with size 1, this will be nullified after the loop */
03908   // buf->w = - u8g_font_GetGlyphBBXOffX(u8g->font, g);
03909   buf->w = - u8g->glyph_x;
03910 
03911   /* Also copy the position of the first glyph. This is the reference point of the string (negated) */
03912   buf->x = u8g->glyph_x;
03913   buf->y = u8g->glyph_y;
03914 
03915   for(;;)
03916   {
03917 
03918     /* calculated y position of the upper left corner (y_max) and lower left corner (y_min) of the string */
03919     /* relative to the base line */
03920 
03921     tmp = u8g->glyph_y;
03922     if ( buf->y_min > tmp )
03923       buf->y_min = tmp;
03924 
03925     tmp +=u8g->glyph_height;
03926     if ( buf->y_max < tmp )
03927       buf->y_max = tmp;
03928 
03929     /* check and stop if the end of the string is reached */
03930     s++;
03931     if ( *s == '\0' )
03932       break;
03933 
03934     /* if there are still more characters, add the delta to the next glyph */
03935     buf->w += u8g->glyph_dx;
03936 
03937     /* load the next glyph information */
03938     u8g_GetGlyph(u8g, *s);
03939   }
03940 
03941   /* finally calculate the width of the last char */
03942   /* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
03943   buf->w += u8g->glyph_width;
03944   // buf->w += u8g_font_GetGlyphBBXOffX(u8g->font, g);
03945 
03946   buf->w += u8g->glyph_x;
03947 }
03948 
03949 /* calculate minimal box */
03950 void u8g_font_box_min(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
03951 {
03952   u8g_font_calc_str_min_box(u8g, s, buf);
03953 }
03954 
03955 /* calculate gA box, but do not calculate the overall width */
03956 void u8g_font_box_left_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
03957 {
03958 
03959 }
03960 
03961 /* calculate gA box, including overall width */
03962 void u8g_font_box_all_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
03963 {
03964 
03965 }
03966 
03967 
03968 static void u8g_font_get_str_box_fill_args(u8g_t *u8g, const char *s, u8g_str_size_t *buf, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
03969 {
03970   /*
03971   u8g_glyph_t g;
03972   g =
03973   */
03974   u8g_GetGlyph(u8g, *s);
03975   *x += u8g->glyph_x;
03976   *width = buf->w;
03977   *y -= buf->y_max;
03978   /* +1 because y_max is a height, this compensates the next step */
03979   //*y += 1;
03980   /* because the reference point is one below the string, this compensates the previous step */
03981   //*y -= 1;
03982   *height = buf->y_max;
03983   *height -= buf->y_min;
03984 }
03985 
03986 
03987 void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
03988 {
03989   u8g_str_size_t buf;
03990 
03991   if ( *s == '\0' )
03992   {
03993     *width= 0;
03994     *height = 0;
03995     return;
03996   }
03997 
03998   u8g_font_calc_str_min_box(u8g, s, &buf);
03999   u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
04000 }
04001 
04002 
04003 void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
04004 {
04005   u8g_str_size_t buf;
04006   uint8_t cap_a;
04007 
04008   if ( *s == '\0' )
04009   {
04010     *width= 0;
04011     *height = 0;
04012     return;
04013   }
04014 
04015   cap_a = u8g_font_GetCapitalAHeight(u8g->font);
04016   u8g_font_calc_str_min_box(u8g, s, &buf);
04017   if ( buf.y_max < cap_a )
04018     buf.y_max = cap_a;
04019   u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
04020 }
04021 
04022 void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t  *font)
04023 {
04024   if ( u8g->font != font )
04025   {
04026     u8g->font = font;
04027     u8g_UpdateRefHeight(u8g);
04028     u8g_SetFontPosBaseline(u8g);
04029   }
04030 }
04031 
04032 /*========================================================================*/
04033 /* anti aliasing fonts */
04034 
04035 int8_t u8g_draw_aa_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
04036 {
04037   const u8g_pgm_uint8_t *data;
04038   uint8_t w, h;
04039   uint8_t i, j;
04040   u8g_uint_t ix, iy;
04041 
04042   {
04043     u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
04044     if ( g == NULL  )
04045       return 0;
04046     data = u8g_font_GetGlyphDataStart(u8g->font, g);
04047   }
04048 
04049   w = u8g->glyph_width;
04050   h = u8g->glyph_height;
04051 
04052   x += u8g->glyph_x;
04053   y -= u8g->glyph_y;
04054   y--;
04055 
04056   if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
04057     return u8g->glyph_dx;
04058 
04059   /* now, w is reused as bytes per line */
04060   w += 3;
04061   w /= 4;
04062 
04063   iy = y;
04064   iy -= h;
04065   iy++;
04066 
04067   for( j = 0; j < h; j++ )
04068   {
04069     ix = x;
04070     for( i = 0; i < w; i++ )
04071     {
04072       u8g_Draw4TPixel(u8g, ix, iy, 0, u8g_pgm_read(data));
04073       data++;
04074       ix+=4;
04075     }
04076     iy++;
04077   }
04078   return u8g->glyph_dx;
04079 }
04080 
04081 int8_t u8g_DrawAAGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
04082 {
04083   y += u8g->font_calc_vref(u8g);
04084   return u8g_draw_aa_glyph(u8g, x, y, encoding);
04085 }
04086 
04087 u8g_uint_t u8g_DrawAAStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
04088 {
04089   u8g_uint_t t = 0;
04090   int8_t d;
04091 
04092   if ( u8g_font_GetFormat(u8g->font)  != 2 )
04093     return 0;
04094   //u8g_uint_t u8g_GetStrWidth(u8g, s);
04095   //u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
04096 
04097   y += u8g->font_calc_vref(u8g);
04098 
04099   while( *s != '\0' )
04100   {
04101     d = u8g_draw_aa_glyph(u8g, x, y, *s);
04102     x += d;
04103     t += d;
04104     s++;
04105   }
04106   return t;
04107 }
04108 
04109 // ============== u8g_page.c ================
04110 
04111 /*
04112 
04113   u8g_page.c
04114 
04115   page helper functions, only called by the dev handler.
04116 
04117   Universal 8bit Graphics Library
04118 
04119   Copyright (c) 2011, olikraus@gmail.com
04120   All rights reserved.
04121 
04122   Redistribution and use in source and binary forms, with or without modification,
04123   are permitted provided that the following conditions are met:
04124 
04125   * Redistributions of source code must retain the above copyright notice, this list
04126     of conditions and the following disclaimer.
04127 
04128   * Redistributions in binary form must reproduce the above copyright notice, this
04129     list of conditions and the following disclaimer in the documentation and/or other
04130     materials provided with the distribution.
04131 
04132   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04133   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04134   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04135   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04136   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04137   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04138   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04139   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04140   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04141   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04142   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04143   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04144   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04145 
04146 
04147 */
04148 
04149 /*
04150   setup page count structure
04151   conditions: page_height <= total_height
04152 */
04153 void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
04154 {
04155   p->page_height = page_height;
04156   p->total_height = total_height;
04157   p->page = 0;
04158   u8g_page_First(p);
04159 }
04160 
04161 void u8g_page_First(u8g_page_t *p)
04162 {
04163   p->page_y0 = 0;
04164   p->page_y1 = p->page_height;
04165   p->page_y1--;
04166   p->page = 0;
04167 }
04168 
04169 uint8_t u8g_page_Next(u8g_page_t * p)
04170 {
04171   register u8g_uint_t y1;
04172   p->page_y0 += p->page_height;
04173   if ( p->page_y0 >= p->total_height )
04174     return 0;
04175   p->page++;
04176   y1 = p->page_y1;
04177   y1 += p->page_height;
04178   if ( y1 >= p->total_height )
04179   {
04180     y1 = p->total_height;
04181     y1--;
04182   }
04183   p->page_y1 = y1;
04184 
04185   return 1;
04186 }
04187 
04188 // =============== u8g_clip.c ================
04189 
04190 /*
04191 
04192   u8g_clip.c
04193 
04194   procedures for clipping
04195   taken over from procs in u8g_pb.c
04196 
04197   Universal 8bit Graphics Library
04198 
04199   Copyright (c) 2012, olikraus@gmail.com
04200   All rights reserved.
04201 
04202   Redistribution and use in source and binary forms, with or without modification,
04203   are permitted provided that the following conditions are met:
04204 
04205   * Redistributions of source code must retain the above copyright notice, this list
04206     of conditions and the following disclaimer.
04207 
04208   * Redistributions in binary form must reproduce the above copyright notice, this
04209     list of conditions and the following disclaimer in the documentation and/or other
04210     materials provided with the distribution.
04211 
04212   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04213   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04214   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04215   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04216   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04217   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04218   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04219   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04220   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04221   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04222   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04223   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04224   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04225 
04226   Notes
04227 
04228   This is one of the most critical parts of u8glib. It must be fast, but still reliable.
04229   Based on the intersection program (see tools folder), there is minimized version of
04230   the condition for the intersaction test:
04231     minimized version
04232     ---1----0 1             b1 <= a2 && b1 > b2
04233     -----1--0 1             b2 >= a1 && b1 > b2
04234     ---1-1--- 1             b1 <= a2 && b2 >= a1
04235   It includes the assumption, that a1 <= a2 is always true (correct, because
04236   a1, a2 are the page dimensions.
04237 
04238   The direct implementation of the above result is done in:
04239   uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
04240   However, this is slower than a decision tree version:
04241   static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
04242   Also suprising is, that the macro implementation is slower than the inlined version.
04243 
04244   The decision tree is based on the expansion of the truth table.
04245 
04246 */
04247 
04248 
04249 #ifdef __GNUC__
04250 #define U8G_ALWAYS_INLINE __inline__ __attribute__((always_inline))
04251 #else
04252 #define U8G_ALWAYS_INLINE
04253  #endif
04254 
04255 /*
04256   intersection assumptions:
04257     a1 <= a2 is always true
04258 
04259     minimized version
04260     ---1----0 1             b1 <= a2 && b1 > b2
04261     -----1--0 1             b2 >= a1 && b1 > b2
04262     ---1-1--- 1             b1 <= a2 && b2 >= a1
04263   */
04264 
04265 #ifdef OLD_CODE_WHICH_IS_TOO_SLOW
04266 static uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
04267 {
04268   uint8_t c1, c2, c3, tmp;
04269   c1 = v0 <= a1;
04270   c2 = v1 >= a0;
04271   c3 = v0 > v1;
04272 
04273   tmp = c1;
04274   c1 &= c2;
04275   c2 &= c3;
04276   c3 &= tmp;
04277   c1 |= c2;
04278   c1 |= c3;
04279   return c1 & 1;
04280 }
04281 #endif
04282 
04283 #define U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1) ((uint8_t)( (v0) <= (a1) ) ? ( ( (v1) >= (a0) ) ? ( 1 ) : ( (v0) > (v1) ) ) : ( ( (v1) >= (a0) ) ? ( (v0) > (v1) ) : ( 0 ) ))
04284 
04285 //static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) U8G_ALWAYS_INLINE;
04286 static uint8_t U8G_ALWAYS_INLINE u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
04287 {
04288   /* surprisingly the macro leads to larger code */
04289   /* return U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1); */
04290   if ( v0 <= a1 )
04291   {
04292     if ( v1 >= a0 )
04293     {
04294       return 1;
04295     }
04296     else
04297     {
04298       if ( v0 > v1 )
04299       {
04300         return 1;
04301       }
04302       else
04303       {
04304         return 0;
04305       }
04306     }
04307   }
04308   else
04309   {
04310     if ( v1 >= a0 )
04311     {
04312       if ( v0 > v1 )
04313       {
04314         return 1;
04315       }
04316       else
04317       {
04318         return 0;
04319       }
04320     }
04321     else
04322     {
04323       return 0;
04324     }
04325   }
04326 }
04327 
04328 
04329 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
04330 {
04331   register u8g_uint_t tmp;
04332   tmp = y;
04333   tmp += h;
04334   tmp--;
04335   if ( u8g_is_intersection_decision_tree(u8g->current_page.y0, u8g->current_page.y1, y, tmp) == 0 )
04336     return 0;
04337 
04338   tmp = x;
04339   tmp += w;
04340   tmp--;
04341   return u8g_is_intersection_decision_tree(u8g->current_page.x0, u8g->current_page.x1, x, tmp);
04342 }
04343 
04344 // ============= u8g_com_arduino_std_sw_spi.c =====================
04345 
04346 /*
04347 
04348   u8g_arduino_std_sw_spi.c
04349 
04350   Universal 8bit Graphics Library
04351 
04352   Copyright (c) 2011, olikraus@gmail.com
04353   All rights reserved.
04354 
04355   Redistribution and use in source and binary forms, with or without modification,
04356   are permitted provided that the following conditions are met:
04357 
04358   * Redistributions of source code must retain the above copyright notice, this list
04359     of conditions and the following disclaimer.
04360 
04361   * Redistributions in binary form must reproduce the above copyright notice, this
04362     list of conditions and the following disclaimer in the documentation and/or other
04363     materials provided with the distribution.
04364 
04365   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04366   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04367   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04368   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04369   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04370   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04371   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04372   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04373   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04374   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04375   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04376   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04377   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04378 
04379 */
04380 
04381 void u8g_arduino_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
04382 {
04383   uint8_t i = 8;
04384   do
04385   {
04386     if ( val & 128 )
04387       digitalWrite(dataPin, HIGH);
04388     else
04389       digitalWrite(dataPin, LOW);
04390     val <<= 1;
04391     u8g_MicroDelay();           /* 23 Sep 2012 */
04392     //delay(1);
04393     digitalWrite(clockPin, HIGH);
04394     u8g_MicroDelay();           /* 23 Sep 2012 */
04395     //delay(1);
04396     digitalWrite(clockPin, LOW);
04397     u8g_MicroDelay();           /* 23 Sep 2012 */
04398     //delay(1);
04399     i--;
04400   } while( i != 0 );
04401 }
04402 
04403 uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
04404 {
04405   switch(msg)
04406   {
04407     case U8G_COM_MSG_INIT:
04408       u8g_com_arduino_assign_pin_output_high(u8g);
04409       u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
04410       u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
04411       break;
04412 
04413     case U8G_COM_MSG_STOP:
04414       break;
04415 
04416     case U8G_COM_MSG_RESET:
04417       if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
04418         u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
04419       break;
04420 
04421     case U8G_COM_MSG_CHIP_SELECT:
04422       if ( arg_val == 0 )
04423       {
04424         /* disable */
04425         u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
04426       }
04427       else
04428       {
04429         /* enable */
04430         u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
04431         u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
04432       }
04433       break;
04434 
04435     case U8G_COM_MSG_WRITE_BYTE:
04436       u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
04437       break;
04438 
04439     case U8G_COM_MSG_WRITE_SEQ:
04440       {
04441         register uint8_t *ptr = (uint8_t*)arg_ptr;
04442         while( arg_val > 0 )
04443         {
04444           u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
04445           arg_val--;
04446         }
04447       }
04448       break;
04449 
04450       case U8G_COM_MSG_WRITE_SEQ_P:
04451       {
04452         register uint8_t *ptr = (uint8_t*)arg_ptr;
04453         while( arg_val > 0 )
04454         {
04455           u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
04456           ptr++;
04457           arg_val--;
04458         }
04459       }
04460       break;
04461 
04462     case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
04463       u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
04464       break;
04465   }
04466   return 1;
04467 }
04468 
04469 
04470 // ======== u8g_com_atmega_st7920_spi.c ==============
04471 
04472 /*
04473 
04474   u8g_com_atmega_st7920_spi.c
04475 
04476   Universal 8bit Graphics Library
04477 
04478   Copyright (c) 2011, olikraus@gmail.com
04479   All rights reserved.
04480 
04481   Redistribution and use in source and binary forms, with or without modification,
04482   are permitted provided that the following conditions are met:
04483 
04484   * Redistributions of source code must retain the above copyright notice, this list
04485     of conditions and the following disclaimer.
04486 
04487   * Redistributions in binary form must reproduce the above copyright notice, this
04488     list of conditions and the following disclaimer in the documentation and/or other
04489     materials provided with the distribution.
04490 
04491   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04492   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04493   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04494   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04495   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04496   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04497   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04498   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04499   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04500   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04501   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04502   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04503   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04504 
04505   A special SPI interface for ST7920 controller
04506 
04507 */
04508 
04509 #if defined(__AVR__)
04510 
04511 static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
04512 static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
04513 {
04514   uint8_t i = 8;
04515   do
04516   {
04517     u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
04518     val <<= 1;
04519     u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
04520     u8g_MicroDelay();           /* 15 Aug 2012: added for high speed uC */
04521     u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
04522     u8g_MicroDelay();           /* 15 Aug 2012: added for high speed uC */
04523     i--;
04524   } while( i != 0 );
04525 }
04526 
04527 static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
04528 static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val)
04529 {
04530   uint8_t i;
04531 
04532   if ( rs == 0 )
04533   {
04534     /* command */
04535     u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0f8);
04536   }
04537   else if ( rs == 1 )
04538   {
04539     /* data */
04540     u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0fa);
04541   }
04542 
04543   u8g_atmega_st7920_sw_spi_shift_out(u8g, val & 0x0f0);
04544   u8g_atmega_st7920_sw_spi_shift_out(u8g, val << 4);
04545 
04546   for( i = 0; i < 4; i++ )
04547     u8g_10MicroDelay();
04548 }
04549 
04550 
04551 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
04552 {
04553   switch(msg)
04554   {
04555     case U8G_COM_MSG_INIT:
04556       u8g_SetPIOutput(u8g, U8G_PI_SCK);
04557       u8g_SetPIOutput(u8g, U8G_PI_MOSI);
04558       /* u8g_SetPIOutput(u8g, U8G_PI_A0); */
04559       u8g_SetPIOutput(u8g, U8G_PI_CS);
04560       u8g_SetPIOutput(u8g, U8G_PI_RESET);
04561 
04562       u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
04563       u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
04564       u8g_SetPILevel(u8g, U8G_PI_CS, 0 );
04565       /* u8g_SetPILevel(u8g, U8G_PI_A0, 0); */
04566 
04567       u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
04568       break;
04569 
04570     case U8G_COM_MSG_STOP:
04571       break;
04572 
04573     case U8G_COM_MSG_RESET:
04574       u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
04575       break;
04576 
04577     case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
04578       u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
04579       break;
04580 
04581     case U8G_COM_MSG_CHIP_SELECT:
04582       if ( arg_val == 0 )
04583       {
04584         /* disable, note: the st7920 has an active high chip select */
04585         u8g_SetPILevel(u8g, U8G_PI_CS, 0);
04586       }
04587       else
04588       {
04589         /* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
04590         /* enable */
04591         u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
04592       }
04593       break;
04594 
04595 
04596     case U8G_COM_MSG_WRITE_BYTE:
04597       u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
04598       u8g->pin_list[U8G_PI_A0_STATE] = 2;
04599       break;
04600 
04601     case U8G_COM_MSG_WRITE_SEQ:
04602       {
04603         register uint8_t *ptr = (uint8_t*)arg_ptr;
04604         while( arg_val > 0 )
04605         {
04606           u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
04607           u8g->pin_list[U8G_PI_A0_STATE] = 2;
04608           arg_val--;
04609         }
04610       }
04611       break;
04612 
04613       case U8G_COM_MSG_WRITE_SEQ_P:
04614       {
04615         register uint8_t *ptr = (uint8_t*)arg_ptr;
04616         while( arg_val > 0 )
04617         {
04618           u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
04619           u8g->pin_list[U8G_PI_A0_STATE] = 2;
04620           ptr++;
04621           arg_val--;
04622         }
04623       }
04624       break;
04625   }
04626   return 1;
04627 }
04628 
04629 #else
04630 
04631 
04632 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
04633 {
04634   return 1;
04635 }
04636 
04637 
04638 #endif
04639 
04640 // ================ u8g_butmap.c ===============
04641 
04642 /*
04643 
04644   u8g_bitmap.c
04645 
04646   Universal 8bit Graphics Library
04647 
04648   Copyright (c) 2011, olikraus@gmail.com
04649   All rights reserved.
04650 
04651   Redistribution and use in source and binary forms, with or without modification,
04652   are permitted provided that the following conditions are met:
04653 
04654   * Redistributions of source code must retain the above copyright notice, this list
04655     of conditions and the following disclaimer.
04656 
04657   * Redistributions in binary form must reproduce the above copyright notice, this
04658     list of conditions and the following disclaimer in the documentation and/or other
04659     materials provided with the distribution.
04660 
04661   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04662   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04663   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04664   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04665   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04666   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04667   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04668   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04669   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04670   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04671   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04672   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04673   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04674 
04675 
04676 */
04677 
04678 
04679 void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
04680 {
04681   while( cnt > 0 )
04682   {
04683     u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
04684     bitmap++;
04685     cnt--;
04686     x+=8;
04687   }
04688 }
04689 
04690 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)
04691 {
04692   if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
04693     return;
04694   while( h > 0 )
04695   {
04696     u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
04697     bitmap += cnt;
04698     y++;
04699     h--;
04700   }
04701 }
04702 
04703 
04704 void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
04705 {
04706   while( cnt > 0 )
04707   {
04708     u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
04709     bitmap++;
04710     cnt--;
04711     x+=8;
04712   }
04713 }
04714 
04715 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)
04716 {
04717   if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
04718     return;
04719   while( h > 0 )
04720   {
04721     u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
04722     bitmap += cnt;
04723     y++;
04724     h--;
04725   }
04726 }
04727 
04728 /*=========================================================================*/
04729 
04730 static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
04731 {
04732   uint8_t d;
04733   x+=7;
04734   while( w >= 8 )
04735   {
04736     u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
04737     bitmap++;
04738     w-= 8;
04739     x+=8;
04740   }
04741   if ( w > 0 )
04742   {
04743     d = *bitmap;
04744     x -= 7;
04745     do
04746     {
04747       if ( d & 1 )
04748         u8g_DrawPixel(u8g, x, y);
04749       x++;
04750       w--;
04751       d >>= 1;
04752     } while ( w > 0 );
04753   }
04754 }
04755 
04756 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)
04757 {
04758   u8g_uint_t b;
04759   b = w;
04760   b += 7;
04761   b >>= 3;
04762 
04763   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
04764     return;
04765 
04766   while( h > 0 )
04767   {
04768     u8g_DrawHXBM(u8g, x, y, w, bitmap);
04769     bitmap += b;
04770     y++;
04771     h--;
04772   }
04773 }
04774 
04775 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)
04776 {
04777   uint8_t d;
04778   x+=7;
04779   while( w >= 8 )
04780   {
04781     u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
04782     bitmap++;
04783     w-= 8;
04784     x+=8;
04785   }
04786   if ( w > 0 )
04787   {
04788     d = u8g_pgm_read(bitmap);
04789     x -= 7;
04790     do
04791     {
04792       if ( d & 1 )
04793         u8g_DrawPixel(u8g, x, y);
04794       x++;
04795       w--;
04796       d >>= 1;
04797     } while ( w > 0 );
04798   }
04799 }
04800 
04801 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)
04802 {
04803   u8g_uint_t b;
04804   b = w;
04805   b += 7;
04806   b >>= 3;
04807 
04808   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
04809     return;
04810   while( h > 0 )
04811   {
04812     u8g_DrawHXBMP(u8g, x, y, w, bitmap);
04813     bitmap += b;
04814     y++;
04815     h--;
04816   }
04817 }
04818 
04819 // ============= u8g_api_ii.c ===============
04820 
04821 /*
04822 
04823   u8g_ll_api.c
04824 
04825   low level api
04826 
04827   Universal 8bit Graphics Library
04828 
04829   Copyright (c) 2011, olikraus@gmail.com
04830   All rights reserved.
04831 
04832   Redistribution and use in source and binary forms, with or without modification,
04833   are permitted provided that the following conditions are met:
04834 
04835   * Redistributions of source code must retain the above copyright notice, this list
04836     of conditions and the following disclaimer.
04837 
04838   * Redistributions in binary form must reproduce the above copyright notice, this
04839     list of conditions and the following disclaimer in the documentation and/or other
04840     materials provided with the distribution.
04841 
04842   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
04843   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
04844   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
04845   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
04846   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
04847   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
04848   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
04849   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
04850   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
04851   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
04852   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
04853   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
04854   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
04855 
04856 
04857 */
04858 
04859 uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
04860 {
04861   return dev->dev_fn(u8g, dev, msg, arg);
04862 }
04863 
04864 /*====================================================================*/
04865 
04866 uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
04867 {
04868   uint8_t r;
04869   u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
04870   r =  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL);
04871   u8g->state_cb(U8G_STATE_MSG_BACKUP_U8G);
04872   u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
04873   return r;
04874 }
04875 
04876 void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev)
04877 {
04878   u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
04879   u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
04880   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL);
04881   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
04882   u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
04883 }
04884 
04885 uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
04886 {
04887   uint8_t r;
04888   u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
04889   u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
04890   r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL);
04891   if ( r != 0 )
04892   {
04893     u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
04894   }
04895   u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
04896   return r;
04897 }
04898 
04899 uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
04900 {
04901   return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast);
04902 }
04903 
04904 void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
04905 {
04906   u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
04907   arg->x = x;
04908   arg->y = y;
04909   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg);
04910 }
04911 
04912 void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
04913 {
04914   u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
04915   arg->x = x;
04916   arg->y = y;
04917   arg->dir = dir;
04918   arg->pixel = pixel;
04919   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg);
04920 }
04921 
04922 void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
04923 {
04924   u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
04925   arg->x = x;
04926   arg->y = y;
04927   arg->dir = dir;
04928   arg->pixel = pixel;
04929   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_4TPIXEL, arg);
04930 }
04931 
04932 
04933 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
04934 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)
04935 {
04936   return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg);
04937 }
04938 #endif
04939 
04940 
04941 
04942 u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
04943 {
04944   u8g_uint_t r;
04945   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r);
04946   return r;
04947 }
04948 
04949 u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
04950 {
04951   u8g_uint_t r;
04952   u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r);
04953   return r;
04954 }
04955 
04956 u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
04957 {
04958   return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL);
04959 }
04960 
04961 
04962 
04963 /*====================================================================*/
04964 
04965 void u8g_UpdateDimension(u8g_t *u8g)
04966 {
04967   u8g->width = u8g_GetWidthLL(u8g, u8g->dev);
04968   u8g->height = u8g_GetHeightLL(u8g, u8g->dev);
04969   u8g->mode = u8g_GetModeLL(u8g, u8g->dev);
04970   /* 9 Dec 2012: u8g_scale.c requires update of current page */
04971   u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
04972 }
04973 
04974 static void u8g_init_data(u8g_t *u8g)
04975 {
04976   u8g->font = NULL;
04977   u8g->cursor_font = NULL;
04978   u8g->cursor_bg_color = 0;
04979   u8g->cursor_fg_color = 1;
04980   u8g->cursor_encoding = 34;
04981   u8g->cursor_fn = (u8g_draw_cursor_fn)0;
04982 
04983 #if defined(U8G_WITH_PINLIST)
04984   {
04985     uint8_t i;
04986     for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
04987       u8g->pin_list[i] = U8G_PIN_NONE;
04988   }
04989 #endif
04990 
04991   u8g_SetColorIndex(u8g, 1);
04992 
04993   u8g_SetFontPosBaseline(u8g);
04994 
04995   u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
04996   u8g->font_ref_ascent = 0;
04997   u8g->font_ref_descent = 0;
04998   u8g->font_line_spacing_factor = 64;           /* 64 = 1.0, 77 = 1.2 line spacing factor */
04999   u8g->line_spacing = 0;
05000 
05001   u8g->state_cb = u8g_state_dummy_cb;
05002 
05003 }
05004 
05005 uint8_t u8g_Begin(u8g_t *u8g)
05006 {
05007   /* call and init low level driver and com device */
05008   if ( u8g_InitLL(u8g, u8g->dev) == 0 )
05009     return 0;
05010   /* fetch width and height from the low level */
05011   u8g_UpdateDimension(u8g);
05012   return 1;
05013 }
05014 
05015 uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
05016 {
05017   u8g_init_data(u8g);
05018   u8g->dev = dev;
05019 
05020   /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
05021   /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
05022   /* if Arduino call u8g_UpdateDimension else u8g_Begin */
05023   /* issue 146 */
05024   return u8g_Begin(u8g);
05025 }
05026 
05027 /* special init for pure ARM systems */
05028 uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn)
05029 {
05030   u8g_init_data(u8g);
05031 
05032 #if defined(U8G_WITH_PINLIST)
05033   {
05034     uint8_t i;
05035     for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
05036       u8g->pin_list[i] = U8G_PIN_DUMMY;
05037   }
05038 #endif
05039 
05040   u8g->dev = dev;
05041 
05042   /* replace the device procedure with a custom communication procedure */
05043   u8g->dev->com_fn = com_fn;
05044 
05045   /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
05046   /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
05047   /* if Arduino call u8g_UpdateDimension else u8g_Begin */
05048   /* issue 146 */
05049   return u8g_Begin(u8g);
05050 }
05051 
05052 
05053 #if defined(U8G_WITH_PINLIST)
05054 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)
05055 {
05056 
05057   /* fill data structure with some suitable values */
05058   u8g_init_data(u8g);
05059   u8g->dev = dev;
05060 
05061   /* assign user pins */
05062   u8g->pin_list[U8G_PI_SCK] = sck;
05063   u8g->pin_list[U8G_PI_MOSI] = mosi;
05064   u8g->pin_list[U8G_PI_CS] = cs;
05065   u8g->pin_list[U8G_PI_A0] = a0;
05066   u8g->pin_list[U8G_PI_RESET] = reset;
05067 
05068   /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
05069   /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
05070   /* if Arduino call u8g_UpdateDimension else u8g_Begin */
05071   /* issue 146 */
05072   return u8g_Begin(u8g);
05073 }
05074 
05075 uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
05076 {
05077   /* fill data structure with some suitable values */
05078   u8g_init_data(u8g);
05079   u8g->dev = dev;
05080 
05081 
05082   /* assign user pins */
05083   u8g->pin_list[U8G_PI_CS] = cs;
05084   u8g->pin_list[U8G_PI_A0] = a0;
05085   u8g->pin_list[U8G_PI_RESET] = reset;
05086 
05087   return u8g_Begin(u8g);
05088 }
05089 
05090 uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
05091 {
05092   /* fill data structure with some suitable values */
05093   u8g_init_data(u8g);
05094   u8g->dev = dev;
05095 
05096   u8g->pin_list[U8G_PI_I2C_OPTION] = options;
05097 
05098   return u8g_Begin(u8g);
05099 }
05100 
05101 
05102 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)
05103 {
05104 
05105   /* fill data structure with some suitable values */
05106   u8g_init_data(u8g);
05107   u8g->dev = dev;
05108 
05109   /* assign user pins */
05110 
05111   u8g->pin_list[U8G_PI_EN] = en;
05112   u8g->pin_list[U8G_PI_CS] = cs;
05113   u8g->pin_list[U8G_PI_DI] = di;
05114   u8g->pin_list[U8G_PI_RW] = rw;
05115   u8g->pin_list[U8G_PI_RESET] = reset;
05116 
05117   return u8g_Begin(u8g);
05118 }
05119 
05120 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,
05121   uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
05122 {
05123 
05124   /* fill data structure with some suitable values */
05125   u8g_init_data(u8g);
05126   u8g->dev = dev;
05127 
05128   /* assign user pins */
05129 
05130   u8g->pin_list[U8G_PI_D0] = d0;
05131   u8g->pin_list[U8G_PI_D1] = d1;
05132   u8g->pin_list[U8G_PI_D2] = d2;
05133   u8g->pin_list[U8G_PI_D3] = d3;
05134   u8g->pin_list[U8G_PI_D4] = d4;
05135   u8g->pin_list[U8G_PI_D5] = d5;
05136   u8g->pin_list[U8G_PI_D6] = d6;
05137   u8g->pin_list[U8G_PI_D7] = d7;
05138 
05139   u8g->pin_list[U8G_PI_EN] = en;
05140   u8g->pin_list[U8G_PI_CS1] = cs1;
05141   u8g->pin_list[U8G_PI_CS2] = cs2;
05142   u8g->pin_list[U8G_PI_DI] = di;
05143   u8g->pin_list[U8G_PI_RW] = rw;
05144   u8g->pin_list[U8G_PI_RESET] = reset;
05145 
05146   return u8g_Begin(u8g);
05147 }
05148 
05149 /*
05150 
05151   PIN_D0 8
05152   PIN_D1 9
05153   PIN_D2 10
05154   PIN_D3 11
05155   PIN_D4 4
05156   PIN_D5 5
05157   PIN_D6 6
05158   PIN_D7 7
05159 
05160   PIN_CS 14
05161   PIN_A0 15
05162   PIN_RESET 16
05163   PIN_WR 17
05164   PIN_RD 18
05165 
05166   u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
05167   u8g_InitRW8Bit(u8g, dev,  8,  9, 10, 11,  4,  5,  6,  7, 14, 15, 17, 18, 16)
05168 
05169 */
05170 
05171 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,
05172   uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
05173 {
05174 
05175   /* fill data structure with some suitable values */
05176   u8g_init_data(u8g);
05177   u8g->dev = dev;
05178 
05179   /* assign user pins */
05180 
05181   u8g->pin_list[U8G_PI_D0] = d0;
05182   u8g->pin_list[U8G_PI_D1] = d1;
05183   u8g->pin_list[U8G_PI_D2] = d2;
05184   u8g->pin_list[U8G_PI_D3] = d3;
05185   u8g->pin_list[U8G_PI_D4] = d4;
05186   u8g->pin_list[U8G_PI_D5] = d5;
05187   u8g->pin_list[U8G_PI_D6] = d6;
05188   u8g->pin_list[U8G_PI_D7] = d7;
05189 
05190   u8g->pin_list[U8G_PI_CS] = cs;
05191   u8g->pin_list[U8G_PI_A0] = a0;
05192   u8g->pin_list[U8G_PI_WR] = wr;
05193   u8g->pin_list[U8G_PI_RD] = rd;
05194   u8g->pin_list[U8G_PI_RESET] = reset;
05195 
05196   return u8g_Begin(u8g);
05197 }
05198 #endif /* defined(U8G_WITH_PINLIST)  */
05199 
05200 void u8g_FirstPage(u8g_t *u8g)
05201 {
05202   u8g_FirstPageLL(u8g, u8g->dev);
05203 }
05204 
05205 uint8_t u8g_NextPage(u8g_t *u8g)
05206 {
05207   if  ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 )
05208   {
05209     u8g->cursor_fn(u8g);
05210   }
05211   return u8g_NextPageLL(u8g, u8g->dev);
05212 }
05213 
05214 uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
05215 {
05216   return u8g_SetContrastLL(u8g, u8g->dev, contrast);
05217 }
05218 
05219 void u8g_SleepOn(u8g_t *u8g)
05220 {
05221   u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL);
05222 }
05223 
05224 void u8g_SleepOff(u8g_t *u8g)
05225 {
05226   u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL);
05227 }
05228 
05229 
05230 void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
05231 {
05232   u8g_DrawPixelLL(u8g, u8g->dev, x, y);
05233 }
05234 
05235 void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
05236 {
05237   u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel);
05238 }
05239 
05240 void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
05241 {
05242   u8g_Draw4TPixelLL(u8g, u8g->dev, x, y, dir, pixel);
05243 }
05244 
05245 
05246 /* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
05247 #ifdef OBSOLETE_CODE
05248 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
05249 {
05250   /* new code */
05251   u8g_dev_arg_bbx_t arg;
05252   arg.x = x;
05253   arg.y = y;
05254   arg.w = w;
05255   arg.h = h;
05256   return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg);
05257 
05258   /* old code */
05259   //return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
05260 }
05261 #endif
05262 
05263 /*
05264   idx: index for the palette entry (0..255)
05265   r: value for red (0..255)
05266   g: value for green (0..255)
05267   b: value for blue (0..255)
05268 */
05269 void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
05270 {
05271   u8g_dev_arg_irgb_t irgb;
05272   irgb.idx = idx;
05273   irgb.r = r;
05274   irgb.g = g;
05275   irgb.b = b;
05276   u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_COLOR_ENTRY, &irgb);
05277 }
05278 
05279 void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
05280 {
05281   u8g->arg_pixel.color = idx;
05282   /*u8g->color_index = idx; */ /* must be removed */
05283 }
05284 
05285 void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb)
05286 {
05287   u8g->arg_pixel.color = rgb&255;
05288   u8g->arg_pixel.hi_color = rgb>>8;
05289   /*u8g->color_index = idx; */ /* must be removed */
05290 }
05291 
05292 void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
05293 {
05294 
05295   r &= ~7;
05296   g >>= 2;
05297   b >>= 3;
05298   u8g->arg_pixel.color = b;
05299   u8g->arg_pixel.color |= (g & 7) << 5;
05300   u8g->arg_pixel.hi_color = r;
05301   u8g->arg_pixel.hi_color |= (g>>3) & 7;
05302 
05303   //u8g_SetHiColor(u8g, U8G_GET_HICOLOR_BY_RGB(r,g,b));
05304 }
05305 
05306 void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
05307 {
05308   if ( u8g->mode == U8G_MODE_R3G3B2 )
05309   {
05310     r &= 0x0e0;
05311     g &= 0x0e0;
05312     g >>= 3;
05313     b >>= 6;
05314     u8g->arg_pixel.color = r | g | b;
05315   }
05316   else if ( u8g->mode == U8G_MODE_HICOLOR )
05317   {
05318     u8g_SetHiColorByRGB(u8g, r,g,b);
05319   }
05320   else
05321   {
05322     u8g->arg_pixel.color = r;
05323     u8g->arg_pixel.hi_color = g;
05324     u8g->arg_pixel.blue = b;
05325   }
05326 }
05327 
05328 
05329 uint8_t u8g_GetColorIndex(u8g_t *u8g)
05330 {
05331   return u8g->arg_pixel.color;
05332 }
05333 
05334 uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
05335 {
05336   uint8_t mode;
05337   mode = u8g_GetMode(u8g);
05338   if ( mode == U8G_MODE_R3G3B2 )
05339     return 255;     /* white */
05340   else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
05341     return 3;         /* max intensity */
05342   else /* if ( u8g.getMode() == U8G_MODE_BW ) */
05343     return 1;         /* pixel on */
05344   return 1;
05345 }
05346 
05347 void u8g_SetDefaultForegroundColor(u8g_t *u8g)
05348 {
05349   if ( u8g->mode == U8G_MODE_HICOLOR )
05350   {
05351     u8g->arg_pixel.color = 0x0ff;
05352     u8g->arg_pixel.hi_color = 0x0ff;
05353   }
05354   else
05355   {
05356     u8g_SetColorIndex(u8g, u8g_GetDefaultForegroundColor(u8g));
05357   }
05358 }
05359 
05360 uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g)
05361 {
05362   return 0;
05363 }
05364 
05365 void u8g_SetDefaultBackgroundColor(u8g_t *u8g)
05366 {
05367   u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g));         /* pixel on / black */
05368 }
05369 
05370 uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
05371 {
05372   uint8_t mode;
05373   mode = u8g_GetMode(u8g);
05374   if ( mode == U8G_MODE_R3G3B2 )
05375     return 0x06d;     /* gray: 01101101 */
05376   else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
05377     return 1;         /* low mid intensity */
05378   else /* if ( u8g.getMode() == U8G_MODE_BW ) */
05379     return 1;         /* pixel on */
05380   return 1;   /* default */
05381 }
05382 
05383 void u8g_SetDefaultMidColor(u8g_t *u8g)
05384 {
05385   u8g_SetColorIndex(u8g, u8g_GetDefaultMidColor(u8g));
05386 }
05387 
05388 // ============== u8g_com_api.c ==================
05389 /*
05390 
05391   u8g_com_api.c
05392 
05393   Universal 8bit Graphics Library
05394 
05395   Copyright (c) 2011, olikraus@gmail.com
05396   All rights reserved.
05397 
05398   Redistribution and use in source and binary forms, with or without modification,
05399   are permitted provided that the following conditions are met:
05400 
05401   * Redistributions of source code must retain the above copyright notice, this list
05402     of conditions and the following disclaimer.
05403 
05404   * Redistributions in binary form must reproduce the above copyright notice, this
05405     list of conditions and the following disclaimer in the documentation and/or other
05406     materials provided with the distribution.
05407 
05408   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
05409   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
05410   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
05411   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
05412   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
05413   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
05414   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
05415   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
05416   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
05417   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
05418   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
05419   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
05420   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
05421 
05422 
05423 */
05424 
05425 
05426 uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time)
05427 {
05428   return dev->com_fn(u8g, U8G_COM_MSG_INIT, clk_cycle_time, NULL);
05429 }
05430 
05431 void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
05432 {
05433   dev->com_fn(u8g, U8G_COM_MSG_STOP, 0, NULL);
05434 }
05435 
05436 /* cs contains the chip number, which should be enabled */
05437 void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
05438 {
05439   dev->com_fn(u8g, U8G_COM_MSG_CHIP_SELECT, cs, NULL);
05440 }
05441 
05442 void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev)
05443 {
05444   dev->com_fn(u8g, U8G_COM_MSG_RESET, 0, NULL);
05445 }
05446 
05447 void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev)
05448 {
05449   dev->com_fn(u8g, U8G_COM_MSG_RESET, 1, NULL);
05450 }
05451 
05452 
05453 void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
05454 {
05455   dev->com_fn(u8g, U8G_COM_MSG_ADDRESS, address, NULL);
05456 }
05457 
05458 uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
05459 {
05460   return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, val, NULL);
05461 }
05462 
05463 uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
05464 {
05465   return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, cnt, seq);
05466 }
05467 
05468 uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
05469 {
05470   return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ_P, cnt, (void *)seq);
05471 }
05472 
05473 /*
05474   sequence := { direct_value | escape_sequence }
05475   direct_value := 0..254
05476   escape_sequence := value_255 | sequence_end | delay | adr | cs | not_used
05477   value_255 := 255 255
05478   sequence_end = 255 254
05479   delay := 255 0..127
05480   adr := 255 0x0e0 .. 0x0ef
05481   cs := 255 0x0d0 .. 0x0df
05482   not_used := 255 101..254
05483 
05484 #define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
05485 #define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
05486 #define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
05487 #define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
05488 #define U8G_ESC_END 255, 254
05489 #define U8G_ESC_255 255, 255
05490 #define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
05491 
05492 */
05493 uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
05494 {
05495   uint8_t is_escape = 0;
05496   uint8_t value;
05497   for(;;)
05498   {
05499     value = u8g_pgm_read(esc_seq);
05500     if ( is_escape == 0 )
05501     {
05502       if ( value != 255 )
05503       {
05504         if ( u8g_WriteByte(u8g, dev, value) == 0 )
05505           return 0;
05506       }
05507       else
05508       {
05509         is_escape = 1;
05510       }
05511     }
05512     else
05513     {
05514       if ( value == 255 )
05515       {
05516         if ( u8g_WriteByte(u8g, dev, value) == 0 )
05517           return 0;
05518       }
05519       else if ( value == 254 )
05520       {
05521         break;
05522       }
05523       else if ( value >= 0x0f0 )
05524       {
05525         /* not yet used, do nothing */
05526       }
05527       else if ( value >= 0xe0  )
05528       {
05529         u8g_SetAddress(u8g, dev, value & 0x0f);
05530       }
05531       else if ( value >= 0xd0 )
05532       {
05533         u8g_SetChipSelect(u8g, dev, value & 0x0f);
05534       }
05535       else if ( value >= 0xc0 )
05536       {
05537         u8g_SetResetLow(u8g, dev);
05538         value &= 0x0f;
05539         value <<= 4;
05540         value+=2;
05541         u8g_Delay(value);
05542         u8g_SetResetHigh(u8g, dev);
05543         u8g_Delay(value);
05544       }
05545       else if ( value >= 0xbe )
05546       {
05547         /* not yet implemented */
05548         /* u8g_SetVCC(u8g, dev, value & 0x01); */
05549       }
05550       else if ( value <= 127 )
05551       {
05552         u8g_Delay(value);
05553       }
05554       is_escape = 0;
05555     }
05556     esc_seq++;
05557   }
05558   return 1;
05559 }
05560 
05561 
05562 // ============ u8g_delay.c ===========
05563 /*
05564 
05565   u8g_delay.c
05566 
05567   Universal 8bit Graphics Library
05568 
05569   Copyright (c) 2011, olikraus@gmail.com
05570   All rights reserved.
05571 
05572   Redistribution and use in source and binary forms, with or without modification,
05573   are permitted provided that the following conditions are met:
05574 
05575   * Redistributions of source code must retain the above copyright notice, this list
05576     of conditions and the following disclaimer.
05577 
05578   * Redistributions in binary form must reproduce the above copyright notice, this
05579     list of conditions and the following disclaimer in the documentation and/or other
05580     materials provided with the distribution.
05581 
05582   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
05583   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
05584   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
05585   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
05586   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
05587   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
05588   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
05589   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
05590   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
05591   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
05592   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
05593   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
05594   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
05595 
05596 
05597   void u8g_Delay(uint16_t val)          Delay by "val" milliseconds
05598   void u8g_MicroDelay(void)             Delay be one microsecond
05599   void u8g_10MicroDelay(void)   Delay by 10 microseconds
05600 
05601 
05602 */
05603 
05604 
05605 
05606 /*==== Part 1: Derive suitable delay procedure ====*/
05607 
05608 #if defined(ARDUINO)
05609 
05610 #  if defined(__AVR__)
05611 #    define USE_AVR_DELAY
05612 #  elif defined(__PIC32MX)
05613 #    define USE_PIC32_DELAY
05614 #  elif defined(__arm__)                /* Arduino Due */
05615 #    define USE_ARDUINO_DELAY
05616 #  else
05617 #    define USE_ARDUINO_DELAY
05618 #  endif
05619 #elif defined(__AVR__)
05620 #  define USE_AVR_DELAY
05621 #elif defined(__18CXX)
05622 #  define USE_PIC18_DELAY
05623 #elif defined(__arm__)
05624 /* do not define anything, all procedures are expected to be defined outside u8glib */
05625 
05626 /*
05627 void u8g_Delay(uint16_t val);
05628 void u8g_MicroDelay(void);
05629 void u8g_10MicroDelay(void);
05630 */
05631 
05632 #else
05633 #  define USE_DUMMY_DELAY
05634 #endif
05635 
05636 
05637 
05638 /*==== Part 2: Definition of the delay procedures ====*/
05639 
05640 /*== AVR Delay ==*/
05641 
05642 #if defined(USE_AVR_DELAY)
05643 #include <avr/interrupt.h>
05644 #include <avr/io.h>
05645 #include <util/delay.h>
05646 
05647 /*
05648   Delay by the provided number of milliseconds.
05649   Thus, a 16 bit value will allow a delay of 0..65 seconds
05650   Makes use of the _delay_loop_2
05651 
05652   _delay_loop_2 will do a delay of n * 4 prozessor cycles.
05653   with f = F_CPU cycles per second,
05654   n = f / (1000 * 4 )
05655   with f = 16000000 the result is 4000
05656   with f = 1000000 the result is 250
05657 
05658   the millisec loop, gcc requires the following overhead:
05659   - movev 1
05660   - subwi 2x2
05661   - bne i 2
05662   ==> 7 cycles
05663   ==> must be devided by 4, rounded up 7/4 = 2
05664 */
05665 void u8g_Delay(uint16_t val)
05666 {
05667   /* old version did a call to the arduino lib: delay(val); */
05668   while( val != 0 )
05669   {
05670     _delay_loop_2( (F_CPU / 4000 ) -2);
05671     val--;
05672   }
05673 }
05674 
05675 /* delay by one micro second */
05676 void u8g_MicroDelay(void)
05677 {
05678 #if (F_CPU / 4000000 ) > 0
05679   _delay_loop_2( (F_CPU / 4000000 ) );
05680 #endif
05681 }
05682 
05683 /* delay by 10 micro seconds */
05684 void u8g_10MicroDelay(void)
05685 {
05686 #if (F_CPU / 400000 ) > 0
05687   _delay_loop_2( (F_CPU / 400000 ) );
05688 #endif
05689 }
05690 
05691 #endif
05692 
05693 
05694 /*== Delay for PIC18 (not tested) ==*/
05695 
05696 #if defined(USE_PIC18_DELAY)
05697 #include <delays.h>
05698 #define GetSystemClock()                (64000000ul)      // Hz
05699 #define GetInstructionClock()   (GetSystemClock()/4)
05700 
05701 void u8g_Delay(uint16_t val)
05702 {/*
05703         unsigned int _iTemp = (val);
05704         while(_iTemp--)
05705                 Delay1KTCYx((GetInstructionClock()+999999)/1000000);
05706                 */
05707 }
05708 void u8g_MicroDelay(void)
05709 {
05710   /* not implemented */
05711 }
05712 void u8g_10MicroDelay(void)
05713 {
05714   /* not implemented */
05715 }
05716 #endif
05717 
05718 
05719 /*== Arduino Delay ==*/
05720 #if defined(USE_ARDUINO_DELAY)
05721 void u8g_Delay(uint16_t val)
05722 {
05723 #if defined(__arm__)
05724         delayMicroseconds((uint32_t)val*(uint32_t)1000);
05725 #else
05726         delay(val);
05727 #endif
05728 }
05729 void u8g_MicroDelay(void)
05730 {
05731         delayMicroseconds(1);
05732 }
05733 void u8g_10MicroDelay(void)
05734 {
05735         delayMicroseconds(10);
05736 }
05737 #endif
05738 
05739 #if defined(USE_PIC32_DELAY)
05740 /*
05741   Assume chipkit here with F_CPU correctly defined
05742   The problem was, that u8g_Delay() is called within the constructor.
05743   It seems that the chipkit is not fully setup at this time, so a
05744   call to delay() will not work. So here is my own implementation.
05745 
05746 */
05747 #define CPU_COUNTS_PER_SECOND (F_CPU/2UL)
05748 #define TICKS_PER_MILLISECOND  (CPU_COUNTS_PER_SECOND/1000UL)
05749 #include "plib.h"
05750 void u8g_Delay(uint16_t val)
05751 {
05752         uint32_t d;
05753         uint32_t s;
05754         d = val;
05755         d *= TICKS_PER_MILLISECOND;
05756         s = ReadCoreTimer();
05757         while ( (uint32_t)(ReadCoreTimer() - s) < d )
05758                 ;
05759 }
05760 
05761 void u8g_MicroDelay(void)
05762 {
05763         uint32_t d;
05764         uint32_t s;
05765         d = TICKS_PER_MILLISECOND/1000;
05766         s = ReadCoreTimer();
05767         while ( (uint32_t)(ReadCoreTimer() - s) < d )
05768                 ;
05769 }
05770 
05771 void u8g_10MicroDelay(void)
05772 {
05773         uint32_t d;
05774         uint32_t s;
05775         d = TICKS_PER_MILLISECOND/100;
05776         s = ReadCoreTimer();
05777         while ( (uint32_t)(ReadCoreTimer() - s) < d )
05778                 ;
05779 }
05780 
05781 #endif
05782 
05783 /*== Any other systems: Dummy Delay ==*/
05784 #if defined(USE_DUMMY_DELAY)
05785 void u8g_Delay(uint16_t val)
05786 {
05787         /* do not know how to delay... */
05788 }
05789 void u8g_MicroDelay(void)
05790 {
05791 }
05792 void u8g_10MicroDelay(void)
05793 {
05794 }
05795 #endif
05796 
05797 
05798 // =============== u8g_state.c ================
05799 
05800 /*
05801 
05802   u8g_state.c
05803 
05804   backup and restore hardware state
05805 
05806   Universal 8bit Graphics Library
05807 
05808   Copyright (c) 2011, olikraus@gmail.com
05809   All rights reserved.
05810 
05811   Redistribution and use in source and binary forms, with or without modification,
05812   are permitted provided that the following conditions are met:
05813 
05814   * Redistributions of source code must retain the above copyright notice, this list
05815     of conditions and the following disclaimer.
05816 
05817   * Redistributions in binary form must reproduce the above copyright notice, this
05818     list of conditions and the following disclaimer in the documentation and/or other
05819     materials provided with the distribution.
05820 
05821   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
05822   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
05823   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
05824   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
05825   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
05826   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
05827   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
05828   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
05829   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
05830   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
05831   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
05832   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
05833   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
05834 
05835 
05836   state callback: backup env U8G_STATE_MSG_BACKUP_ENV
05837   device callback: DEV_MSG_INIT
05838   state callback: backup u8g U8G_STATE_MSG_BACKUP_U8G
05839   state callback: restore env U8G_STATE_MSG_RESTORE_ENV
05840 
05841   state callback: backup env U8G_STATE_MSG_BACKUP_ENV
05842   state callback: retore u8g U8G_STATE_MSG_RESTORE_U8G
05843   DEV_MSG_PAGE_FIRST or DEV_MSG_PAGE_NEXT
05844   state callback: restore env U8G_STATE_MSG_RESTORE_ENV
05845 
05846 */
05847 
05848 
05849 void u8g_state_dummy_cb(uint8_t msg)
05850 {
05851   /* the dummy procedure does nothing */
05852 }
05853 
05854 void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb)
05855 {
05856   u8g->state_cb = backup_cb;
05857   /* in most cases the init message was already sent, so this will backup the */
05858   /* current u8g state */
05859   backup_cb(U8G_STATE_MSG_BACKUP_U8G);
05860 }
05861 
05862 
05863 /*===============================================================*/
05864 /* register variable for restoring interrupt state */
05865 
05866 #if defined(__AVR__)
05867 uint8_t global_SREG_backup;
05868 #endif
05869 
05870 
05871 
05872 /*===============================================================*/
05873 /* AVR */
05874 
05875 #if defined(__AVR__)
05876 #define U8G_ATMEGA_HW_SPI
05877 
05878 /* remove the definition for attiny */
05879 #if __AVR_ARCH__ == 2
05880 #undef U8G_ATMEGA_HW_SPI
05881 #endif
05882 #if __AVR_ARCH__ == 25
05883 #undef U8G_ATMEGA_HW_SPI
05884 #endif
05885 #endif
05886 
05887 #if defined(U8G_ATMEGA_HW_SPI)
05888 #include <avr/interrupt.h>
05889 static uint8_t u8g_state_avr_spi_memory[2];
05890 
05891 void u8g_backup_spi(uint8_t msg)
05892 {
05893   if ( U8G_STATE_MSG_IS_BACKUP(msg) )
05894   {
05895     u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)] = SPCR;
05896   }
05897   else
05898   {
05899     uint8_t tmp = SREG;
05900     cli();
05901     SPCR = 0;
05902     SPCR = u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)];
05903     SREG = tmp;
05904   }
05905 }
05906 
05907 #elif defined(ARDUINO) && defined(__arm__)              // Arduino Due, maybe we should better check for __SAM3X8E__
05908 
05909 #include "sam.h"
05910 
05911 struct sam_backup_struct
05912 {
05913   uint32_t mr;
05914   uint32_t sr;
05915   uint32_t csr[4];
05916 } sam_backup[2];
05917 
05918 void u8g_backup_spi(uint8_t msg)
05919 {
05920   uint8_t idx = U8G_STATE_MSG_GET_IDX(msg);
05921   if ( U8G_STATE_MSG_IS_BACKUP(msg) )
05922   {
05923     sam_backup[idx].mr = SPI0->SPI_MR;
05924     sam_backup[idx].sr = SPI0->SPI_SR;
05925     sam_backup[idx].csr[0] = SPI0->SPI_CSR[0];
05926     sam_backup[idx].csr[1] = SPI0->SPI_CSR[1];
05927     sam_backup[idx].csr[2] = SPI0->SPI_CSR[2];
05928     sam_backup[idx].csr[3] = SPI0->SPI_CSR[3];
05929   }
05930   else
05931   {
05932     SPI0->SPI_MR = sam_backup[idx].mr;
05933     SPI0->SPI_CSR[0] = sam_backup[idx].csr[0];
05934     SPI0->SPI_CSR[1] = sam_backup[idx].csr[1];
05935     SPI0->SPI_CSR[2] = sam_backup[idx].csr[2];
05936     SPI0->SPI_CSR[3] = sam_backup[idx].csr[3];
05937   }
05938 }
05939 
05940 #else
05941 
05942 void u8g_backup_spi(uint8_t msg)
05943 {
05944 }
05945 
05946 #endif
05947 
05948 // =========== u8g_pb8h1.c ==============
05949 
05950 /*
05951 
05952   u8g_pb8h1.c
05953 
05954   8bit height monochrom (1 bit) page buffer
05955   byte has horizontal orientation
05956 
05957   Universal 8bit Graphics Library
05958 
05959   Copyright (c) 2011, olikraus@gmail.com
05960   All rights reserved.
05961 
05962   Redistribution and use in source and binary forms, with or without modification,
05963   are permitted provided that the following conditions are met:
05964 
05965   * Redistributions of source code must retain the above copyright notice, this list
05966     of conditions and the following disclaimer.
05967 
05968   * Redistributions in binary form must reproduce the above copyright notice, this
05969     list of conditions and the following disclaimer in the documentation and/or other
05970     materials provided with the distribution.
05971 
05972   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
05973   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
05974   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
05975   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
05976   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
05977   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
05978   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
05979   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
05980   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
05981   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
05982   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
05983   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
05984   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
05985 
05986 
05987   total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
05988 
05989   23. Sep 2012: Bug with down procedure, see FPS 1st page --> fixed (bug located in u8g_clip.c)
05990 
05991 */
05992 
05993 #include <string.h>
05994 
05995 #ifdef __unix__
05996 #include <assert.h>
05997 #endif
05998 
05999 /* NEW_CODE disabled, because the performance increase was too slow and not worth compared */
06000 /* to the increase of code size */
06001 /* #define NEW_CODE */
06002 
06003 #ifdef __unix__
06004 void *u8g_buf_lower_limit;
06005 void *u8g_buf_upper_limit;
06006 #endif
06007 
06008 void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
06009 void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
06010 void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
06011 void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
06012 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
06013 
06014 
06015 #ifdef NEW_CODE
06016 struct u8g_pb_h1_struct
06017 {
06018   u8g_uint_t x;
06019   u8g_uint_t y;
06020   uint8_t *ptr;
06021   uint8_t mask;
06022   uint8_t line_byte_len;
06023   uint8_t cnt;
06024 };
06025 
06026 static uint8_t u8g_pb8h1_bitmask[8] = { 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001 };
06027 
06028 static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s)  U8G_NOINLINE;
06029 static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s)
06030 {
06031   register u8g_uint_t x;
06032   x = s->x;
06033   x++;
06034   s->x = x;
06035   x &= 7;
06036   s->mask = u8g_pb8h1_bitmask[x];
06037   if ( x == 0 )
06038     s->ptr++;
06039 }
06040 
06041 static void u8g_pb8h1_state_left(struct u8g_pb_h1_struct *s)
06042 {
06043   register u8g_uint_t x;
06044   x = s->x;
06045   x--;
06046   s->x = x;
06047   x &= 7;
06048   s->mask = u8g_pb8h1_bitmask[x];
06049   if ( x == 7 )
06050     s->ptr--;
06051 }
06052 
06053 static void u8g_pb8h1_state_down(struct u8g_pb_h1_struct *s)
06054 {
06055   s->y++;
06056   s->ptr += s->line_byte_len;
06057 }
06058 
06059 static void u8g_pb8h1_state_up(struct u8g_pb_h1_struct *s)
06060 {
06061   s->y--;
06062   s->ptr -= s->line_byte_len;
06063 }
06064 
06065 static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y) U8G_NOINLINE;
06066 static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y)
06067 {
06068   u8g_uint_t tmp;
06069 
06070   uint8_t *ptr = b->buf;
06071 
06072   s->x = x;
06073   s->y = y;
06074 
06075   y -= b->p.page_y0;
06076 
06077   tmp = b->width;
06078   tmp >>= 3;
06079   s->line_byte_len = tmp;
06080 
06081   /* assume negative y values, can be down to -7, subtract this from the pointer and add correction of 8 to y */
06082   ptr -= tmp*8;
06083   y+=8;
06084   /* it is important that the result of tmp*y can be 16 bit value also for 8 bit mode */
06085   ptr += tmp*y;
06086 
06087   s->mask = u8g_pb8h1_bitmask[x & 7];
06088 
06089   /* assume negative x values (to -7), subtract 8 pixel from the pointer and add 8 to x */
06090   ptr--;
06091   x += 8;
06092   x >>= 3;
06093   ptr += x;
06094   s->ptr = ptr;
06095 }
06096 
06097 static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index) U8G_NOINLINE;
06098 static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index)
06099 {
06100 
06101 #ifdef __unix__
06102   assert( s->ptr >= u8g_buf_lower_limit );
06103   assert( s->ptr < u8g_buf_upper_limit );
06104 #endif
06105 
06106   if ( color_index )
06107   {
06108     *s->ptr |= s->mask;
06109   }
06110   else
06111   {
06112     uint8_t mask = s->mask;
06113     mask ^=0xff;
06114     *s->ptr &= mask;
06115   }
06116 }
06117 #endif
06118 
06119 
06120 void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
06121 {
06122   b->buf = buf;
06123   b->width = width;
06124   u8g_pb_Clear(b);
06125 }
06126 
06127 /* limitation: total buffer must not exceed 256 bytes */
06128 void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
06129 {
06130 #ifdef NEW_CODE
06131   struct u8g_pb_h1_struct s;
06132   u8g_pb8h1_state_init(&s, b, x, y);
06133   u8g_pb8h1_state_set_pixel(&s, color_index);
06134 
06135 //  u8g_pb8h1_state_up(&s);
06136 //  if ( s.y > b->p.page_y1 )
06137 //    return;
06138 //  if ( s.x > b->width )
06139 //    return;
06140 //  u8g_pb8h1_state_set_pixel(&s, color_index);
06141 #else
06142   register uint8_t mask;
06143   u8g_uint_t tmp;
06144   uint8_t *ptr = (uint8_t*)b->buf;
06145 
06146   y -= b->p.page_y0;
06147   tmp = b->width;
06148   tmp >>= 3;
06149   tmp *= (uint8_t)y;
06150   ptr += tmp;
06151 
06152   mask = 0x080;
06153   mask >>= x & 7;
06154   x >>= 3;
06155   ptr += x;
06156   if ( color_index )
06157   {
06158     *ptr |= mask;
06159   }
06160   else
06161   {
06162     mask ^=0xff;
06163     *ptr &= mask;
06164   }
06165 #endif
06166 }
06167 
06168 
06169 void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
06170 {
06171   if ( arg_pixel->y < b->p.page_y0 )
06172     return;
06173   if ( arg_pixel->y > b->p.page_y1 )
06174     return;
06175   if ( arg_pixel->x >= b->width )
06176     return;
06177   u8g_pb8h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
06178 }
06179 
06180 void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
06181 {
06182   register uint8_t pixel = arg_pixel->pixel;
06183   do
06184   {
06185     if ( pixel & 128 )
06186     {
06187       u8g_pb8h1_SetPixel(b, arg_pixel);
06188     }
06189     switch( arg_pixel->dir )
06190     {
06191       case 0: arg_pixel->x++; break;
06192       case 1: arg_pixel->y++; break;
06193       case 2: arg_pixel->x--; break;
06194       case 3: arg_pixel->y--; break;
06195     }
06196     pixel <<= 1;
06197   } while( pixel != 0  );
06198 }
06199 
06200 void u8g_pb8h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
06201 {
06202   register uint8_t pixel = arg_pixel->pixel;
06203   u8g_uint_t dx = 0;
06204   u8g_uint_t dy = 0;
06205 
06206   switch( arg_pixel->dir )
06207   {
06208     case 0: dx++; break;
06209     case 1: dy++; break;
06210     case 2: dx--; break;
06211     case 3: dy--; break;
06212   }
06213 
06214   do
06215   {
06216     if ( pixel & 128 )
06217       u8g_pb8h1_SetPixel(b, arg_pixel);
06218     arg_pixel->x += dx;
06219     arg_pixel->y += dy;
06220     pixel <<= 1;
06221   } while( pixel != 0  );
06222 }
06223 
06224 #ifdef NEW_CODE
06225 static void u8g_pb8h1_Set8PixelState(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
06226 {
06227   register uint8_t pixel = arg_pixel->pixel;
06228   struct u8g_pb_h1_struct s;
06229   uint8_t cnt;
06230   u8g_pb8h1_state_init(&s, b, arg_pixel->x, arg_pixel->y);
06231   cnt = 8;
06232   switch( arg_pixel->dir )
06233   {
06234     case 0:
06235       do
06236       {
06237         if ( s.x < b->width )
06238           if ( pixel & 128 )
06239             u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
06240         u8g_pb8h1_state_right(&s);
06241         pixel <<= 1;
06242         cnt--;
06243       } while( cnt > 0 && pixel != 0  );
06244       break;
06245     case 1:
06246       do
06247       {
06248         if ( s.y >= b->p.page_y0 )
06249           if ( s.y <= b->p.page_y1 )
06250             if ( pixel & 128 )
06251               u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
06252         u8g_pb8h1_state_down(&s);
06253         pixel <<= 1;
06254         cnt--;
06255       } while( cnt > 0 && pixel != 0  );
06256       break;
06257     case 2:
06258       do
06259       {
06260         if ( s.x < b->width )
06261           if ( pixel & 128 )
06262             u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
06263         u8g_pb8h1_state_left(&s);
06264         pixel <<= 1;
06265         cnt--;
06266       } while( cnt > 0 && pixel != 0 );
06267       break;
06268     case 3:
06269       do
06270       {
06271         if ( s.y >= b->p.page_y0 )
06272           if ( s.y <= b->p.page_y1 )
06273             if ( pixel & 128 )
06274               u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
06275         u8g_pb8h1_state_up(&s);
06276         pixel <<= 1;
06277         cnt--;
06278       } while( cnt > 0 && pixel != 0  );
06279       break;
06280   }
06281 }
06282 #endif
06283 
06284 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
06285 {
06286   u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
06287   switch(msg)
06288   {
06289     case U8G_DEV_MSG_SET_8PIXEL:
06290 #ifdef NEW_CODE
06291       if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
06292         u8g_pb8h1_Set8PixelState(pb, (u8g_dev_arg_pixel_t *)arg);
06293 #else
06294       if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
06295         u8g_pb8h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
06296 #endif
06297       break;
06298     case U8G_DEV_MSG_SET_PIXEL:
06299       u8g_pb8h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
06300       break;
06301     case U8G_DEV_MSG_INIT:
06302       break;
06303     case U8G_DEV_MSG_STOP:
06304       break;
06305     case U8G_DEV_MSG_PAGE_FIRST:
06306       u8g_pb_Clear(pb);
06307       u8g_page_First(&(pb->p));
06308       break;
06309     case U8G_DEV_MSG_PAGE_NEXT:
06310       if ( u8g_page_Next(&(pb->p)) == 0 )
06311         return 0;
06312       u8g_pb_Clear(pb);
06313       break;
06314 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
06315     case U8G_DEV_MSG_IS_BBX_INTERSECTION:
06316       return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
06317 #endif
06318     case U8G_DEV_MSG_GET_PAGE_BOX:
06319       u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
06320       break;
06321     case U8G_DEV_MSG_GET_WIDTH:
06322       *((u8g_uint_t *)arg) = pb->width;
06323       break;
06324     case U8G_DEV_MSG_GET_HEIGHT:
06325       *((u8g_uint_t *)arg) = pb->p.total_height;
06326       break;
06327     case U8G_DEV_MSG_SET_COLOR_ENTRY:
06328       break;
06329     case U8G_DEV_MSG_SET_XY_CB:
06330       break;
06331     case U8G_DEV_MSG_GET_MODE:
06332       return U8G_MODE_BW;
06333   }
06334   return 1;
06335 }
06336 
06337 // =========== u8g_com_arduino_st7920_spi.c ============
06338 /*
06339 
06340   u8g_com_arduino_st7920_spi.c
06341 
06342   Universal 8bit Graphics Library
06343 
06344   Copyright (c) 2011, olikraus@gmail.com
06345   All rights reserved.
06346 
06347   Redistribution and use in source and binary forms, with or without modification,
06348   are permitted provided that the following conditions are met:
06349 
06350   * Redistributions of source code must retain the above copyright notice, this list
06351     of conditions and the following disclaimer.
06352 
06353   * Redistributions in binary form must reproduce the above copyright notice, this
06354     list of conditions and the following disclaimer in the documentation and/or other
06355     materials provided with the distribution.
06356 
06357   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
06358   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
06359   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
06360   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
06361   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
06362   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
06363   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
06364   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
06365   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
06366   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
06367   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
06368   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
06369   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
06370 
06371   A special SPI interface for ST7920 controller
06372 
06373   Update for ATOMIC operation done (01 Jun 2013)
06374     U8G_ATOMIC_OR(ptr, val)
06375     U8G_ATOMIC_AND(ptr, val)
06376     U8G_ATOMIC_START();
06377     U8G_ATOMIC_END();
06378 
06379 
06380 */
06381 
06382 
06383 #if defined(ARDUINO)
06384 
06385 #if ARDUINO < 100
06386 #include <WProgram.h>
06387 #include "wiring_private.h"
06388 #include "pins_arduino.h"
06389 
06390 #else
06391 #include <Arduino.h>
06392 #include "wiring_private.h"
06393 #endif
06394 
06395 #if defined(__AVR__)
06396 
06397 uint8_t u8g_bitData, u8g_bitNotData;
06398 uint8_t u8g_bitClock, u8g_bitNotClock;
06399 volatile uint8_t *u8g_outData;
06400 volatile uint8_t *u8g_outClock;
06401 
06402 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
06403 {
06404   u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
06405   u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
06406   u8g_bitData = digitalPinToBitMask(dataPin);
06407   u8g_bitClock = digitalPinToBitMask(clockPin);
06408 
06409   u8g_bitNotClock = u8g_bitClock;
06410   u8g_bitNotClock ^= 0x0ff;
06411 
06412   u8g_bitNotData = u8g_bitData;
06413   u8g_bitNotData ^= 0x0ff;
06414 }
06415 
06416 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
06417 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
06418 {
06419   uint8_t cnt = 8;
06420   uint8_t bitData = u8g_bitData;
06421   uint8_t bitNotData = u8g_bitNotData;
06422   uint8_t bitClock = u8g_bitClock;
06423   uint8_t bitNotClock = u8g_bitNotClock;
06424   volatile uint8_t *outData = u8g_outData;
06425   volatile uint8_t *outClock = u8g_outClock;
06426 
06427 
06428   U8G_ATOMIC_START();
06429   bitData |= *outData;
06430   bitNotData &= *outData;
06431   do
06432   {
06433     if ( val & 128 )
06434       *outData = bitData;
06435     else
06436       *outData = bitNotData;
06437 
06438     /*
06439     *outClock |= bitClock;
06440     val <<= 1;
06441     cnt--;
06442     *outClock &= bitNotClock;
06443     */
06444 
06445     val <<= 1;
06446     *outClock &= bitNotClock;
06447     cnt--;
06448     // removed micro delays, because AVRs are too slow and the delay is not required
06449     //u8g_MicroDelay();
06450     *outClock |= bitClock;
06451     //u8g_MicroDelay();
06452   } while( cnt != 0 );
06453   U8G_ATOMIC_END();
06454 }
06455 
06456 #elif defined(__18CXX) || defined(__PIC32MX)
06457 
06458 uint16_t dog_bitData, dog_bitNotData;
06459 uint16_t dog_bitClock, dog_bitNotClock;
06460 volatile uint32_t *dog_outData;
06461 volatile uint32_t *dog_outClock;
06462 volatile uint32_t dog_pic32_spi_tmp;
06463 
06464 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
06465 {
06466   dog_outData = portOutputRegister(digitalPinToPort(dataPin));
06467   dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
06468   dog_bitData = digitalPinToBitMask(dataPin);
06469   dog_bitClock = digitalPinToBitMask(clockPin);
06470 
06471   dog_bitNotClock = dog_bitClock;
06472   dog_bitNotClock ^= 0x0ffff;
06473 
06474   dog_bitNotData = dog_bitData;
06475   dog_bitNotData ^= 0x0ffff;
06476 }
06477 
06478 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
06479 {
06480   uint8_t cnt = 8;
06481   U8G_ATOMIC_START();
06482   do
06483   {
06484     if ( val & 128 )
06485         *dog_outData |= dog_bitData;
06486     else
06487         *dog_outData &= dog_bitNotData;
06488     val <<= 1;
06489     //u8g_MicroDelay();
06490     //*dog_outClock |= dog_bitClock;
06491     *dog_outClock &= dog_bitNotClock;
06492     cnt--;
06493     u8g_MicroDelay();
06494     //*dog_outClock &= dog_bitNotClock;
06495     *dog_outClock |= dog_bitClock;
06496     u8g_MicroDelay();
06497 
06498   } while( cnt != 0 );
06499   U8G_ATOMIC_END();
06500 }
06501 
06502 #else
06503 
06504 /* default interface, Arduino DUE (__arm__) */
06505 
06506 uint8_t u8g_data_pin;
06507 uint8_t u8g_clock_pin;
06508 
06509 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
06510 {
06511   u8g_data_pin = dataPin;
06512   u8g_clock_pin = clockPin;
06513 }
06514 
06515 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
06516 {
06517   uint8_t cnt = 8;
06518   do
06519   {
06520 #ifdef UI_SPI_MOSI
06521     WRITE(UI_SPI_MOSI,val & 128);
06522 #else
06523     if ( val & 128 )
06524         digitalWrite(u8g_data_pin, HIGH);
06525     else
06526         digitalWrite(u8g_data_pin, LOW);
06527 #endif
06528     val <<= 1;
06529     //u8g_MicroDelay();
06530 #ifdef UI_SPI_SCK
06531     WRITE(UI_SPI_SCK,LOW);
06532 #else
06533     digitalWrite(u8g_clock_pin, LOW);
06534 #endif
06535     cnt--;
06536     u8g_MicroDelay();
06537 #ifdef UI_SPI_SCK
06538     WRITE(UI_SPI_SCK,HIGH);
06539 #else
06540     digitalWrite(u8g_clock_pin, HIGH);
06541 #endif
06542     u8g_MicroDelay();
06543   } while( cnt != 0 );
06544 }
06545 
06546 #endif
06547 
06548 
06549 static void u8g_com_arduino_st7920_write_byte_seq(uint8_t rs, uint8_t *ptr, uint8_t len)
06550 {
06551   uint8_t i;
06552 
06553   if ( rs == 0 )
06554   {
06555     /* command */
06556     u8g_com_arduino_do_shift_out_msb_first(0x0f8);
06557   }
06558   else if ( rs == 1 )
06559   {
06560     /* data */
06561     u8g_com_arduino_do_shift_out_msb_first(0x0fa);
06562   }
06563 
06564   while( len > 0 )
06565   {
06566     u8g_com_arduino_do_shift_out_msb_first(*ptr & 0x0f0);
06567     u8g_com_arduino_do_shift_out_msb_first(*ptr << 4);
06568     ptr++;
06569     len--;
06570     u8g_10MicroDelay();
06571   }
06572 
06573   for( i = 0; i < 4; i++ )
06574     u8g_10MicroDelay();
06575 }
06576 
06577 static void u8g_com_arduino_st7920_write_byte(uint8_t rs, uint8_t val)
06578 {
06579   uint8_t i;
06580 
06581   if ( rs == 0 )
06582   {
06583     /* command */
06584     u8g_com_arduino_do_shift_out_msb_first(0x0f8);
06585   }
06586   else if ( rs == 1 )
06587   {
06588     /* data */
06589     u8g_com_arduino_do_shift_out_msb_first(0x0fa);
06590   }
06591 
06592   u8g_com_arduino_do_shift_out_msb_first(val & 0x0f0);
06593   u8g_com_arduino_do_shift_out_msb_first(val << 4);
06594 
06595   for( i = 0; i < 4; i++ )
06596     u8g_10MicroDelay();
06597 
06598 }
06599 
06600 
06601 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
06602 {
06603   switch(msg)
06604   {
06605     case U8G_COM_MSG_INIT:
06606       u8g_com_arduino_assign_pin_output_high(u8g);
06607 #ifdef UI_SPI_CS
06608       WRITE(UI_SPI_CS,LOW);
06609 #else
06610       u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
06611 #endif
06612       // u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
06613 #ifdef UI_SPI_SCK
06614         WRITE(UI_SPI_SCK,HIGH);
06615 #else
06616       u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
06617 #endif
06618 #ifdef UI_SPI_MOSI
06619       WRITE(UI_SPI_MOSI,LOW);
06620 #else
06621       u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
06622 #endif
06623       u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
06624       u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
06625       break;
06626 
06627     case U8G_COM_MSG_STOP:
06628       break;
06629 
06630     case U8G_COM_MSG_RESET:
06631       if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
06632         u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
06633       break;
06634 
06635     case U8G_COM_MSG_CHIP_SELECT:
06636 #ifdef UI_SPI_CS
06637       WRITE(UI_SPI_CS,arg_val);
06638 #else
06639       if ( arg_val == 0 )
06640       {
06641         /* disable, note: the st7920 has an active high chip select */
06642         u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
06643       }
06644       else
06645       {
06646         /* enable */
06647         //u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
06648         u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
06649       }
06650 #endif
06651       break;
06652 
06653     case U8G_COM_MSG_WRITE_BYTE:
06654       u8g_com_arduino_st7920_write_byte( u8g->pin_list[U8G_PI_A0_STATE], arg_val);
06655       //u8g->pin_list[U8G_PI_A0_STATE] = 2;
06656       //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
06657       break;
06658 
06659     case U8G_COM_MSG_WRITE_SEQ:
06660       u8g_com_arduino_st7920_write_byte_seq(u8g->pin_list[U8G_PI_A0_STATE], (uint8_t *)arg_ptr, arg_val);
06661       break;
06662 
06663       case U8G_COM_MSG_WRITE_SEQ_P:
06664       {
06665         register uint8_t *ptr = (uint8_t*)arg_ptr;
06666         while( arg_val > 0 )
06667         {
06668           u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
06669           //u8g->pin_list[U8G_PI_A0_STATE] = 2;
06670           ptr++;
06671           arg_val--;
06672         }
06673       }
06674       break;
06675 
06676     case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
06677       u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
06678       break;
06679   }
06680   return 1;
06681 }
06682 
06683 #else /* ARDUINO */
06684 
06685 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
06686 {
06687   return 1;
06688 }
06689 
06690 #endif /* ARDUINO */
06691 
06692 // ============= u8g_com_arduino_common.c =============
06693 /*
06694 
06695   u8g_com_arduino_common.c
06696 
06697   shared procedures for the arduino communication procedures
06698 
06699   Universal 8bit Graphics Library
06700 
06701   Copyright (c) 2011, olikraus@gmail.com
06702   All rights reserved.
06703 
06704   Redistribution and use in source and binary forms, with or without modification,
06705   are permitted provided that the following conditions are met:
06706 
06707   * Redistributions of source code must retain the above copyright notice, this list
06708     of conditions and the following disclaimer.
06709 
06710   * Redistributions in binary form must reproduce the above copyright notice, this
06711     list of conditions and the following disclaimer in the documentation and/or other
06712     materials provided with the distribution.
06713 
06714   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
06715   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
06716   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
06717   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
06718   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
06719   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
06720   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
06721   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
06722   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
06723   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
06724   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
06725   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
06726   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
06727 
06728 
06729 */
06730 
06731 
06732 #if defined(ARDUINO)
06733 
06734 
06735 void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
06736 {
06737   uint8_t pin;
06738   pin = u8g->pin_list[pin_index];
06739   if ( pin != U8G_PIN_NONE )
06740     digitalWrite(pin, value);
06741 }
06742 
06743 /* this procedure does not set the RW pin */
06744 void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g)
06745 {
06746   uint8_t i;
06747   /* skip the RW pin, which is the last pin in the list */
06748   for( i = 0; i < U8G_PIN_LIST_LEN-1; i++ )
06749   {
06750     if ( u8g->pin_list[i] != U8G_PIN_NONE )
06751     {
06752       pinMode(u8g->pin_list[i], OUTPUT);
06753       digitalWrite(u8g->pin_list[i], HIGH);
06754     }
06755   }
06756 }
06757 
06758 
06759 #endif
06760 
06761 /*
06762 
06763   u8g_pb.c
06764 
06765   common procedures for the page buffer
06766 
06767   Universal 8bit Graphics Library
06768 
06769   Copyright (c) 2011, olikraus@gmail.com
06770   All rights reserved.
06771 
06772   Redistribution and use in source and binary forms, with or without modification,
06773   are permitted provided that the following conditions are met:
06774 
06775   * Redistributions of source code must retain the above copyright notice, this list
06776     of conditions and the following disclaimer.
06777 
06778   * Redistributions in binary form must reproduce the above copyright notice, this
06779     list of conditions and the following disclaimer in the documentation and/or other
06780     materials provided with the distribution.
06781 
06782   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
06783   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
06784   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
06785   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
06786   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
06787   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
06788   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
06789   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
06790   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
06791   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
06792   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
06793   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
06794   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
06795 
06796 
06797 */
06798 
06799 
06800 void u8g_pb_Clear(u8g_pb_t *b)
06801 {
06802   uint8_t *ptr = (uint8_t *)b->buf;
06803   uint8_t *end_ptr = ptr;
06804   end_ptr += b->width;
06805   do
06806   {
06807     *ptr++ = 0;
06808   } while( ptr != end_ptr );
06809 }
06810 
06811 /* the following procedure does not work. why? Can be checked with descpic */
06812 /*
06813 void u8g_pb_Clear(u8g_pb_t *b)
06814 {
06815   uint8_t *ptr = (uint8_t *)b->buf;
06816   uint8_t cnt = b->width;
06817   do
06818   {
06819     *ptr++ = 0;
06820     cnt--;
06821   } while( cnt != 0 );
06822 }
06823 */
06824 
06825 /*
06826   intersection assumptions:
06827     a1 <= a2 is always true
06828 */
06829   /*
06830     minimized version
06831     ---1----0 1             b1 <= a2 && b1 > b2
06832     -----1--0 1             b2 >= a1 && b1 > b2
06833     ---1-1--- 1             b1 <= a2 && b2 >= a1
06834   */
06835 /*
06836 uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
06837 {
06838   uint8_t c0, c1, c;
06839   c0 = v0 <= b->p.page_y1;
06840   c1 = v1 >= b->p.page_y0;
06841   c = v0 > v1;
06842   if ( c0 && c1 ) return 1;
06843   if ( c0 && c ) return 1;
06844   if ( c1 && c ) return 1;
06845   return 0;
06846 }
06847 */
06848 
06849 uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
06850 {
06851   uint8_t c1, c2, c3, tmp;
06852   c1 = v0 <= pb->p.page_y1;
06853   c2 = v1 >= pb->p.page_y0;
06854   c3 = v0 > v1;
06855   /*
06856   if ( c1 && c2 )
06857     return 1;
06858   if ( c1 && c3 )
06859     return 1;
06860   if ( c2 && c3 )
06861     return 1;
06862   return 0;
06863   */
06864 
06865   tmp = c1;
06866   c1 &= c2;
06867   c2 &= c3;
06868   c3 &= tmp;
06869   c1 |= c2;
06870   c1 |= c3;
06871   return c1 & 1;
06872 }
06873 
06874 
06875 uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
06876 {
06877   uint8_t /*c0, c1, */ c2, c3;
06878   /*
06879     conditions: b->p.page_y0 < b->p.page_y1
06880     there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
06881   */
06882   /*
06883   c0 = v0 < 0;
06884   c1 = v1 < 0;
06885   */
06886   c2 = v0 > b->width;
06887   c3 = v1 > b->width;
06888   /*if ( c0 && c1 ) return 0;*/
06889   if ( c2 && c3 ) return 0;
06890   /*if ( c1 && c2 ) return 0;*/
06891   return 1;
06892 }
06893 
06894 uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx)
06895 {
06896   u8g_uint_t tmp;
06897 
06898   tmp = bbx->y;
06899   tmp += bbx->h;
06900   tmp--;
06901 
06902   if ( u8g_pb_IsYIntersection(pb, bbx->y, tmp) == 0 )
06903     return 0;
06904 
06905   /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
06906   tmp = bbx->x;
06907   tmp += bbx->w;
06908   tmp--;
06909 
06910   return u8g_pb_IsXIntersection(pb, bbx->x, tmp);
06911 }
06912 
06913 void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
06914 {
06915   box->x0 = 0;
06916   box->y0 = pb->p.page_y0;
06917   box->x1 = pb->width;
06918   box->x1--;
06919   box->y1 = pb->p.page_y1;
06920 }
06921 
06922 
06923 uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
06924 {
06925   u8g_uint_t v0, v1;
06926   v0 = arg_pixel->y;
06927   v1 = v0;
06928   switch( arg_pixel->dir )
06929   {
06930     case 0:
06931       break;
06932     case 1:
06933       v1 += 8;          /* this is independent from the page height */
06934       break;
06935     case 2:
06936       break;
06937     case 3:
06938       v0 -= 8;
06939       break;
06940   }
06941   return u8g_pb_IsYIntersection(b, v0, v1);
06942 }
06943 
06944 
06945 
06946 uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
06947 {
06948   return u8g_WriteSequence(u8g, dev, b->width,(uint8_t*) b->buf);
06949 }
06950 
06951 /*
06952 
06953   u8g_rect.c
06954 
06955   U8G high level interface for horizontal and vertical things
06956 
06957   Universal 8bit Graphics Library
06958 
06959   Copyright (c) 2011, olikraus@gmail.com
06960   All rights reserved.
06961 
06962   Redistribution and use in source and binary forms, with or without modification,
06963   are permitted provided that the following conditions are met:
06964 
06965   * Redistributions of source code must retain the above copyright notice, this list
06966     of conditions and the following disclaimer.
06967 
06968   * Redistributions in binary form must reproduce the above copyright notice, this
06969     list of conditions and the following disclaimer in the documentation and/or other
06970     materials provided with the distribution.
06971 
06972   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
06973   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
06974   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
06975   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
06976   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
06977   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
06978   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
06979   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
06980   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
06981   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
06982   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
06983   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
06984   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
06985 
06986 
06987 */
06988 
06989 void u8g_draw_hline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
06990 {
06991   uint8_t pixel = 0x0ff;
06992   while( w >= 8 )
06993   {
06994     u8g_Draw8Pixel(u8g, x, y, 0, pixel);
06995     w-=8;
06996     x+=8;
06997   }
06998   if ( w != 0 )
06999   {
07000     w ^=7;
07001     w++;
07002     pixel <<= w&7;
07003     u8g_Draw8Pixel(u8g, x, y, 0, pixel);
07004   }
07005 }
07006 
07007 void u8g_draw_vline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t h)
07008 {
07009   uint8_t pixel = 0x0ff;
07010   while( h >= 8 )
07011   {
07012     u8g_Draw8Pixel(u8g, x, y, 1, pixel);
07013     h-=8;
07014     y+=8;
07015   }
07016   if ( h != 0 )
07017   {
07018     h ^=7;
07019     h++;
07020     pixel <<= h&7;
07021     u8g_Draw8Pixel(u8g, x, y, 1, pixel);
07022   }
07023 }
07024 
07025 void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
07026 {
07027   if ( u8g_IsBBXIntersection(u8g, x, y, w, 1) == 0 )
07028     return;
07029   u8g_draw_hline(u8g, x, y, w);
07030 }
07031 
07032 void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
07033 {
07034   if ( u8g_IsBBXIntersection(u8g, x, y, 1, w) == 0 )
07035     return;
07036   u8g_draw_vline(u8g, x, y, w);
07037 }
07038 
07039 /* restrictions: w > 0 && h > 0 */
07040 void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
07041 {
07042   u8g_uint_t xtmp = x;
07043 
07044   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
07045     return;
07046 
07047 
07048   u8g_draw_hline(u8g, x, y, w);
07049   u8g_draw_vline(u8g, x, y, h);
07050   x+=w;
07051   x--;
07052   u8g_draw_vline(u8g, x, y, h);
07053   y+=h;
07054   y--;
07055   u8g_draw_hline(u8g, xtmp, y, w);
07056 }
07057 
07058 void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
07059 {
07060   do
07061   {
07062     u8g_draw_hline(u8g, x, y, w);
07063     y++;
07064     h--;
07065   } while( h != 0 );
07066 }
07067 
07068 /* restrictions: h > 0 */
07069 void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
07070 {
07071   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
07072     return;
07073   u8g_draw_box(u8g, x, y, w, h);
07074 }
07075 
07076 
07077 void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
07078 {
07079   u8g_uint_t xl, yu;
07080 
07081   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
07082     return;
07083 
07084   xl = x;
07085   xl += r;
07086   yu = y;
07087   yu += r;
07088 
07089   {
07090     u8g_uint_t yl, xr;
07091 
07092     xr = x;
07093     xr += w;
07094     xr -= r;
07095     xr -= 1;
07096 
07097     yl = y;
07098     yl += h;
07099     yl -= r;
07100     yl -= 1;
07101 
07102     u8g_draw_circle(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
07103     u8g_draw_circle(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
07104     u8g_draw_circle(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
07105     u8g_draw_circle(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
07106   }
07107 
07108   {
07109     u8g_uint_t ww, hh;
07110 
07111     ww = w;
07112     ww -= r;
07113     ww -= r;
07114     ww -= 2;
07115     hh = h;
07116     hh -= r;
07117     hh -= r;
07118     hh -= 2;
07119 
07120     xl++;
07121     yu++;
07122     h--;
07123     w--;
07124     u8g_draw_hline(u8g, xl, y, ww);
07125     u8g_draw_hline(u8g, xl, y+h, ww);
07126     u8g_draw_vline(u8g, x,         yu, hh);
07127     u8g_draw_vline(u8g, x+w, yu, hh);
07128   }
07129 }
07130 
07131 void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
07132 {
07133   u8g_uint_t xl, yu;
07134     u8g_uint_t yl, xr;
07135 
07136   if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
07137     return;
07138 
07139   xl = x;
07140   xl += r;
07141   yu = y;
07142   yu += r;
07143 
07144   xr = x;
07145   xr += w;
07146   xr -= r;
07147   xr -= 1;
07148 
07149   yl = y;
07150   yl += h;
07151   yl -= r;
07152   yl -= 1;
07153 
07154   u8g_draw_disc(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
07155   u8g_draw_disc(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
07156   u8g_draw_disc(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
07157   u8g_draw_disc(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
07158 
07159   {
07160     u8g_uint_t ww, hh;
07161 
07162     ww = w;
07163     ww -= r;
07164     ww -= r;
07165     ww -= 2;
07166     hh = h;
07167     hh -= r;
07168     hh -= r;
07169     hh -= 2;
07170 
07171     xl++;
07172     yu++;
07173     h--;
07174     u8g_draw_box(u8g, xl, y, ww, r+1);
07175     u8g_draw_box(u8g, xl, yl, ww, r+1);
07176     //u8g_draw_hline(u8g, xl, y+h, ww);
07177     u8g_draw_box(u8g, x, yu, w, hh);
07178     //u8g_draw_vline(u8g, x+w, yu, hh);
07179   }
07180 }
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines