microbit-dal/inc/MicroBitMatrixMaps.h

75 lines
3.5 KiB
C
Raw Normal View History

/**
* Definition of the LED Matrix maps supported.
* Each map represents the layou of a different device.
*
* Ensure only one of these is selected.
*/
#ifndef MICROBIT_MATRIX_MAPS_H
#define MICROBIT_MATRIX_MAPS_H
microbit: Added configurable concurrency modes for MicroBitMessageBus handlers. MessageBus handlers can now have one of four concurrency modes for the eventuality of an event being raised whilst a previous event is still being processed. An additional (optional) parameter is provided to the listen() functions to allow this to be selected on a per event handler basis. The permissable options are: MESSAGE_BUS_LISTENER_REENTRANT: The event handler is fired with the new event, regardless of whether or not a previous event is still be processed by that handler. MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY: The new event is queued until such a time as the previous event has completed execution. The new event is then processed. This option does not preclude the processing of the new event by other event handlers. MESSAGE_BUS_LISTENER_DROP_IF_BUSY: The new event is dropped, and will never be processed the the event handler. This option does not preclude the processing of the new event by other event handlers. MESSAGE_BUS_LISTENER_NONBLOCKING: The event handler is self-declaring that it never blocks. This flag is used purely for optimisation, as it permits direct execution of the event hadnelr without inducing any overhead from the scheduler. In addition, the following minor revisions were made in this release: * Cleanup of the #include dependencies contained in the microbit-dal .h files * Bugfix to the scheduler block on event matching code. * Introduced a MICROBIT_ID_ALERT MessageBus channel, for general purpose eventing using nonces.
2015-09-11 15:39:38 +00:00
#include "mbed.h"
#include "MicroBitDisplay.h"
/**
* Provides the mapping from Matrix ROW/COL to a linear X/Y buffer.
* It's arranged such that matrixMap[col, row] provides the [x,y] screen co-ord.
*/
#define NO_CONN 0
#if MICROBIT_DISPLAY_TYPE == MICROBUG_REFERENCE_DEVICE
const MatrixPoint MicroBitDisplay::matrixMap[MICROBIT_DISPLAY_COLUMN_COUNT][MICROBIT_DISPLAY_ROW_COUNT] =
{ {MatrixPoint(0,0),MatrixPoint(0,1),MatrixPoint(0,2), MatrixPoint(0,3), MatrixPoint(0,4)},
{MatrixPoint(1,0),MatrixPoint(1,1),MatrixPoint(1,2), MatrixPoint(1,3), MatrixPoint(1,4)},
{MatrixPoint(2,0),MatrixPoint(2,1),MatrixPoint(2,2), MatrixPoint(2,3), MatrixPoint(2,4)},
{MatrixPoint(3,0),MatrixPoint(3,1),MatrixPoint(3,2), MatrixPoint(3,3), MatrixPoint(3,4)},
{MatrixPoint(4,0),MatrixPoint(4,1),MatrixPoint(4,2), MatrixPoint(4,3), MatrixPoint(4,4)}
};
#endif
#if MICROBIT_DISPLAY_TYPE == MICROBIT_3X9
const MatrixPoint MicroBitDisplay::matrixMap[MICROBIT_DISPLAY_COLUMN_COUNT][MICROBIT_DISPLAY_ROW_COUNT] =
{
{MatrixPoint(0,4),MatrixPoint(0,3),MatrixPoint(1,1)},
{MatrixPoint(1,4),MatrixPoint(4,2),MatrixPoint(0,1)},
{MatrixPoint(2,4),MatrixPoint(3,2),MatrixPoint(4,0)},
{MatrixPoint(3,4),MatrixPoint(2,2),MatrixPoint(3,0)},
{MatrixPoint(4,4),MatrixPoint(1,2),MatrixPoint(2,0)},
{MatrixPoint(4,3),MatrixPoint(0,2),MatrixPoint(1,0)},
{MatrixPoint(3,3),MatrixPoint(4,1),MatrixPoint(0,0)},
{MatrixPoint(2,3),MatrixPoint(3,1),MatrixPoint(NO_CONN,NO_CONN)},
{MatrixPoint(1,3),MatrixPoint(2,1),MatrixPoint(NO_CONN,NO_CONN)}
};
#endif
#if MICROBIT_DISPLAY_TYPE == MICROBIT_SB1
const MatrixPoint MicroBitDisplay::matrixMap[MICROBIT_DISPLAY_COLUMN_COUNT][MICROBIT_DISPLAY_ROW_COUNT] =
{
{MatrixPoint(0,4), MatrixPoint(1,4), MatrixPoint(2,4), MatrixPoint(3,4), MatrixPoint(4,4), MatrixPoint(4,3), MatrixPoint(3,3), MatrixPoint(2,3), MatrixPoint(1,3)},
{MatrixPoint(0,3), MatrixPoint(4,2), MatrixPoint(3,2), MatrixPoint(2,2), MatrixPoint(1,2), MatrixPoint(0,2), MatrixPoint(4,1), MatrixPoint(3,1), MatrixPoint(2,1)},
{MatrixPoint(1,1), MatrixPoint(0,1), MatrixPoint(4,0), MatrixPoint(3,0), MatrixPoint(2,0), MatrixPoint(1,0), MatrixPoint(0,0), MatrixPoint(NO_CONN,NO_CONN), MatrixPoint(NO_CONN,NO_CONN)}
};
#endif
#if MICROBIT_DISPLAY_TYPE == MICROBIT_SB2
const MatrixPoint MicroBitDisplay::matrixMap[MICROBIT_DISPLAY_COLUMN_COUNT][MICROBIT_DISPLAY_ROW_COUNT] =
{
{MatrixPoint(0,0),MatrixPoint(4,2),MatrixPoint(2,4)},
{MatrixPoint(2,0),MatrixPoint(0,2),MatrixPoint(4,4)},
{MatrixPoint(4,0),MatrixPoint(2,2),MatrixPoint(0,4)},
{MatrixPoint(4,3),MatrixPoint(1,0),MatrixPoint(0,1)},
{MatrixPoint(3,3),MatrixPoint(3,0),MatrixPoint(1,1)},
{MatrixPoint(2,3),MatrixPoint(3,4),MatrixPoint(2,1)},
{MatrixPoint(1,3),MatrixPoint(1,4),MatrixPoint(3,1)},
{MatrixPoint(0,3),MatrixPoint(NO_CONN,NO_CONN),MatrixPoint(4,1)},
{MatrixPoint(1,2),MatrixPoint(NO_CONN,NO_CONN),MatrixPoint(3,2)}
};
#endif
const PinName rowPins[MICROBIT_DISPLAY_ROW_COUNT] = {MICROBIT_DISPLAY_ROW_PINS};
const uint8_t panicFace[MICROBIT_DISPLAY_COLUMN_COUNT] = {0x1B, 0x1B,0x0,0x0E,0x11};
#endif