Attempting to publish a tree
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
MicroBitMatrixMaps.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 /** 00027 * Definition of the LED Matrix maps supported. 00028 * Each map represents the layou of a different device. 00029 * 00030 * Ensure only one of these is selected. 00031 */ 00032 00033 #ifndef MICROBIT_MATRIX_MAPS_H 00034 #define MICROBIT_MATRIX_MAPS_H 00035 00036 #include "MicroBitConfig.h" 00037 #include "mbed.h" 00038 00039 #define NO_CONN 0 00040 00041 /** 00042 * Provides the mapping from Matrix ROW/COL to a linear X/Y buffer. 00043 * It's arranged such that matrixMap[col, row] provides the [x,y] screen co-ord. 00044 */ 00045 00046 struct MatrixPoint 00047 { 00048 uint8_t x; 00049 uint8_t y; 00050 }; 00051 00052 /** 00053 * This struct presumes rows and columns are arranged contiguously... 00054 */ 00055 struct MatrixMap 00056 { 00057 int width; // The physical width of the LED matrix, in pixels. 00058 int height; // The physical height of the LED matrix, in pixels. 00059 int rows; // The number of drive pins connected to LEDs. 00060 int columns; // The number of sink pins connected to the LEDs. 00061 00062 PinName rowStart; // ID of the first drive pin. 00063 PinName columnStart; // ID of the first sink pink. 00064 00065 const MatrixPoint *map; // Table mapping logical LED positions to physical positions. 00066 }; 00067 00068 /* 00069 * Dimensions for well known micro:bit LED configurations 00070 */ 00071 #define MICROBIT_DISPLAY_WIDTH 5 00072 #define MICROBIT_DISPLAY_HEIGHT 5 00073 00074 #if MICROBIT_DISPLAY_TYPE == MICROBUG_REFERENCE_DEVICE 00075 00076 #define MICROBIT_DISPLAY_COLUMN_COUNT 5 00077 #define MICROBIT_DISPLAY_ROW_COUNT 5 00078 00079 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00080 { 00081 {0,0},{0,1},{0,2},{0,3},{0,4}, 00082 {1,0},{1,1},{1,2},{1,3},{1,4}, 00083 {2,0},{2,1},{2,2},{2,3},{2,4}, 00084 {3,0},{3,1},{3,2},{3,3},{3,4}, 00085 {4,0},{4,1},{4,2},{4,3},{4,4} 00086 }; 00087 00088 #endif 00089 00090 #if MICROBIT_DISPLAY_TYPE == MICROBIT_3X9 00091 00092 #define MICROBIT_DISPLAY_COLUMN_COUNT 9 00093 #define MICROBIT_DISPLAY_ROW_COUNT 3 00094 00095 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00096 { 00097 {0,4},{0,3},{1,1}, 00098 {1,4},{4,2},{0,1}, 00099 {2,4},{3,2},{4,0}, 00100 {3,4},{2,2},{3,0}, 00101 {4,4},{1,2},{2,0}, 00102 {4,3},{0,2},{1,0}, 00103 {3,3},{4,1},{0,0}, 00104 {2,3},{3,1},{NO_CONN,NO_CONN}, 00105 {1,3},{2,1},{NO_CONN,NO_CONN} 00106 }; 00107 00108 #endif 00109 00110 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB1 00111 00112 #define MICROBIT_DISPLAY_COLUMN_COUNT 3 00113 #define MICROBIT_DISPLAY_ROW_COUNT 9 00114 00115 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00116 { 00117 {0,4},{1,4},{2,4},{3,4},{4,4},{4,3},{3,3},{2,3},{1,3}, 00118 {0,3},{4,2},{3,2},{2,2},{1,2},{0,2},{4,1},{3,1},{2,1}, 00119 {1,1},{0,1},{4,0},{3,0},{2,0},{1,0},{0,0},{NO_CONN,NO_CONN},{NO_CONN,NO_CONN} 00120 }; 00121 00122 #endif 00123 00124 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB2 00125 00126 #define MICROBIT_DISPLAY_COLUMN_COUNT 9 00127 #define MICROBIT_DISPLAY_ROW_COUNT 3 00128 00129 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00130 { 00131 {0,0},{4,2},{2,4}, 00132 {2,0},{0,2},{4,4}, 00133 {4,0},{2,2},{0,4}, 00134 {4,3},{1,0},{0,1}, 00135 {3,3},{3,0},{1,1}, 00136 {2,3},{3,4},{2,1}, 00137 {1,3},{1,4},{3,1}, 00138 {0,3},{NO_CONN,NO_CONN},{4,1}, 00139 {1,2},{NO_CONN,NO_CONN},{3,2} 00140 }; 00141 00142 #endif 00143 00144 //ROW1 and COL1 are defined in mbed classic: 00145 //https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_NRF51_MICROBIT/PinNames.h 00146 const MatrixMap microbitMatrixMap = 00147 { 00148 MICROBIT_DISPLAY_WIDTH, 00149 MICROBIT_DISPLAY_HEIGHT, 00150 MICROBIT_DISPLAY_ROW_COUNT, 00151 MICROBIT_DISPLAY_COLUMN_COUNT, 00152 ROW1, 00153 COL1, 00154 microbitDisplayMap 00155 }; 00156 00157 #endif
Generated on Tue Jul 12 2022 19:58:09 by 1.7.2