Hardware testing for M24SR-DISCOVERY demo PCB. as help to others
Set up to use MB1138 M24SR-DISCOVERY PCB http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/st25-nfc-rfid-eval-boards/st25-nfc-rfid-eval-boards/m24sr-discovery.html with MBED system. based on https://developer.mbed.org/users/hudakz/code/STM32F103C8T6_Hello/ code and https://developer.mbed.org/users/wim/notebook/m24sr64-nfcrfid-tag-with-i2c-interface/ Which lead me to look at Peter Drescher's work on ILI9341 LCD controller
https://developer.mbed.org/users/dreschpe/code/SPI_TFT_ILI9341/
SPI_TFT_ILI9341/GraphicsDisplay.cpp@2:2033db202017, 2016-09-29 (annotated)
- Committer:
- lloydg
- Date:
- Thu Sep 29 11:07:41 2016 +0000
- Revision:
- 2:2033db202017
- Parent:
- M24SR-DISCOVERY_hardware/SPI_TFT_ILI9341/GraphicsDisplay.cpp@0:ce5a25daadce
re jig folders
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lloydg | 0:ce5a25daadce | 1 | /* mbed GraphicsDisplay Display Library Base Class |
lloydg | 0:ce5a25daadce | 2 | * Copyright (c) 2007-2009 sford |
lloydg | 0:ce5a25daadce | 3 | * Released under the MIT License: http://mbed.org/license/mit |
lloydg | 0:ce5a25daadce | 4 | */ |
lloydg | 0:ce5a25daadce | 5 | |
lloydg | 0:ce5a25daadce | 6 | #include "GraphicsDisplay.h" |
lloydg | 0:ce5a25daadce | 7 | |
lloydg | 0:ce5a25daadce | 8 | const unsigned char FONT8x8[97][8] = { |
lloydg | 0:ce5a25daadce | 9 | 0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char |
lloydg | 0:ce5a25daadce | 10 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20 |
lloydg | 0:ce5a25daadce | 11 | 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // ! |
lloydg | 0:ce5a25daadce | 12 | 0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // " |
lloydg | 0:ce5a25daadce | 13 | 0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // # |
lloydg | 0:ce5a25daadce | 14 | 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $ |
lloydg | 0:ce5a25daadce | 15 | 0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // % |
lloydg | 0:ce5a25daadce | 16 | 0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // & |
lloydg | 0:ce5a25daadce | 17 | 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // ' |
lloydg | 0:ce5a25daadce | 18 | 0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // ( |
lloydg | 0:ce5a25daadce | 19 | 0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // ) |
lloydg | 0:ce5a25daadce | 20 | 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // * |
lloydg | 0:ce5a25daadce | 21 | 0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // + |
lloydg | 0:ce5a25daadce | 22 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // , |
lloydg | 0:ce5a25daadce | 23 | 0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // - |
lloydg | 0:ce5a25daadce | 24 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // . |
lloydg | 0:ce5a25daadce | 25 | 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash) |
lloydg | 0:ce5a25daadce | 26 | 0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30 |
lloydg | 0:ce5a25daadce | 27 | 0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1 |
lloydg | 0:ce5a25daadce | 28 | 0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2 |
lloydg | 0:ce5a25daadce | 29 | 0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3 |
lloydg | 0:ce5a25daadce | 30 | 0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4 |
lloydg | 0:ce5a25daadce | 31 | 0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5 |
lloydg | 0:ce5a25daadce | 32 | 0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6 |
lloydg | 0:ce5a25daadce | 33 | 0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7 |
lloydg | 0:ce5a25daadce | 34 | 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8 |
lloydg | 0:ce5a25daadce | 35 | 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9 |
lloydg | 0:ce5a25daadce | 36 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // : |
lloydg | 0:ce5a25daadce | 37 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ; |
lloydg | 0:ce5a25daadce | 38 | 0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // < |
lloydg | 0:ce5a25daadce | 39 | 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // = |
lloydg | 0:ce5a25daadce | 40 | 0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // > |
lloydg | 0:ce5a25daadce | 41 | 0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ? |
lloydg | 0:ce5a25daadce | 42 | 0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40 |
lloydg | 0:ce5a25daadce | 43 | 0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A |
lloydg | 0:ce5a25daadce | 44 | 0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B |
lloydg | 0:ce5a25daadce | 45 | 0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C |
lloydg | 0:ce5a25daadce | 46 | 0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D |
lloydg | 0:ce5a25daadce | 47 | 0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E |
lloydg | 0:ce5a25daadce | 48 | 0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F |
lloydg | 0:ce5a25daadce | 49 | 0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G |
lloydg | 0:ce5a25daadce | 50 | 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H |
lloydg | 0:ce5a25daadce | 51 | 0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I |
lloydg | 0:ce5a25daadce | 52 | 0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J |
lloydg | 0:ce5a25daadce | 53 | 0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K |
lloydg | 0:ce5a25daadce | 54 | 0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L |
lloydg | 0:ce5a25daadce | 55 | 0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M |
lloydg | 0:ce5a25daadce | 56 | 0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N |
lloydg | 0:ce5a25daadce | 57 | 0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O |
lloydg | 0:ce5a25daadce | 58 | 0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50 |
lloydg | 0:ce5a25daadce | 59 | 0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q |
lloydg | 0:ce5a25daadce | 60 | 0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R |
lloydg | 0:ce5a25daadce | 61 | 0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S |
lloydg | 0:ce5a25daadce | 62 | 0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T |
lloydg | 0:ce5a25daadce | 63 | 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U |
lloydg | 0:ce5a25daadce | 64 | 0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V |
lloydg | 0:ce5a25daadce | 65 | 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W |
lloydg | 0:ce5a25daadce | 66 | 0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X |
lloydg | 0:ce5a25daadce | 67 | 0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y |
lloydg | 0:ce5a25daadce | 68 | 0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z |
lloydg | 0:ce5a25daadce | 69 | 0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [ |
lloydg | 0:ce5a25daadce | 70 | 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash) |
lloydg | 0:ce5a25daadce | 71 | 0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ] |
lloydg | 0:ce5a25daadce | 72 | 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^ |
lloydg | 0:ce5a25daadce | 73 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _ |
lloydg | 0:ce5a25daadce | 74 | 0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60 |
lloydg | 0:ce5a25daadce | 75 | 0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a |
lloydg | 0:ce5a25daadce | 76 | 0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b |
lloydg | 0:ce5a25daadce | 77 | 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c |
lloydg | 0:ce5a25daadce | 78 | 0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d |
lloydg | 0:ce5a25daadce | 79 | 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e |
lloydg | 0:ce5a25daadce | 80 | 0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f |
lloydg | 0:ce5a25daadce | 81 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g |
lloydg | 0:ce5a25daadce | 82 | 0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h |
lloydg | 0:ce5a25daadce | 83 | 0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i |
lloydg | 0:ce5a25daadce | 84 | 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j |
lloydg | 0:ce5a25daadce | 85 | 0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k |
lloydg | 0:ce5a25daadce | 86 | 0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l |
lloydg | 0:ce5a25daadce | 87 | 0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m |
lloydg | 0:ce5a25daadce | 88 | 0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n |
lloydg | 0:ce5a25daadce | 89 | 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o |
lloydg | 0:ce5a25daadce | 90 | 0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p |
lloydg | 0:ce5a25daadce | 91 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q |
lloydg | 0:ce5a25daadce | 92 | 0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r |
lloydg | 0:ce5a25daadce | 93 | 0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s |
lloydg | 0:ce5a25daadce | 94 | 0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t |
lloydg | 0:ce5a25daadce | 95 | 0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u |
lloydg | 0:ce5a25daadce | 96 | 0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v |
lloydg | 0:ce5a25daadce | 97 | 0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w |
lloydg | 0:ce5a25daadce | 98 | 0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x |
lloydg | 0:ce5a25daadce | 99 | 0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y |
lloydg | 0:ce5a25daadce | 100 | 0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z |
lloydg | 0:ce5a25daadce | 101 | 0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // { |
lloydg | 0:ce5a25daadce | 102 | 0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // | |
lloydg | 0:ce5a25daadce | 103 | 0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // } |
lloydg | 0:ce5a25daadce | 104 | 0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~ |
lloydg | 0:ce5a25daadce | 105 | 0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL |
lloydg | 0:ce5a25daadce | 106 | |
lloydg | 0:ce5a25daadce | 107 | |
lloydg | 0:ce5a25daadce | 108 | GraphicsDisplay::GraphicsDisplay(const char *name):TextDisplay(name) { |
lloydg | 0:ce5a25daadce | 109 | foreground(0xFFFF); |
lloydg | 0:ce5a25daadce | 110 | background(0x0000); |
lloydg | 0:ce5a25daadce | 111 | } |
lloydg | 0:ce5a25daadce | 112 | |
lloydg | 0:ce5a25daadce | 113 | void GraphicsDisplay::character(int column, int row, int value) { |
lloydg | 0:ce5a25daadce | 114 | blitbit(column * 8, row * 8, 8, 8, (char*)&(FONT8x8[value - 0x1F][0])); |
lloydg | 0:ce5a25daadce | 115 | } |
lloydg | 0:ce5a25daadce | 116 | |
lloydg | 0:ce5a25daadce | 117 | void GraphicsDisplay::window(unsigned int x, unsigned int y, unsigned int w, unsigned int h) { |
lloydg | 0:ce5a25daadce | 118 | // current pixel location |
lloydg | 0:ce5a25daadce | 119 | _x = x; |
lloydg | 0:ce5a25daadce | 120 | _y = y; |
lloydg | 0:ce5a25daadce | 121 | // window settings |
lloydg | 0:ce5a25daadce | 122 | _x1 = x; |
lloydg | 0:ce5a25daadce | 123 | _x2 = x + w - 1; |
lloydg | 0:ce5a25daadce | 124 | _y1 = y; |
lloydg | 0:ce5a25daadce | 125 | _y2 = y + h - 1; |
lloydg | 0:ce5a25daadce | 126 | } |
lloydg | 0:ce5a25daadce | 127 | |
lloydg | 0:ce5a25daadce | 128 | void GraphicsDisplay::putp(int colour) { |
lloydg | 0:ce5a25daadce | 129 | // put pixel at current pixel location |
lloydg | 0:ce5a25daadce | 130 | pixel(_x, _y, colour); |
lloydg | 0:ce5a25daadce | 131 | // update pixel location based on window settings |
lloydg | 0:ce5a25daadce | 132 | _x++; |
lloydg | 0:ce5a25daadce | 133 | if(_x > _x2) { |
lloydg | 0:ce5a25daadce | 134 | _x = _x1; |
lloydg | 0:ce5a25daadce | 135 | _y++; |
lloydg | 0:ce5a25daadce | 136 | if(_y > _y2) { |
lloydg | 0:ce5a25daadce | 137 | _y = _y1; |
lloydg | 0:ce5a25daadce | 138 | } |
lloydg | 0:ce5a25daadce | 139 | } |
lloydg | 0:ce5a25daadce | 140 | } |
lloydg | 0:ce5a25daadce | 141 | |
lloydg | 0:ce5a25daadce | 142 | void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) { |
lloydg | 0:ce5a25daadce | 143 | int pixels = w*h; |
lloydg | 0:ce5a25daadce | 144 | |
lloydg | 0:ce5a25daadce | 145 | window(x, y, w, h); |
lloydg | 0:ce5a25daadce | 146 | for(int i=0; i<pixels; i++) { |
lloydg | 0:ce5a25daadce | 147 | putp(colour); |
lloydg | 0:ce5a25daadce | 148 | } |
lloydg | 0:ce5a25daadce | 149 | } |
lloydg | 0:ce5a25daadce | 150 | |
lloydg | 0:ce5a25daadce | 151 | void GraphicsDisplay::cls() { |
lloydg | 0:ce5a25daadce | 152 | fill(0, 0, width(), height(), _background); |
lloydg | 0:ce5a25daadce | 153 | } |
lloydg | 0:ce5a25daadce | 154 | |
lloydg | 0:ce5a25daadce | 155 | void GraphicsDisplay::blit(int x, int y, int w, int h, const int *colour) { |
lloydg | 0:ce5a25daadce | 156 | int pixels = w*h; |
lloydg | 0:ce5a25daadce | 157 | |
lloydg | 0:ce5a25daadce | 158 | window(x, y, w, h); |
lloydg | 0:ce5a25daadce | 159 | for(int i=0; i<pixels; i++) { |
lloydg | 0:ce5a25daadce | 160 | putp(colour[i]); |
lloydg | 0:ce5a25daadce | 161 | } |
lloydg | 0:ce5a25daadce | 162 | } |
lloydg | 0:ce5a25daadce | 163 | |
lloydg | 0:ce5a25daadce | 164 | void GraphicsDisplay::blitbit(int x, int y, int w, int h, const char* colour) { |
lloydg | 0:ce5a25daadce | 165 | int pixels = w*h; |
lloydg | 0:ce5a25daadce | 166 | |
lloydg | 0:ce5a25daadce | 167 | window(x, y, w, h); |
lloydg | 0:ce5a25daadce | 168 | for(int i = 0; i < pixels; i++) { |
lloydg | 0:ce5a25daadce | 169 | char byte = colour[i >> 3]; |
lloydg | 0:ce5a25daadce | 170 | int offset = i & 0x7; |
lloydg | 0:ce5a25daadce | 171 | int c = ((byte << offset) & 0x80) ? _foreground : _background; |
lloydg | 0:ce5a25daadce | 172 | putp(c); |
lloydg | 0:ce5a25daadce | 173 | } |
lloydg | 0:ce5a25daadce | 174 | } |
lloydg | 0:ce5a25daadce | 175 | |
lloydg | 0:ce5a25daadce | 176 | int GraphicsDisplay::columns() { |
lloydg | 0:ce5a25daadce | 177 | return width() / 8; |
lloydg | 0:ce5a25daadce | 178 | } |
lloydg | 0:ce5a25daadce | 179 | |
lloydg | 0:ce5a25daadce | 180 | int GraphicsDisplay::rows() { |
lloydg | 0:ce5a25daadce | 181 | return height() / 8; |
lloydg | 0:ce5a25daadce | 182 | } |
lloydg | 0:ce5a25daadce | 183 |