![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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/TextDisplay.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/TextDisplay.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 TextDisplay 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 "TextDisplay.h" |
lloydg | 0:ce5a25daadce | 7 | |
lloydg | 0:ce5a25daadce | 8 | TextDisplay::TextDisplay(const char *name) : Stream(name){ |
lloydg | 0:ce5a25daadce | 9 | _row = 0; |
lloydg | 0:ce5a25daadce | 10 | _column = 0; |
lloydg | 0:ce5a25daadce | 11 | if (name == NULL) { |
lloydg | 0:ce5a25daadce | 12 | _path = NULL; |
lloydg | 0:ce5a25daadce | 13 | } else { |
lloydg | 0:ce5a25daadce | 14 | _path = new char[strlen(name) + 2]; |
lloydg | 0:ce5a25daadce | 15 | sprintf(_path, "/%s", name); |
lloydg | 0:ce5a25daadce | 16 | } |
lloydg | 0:ce5a25daadce | 17 | } |
lloydg | 0:ce5a25daadce | 18 | |
lloydg | 0:ce5a25daadce | 19 | int TextDisplay::_putc(int value) { |
lloydg | 0:ce5a25daadce | 20 | if(value == '\n') { |
lloydg | 0:ce5a25daadce | 21 | _column = 0; |
lloydg | 0:ce5a25daadce | 22 | _row++; |
lloydg | 0:ce5a25daadce | 23 | if(_row >= rows()) { |
lloydg | 0:ce5a25daadce | 24 | _row = 0; |
lloydg | 0:ce5a25daadce | 25 | } |
lloydg | 0:ce5a25daadce | 26 | } else { |
lloydg | 0:ce5a25daadce | 27 | character(_column, _row, value); |
lloydg | 0:ce5a25daadce | 28 | _column++; |
lloydg | 0:ce5a25daadce | 29 | if(_column >= columns()) { |
lloydg | 0:ce5a25daadce | 30 | _column = 0; |
lloydg | 0:ce5a25daadce | 31 | _row++; |
lloydg | 0:ce5a25daadce | 32 | if(_row >= rows()) { |
lloydg | 0:ce5a25daadce | 33 | _row = 0; |
lloydg | 0:ce5a25daadce | 34 | } |
lloydg | 0:ce5a25daadce | 35 | } |
lloydg | 0:ce5a25daadce | 36 | } |
lloydg | 0:ce5a25daadce | 37 | return value; |
lloydg | 0:ce5a25daadce | 38 | } |
lloydg | 0:ce5a25daadce | 39 | |
lloydg | 0:ce5a25daadce | 40 | // crude cls implementation, should generally be overwritten in derived class |
lloydg | 0:ce5a25daadce | 41 | void TextDisplay::cls() { |
lloydg | 0:ce5a25daadce | 42 | locate(0, 0); |
lloydg | 0:ce5a25daadce | 43 | for(int i=0; i<columns()*rows(); i++) { |
lloydg | 0:ce5a25daadce | 44 | putc(' '); |
lloydg | 0:ce5a25daadce | 45 | } |
lloydg | 0:ce5a25daadce | 46 | } |
lloydg | 0:ce5a25daadce | 47 | |
lloydg | 0:ce5a25daadce | 48 | void TextDisplay::locate(int column, int row) { |
lloydg | 0:ce5a25daadce | 49 | _column = column; |
lloydg | 0:ce5a25daadce | 50 | _row = row; |
lloydg | 0:ce5a25daadce | 51 | } |
lloydg | 0:ce5a25daadce | 52 | |
lloydg | 0:ce5a25daadce | 53 | int TextDisplay::_getc() { |
lloydg | 0:ce5a25daadce | 54 | return -1; |
lloydg | 0:ce5a25daadce | 55 | } |
lloydg | 0:ce5a25daadce | 56 | |
lloydg | 0:ce5a25daadce | 57 | void TextDisplay::foreground(uint16_t colour) { |
lloydg | 0:ce5a25daadce | 58 | _foreground = colour; |
lloydg | 0:ce5a25daadce | 59 | } |
lloydg | 0:ce5a25daadce | 60 | |
lloydg | 0:ce5a25daadce | 61 | void TextDisplay::background(uint16_t colour) { |
lloydg | 0:ce5a25daadce | 62 | _background = colour; |
lloydg | 0:ce5a25daadce | 63 | } |
lloydg | 0:ce5a25daadce | 64 | |
lloydg | 0:ce5a25daadce | 65 | bool TextDisplay::claim (FILE *stream) { |
lloydg | 0:ce5a25daadce | 66 | if ( _path == NULL) { |
lloydg | 0:ce5a25daadce | 67 | fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n"); |
lloydg | 0:ce5a25daadce | 68 | return false; |
lloydg | 0:ce5a25daadce | 69 | } |
lloydg | 0:ce5a25daadce | 70 | if (freopen(_path, "w", stream) == NULL) { |
lloydg | 0:ce5a25daadce | 71 | // Failed, should not happen |
lloydg | 0:ce5a25daadce | 72 | return false; |
lloydg | 0:ce5a25daadce | 73 | } |
lloydg | 0:ce5a25daadce | 74 | // make sure we use line buffering |
lloydg | 0:ce5a25daadce | 75 | setvbuf(stdout, NULL, _IOLBF, columns()); |
lloydg | 0:ce5a25daadce | 76 | return true; |
lloydg | 0:ce5a25daadce | 77 | } |