Attempting to publish a tree

Dependencies:   BLE_API mbed-dev-bin nRF51822

Fork of microbit-dal by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MicroBitFont.h Source File

MicroBitFont.h

00001 /*
00002 The MIT License (MIT)
00003 
00004 Copyright (c) 2016 British Broadcasting Corporation.
00005 This software is provided by Lancaster University by arrangement with the BBC.
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a
00008 copy of this software and associated documentation files (the "Software"),
00009 to deal in the Software without restriction, including without limitation
00010 the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 and/or sell copies of the Software, and to permit persons to whom the
00012 Software is furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00020 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 DEALINGS IN THE SOFTWARE.
00024 */
00025 
00026 #ifndef MICROBIT_FONT_H
00027 #define MICROBIT_FONT_H
00028 
00029 #include "mbed.h"
00030 #include "MicroBitConfig.h"
00031 
00032 #define MICROBIT_FONT_WIDTH 5
00033 #define MICROBIT_FONT_HEIGHT 5
00034 #define MICROBIT_FONT_ASCII_START 32
00035 #define MICROBIT_FONT_ASCII_END 126
00036 
00037 /**
00038   * Class definition for a MicrobitFont
00039   * This class represents a font that can be used by the display to render text.
00040   *
00041   * A MicroBitFont is 5x5.
00042   * Each Row is represented by a byte in the array.
00043   *
00044   * Row Format:
00045   *            ================================================================
00046   *            | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
00047   *            ================================================================
00048   *            |  N/A  |  N/A  |  N/A  | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 |
00049   *            |  0x80 |  0x40 |  0x20 | 0x10  | 0x08  | 0x04  | 0x02  | 0x01  |
00050   *
00051   * Example: { 0x08, 0x08, 0x08, 0x0, 0x08 }
00052   *
00053   * The above will produce an exclaimation mark on the second column in form the left.
00054   *
00055   * We could compress further, but the complexity of decode would likely outweigh the gains.
00056   */
00057 class MicroBitFont
00058 {
00059     public:
00060 
00061     static const unsigned char* defaultFont;
00062     static MicroBitFont systemFont;
00063 
00064     const unsigned char* characters;
00065 
00066     int asciiEnd;
00067 
00068     /**
00069       * Constructor.
00070       *
00071       * Sets the font represented by this font object.
00072       *
00073       * @param font A pointer to the beginning of the new font.
00074       *
00075       * @param asciiEnd the char value at which this font finishes.
00076       */
00077     MicroBitFont(const unsigned char* font, int asciiEnd = MICROBIT_FONT_ASCII_END);
00078 
00079     /**
00080       * Default Constructor.
00081       *
00082       * Configures the default font for the display to use.
00083       */
00084     MicroBitFont();
00085 
00086     /**
00087       * Modifies the current system font to the given instance of MicroBitFont.
00088       *
00089       * @param font the new font that will be used to render characters on the display.
00090       */
00091     static void setSystemFont(MicroBitFont font);
00092 
00093     /**
00094       * Retreives the font object used for rendering characters on the display.
00095       */
00096     static MicroBitFont getSystemFont();
00097 
00098 };
00099 
00100 #endif