My fork

Dependencies:   BLE_API mbed-dev-bin nRF51822-bluetooth-mdw

Fork of microbit-dal-bluetooth-mdw by Martin Woolley

Committer:
Jonathan Austin
Date:
Thu Apr 07 01:33:22 2016 +0100
Revision:
1:8aa5cdb4ab67
Child:
71:2f5caf7dd454
Synchronized with git rev 55cb9199

Who changed what in which revision?

UserRevisionLine numberNew 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
Jonathan Austin 1:8aa5cdb4ab67 73
Jonathan Austin 1:8aa5cdb4ab67 74 #if MICROBIT_DISPLAY_TYPE == MICROBUG_REFERENCE_DEVICE
Jonathan Austin 1:8aa5cdb4ab67 75
Jonathan Austin 1:8aa5cdb4ab67 76 #define MICROBIT_DISPLAY_COLUMN_COUNT 5
Jonathan Austin 1:8aa5cdb4ab67 77 #define MICROBIT_DISPLAY_ROW_COUNT 5
Jonathan Austin 1:8aa5cdb4ab67 78
Jonathan Austin 1:8aa5cdb4ab67 79 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] =
Jonathan Austin 1:8aa5cdb4ab67 80 {
Jonathan Austin 1:8aa5cdb4ab67 81 {0,0},{0,1},{0,2},{0,3},{0,4},
Jonathan Austin 1:8aa5cdb4ab67 82 {1,0},{1,1},{1,2},{1,3},{1,4},
Jonathan Austin 1:8aa5cdb4ab67 83 {2,0},{2,1},{2,2},{2,3},{2,4},
Jonathan Austin 1:8aa5cdb4ab67 84 {3,0},{3,1},{3,2},{3,3},{3,4},
Jonathan Austin 1:8aa5cdb4ab67 85 {4,0},{4,1},{4,2},{4,3},{4,4}
Jonathan Austin 1:8aa5cdb4ab67 86 };
Jonathan Austin 1:8aa5cdb4ab67 87
Jonathan Austin 1:8aa5cdb4ab67 88 #endif
Jonathan Austin 1:8aa5cdb4ab67 89
Jonathan Austin 1:8aa5cdb4ab67 90 #if MICROBIT_DISPLAY_TYPE == MICROBIT_3X9
Jonathan Austin 1:8aa5cdb4ab67 91
Jonathan Austin 1:8aa5cdb4ab67 92 #define MICROBIT_DISPLAY_COLUMN_COUNT 9
Jonathan Austin 1:8aa5cdb4ab67 93 #define MICROBIT_DISPLAY_ROW_COUNT 3
Jonathan Austin 1:8aa5cdb4ab67 94
Jonathan Austin 1:8aa5cdb4ab67 95 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] =
Jonathan Austin 1:8aa5cdb4ab67 96 {
Jonathan Austin 1:8aa5cdb4ab67 97 {0,4},{0,3},{1,1},
Jonathan Austin 1:8aa5cdb4ab67 98 {1,4},{4,2},{0,1},
Jonathan Austin 1:8aa5cdb4ab67 99 {2,4},{3,2},{4,0},
Jonathan Austin 1:8aa5cdb4ab67 100 {3,4},{2,2},{3,0},
Jonathan Austin 1:8aa5cdb4ab67 101 {4,4},{1,2},{2,0},
Jonathan Austin 1:8aa5cdb4ab67 102 {4,3},{0,2},{1,0},
Jonathan Austin 1:8aa5cdb4ab67 103 {3,3},{4,1},{0,0},
Jonathan Austin 1:8aa5cdb4ab67 104 {2,3},{3,1},{NO_CONN,NO_CONN},
Jonathan Austin 1:8aa5cdb4ab67 105 {1,3},{2,1},{NO_CONN,NO_CONN}
Jonathan Austin 1:8aa5cdb4ab67 106 };
Jonathan Austin 1:8aa5cdb4ab67 107
Jonathan Austin 1:8aa5cdb4ab67 108 #endif
Jonathan Austin 1:8aa5cdb4ab67 109
Jonathan Austin 1:8aa5cdb4ab67 110 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB1
Jonathan Austin 1:8aa5cdb4ab67 111
Jonathan Austin 1:8aa5cdb4ab67 112 #define MICROBIT_DISPLAY_COLUMN_COUNT 3
Jonathan Austin 1:8aa5cdb4ab67 113 #define MICROBIT_DISPLAY_ROW_COUNT 9
Jonathan Austin 1:8aa5cdb4ab67 114
Jonathan Austin 1:8aa5cdb4ab67 115 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] =
Jonathan Austin 1:8aa5cdb4ab67 116 {
Jonathan Austin 1:8aa5cdb4ab67 117 {0,4},{1,4},{2,4},{3,4},{4,4},{4,3},{3,3},{2,3},{1,3},
Jonathan Austin 1:8aa5cdb4ab67 118 {0,3},{4,2},{3,2},{2,2},{1,2},{0,2},{4,1},{3,1},{2,1},
Jonathan Austin 1:8aa5cdb4ab67 119 {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 120 };
Jonathan Austin 1:8aa5cdb4ab67 121
Jonathan Austin 1:8aa5cdb4ab67 122 #endif
Jonathan Austin 1:8aa5cdb4ab67 123
Jonathan Austin 1:8aa5cdb4ab67 124 #if MICROBIT_DISPLAY_TYPE == MICROBIT_SB2
Jonathan Austin 1:8aa5cdb4ab67 125
Jonathan Austin 1:8aa5cdb4ab67 126 #define MICROBIT_DISPLAY_COLUMN_COUNT 9
Jonathan Austin 1:8aa5cdb4ab67 127 #define MICROBIT_DISPLAY_ROW_COUNT 3
Jonathan Austin 1:8aa5cdb4ab67 128
Jonathan Austin 1:8aa5cdb4ab67 129 const MatrixPoint microbitDisplayMap[MICROBIT_DISPLAY_ROW_COUNT * MICROBIT_DISPLAY_COLUMN_COUNT] =
Jonathan Austin 1:8aa5cdb4ab67 130 {
Jonathan Austin 1:8aa5cdb4ab67 131 {0,0},{4,2},{2,4},
Jonathan Austin 1:8aa5cdb4ab67 132 {2,0},{0,2},{4,4},
Jonathan Austin 1:8aa5cdb4ab67 133 {4,0},{2,2},{0,4},
Jonathan Austin 1:8aa5cdb4ab67 134 {4,3},{1,0},{0,1},
Jonathan Austin 1:8aa5cdb4ab67 135 {3,3},{3,0},{1,1},
Jonathan Austin 1:8aa5cdb4ab67 136 {2,3},{3,4},{2,1},
Jonathan Austin 1:8aa5cdb4ab67 137 {1,3},{1,4},{3,1},
Jonathan Austin 1:8aa5cdb4ab67 138 {0,3},{NO_CONN,NO_CONN},{4,1},
Jonathan Austin 1:8aa5cdb4ab67 139 {1,2},{NO_CONN,NO_CONN},{3,2}
Jonathan Austin 1:8aa5cdb4ab67 140 };
Jonathan Austin 1:8aa5cdb4ab67 141
Jonathan Austin 1:8aa5cdb4ab67 142 #endif
Jonathan Austin 1:8aa5cdb4ab67 143
Jonathan Austin 1:8aa5cdb4ab67 144 //ROW1 and COL1 are defined in mbed classic:
Jonathan Austin 1:8aa5cdb4ab67 145 //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 146 const MatrixMap microbitMatrixMap =
Jonathan Austin 1:8aa5cdb4ab67 147 {
Jonathan Austin 1:8aa5cdb4ab67 148 MICROBIT_DISPLAY_WIDTH,
Jonathan Austin 1:8aa5cdb4ab67 149 MICROBIT_DISPLAY_HEIGHT,
Jonathan Austin 1:8aa5cdb4ab67 150 MICROBIT_DISPLAY_ROW_COUNT,
Jonathan Austin 1:8aa5cdb4ab67 151 MICROBIT_DISPLAY_COLUMN_COUNT,
Jonathan Austin 1:8aa5cdb4ab67 152 ROW1,
Jonathan Austin 1:8aa5cdb4ab67 153 COL1,
Jonathan Austin 1:8aa5cdb4ab67 154 microbitDisplayMap
Jonathan Austin 1:8aa5cdb4ab67 155 };
Jonathan Austin 1:8aa5cdb4ab67 156
Jonathan Austin 1:8aa5cdb4ab67 157 #endif