Fork of SSD1289 lib for Landtiger board

Revision:
2:799c4fb113c5
Parent:
1:f4f77e6729cd
--- a/fonts.h	Wed Nov 21 23:11:20 2012 +0000
+++ b/fonts.h	Thu Nov 22 08:42:01 2012 +0000
@@ -1,6 +1,137 @@
+/** \file fonts.h
+ *  \brief Fixed-width fonts for use with the SSD1289 LCD controller library and mbed
+ *
+ * Original work by Henning Karlsen in his UTFT display library for Arduino/chipKIT.
+ * \sa Comments in ssd1289.h
+ *
+ * This header provides 3 fixed-width fonts - 2 with all printable characters from the
+ * ASCII table and one 7-segment font with only the numbers 0-9.  The smallest font is
+ * 8px wide and 12px tall, the big font is 16x16 pixels, and the 7-segment font is the
+ * biggest.
+ *
+ * If none of the provided fonts is suitable for your reuqirements, you can provide
+ * your own font, if the following rules are followed:
+ *
+ * 1) The library is not designed to deal with TrueType or Postscript fonts.  Only
+ *    fixed-width fonts can be used.
+ *
+ * 2) The font data should include only printable characters. For example, the provided
+ *    fonts show either only numbers (7-segment), or contain the Latin-1 characters in
+ *    the ASCII table starting from position 32 (the space character ' ').
+ *
+ * 3) No characters can be skipped.  If you start with capital 'A' and wish to include
+ *    small-case letters in your font as well, then all the characters in between 'A'
+ *    and 'z' must be included in the font.  If you WISH TO AVOID PRINTING a specific
+ *    caracter, do not skip it, but include the appropriate amount of empty (0) bits
+ *    to make-up for the "hidden" value.
+ *
+ * 4) Every pixel in the character is represented by a bit.  It is not required, that a
+ *    character is represented by a full number of bytes; however if the last character
+ *    in the font does not end in a full byte, then add the appropriate 0 bits as fillers.
+ *    For example a character in a 10x18 font (10px wide, 18px high) has 180 bits, which
+ *    is 22 bytes and 4 remaining bits per character. If all whole sum of the bits of
+ *    each character in the font is not evenly divisible by 8, then add as many 0 bits to
+ *    the last character in the font, until this condition is satisfied.
+ *
+ * 5) The font array must start with the following 4 bytes before the first byte of the
+ *    first character in the font: a) the width of the characters; b) the height of the
+ *    characters; c) the offset of the first character in the font (the number of the
+ *    first character as found in the ASCII table); and d) total number of characters in
+ *    the font (placeholders for "hidden" characters are counted as well).
+ *
+ * As example let's continue the aforementioned 10x18 font.  This would mean that each
+ * character is 10 bits wide and 18 tall.  To design a character, 0s and 1s are used in
+ * a grid with the character dimensions, where 0 represents and empty, "background color"
+ * pixel, while 1 represents a "foreground" pixel.  So to print "0" on the screen, the
+ * character data might look like the following:
+ * \code
+ * 0000000000
+ * 0111111110
+ * 0111111110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0110000110
+ * 0111111110
+ * 0111111110
+ * 0000000000
+ * 0000000000
+ * \endcode
+ * When all characters in the font have their bit grids, just place them in order one after
+ * another, and remove the "new lines" - you will have the whole font array in one very very
+ * long line.  Start from the beginning of this line and break it up in pieces of 1 byte (8
+ * bits). Our "0" will look at first something like:
+ * \code
+ * 000000000001111111100111111110011000011001100001100110000110011000011001100001100110000110011000011001100001100110000110011000011001100001100111111110011111111000000000000000000000
+ * \endcode
+ * and after breaking up
+ * \code
+ * 00000000
+ * 00011111
+ * 11100111
+ * 11111001
+ * 10000110
+ * 01100001
+ * 10011000
+ * 01100110
+ * 00011001
+ * 10000110
+ * 01100001
+ * 10011000
+ * 01100110
+ * 00011001
+ * 10000110
+ * 01100001
+ * 10011000
+ * 01100111
+ * 11111001
+ * 11111110
+ * 00000000
+ * 00000000
+ * 0000
+ * \endcode
+ * If this were the last character int the font array, just add the four 0 bits to fill-up
+ * to a full byte, otherwise concatenate the first four bits from the next character, etc.,
+ * etc.  When you have all te bytes for the font, convert them to hexadecimal format for
+ * more compact representation.
+ *
+ * The new font array is almost done.  In order to satisfy requirement #5, prepend the
+ * following 4 bytes to the beginning of the array: 0x0A for the font width; 0x12 for the
+ * font height; 0x20 for offset, if the first character in the font is <space>, or 0x60 if
+ * "0" is the first character; and 0x?? for the total number of characters in the font.
+ * That's it, the font is done.  Just use the array name with the #SetFont(const char*)
+ * function as with the fonts contained in this header file.
+ *
+ * Copyright (C)2010-2012 Henning Karlsen. All right reserved.
+ * Copyright (C)2012 Todor Todorov.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA
+ */
 #ifndef SSD1289_FONTS_H
 #define SSD1289_FONTS_H
 
+/** Small font, 8x12 pixels, <space> 1st character, 95 total characters */
 const char Font8x12[] = {
     0x08,0x0C,0x20,0x5F,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // <Space>
@@ -100,6 +231,7 @@
     0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~
 };
 
+/** Big font, 16x16 pixels, <space> 1st character, 95 total characters */
 const char Font16x16[] = {
     0x10,0x10,0x20,0x5F,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //  <Space>
@@ -204,6 +336,7 @@
     0x00,0x00,0x00,0x00,0x1F,0x1C,0x3B,0x9C,0x39,0xDC,0x38,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00  // ~
 };
 
+/** 7-segment font, only digits 0-9, 10 total characters */
 const char Font7Segment[] = {
     0x20,0x32,0x30,0x0A,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x0C,0xFF,0xFE,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x38,0x00,0x00,0x18,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x38,0x00,0x00,0x18,0x3E,0x00,0x00,0x78,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x1E,0x00,0x00,0xF0,0x0C,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // 0