mbed.org local branch of microbit-dal. The real version lives in git at https://github.com/lancaster-university/microbit-dal

Dependencies:   BLE_API nRF51822 mbed-dev-bin

Dependents:   microbit Microbit IoTChallenge1 microbit ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MicroBitDisplay.h Source File

MicroBitDisplay.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_DISPLAY_H
00027 #define MICROBIT_DISPLAY_H
00028 
00029 #include "mbed.h"
00030 #include "MicroBitConfig.h"
00031 #include "ManagedString.h"
00032 #include "MicroBitComponent.h"
00033 #include "MicroBitImage.h"
00034 #include "MicroBitFont.h"
00035 #include "MicroBitMatrixMaps.h"
00036 #include "MicroBitLightSensor.h"
00037 
00038 /**
00039   * Event codes raised by MicroBitDisplay
00040   */
00041 #define MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE         1
00042 #define MICROBIT_DISPLAY_EVT_LIGHT_SENSE                2
00043 
00044 //
00045 // Internal constants
00046 //
00047 #define MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR      1
00048 #define MICROBIT_DISPLAY_SPACING                1
00049 #define MICROBIT_DISPLAY_GREYSCALE_BIT_DEPTH    8
00050 #define MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS    -255
00051 
00052 enum AnimationMode {
00053     ANIMATION_MODE_NONE,
00054     ANIMATION_MODE_STOPPED,
00055     ANIMATION_MODE_SCROLL_TEXT,
00056     ANIMATION_MODE_PRINT_TEXT,
00057     ANIMATION_MODE_SCROLL_IMAGE,
00058     ANIMATION_MODE_ANIMATE_IMAGE,
00059     ANIMATION_MODE_ANIMATE_IMAGE_WITH_CLEAR,
00060     ANIMATION_MODE_PRINT_CHARACTER
00061 };
00062 
00063 enum DisplayMode {
00064     DISPLAY_MODE_BLACK_AND_WHITE,
00065     DISPLAY_MODE_GREYSCALE,
00066     DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
00067 };
00068 
00069 enum DisplayRotation {
00070     MICROBIT_DISPLAY_ROTATION_0,
00071     MICROBIT_DISPLAY_ROTATION_90,
00072     MICROBIT_DISPLAY_ROTATION_180,
00073     MICROBIT_DISPLAY_ROTATION_270
00074 };
00075 
00076 /**
00077   * Class definition for MicroBitDisplay.
00078   *
00079   * A MicroBitDisplay represents the LED matrix array on the micro:bit.
00080   */
00081 class MicroBitDisplay : public MicroBitComponent
00082 {
00083     uint8_t width;
00084     uint8_t height;
00085     uint8_t brightness;
00086     uint8_t strobeRow;
00087     uint8_t rotation;
00088     uint8_t mode;
00089     uint8_t greyscaleBitMsk;
00090     uint8_t timingCount;
00091     uint32_t col_mask;
00092 
00093     Timeout renderTimer;
00094     PortOut *LEDMatrix;
00095 
00096     //
00097     // State used by all animation routines.
00098     //
00099 
00100     // The animation mode that's currently running (if any)
00101     volatile AnimationMode animationMode;
00102 
00103     // The time in milliseconds between each frame update.
00104     uint16_t animationDelay;
00105 
00106     // The time in milliseconds since the frame update.
00107     uint16_t animationTick;
00108 
00109     // Stop playback of any animations
00110     void stopAnimation(int delay);
00111 
00112     //
00113     // State for scrollString() method.
00114     // This is a surprisingly intricate method.
00115     //
00116     // The text being displayed.
00117     ManagedString scrollingText;
00118 
00119     // The index of the character currently being displayed.
00120     uint16_t scrollingChar;
00121 
00122     // The number of pixels the current character has been shifted on the display.
00123     uint8_t scrollingPosition;
00124 
00125     //
00126     // State for printString() method.
00127     //
00128     // The text being displayed. NULL if no message is scheduled for playback.
00129     // We *could* get some reuse in here with the scroll* variables above,
00130     // but best to keep it clean in case kids try concurrent operation (they will!),
00131     // given the small RAM overhead needed to maintain orthogonality.
00132     ManagedString printingText;
00133 
00134     // The index of the character currently being displayed.
00135     uint16_t printingChar;
00136 
00137     //
00138     // State for scrollImage() method.
00139     //
00140     // The image being displayed.
00141     MicroBitImage scrollingImage;
00142 
00143     // The number of pixels the image has been shifted on the display.
00144     int16_t scrollingImagePosition;
00145 
00146     // The number of pixels the image is shifted on the display in each quantum.
00147     int8_t scrollingImageStride;
00148 
00149     // A pointer to an instance of light sensor, if in use
00150     MicroBitLightSensor* lightSensor;
00151 
00152     // Flag to indicate if image has been rendered to screen yet (or not)
00153     bool scrollingImageRendered;
00154 
00155     const MatrixMap &matrixMap;
00156 
00157     // Internal methods to handle animation.
00158 
00159     /**
00160       *  Periodic callback, that we use to perform any animations we have running.
00161       */
00162     void animationUpdate();
00163 
00164     /**
00165       *  Called by the display in an interval determined by the brightness of the display, to give an impression
00166       *  of brightness.
00167       */
00168     void renderFinish();
00169 
00170     /**
00171       * Translates a bit mask to a bit mask suitable for the nrf PORT0 and PORT1.
00172       * Brightness has two levels on, or off.
00173       */
00174     void render();
00175 
00176     /**
00177       * Renders the current image, and drops the fourth frame to allow for
00178       * sensors that require the display to operate.
00179       */
00180     void renderWithLightSense();
00181 
00182     /**
00183       * Translates a bit mask into a timer interrupt that gives the appearence of greyscale.
00184       */
00185     void renderGreyscale();
00186 
00187     /**
00188       * Internal scrollText update method.
00189       * Shift the screen image by one pixel to the left. If necessary, paste in the next char.
00190       */
00191     void updateScrollText();
00192 
00193     /**
00194       * Internal printText update method.
00195       * Paste the next character in the string.
00196       */
00197     void updatePrintText();
00198 
00199     /**
00200       * Internal scrollImage update method.
00201       * Paste the stored bitmap at the appropriate point.
00202       */
00203     void updateScrollImage();
00204 
00205     /**
00206       * Internal animateImage update method.
00207       * Paste the stored bitmap at the appropriate point and stop on the last frame.
00208       */
00209     void updateAnimateImage();
00210 
00211     /**
00212      * Broadcasts an event onto the defult EventModel indicating that the
00213      * current animation has completed.
00214      */
00215     void sendAnimationCompleteEvent();
00216 
00217     /**
00218       * Blocks the current fiber until the display is available (i.e. does not effect is being displayed).
00219       * Animations are queued until their time to display.
00220       */
00221     void waitForFreeDisplay();
00222 
00223     /**
00224       * Blocks the current fiber until the current animation has finished.
00225       * If the scheduler is not running, this call will essentially perform a spinning wait.
00226       */
00227     void fiberWait();
00228 
00229     /**
00230       * Enables or disables the display entirely, and releases the pins for other uses.
00231       *
00232       * @param enableDisplay true to enabled the display, or false to disable it.
00233       */
00234     void setEnable(bool enableDisplay);
00235 
00236 public:
00237     // The mutable bitmap buffer being rendered to the LED matrix.
00238     MicroBitImage image;
00239 
00240     /**
00241       * Constructor.
00242       *
00243       * Create a software representation the micro:bit's 5x5 LED matrix.
00244       * The display is initially blank.
00245       *
00246       * @param id The id the display should use when sending events on the MessageBus. Defaults to MICROBIT_ID_DISPLAY.
00247       *
00248       * @param map The mapping information that relates pin inputs/outputs to physical screen coordinates.
00249       *            Defaults to microbitMatrixMap, defined in MicroBitMatrixMaps.h.
00250       *
00251       * @code
00252       * MicroBitDisplay display;
00253       * @endcode
00254       */
00255     MicroBitDisplay(uint16_t id = MICROBIT_ID_DISPLAY, const MatrixMap &map = microbitMatrixMap);
00256 
00257     /**
00258       * Stops any currently running animation, and any that are waiting to be displayed.
00259       */
00260     void stopAnimation();
00261 
00262     /**
00263       * Frame update method, invoked periodically to strobe the display.
00264       */
00265     virtual void systemTick();
00266 
00267     /**
00268       * Prints the given character to the display, if it is not in use.
00269       *
00270       * @param c The character to display.
00271       *
00272       * @param delay Optional parameter - the time for which to show the character. Zero displays the character forever,
00273       *              or until the Displays next use.
00274       *
00275       * @return MICROBIT_OK, MICROBIT_BUSY is the screen is in use, or MICROBIT_INVALID_PARAMETER.
00276       *
00277       * @code
00278       * display.printAsync('p');
00279       * display.printAsync('p',100);
00280       * @endcode
00281       */
00282     int printCharAsync(char c, int delay = 0);
00283 
00284     /**
00285       * Prints the given ManagedString to the display, one character at a time.
00286       * Returns immediately, and executes the animation asynchronously.
00287       *
00288       * @param s The string to display.
00289       *
00290       * @param delay The time to delay between characters, in milliseconds. Must be > 0.
00291       *              Defaults to: MICROBIT_DEFAULT_PRINT_SPEED.
00292       *
00293       * @return MICROBIT_OK, or MICROBIT_INVALID_PARAMETER.
00294       *
00295       * @code
00296       * display.printAsync("abc123",400);
00297       * @endcode
00298       */
00299     int printAsync(ManagedString s, int delay = MICROBIT_DEFAULT_PRINT_SPEED);
00300 
00301     /**
00302       * Prints the given image to the display, if the display is not in use.
00303       * Returns immediately, and executes the animation asynchronously.
00304       *
00305       * @param i The image to display.
00306       *
00307       * @param x The horizontal position on the screen to display the image. Defaults to 0.
00308       *
00309       * @param y The vertical position on the screen to display the image. Defaults to 0.
00310       *
00311       * @param alpha Treats the brightness level '0' as transparent. Defaults to 0.
00312       *
00313       * @param delay The time to delay between characters, in milliseconds. Defaults to 0.
00314       *
00315       * @code
00316       * MicrobitImage i("1,1,1,1,1\n1,1,1,1,1\n");
00317       * display.print(i,400);
00318       * @endcode
00319       */
00320     int printAsync(MicroBitImage i, int x = 0, int y = 0, int alpha = 0, int delay = 0);
00321 
00322     /**
00323       * Prints the given character to the display.
00324       *
00325       * @param c The character to display.
00326       *
00327       * @param delay Optional parameter - the time for which to show the character. Zero displays the character forever,
00328       *              or until the Displays next use.
00329       *
00330       * @return MICROBIT_OK, MICROBIT_CANCELLED or MICROBIT_INVALID_PARAMETER.
00331       *
00332       * @code
00333       * display.printAsync('p');
00334       * display.printAsync('p',100);
00335       * @endcode
00336       */
00337     int printChar(char c, int delay = 0);
00338 
00339     /**
00340       * Prints the given string to the display, one character at a time.
00341       *
00342       * Blocks the calling thread until all the text has been displayed.
00343       *
00344       * @param s The string to display.
00345       *
00346       * @param delay The time to delay between characters, in milliseconds. Defaults
00347       *              to: MICROBIT_DEFAULT_PRINT_SPEED.
00348       *
00349       * @return MICROBIT_OK, MICROBIT_CANCELLED or MICROBIT_INVALID_PARAMETER.
00350       *
00351       * @code
00352       * display.print("abc123",400);
00353       * @endcode
00354       */
00355     int print(ManagedString s, int delay = MICROBIT_DEFAULT_PRINT_SPEED);
00356 
00357     /**
00358       * Prints the given image to the display.
00359       * Blocks the calling thread until all the image has been displayed.
00360       *
00361       * @param i The image to display.
00362       *
00363       * @param x The horizontal position on the screen to display the image. Defaults to 0.
00364       *
00365       * @param y The vertical position on the screen to display the image. Defaults to 0.
00366       *
00367       * @param alpha Treats the brightness level '0' as transparent. Defaults to 0.
00368       *
00369       * @param delay The time to display the image for, or zero to show the image forever. Defaults to 0.
00370       *
00371       * @return MICROBIT_OK, MICROBIT_BUSY if the display is already in use, or MICROBIT_INVALID_PARAMETER.
00372       *
00373       * @code
00374       * MicrobitImage i("1,1,1,1,1\n1,1,1,1,1\n");
00375       * display.print(i,400);
00376       * @endcode
00377       */
00378     int print(MicroBitImage i, int x = 0, int y = 0, int alpha = 0, int delay = 0);
00379 
00380     /**
00381       * Scrolls the given string to the display, from right to left.
00382       * Returns immediately, and executes the animation asynchronously.
00383       *
00384       * @param s The string to display.
00385       *
00386       * @param delay The time to delay between characters, in milliseconds. Defaults
00387       *              to: MICROBIT_DEFAULT_SCROLL_SPEED.
00388       *
00389       * @return MICROBIT_OK, MICROBIT_BUSY if the display is already in use, or MICROBIT_INVALID_PARAMETER.
00390       *
00391       * @code
00392       * display.scrollAsync("abc123",100);
00393       * @endcode
00394       */
00395     int scrollAsync(ManagedString s, int delay = MICROBIT_DEFAULT_SCROLL_SPEED);
00396 
00397     /**
00398       * Scrolls the given image across the display, from right to left.
00399       * Returns immediately, and executes the animation asynchronously.
00400       *
00401       * @param image The image to display.
00402       *
00403       * @param delay The time between updates, in milliseconds. Defaults
00404       *              to: MICROBIT_DEFAULT_SCROLL_SPEED.
00405       *
00406       * @param stride The number of pixels to shift by in each update. Defaults to MICROBIT_DEFAULT_SCROLL_STRIDE.
00407       *
00408       * @return MICROBIT_OK, MICROBIT_BUSY if the display is already in use, or MICROBIT_INVALID_PARAMETER.
00409       *
00410       * @code
00411       * MicrobitImage i("1,1,1,1,1\n1,1,1,1,1\n");
00412       * display.scrollAsync(i,100,1);
00413       * @endcode
00414       */
00415     int scrollAsync(MicroBitImage image, int delay = MICROBIT_DEFAULT_SCROLL_SPEED, int stride = MICROBIT_DEFAULT_SCROLL_STRIDE);
00416 
00417     /**
00418       * Scrolls the given string across the display, from right to left.
00419       * Blocks the calling thread until all text has been displayed.
00420       *
00421       * @param s The string to display.
00422       *
00423       * @param delay The time to delay between characters, in milliseconds. Defaults
00424       *              to: MICROBIT_DEFAULT_SCROLL_SPEED.
00425       *
00426       * @return MICROBIT_OK, MICROBIT_CANCELLED or MICROBIT_INVALID_PARAMETER.
00427       *
00428       * @code
00429       * display.scroll("abc123",100);
00430       * @endcode
00431       */
00432     int scroll(ManagedString s, int delay = MICROBIT_DEFAULT_SCROLL_SPEED);
00433 
00434     /**
00435       * Scrolls the given image across the display, from right to left.
00436       * Blocks the calling thread until all the text has been displayed.
00437       *
00438       * @param image The image to display.
00439       *
00440       * @param delay The time between updates, in milliseconds. Defaults
00441       *              to: MICROBIT_DEFAULT_SCROLL_SPEED.
00442       *
00443       * @param stride The number of pixels to shift by in each update. Defaults to MICROBIT_DEFAULT_SCROLL_STRIDE.
00444       *
00445       * @return MICROBIT_OK, MICROBIT_CANCELLED or MICROBIT_INVALID_PARAMETER.
00446       *
00447       * @code
00448       * MicrobitImage i("1,1,1,1,1\n1,1,1,1,1\n");
00449       * display.scroll(i,100,1);
00450       * @endcode
00451       */
00452     int scroll(MicroBitImage image, int delay = MICROBIT_DEFAULT_SCROLL_SPEED, int stride = MICROBIT_DEFAULT_SCROLL_STRIDE);
00453 
00454     /**
00455       * "Animates" the current image across the display with a given stride, finishing on the last frame of the animation.
00456       * Returns immediately.
00457       *
00458       * @param image The image to display.
00459       *
00460       * @param delay The time to delay between each update of the display, in milliseconds.
00461       *
00462       * @param stride The number of pixels to shift by in each update.
00463       *
00464       * @param startingPosition the starting position on the display for the animation
00465       *                         to begin at. Defaults to MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS.
00466       *
00467       * @param autoClear defines whether or not the display is automatically cleared once the animation is complete. By default, the display is cleared. Set this parameter to zero to disable the autoClear operation.
00468       *
00469       * @return MICROBIT_OK, MICROBIT_BUSY if the screen is in use, or MICROBIT_INVALID_PARAMETER.
00470       *
00471       * @code
00472       * const int heart_w = 10;
00473       * const int heart_h = 5;
00474       * const uint8_t heart[] = { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, };
00475       *
00476       * MicroBitImage i(heart_w,heart_h,heart);
00477       * display.animateAsync(i,100,5);
00478       * @endcode
00479       */
00480     int animateAsync(MicroBitImage image, int delay, int stride, int startingPosition = MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS, int autoClear = MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR);
00481 
00482     /**
00483       * "Animates" the current image across the display with a given stride, finishing on the last frame of the animation.
00484       * Blocks the calling thread until the animation is complete.
00485       *
00486       *
00487       * @param delay The time to delay between each update of the display, in milliseconds.
00488       *
00489       * @param stride The number of pixels to shift by in each update.
00490       *
00491       * @param startingPosition the starting position on the display for the animation
00492       *                         to begin at. Defaults to MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS.
00493       *
00494       * @param autoClear defines whether or not the display is automatically cleared once the animation is complete. By default, the display is cleared. Set this parameter to zero to disable the autoClear operation.
00495       *
00496       * @return MICROBIT_OK, MICROBIT_CANCELLED or MICROBIT_INVALID_PARAMETER.
00497       *
00498       * @code
00499       * const int heart_w = 10;
00500       * const int heart_h = 5;
00501       * const uint8_t heart[] = { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, };
00502       *
00503       * MicroBitImage i(heart_w,heart_h,heart);
00504       * display.animate(i,100,5);
00505       * @endcode
00506       */
00507     int animate(MicroBitImage image, int delay, int stride, int startingPosition = MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS, int autoClear = MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR);
00508 
00509     /**
00510       * Configures the brightness of the display.
00511       *
00512       * @param b The brightness to set the brightness to, in the range 0 - 255.
00513       *
00514       * @return MICROBIT_OK, or MICROBIT_INVALID_PARAMETER
00515       *
00516       * @code
00517       * display.setBrightness(255); //max brightness
00518       * @endcode
00519       */
00520     int setBrightness(int b);
00521 
00522     /**
00523       * Configures the mode of the display.
00524       *
00525       * @param mode The mode to swap the display into. One of: DISPLAY_MODE_GREYSCALE,
00526       *             DISPLAY_MODE_BLACK_AND_WHITE, DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
00527       *
00528       * @code
00529       * display.setDisplayMode(DISPLAY_MODE_GREYSCALE); //per pixel brightness
00530       * @endcode
00531       */
00532     void setDisplayMode(DisplayMode mode);
00533 
00534     /**
00535       * Retrieves the mode of the display.
00536       *
00537       * @return the current mode of the display
00538       */
00539     int getDisplayMode();
00540 
00541     /**
00542       * Fetches the current brightness of this display.
00543       *
00544       * @return the brightness of this display, in the range 0..255.
00545       *
00546       * @code
00547       * display.getBrightness(); //the current brightness
00548       * @endcode
00549       */
00550     int getBrightness();
00551 
00552     /**
00553       * Rotates the display to the given position.
00554       *
00555       * Axis aligned values only.
00556       *
00557       * @code
00558       * display.rotateTo(MICROBIT_DISPLAY_ROTATION_180); //rotates 180 degrees from original orientation
00559       * @endcode
00560       */
00561     void rotateTo(DisplayRotation position);
00562 
00563     /**
00564       * Enables the display, should only be called if the display is disabled.
00565       *
00566       * @code
00567       * display.enable(); //Enables the display mechanics
00568       * @endcode
00569       *
00570       * @note Only enables the display if the display is currently disabled.
00571       */
00572     void enable();
00573 
00574     /**
00575       * Disables the display, which releases control of the GPIO pins used by the display,
00576       * which are exposed on the edge connector.
00577       *
00578       * @code
00579       * display.disable(); //disables the display
00580       * @endcode
00581       *
00582       * @note Only disables the display if the display is currently enabled.
00583       */
00584     void disable();
00585 
00586     /**
00587       * Clears the display of any remaining pixels.
00588       *
00589       * `display.image.clear()` can also be used!
00590       *
00591       * @code
00592       * display.clear(); //clears the display
00593       * @endcode
00594       */
00595     void clear();
00596 
00597     /**
00598       * Updates the font that will be used for display operations.
00599       *
00600       * @param font the new font that will be used to render characters.
00601       *
00602       * @note DEPRECATED! Please use MicroBitFont::setSystemFont() instead.
00603       */
00604     void setFont(MicroBitFont font);
00605 
00606     /**
00607       * Retrieves the font object used for rendering characters on the display.
00608       *
00609       * @note DEPRECATED! Please use MicroBitFont::getSystemFont() instead.
00610       */
00611     MicroBitFont getFont();
00612 
00613     /**
00614       * Captures the bitmap currently being rendered on the display.
00615       *
00616       * @return a MicroBitImage containing the captured data.
00617       */
00618     MicroBitImage screenShot();
00619 
00620     /**
00621       * Gives a representative figure of the light level in the current environment
00622       * where are micro:bit is situated.
00623       *
00624       * Internally, it constructs an instance of a MicroBitLightSensor if not already configured
00625       * and sets the display mode to DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE.
00626       *
00627       * This also changes the tickPeriod to MICROBIT_LIGHT_SENSOR_TICK_SPEED so
00628       * that the display does not suffer from artifacts.
00629       *
00630       * @return an indicative light level in the range 0 - 255.
00631       *
00632       * @note this will return 0 on the first call to this method, a light reading
00633       * will be available after the display has activated the light sensor for the
00634       * first time.
00635       */
00636     int readLightLevel();
00637 
00638     /**
00639       * Destructor for MicroBitDisplay, where we deregister this instance from the array of system components.
00640       */
00641     ~MicroBitDisplay();
00642 };
00643 
00644 #endif