fsdfds
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 #define MICROBIT_DISPLAY_ROW1 p13 00074 #define MICROBIT_DISPLAY_COL1 p4 00075 00076 00077 #if MICROBIT_DISPLAY_TYPE == MICROBUG_REFERENCE_DEVICE 00078 00079 #define MICROBIT_DISPLAY_COLUMN_COUNT 5 00080 #define MICROBIT_DISPLAY_ROW_COUNT 5 00081 00082 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00083 { 00084 {0,0},{0,1},{0,2},{0,3},{0,4}, 00085 {1,0},{1,1},{1,2},{1,3},{1,4}, 00086 {2,0},{2,1},{2,2},{2,3},{2,4}, 00087 {3,0},{3,1},{3,2},{3,3},{3,4}, 00088 {4,0},{4,1},{4,2},{4,3},{4,4} 00089 }; 00090 00091 #endif 00092 00093 #if MICROBIT_DISPLAY_TYPE == MICROBIT_3X9 00094 00095 #define MICROBIT_DISPLAY_COLUMN_COUNT 9 00096 #define MICROBIT_DISPLAY_ROW_COUNT 3 00097 00098 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00099 { 00100 {0,4},{0,3},{1,1}, 00101 {1,4},{4,2},{0,1}, 00102 {2,4},{3,2},{4,0}, 00103 {3,4},{2,2},{3,0}, 00104 {4,4},{1,2},{2,0}, 00105 {4,3},{0,2},{1,0}, 00106 {3,3},{4,1},{0,0}, 00107 {2,3},{3,1},{NO_CONN,NO_CONN}, 00108 {1,3},{2,1},{NO_CONN,NO_CONN} 00109 }; 00110 00111 #endif 00112 00113 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB1 00114 00115 #define MICROBIT_DISPLAY_COLUMN_COUNT 3 00116 #define MICROBIT_DISPLAY_ROW_COUNT 9 00117 00118 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00119 { 00120 {0,4},{1,4},{2,4},{3,4},{4,4},{4,3},{3,3},{2,3},{1,3}, 00121 {0,3},{4,2},{3,2},{2,2},{1,2},{0,2},{4,1},{3,1},{2,1}, 00122 {1,1},{0,1},{4,0},{3,0},{2,0},{1,0},{0,0},{NO_CONN,NO_CONN},{NO_CONN,NO_CONN} 00123 }; 00124 00125 #endif 00126 00127 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB2 00128 00129 #define MICROBIT_DISPLAY_COLUMN_COUNT 9 00130 #define MICROBIT_DISPLAY_ROW_COUNT 3 00131 00132 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] = 00133 { 00134 {0,0},{4,2},{2,4}, 00135 {2,0},{0,2},{4,4}, 00136 {4,0},{2,2},{0,4}, 00137 {4,3},{1,0},{0,1}, 00138 {3,3},{3,0},{1,1}, 00139 {2,3},{3,4},{2,1}, 00140 {1,3},{1,4},{3,1}, 00141 {0,3},{NO_CONN,NO_CONN},{4,1}, 00142 {1,2},{NO_CONN,NO_CONN},{3,2} 00143 }; 00144 00145 #endif 00146 00147 //ROW1 and COL1 are defined in mbed classic: 00148 //https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_NRF51_MICROBIT/PinNames.h 00149 const MatrixMap microbitMatrixMap = 00150 { 00151 MICROBIT_DISPLAY_WIDTH, 00152 MICROBIT_DISPLAY_HEIGHT, 00153 MICROBIT_DISPLAY_ROW_COUNT, 00154 MICROBIT_DISPLAY_COLUMN_COUNT, 00155 MICROBIT_DISPLAY_ROW1, 00156 MICROBIT_DISPLAY_COL1, 00157 microbitDisplayMap 00158 }; 00159 00160 #endif
Generated on Wed Jul 13 2022 00:58:03 by 1.7.2