forking microbit-dal
Dependencies: BLE_API mbed-dev-bin nRF51822-bluetooth-mdw
Fork of microbit-dal by
inc/drivers/MicroBitMatrixMaps.h@71:2f5caf7dd454, 2016-07-13 (annotated)
- Committer:
- LancasterUniversity
- Date:
- Wed Jul 13 12:18:51 2016 +0100
- Revision:
- 71:2f5caf7dd454
- Parent:
- 1:8aa5cdb4ab67
Synchronized with git rev ff547977
Author: Joe Finney
microbit: Removed dependency on microbit target for MicroBitDisplay
- removed ROW1 and COL1 dependencies that are defined in the bbc-microbit
family of mbed targets, so that microbit-dal can be compiled for other mbed
targets. #172
- removed legacy reference to the default microbitMatrixMap in
MicroBitDisplay, in favour of the map configured through the constructor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
1:8aa5cdb4ab67 | 1 | /* |
Jonathan Austin |
1:8aa5cdb4ab67 | 2 | The MIT License (MIT) |
Jonathan Austin |
1:8aa5cdb4ab67 | 3 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
Jonathan Austin |
1:8aa5cdb4ab67 | 6 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
Jonathan Austin |
1:8aa5cdb4ab67 | 8 | copy of this software and associated documentation files (the "Software"), |
Jonathan Austin |
1:8aa5cdb4ab67 | 9 | to deal in the Software without restriction, including without limitation |
Jonathan Austin |
1:8aa5cdb4ab67 | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Jonathan Austin |
1:8aa5cdb4ab67 | 11 | and/or sell copies of the Software, and to permit persons to whom the |
Jonathan Austin |
1:8aa5cdb4ab67 | 12 | Software is furnished to do so, subject to the following conditions: |
Jonathan Austin |
1:8aa5cdb4ab67 | 13 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 14 | The above copyright notice and this permission notice shall be included in |
Jonathan Austin |
1:8aa5cdb4ab67 | 15 | all copies or substantial portions of the Software. |
Jonathan Austin |
1:8aa5cdb4ab67 | 16 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Jonathan Austin |
1:8aa5cdb4ab67 | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Jonathan Austin |
1:8aa5cdb4ab67 | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
Jonathan Austin |
1:8aa5cdb4ab67 | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Jonathan Austin |
1:8aa5cdb4ab67 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
Jonathan Austin |
1:8aa5cdb4ab67 | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
Jonathan Austin |
1:8aa5cdb4ab67 | 23 | DEALINGS IN THE SOFTWARE. |
Jonathan Austin |
1:8aa5cdb4ab67 | 24 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 25 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 26 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 27 | * Definition of the LED Matrix maps supported. |
Jonathan Austin |
1:8aa5cdb4ab67 | 28 | * Each map represents the layou of a different device. |
Jonathan Austin |
1:8aa5cdb4ab67 | 29 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 30 | * Ensure only one of these is selected. |
Jonathan Austin |
1:8aa5cdb4ab67 | 31 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 32 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 33 | #ifndef MICROBIT_MATRIX_MAPS_H |
Jonathan Austin |
1:8aa5cdb4ab67 | 34 | #define MICROBIT_MATRIX_MAPS_H |
Jonathan Austin |
1:8aa5cdb4ab67 | 35 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 36 | #include "MicroBitConfig.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 37 | #include "mbed.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 38 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 39 | #define NO_CONN 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 40 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 41 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 42 | * Provides the mapping from Matrix ROW/COL to a linear X/Y buffer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 43 | * It's arranged such that matrixMap[col, row] provides the [x,y] screen co-ord. |
Jonathan Austin |
1:8aa5cdb4ab67 | 44 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 45 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 46 | struct MatrixPoint |
Jonathan Austin |
1:8aa5cdb4ab67 | 47 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 48 | uint8_t x; |
Jonathan Austin |
1:8aa5cdb4ab67 | 49 | uint8_t y; |
Jonathan Austin |
1:8aa5cdb4ab67 | 50 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 51 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 52 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 53 | * This struct presumes rows and columns are arranged contiguously... |
Jonathan Austin |
1:8aa5cdb4ab67 | 54 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 55 | struct MatrixMap |
Jonathan Austin |
1:8aa5cdb4ab67 | 56 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 57 | int width; // The physical width of the LED matrix, in pixels. |
Jonathan Austin |
1:8aa5cdb4ab67 | 58 | int height; // The physical height of the LED matrix, in pixels. |
Jonathan Austin |
1:8aa5cdb4ab67 | 59 | int rows; // The number of drive pins connected to LEDs. |
Jonathan Austin |
1:8aa5cdb4ab67 | 60 | int columns; // The number of sink pins connected to the LEDs. |
Jonathan Austin |
1:8aa5cdb4ab67 | 61 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 62 | PinName rowStart; // ID of the first drive pin. |
Jonathan Austin |
1:8aa5cdb4ab67 | 63 | PinName columnStart; // ID of the first sink pink. |
Jonathan Austin |
1:8aa5cdb4ab67 | 64 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 65 | const MatrixPoint *map; // Table mapping logical LED positions to physical positions. |
Jonathan Austin |
1:8aa5cdb4ab67 | 66 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 67 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 68 | /* |
Jonathan Austin |
1:8aa5cdb4ab67 | 69 | * Dimensions for well known micro:bit LED configurations |
Jonathan Austin |
1:8aa5cdb4ab67 | 70 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 71 | #define MICROBIT_DISPLAY_WIDTH 5 |
Jonathan Austin |
1:8aa5cdb4ab67 | 72 | #define MICROBIT_DISPLAY_HEIGHT 5 |
LancasterUniversity | 71:2f5caf7dd454 | 73 | #define MICROBIT_DISPLAY_ROW1 p13 |
LancasterUniversity | 71:2f5caf7dd454 | 74 | #define MICROBIT_DISPLAY_COL1 p4 |
LancasterUniversity | 71:2f5caf7dd454 | 75 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 76 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 77 | #if MICROBIT_DISPLAY_TYPE == MICROBUG_REFERENCE_DEVICE |
Jonathan Austin |
1:8aa5cdb4ab67 | 78 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 79 | #define MICROBIT_DISPLAY_COLUMN_COUNT 5 |
Jonathan Austin |
1:8aa5cdb4ab67 | 80 | #define MICROBIT_DISPLAY_ROW_COUNT 5 |
Jonathan Austin |
1:8aa5cdb4ab67 | 81 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 82 | const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = |
Jonathan Austin |
1:8aa5cdb4ab67 | 83 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 84 | {0,0},{0,1},{0,2},{0,3},{0,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 85 | {1,0},{1,1},{1,2},{1,3},{1,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 86 | {2,0},{2,1},{2,2},{2,3},{2,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 87 | {3,0},{3,1},{3,2},{3,3},{3,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 88 | {4,0},{4,1},{4,2},{4,3},{4,4} |
Jonathan Austin |
1:8aa5cdb4ab67 | 89 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 90 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 91 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 92 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 93 | #if MICROBIT_DISPLAY_TYPE == MICROBIT_3X9 |
Jonathan Austin |
1:8aa5cdb4ab67 | 94 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 95 | #define MICROBIT_DISPLAY_COLUMN_COUNT 9 |
Jonathan Austin |
1:8aa5cdb4ab67 | 96 | #define MICROBIT_DISPLAY_ROW_COUNT 3 |
Jonathan Austin |
1:8aa5cdb4ab67 | 97 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 98 | const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = |
Jonathan Austin |
1:8aa5cdb4ab67 | 99 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 100 | {0,4},{0,3},{1,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 101 | {1,4},{4,2},{0,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 102 | {2,4},{3,2},{4,0}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 103 | {3,4},{2,2},{3,0}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 104 | {4,4},{1,2},{2,0}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 105 | {4,3},{0,2},{1,0}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 106 | {3,3},{4,1},{0,0}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 107 | {2,3},{3,1},{NO_CONN,NO_CONN}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 108 | {1,3},{2,1},{NO_CONN,NO_CONN} |
Jonathan Austin |
1:8aa5cdb4ab67 | 109 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 110 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 111 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 112 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 113 | #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 114 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 115 | #define MICROBIT_DISPLAY_COLUMN_COUNT 3 |
Jonathan Austin |
1:8aa5cdb4ab67 | 116 | #define MICROBIT_DISPLAY_ROW_COUNT 9 |
Jonathan Austin |
1:8aa5cdb4ab67 | 117 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 118 | const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = |
Jonathan Austin |
1:8aa5cdb4ab67 | 119 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 120 | {0,4},{1,4},{2,4},{3,4},{4,4},{4,3},{3,3},{2,3},{1,3}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 121 | {0,3},{4,2},{3,2},{2,2},{1,2},{0,2},{4,1},{3,1},{2,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 122 | {1,1},{0,1},{4,0},{3,0},{2,0},{1,0},{0,0},{NO_CONN,NO_CONN},{NO_CONN,NO_CONN} |
Jonathan Austin |
1:8aa5cdb4ab67 | 123 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 124 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 125 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 126 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 127 | #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB2 |
Jonathan Austin |
1:8aa5cdb4ab67 | 128 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 129 | #define MICROBIT_DISPLAY_COLUMN_COUNT 9 |
Jonathan Austin |
1:8aa5cdb4ab67 | 130 | #define MICROBIT_DISPLAY_ROW_COUNT 3 |
Jonathan Austin |
1:8aa5cdb4ab67 | 131 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 132 | const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = |
Jonathan Austin |
1:8aa5cdb4ab67 | 133 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 134 | {0,0},{4,2},{2,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 135 | {2,0},{0,2},{4,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 136 | {4,0},{2,2},{0,4}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 137 | {4,3},{1,0},{0,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 138 | {3,3},{3,0},{1,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 139 | {2,3},{3,4},{2,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 140 | {1,3},{1,4},{3,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 141 | {0,3},{NO_CONN,NO_CONN},{4,1}, |
Jonathan Austin |
1:8aa5cdb4ab67 | 142 | {1,2},{NO_CONN,NO_CONN},{3,2} |
Jonathan Austin |
1:8aa5cdb4ab67 | 143 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 144 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 145 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 146 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 147 | //ROW1 and COL1 are defined in mbed classic: |
Jonathan Austin |
1:8aa5cdb4ab67 | 148 | //https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_NRF51_MICROBIT/PinNames.h |
Jonathan Austin |
1:8aa5cdb4ab67 | 149 | const MatrixMap microbitMatrixMap = |
Jonathan Austin |
1:8aa5cdb4ab67 | 150 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 151 | MICROBIT_DISPLAY_WIDTH, |
Jonathan Austin |
1:8aa5cdb4ab67 | 152 | MICROBIT_DISPLAY_HEIGHT, |
Jonathan Austin |
1:8aa5cdb4ab67 | 153 | MICROBIT_DISPLAY_ROW_COUNT, |
Jonathan Austin |
1:8aa5cdb4ab67 | 154 | MICROBIT_DISPLAY_COLUMN_COUNT, |
LancasterUniversity | 71:2f5caf7dd454 | 155 | MICROBIT_DISPLAY_ROW1, |
LancasterUniversity | 71:2f5caf7dd454 | 156 | MICROBIT_DISPLAY_COL1, |
Jonathan Austin |
1:8aa5cdb4ab67 | 157 | microbitDisplayMap |
Jonathan Austin |
1:8aa5cdb4ab67 | 158 | }; |
Jonathan Austin |
1:8aa5cdb4ab67 | 159 | |
LancasterUniversity | 71:2f5caf7dd454 | 160 | #endif |