Alphanumeric LED display, 8 digits, 5x7 pattern. Supports 8x1, 8x2, 16x1 and 16x2 display configuration.

Dependents:   mbed_HCMS2975

Alphanumeric LED display, 8 digits, 5x7 LED pattern. The device has SPI interface. The library supports multiple devices connected in a daisy chain. This provides a 8x1, 8x2, 16x1 and 16x2 display configuration.The library methods are similar to those used for the LCDText library.

/media/uploads/wim/hcms2975.jpg

These displays are from mid 80s to mid 90s and they look cool, but they are rather expensive ($100 a piece..). The lib was developed and tested with displays salvaged from some equipment. You see them mostly in HP printers, medical equipment etc.

Some info can be found here and here.

Datasheet is here

Committer:
wim
Date:
Wed Oct 15 16:46:12 2014 +0000
Revision:
0:a332431006fb
Child:
1:f46d90374eb2
Alphanumeric LED display, 8 digits, 5x7 pattern. Initial library release. Supports 8x1, 8x2, 16x1 and 16x2 display configuration.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:a332431006fb 1 /**
wim 0:a332431006fb 2 * @file HCMS2975.cpp
wim 0:a332431006fb 3 * @brief mbed Avago/HP HCMS2975 LED matrix display Library.
wim 0:a332431006fb 4 * @author WH
wim 0:a332431006fb 5 * @date Copyright (c) 2014
wim 0:a332431006fb 6 * v01: WH, Initial release
wim 0:a332431006fb 7 * Info available at http://playground.arduino.cc/Main/LedDisplay and http://www.pjrc.com/teensy/td_libs_LedDisplay.html
wim 0:a332431006fb 8 *
wim 0:a332431006fb 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 0:a332431006fb 10 * of this software and associated documentation files (the "Software"), to deal
wim 0:a332431006fb 11 * in the Software without restriction, including without limitation the rights
wim 0:a332431006fb 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 0:a332431006fb 13 * copies of the Software, and to permit persons to whom the Software is
wim 0:a332431006fb 14 * furnished to do so, subject to the following conditions:
wim 0:a332431006fb 15 *
wim 0:a332431006fb 16 * The above copyright notice and this permission notice shall be included in
wim 0:a332431006fb 17 * all copies or substantial portions of the Software.
wim 0:a332431006fb 18 *
wim 0:a332431006fb 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 0:a332431006fb 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 0:a332431006fb 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 0:a332431006fb 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 0:a332431006fb 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 0:a332431006fb 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 0:a332431006fb 25 * THE SOFTWARE.
wim 0:a332431006fb 26 */
wim 0:a332431006fb 27 #include "mbed.h"
wim 0:a332431006fb 28 #include "HCMS2975.h"
wim 0:a332431006fb 29 #include "font_5x7.h" // Pascal Stang's 5x7 font library
wim 0:a332431006fb 30
wim 0:a332431006fb 31 // User Defined Characters (UDCs) are defined by a 5 byte bitpattern. The P0..P6 form the character pattern, P7 is ignored.
wim 0:a332431006fb 32 // Byte0 Byte1 Byte2 Byte3 Byte4
wim 0:a332431006fb 33 // b0 P0 P0 P0 P0 P0
wim 0:a332431006fb 34 // b1 P1 P1 P1 P1 P1
wim 0:a332431006fb 35 // . .............
wim 0:a332431006fb 36 // b6 P6 P6 P6 P6 P6
wim 0:a332431006fb 37 // b7 x x x x x
wim 0:a332431006fb 38
wim 0:a332431006fb 39 /** Some sample User Defined Chars 5x7 dots */
wim 0:a332431006fb 40 const char udc_0[] = {0x7F, 0x41, 0x22, 0x14, 0x08}; /* |> */
wim 0:a332431006fb 41 const char udc_1[] = {0x08, 0x14, 0x22, 0x41, 0x7F}; /* <| */
wim 0:a332431006fb 42 const char udc_2[] = {0x7F, 0x00, 0x00, 0x00, 0x00}; /* | */
wim 0:a332431006fb 43 const char udc_3[] = {0x7F, 0x00, 0x7F, 0x00, 0x00}; /* || */
wim 0:a332431006fb 44 const char udc_4[] = {0x7F, 0x00, 0x7F, 0x00, 0x7F}; /* ||| */
wim 0:a332431006fb 45 const char udc_5[] = {0x2A, 0x2A, 0x2A, 0x2A, 0x2A}; /* = */
wim 0:a332431006fb 46 const char udc_6[] = {0x55, 0x2A, 0x55, 0x2A, 0x55}; /* checkerboard */
wim 0:a332431006fb 47 const char udc_7[] = {0x01, 0x02, 0x04, 0x08, 0x10}; /* \ */
wim 0:a332431006fb 48
wim 0:a332431006fb 49 const char udc_Bat_Hi[] = {0x7E, 0x7F, 0x7F, 0x7F, 0x7E}; /* Battery Full */
wim 0:a332431006fb 50 const char udc_Bat_Ha[] = {0x7E, 0x7D, 0x7D, 0x7D, 0x7E}; /* Battery Half */
wim 0:a332431006fb 51 const char udc_Bat_Lo[] = {0x7E, 0x61, 0x61, 0x61, 0x7E}; /* Battery Low */
wim 0:a332431006fb 52 const char udc_AC[] = {0x0C, 0x17, 0x74, 0x17, 0x0C}; /* AC Power */
wim 0:a332431006fb 53 const char udc_smiley[] = {0x10, 0x22, 0x28, 0x22, 0x10}; /* Smiley */
wim 0:a332431006fb 54
wim 0:a332431006fb 55 /** Create an HCMS2975 Display object connected to the proper pins
wim 0:a332431006fb 56 *
wim 0:a332431006fb 57 * @param *spi SPI port
wim 0:a332431006fb 58 * @param cs PinName for Chip Select (active low)
wim 0:a332431006fb 59 * @param rs PinName for RS ()
wim 0:a332431006fb 60 * @param rst PinName for Rst (active low, optional, default=NC)
wim 0:a332431006fb 61 * @param type Sets the panel size (default = LED8x1)
wim 0:a332431006fb 62 */
wim 0:a332431006fb 63 HCMS2975::HCMS2975(SPI *spi, PinName cs, PinName rs, PinName rst, LEDType type) : _spi(spi), _cs(cs), _rs(rs), _type(type) {
wim 0:a332431006fb 64
wim 0:a332431006fb 65 // Extract LCDType data
wim 0:a332431006fb 66
wim 0:a332431006fb 67 // Columns encoded in b7..b0
wim 0:a332431006fb 68 _nr_cols = (_type & 0xFF);
wim 0:a332431006fb 69
wim 0:a332431006fb 70 // Rows encoded in b15..b8
wim 0:a332431006fb 71 _nr_rows = ((_type >> 8) & 0xFF);
wim 0:a332431006fb 72
wim 0:a332431006fb 73 _displaySize = _nr_cols * _nr_rows;
wim 0:a332431006fb 74
wim 0:a332431006fb 75 // Number of devices encoded in b23..b16
wim 0:a332431006fb 76 _deviceCount = ((_type >> 16) & 0xFF);
wim 0:a332431006fb 77
wim 0:a332431006fb 78
wim 0:a332431006fb 79 // The hardware Reset pin is optional. Test and make sure whether it exists or not to prevent illegal access.
wim 0:a332431006fb 80 if (rst != NC) {
wim 0:a332431006fb 81 _rst = new DigitalOut(rst); //Construct new pin
wim 0:a332431006fb 82 _rst->write(1); //Deactivate
wim 0:a332431006fb 83 }
wim 0:a332431006fb 84 else {
wim 0:a332431006fb 85 // No Hardware Backlight pin
wim 0:a332431006fb 86 _rst = NULL; //Construct dummy pin
wim 0:a332431006fb 87 }
wim 0:a332431006fb 88
wim 0:a332431006fb 89 _init();
wim 0:a332431006fb 90 }
wim 0:a332431006fb 91
wim 0:a332431006fb 92 /** Destructor for HCMS2975 Display object
wim 0:a332431006fb 93 *
wim 0:a332431006fb 94 */
wim 0:a332431006fb 95 HCMS2975::~HCMS2975() {
wim 0:a332431006fb 96 if (_rst != NULL) {delete _rst;} // RST pin
wim 0:a332431006fb 97 }
wim 0:a332431006fb 98
wim 0:a332431006fb 99 #if(HCMS2975_PRINTF != 1)
wim 0:a332431006fb 100 /** Write a character to the Display
wim 0:a332431006fb 101 *
wim 0:a332431006fb 102 * @param c The character to write to the display
wim 0:a332431006fb 103 */
wim 0:a332431006fb 104 int HCMS2975::putc(int c){
wim 0:a332431006fb 105 return _putc(c);
wim 0:a332431006fb 106 }
wim 0:a332431006fb 107
wim 0:a332431006fb 108 /** Write a raw string to the Display
wim 0:a332431006fb 109 *
wim 0:a332431006fb 110 * @param string text, may be followed by variables to emulate formatting the string.
wim 0:a332431006fb 111 * However, printf formatting is NOT supported and variables will be ignored!
wim 0:a332431006fb 112 */
wim 0:a332431006fb 113 int HCMS2975::printf(const char* text, ...) {
wim 0:a332431006fb 114
wim 0:a332431006fb 115 while (*text !=0) {
wim 0:a332431006fb 116 _putc(*text);
wim 0:a332431006fb 117 text++;
wim 0:a332431006fb 118 }
wim 0:a332431006fb 119 return 0;
wim 0:a332431006fb 120 }
wim 0:a332431006fb 121 #else
wim 0:a332431006fb 122 #if DOXYGEN_ONLY
wim 0:a332431006fb 123 /** Write a character to the Display
wim 0:a332431006fb 124 *
wim 0:a332431006fb 125 * @param c The character to write to the display
wim 0:a332431006fb 126 */
wim 0:a332431006fb 127 int HCMS2975::putc(int c){
wim 0:a332431006fb 128 return _putc(c);
wim 0:a332431006fb 129 }
wim 0:a332431006fb 130
wim 0:a332431006fb 131 /** Write a formatted string to the Display
wim 0:a332431006fb 132 *
wim 0:a332431006fb 133 * @param format A printf-style format string, followed by the
wim 0:a332431006fb 134 * variables to use in formatting the string.
wim 0:a332431006fb 135 */
wim 0:a332431006fb 136 int HCMS2975::printf(const char* format, ...){
wim 0:a332431006fb 137 }
wim 0:a332431006fb 138 #endif
wim 0:a332431006fb 139
wim 0:a332431006fb 140 #endif
wim 0:a332431006fb 141
wim 0:a332431006fb 142 /** Clear the screen and locate to 0,0
wim 0:a332431006fb 143 */
wim 0:a332431006fb 144 void HCMS2975::cls(){
wim 0:a332431006fb 145
wim 0:a332431006fb 146 // fill _displayBuffer with spaces
wim 0:a332431006fb 147 for (int i=0; i < HCMS2975_BUFFER_SIZE; i++) {
wim 0:a332431006fb 148 _displayBuffer[i] = ' ';
wim 0:a332431006fb 149 }
wim 0:a332431006fb 150
wim 0:a332431006fb 151 // display buffer
wim 0:a332431006fb 152 _pushBuffer();
wim 0:a332431006fb 153
wim 0:a332431006fb 154 //cursor
wim 0:a332431006fb 155 _row = 0;
wim 0:a332431006fb 156 _column = 0;
wim 0:a332431006fb 157 }
wim 0:a332431006fb 158
wim 0:a332431006fb 159 /** Locate cursor to a screen column and row
wim 0:a332431006fb 160 *
wim 0:a332431006fb 161 * @param column The horizontal position from the left, indexed from 0
wim 0:a332431006fb 162 * @param row The vertical position from the top, indexed from 0
wim 0:a332431006fb 163 */
wim 0:a332431006fb 164 void HCMS2975::locate(int column, int row){
wim 0:a332431006fb 165
wim 0:a332431006fb 166 // Sanity Check column
wim 0:a332431006fb 167 if (column < 0) {
wim 0:a332431006fb 168 _column = 0;
wim 0:a332431006fb 169 }
wim 0:a332431006fb 170 else {
wim 0:a332431006fb 171 if (column >= _nr_cols) {
wim 0:a332431006fb 172 _column = _nr_cols - 1;
wim 0:a332431006fb 173 }
wim 0:a332431006fb 174 else {
wim 0:a332431006fb 175 _column = column;
wim 0:a332431006fb 176 }
wim 0:a332431006fb 177 }
wim 0:a332431006fb 178
wim 0:a332431006fb 179 // Sanity Check row
wim 0:a332431006fb 180 if (row < 0) {
wim 0:a332431006fb 181 _row = 0;
wim 0:a332431006fb 182 }
wim 0:a332431006fb 183 else {
wim 0:a332431006fb 184 if (row >= _nr_rows) {
wim 0:a332431006fb 185 _row = _nr_rows - 1;
wim 0:a332431006fb 186 }
wim 0:a332431006fb 187 else {
wim 0:a332431006fb 188 _row = row;
wim 0:a332431006fb 189 }
wim 0:a332431006fb 190 }
wim 0:a332431006fb 191 }
wim 0:a332431006fb 192
wim 0:a332431006fb 193 /** Return the number of columns
wim 0:a332431006fb 194 *
wim 0:a332431006fb 195 * @param return The number of columns
wim 0:a332431006fb 196 */
wim 0:a332431006fb 197 int HCMS2975::columns() {
wim 0:a332431006fb 198
wim 0:a332431006fb 199 // Columns encoded in b7..b0
wim 0:a332431006fb 200 //return (_type & 0xFF);
wim 0:a332431006fb 201 return _nr_cols;
wim 0:a332431006fb 202 }
wim 0:a332431006fb 203
wim 0:a332431006fb 204 /** Return the number of rows
wim 0:a332431006fb 205 *
wim 0:a332431006fb 206 * @param return The number of rows
wim 0:a332431006fb 207 */
wim 0:a332431006fb 208 int HCMS2975::rows() {
wim 0:a332431006fb 209
wim 0:a332431006fb 210 // Rows encoded in b15..b8
wim 0:a332431006fb 211 //return ((_type >> 8) & 0xFF);
wim 0:a332431006fb 212 return _nr_rows;
wim 0:a332431006fb 213 }
wim 0:a332431006fb 214
wim 0:a332431006fb 215
wim 0:a332431006fb 216 /** Set Brightness
wim 0:a332431006fb 217 *
wim 0:a332431006fb 218 * @param brightness The brightness level (valid range 0..15)
wim 0:a332431006fb 219 */
wim 0:a332431006fb 220 void HCMS2975::setBrightness(uint8_t brightness){
wim 0:a332431006fb 221
wim 0:a332431006fb 222 _brightness = brightness & 0x0F;
wim 0:a332431006fb 223
wim 0:a332431006fb 224 //Set brightness
wim 0:a332431006fb 225 //Set display to normal
wim 0:a332431006fb 226 _writeCommand(HCMS2975_CONTROL0 | HCMS2975_NORMAL | _peak | _brightness);
wim 0:a332431006fb 227 }
wim 0:a332431006fb 228
wim 0:a332431006fb 229 /** Set the Displaymode
wim 0:a332431006fb 230 *
wim 0:a332431006fb 231 * @param displayMode The Display mode (DispOff, DispOn)
wim 0:a332431006fb 232 */
wim 0:a332431006fb 233 void HCMS2975::setMode(DisplayMode displayMode){
wim 0:a332431006fb 234
wim 0:a332431006fb 235 if (displayMode == DispOff) {
wim 0:a332431006fb 236 //Set brightness to Zero
wim 0:a332431006fb 237 _writeCommand(HCMS2975_CONTROL0 | HCMS2975_NORMAL | _peak | HCMS2975_BRIGHT_0);
wim 0:a332431006fb 238 // //Set Sleep mode
wim 0:a332431006fb 239 // _writeCommand(HCMS2975_CONTROL0 | HCMS2975_SLP | _peak | _brightness);
wim 0:a332431006fb 240 }
wim 0:a332431006fb 241 else {
wim 0:a332431006fb 242 //Restore brightness
wim 0:a332431006fb 243 //Set display to normal
wim 0:a332431006fb 244 _writeCommand(HCMS2975_CONTROL0 | HCMS2975_NORMAL | _peak | _brightness);
wim 0:a332431006fb 245 }
wim 0:a332431006fb 246 }
wim 0:a332431006fb 247
wim 0:a332431006fb 248 /** Set User Defined Characters (UDC)
wim 0:a332431006fb 249 *
wim 0:a332431006fb 250 * @param unsigned char c The Index of the UDC (0..7)
wim 0:a332431006fb 251 * @param char *udc_data The bitpatterns for the UDC (5 bytes of 7 significant bits for bitpattern)
wim 0:a332431006fb 252 */
wim 0:a332431006fb 253 void HCMS2975::setUDC(unsigned char c, char *udc_data){
wim 0:a332431006fb 254 char *udc;
wim 0:a332431006fb 255 int idx;
wim 0:a332431006fb 256
wim 0:a332431006fb 257 c = c & 0x07; // mask to valid range
wim 0:a332431006fb 258
wim 0:a332431006fb 259 udc = (char *) _udc[c];
wim 0:a332431006fb 260
wim 0:a332431006fb 261 // Copy UDC data to local UDC memory
wim 0:a332431006fb 262 for (idx=0; idx < 5; idx++) {
wim 0:a332431006fb 263 *udc++ = *udc_data++;
wim 0:a332431006fb 264 }
wim 0:a332431006fb 265 }
wim 0:a332431006fb 266
wim 0:a332431006fb 267
wim 0:a332431006fb 268 /** Low level Reset method for controller
wim 0:a332431006fb 269 */
wim 0:a332431006fb 270 void HCMS2975::_reset(){
wim 0:a332431006fb 271
wim 0:a332431006fb 272 // Reset when pin defined
wim 0:a332431006fb 273 if (_rst) {
wim 0:a332431006fb 274 _rst->write(0);
wim 0:a332431006fb 275 wait_us(500);
wim 0:a332431006fb 276 _rst->write(1);
wim 0:a332431006fb 277 }
wim 0:a332431006fb 278 }
wim 0:a332431006fb 279
wim 0:a332431006fb 280 /** Low level Init method for controller
wim 0:a332431006fb 281 */
wim 0:a332431006fb 282 void HCMS2975::_init(){
wim 0:a332431006fb 283
wim 0:a332431006fb 284 // Hard Reset
wim 0:a332431006fb 285 _reset();
wim 0:a332431006fb 286
wim 0:a332431006fb 287 // Init CS en RS
wim 0:a332431006fb 288 _cs = 1;
wim 0:a332431006fb 289 _rs = 0;
wim 0:a332431006fb 290
wim 0:a332431006fb 291 // Setup the spi for 8 bit data, low steady state clock,
wim 0:a332431006fb 292 // rising edge capture, with a 500KHz or 1MHz clock rate
wim 0:a332431006fb 293 _spi->format(8,0);
wim 0:a332431006fb 294 _spi->frequency(1000000); // Max SCL is 5 MHz for HCMS2975
wim 0:a332431006fb 295 // _spi->frequency(50000); // Max SCL is 5 MHz for HCMS2975
wim 0:a332431006fb 296
wim 0:a332431006fb 297 //Clear display
wim 0:a332431006fb 298 cls();
wim 0:a332431006fb 299
wim 0:a332431006fb 300 // default display brightness and peak
wim 0:a332431006fb 301 _brightness = HCMS2975_DEF_BRIGHT;
wim 0:a332431006fb 302 _peak = HCMS2975_DEF_PEAK;
wim 0:a332431006fb 303
wim 0:a332431006fb 304 //Set display to normal
wim 0:a332431006fb 305 _writeCommand(HCMS2975_CONTROL0 | HCMS2975_NORMAL | _peak | _brightness);
wim 0:a332431006fb 306
wim 0:a332431006fb 307 }
wim 0:a332431006fb 308
wim 0:a332431006fb 309
wim 0:a332431006fb 310 /** Low level command byte write operation.
wim 0:a332431006fb 311 * @param command commandbyte to write
wim 0:a332431006fb 312 */
wim 0:a332431006fb 313 void HCMS2975::_writeCommand(uint8_t command){
wim 0:a332431006fb 314 int cnt;
wim 0:a332431006fb 315
wim 0:a332431006fb 316 // Set RS
wim 0:a332431006fb 317 _rs = 1;
wim 0:a332431006fb 318 wait_us(1);
wim 0:a332431006fb 319
wim 0:a332431006fb 320 // Enable CS
wim 0:a332431006fb 321 _cs = 0;
wim 0:a332431006fb 322 wait_us(1);
wim 0:a332431006fb 323
wim 0:a332431006fb 324 // Must write the command to all devices...!
wim 0:a332431006fb 325 // Note that internally the 8 digit display consist of 2 display devices with 4 digits each!
wim 0:a332431006fb 326 for (cnt=0; cnt < (_deviceCount << 1); cnt++) {
wim 0:a332431006fb 327 _spi->write(command);
wim 0:a332431006fb 328 // wait_us(1); // Min setup time is x ns for HCMS2975
wim 0:a332431006fb 329 }
wim 0:a332431006fb 330
wim 0:a332431006fb 331 // Disable CS
wim 0:a332431006fb 332 _cs = 1;
wim 0:a332431006fb 333
wim 0:a332431006fb 334 // Reset RS
wim 0:a332431006fb 335 _rs = 0;
wim 0:a332431006fb 336
wim 0:a332431006fb 337 }
wim 0:a332431006fb 338
wim 0:a332431006fb 339 /** Low level _dataBuffer write operation.
wim 0:a332431006fb 340 */
wim 0:a332431006fb 341 void HCMS2975::_pushBuffer(){
wim 0:a332431006fb 342 char charcode;
wim 0:a332431006fb 343 char *fnt_ptr;
wim 0:a332431006fb 344 int idx, pidx;
wim 0:a332431006fb 345
wim 0:a332431006fb 346 // Reset RS
wim 0:a332431006fb 347 _rs = 0;
wim 0:a332431006fb 348 wait_us(1);
wim 0:a332431006fb 349
wim 0:a332431006fb 350 // Enable CS
wim 0:a332431006fb 351 _cs = 0;
wim 0:a332431006fb 352 wait_us(1);
wim 0:a332431006fb 353
wim 0:a332431006fb 354 // Encode and push the character data to the display
wim 0:a332431006fb 355 for (idx=0; idx < _displaySize; idx++) {
wim 0:a332431006fb 356 charcode = _displayBuffer[idx];
wim 0:a332431006fb 357
wim 0:a332431006fb 358 //Sanity check and font pointer
wim 0:a332431006fb 359 if (charcode < 0x08) {
wim 0:a332431006fb 360 //UDC
wim 0:a332431006fb 361 fnt_ptr = (char *) _udc[charcode];
wim 0:a332431006fb 362 }
wim 0:a332431006fb 363 else {
wim 0:a332431006fb 364 if ((charcode < 0x20) || (charcode > 0x7F)) {
wim 0:a332431006fb 365 // non-printable, show 'space'
wim 0:a332431006fb 366 fnt_ptr = (char *) font_5x7[0];
wim 0:a332431006fb 367 }
wim 0:a332431006fb 368 else {
wim 0:a332431006fb 369 //Pointer to char pattern
wim 0:a332431006fb 370 fnt_ptr = (char *) font_5x7[charcode - 0x20];
wim 0:a332431006fb 371 }
wim 0:a332431006fb 372 } // end sanity check
wim 0:a332431006fb 373
wim 0:a332431006fb 374 //Write char pattern of 5 bytes
wim 0:a332431006fb 375 for (pidx=0; pidx < 5; pidx++) {
wim 0:a332431006fb 376 _spi->write(*fnt_ptr);
wim 0:a332431006fb 377 fnt_ptr++;
wim 0:a332431006fb 378 //wait_us(1); // Min setup time is x ns for HCMS2975
wim 0:a332431006fb 379 } //for pidx
wim 0:a332431006fb 380
wim 0:a332431006fb 381 } //for idx
wim 0:a332431006fb 382
wim 0:a332431006fb 383 // Disable CS
wim 0:a332431006fb 384 _cs = 1;
wim 0:a332431006fb 385
wim 0:a332431006fb 386 }
wim 0:a332431006fb 387
wim 0:a332431006fb 388
wim 0:a332431006fb 389 // Stream implementation functions
wim 0:a332431006fb 390 int HCMS2975::_putc(int value){
wim 0:a332431006fb 391
wim 0:a332431006fb 392 if ((value == '\n') || (value == '\r')) {
wim 0:a332431006fb 393 //No character to write
wim 0:a332431006fb 394
wim 0:a332431006fb 395 //Update Cursor
wim 0:a332431006fb 396 _column = 0;
wim 0:a332431006fb 397 _row++;
wim 0:a332431006fb 398 if (_row >= _nr_rows) {
wim 0:a332431006fb 399 _row = 0;
wim 0:a332431006fb 400 }
wim 0:a332431006fb 401
wim 0:a332431006fb 402 return 0;
wim 0:a332431006fb 403 }
wim 0:a332431006fb 404 else {
wim 0:a332431006fb 405 //Character to write
wim 0:a332431006fb 406 _displayBuffer[(_row * _nr_cols) + _column] = value;
wim 0:a332431006fb 407
wim 0:a332431006fb 408 //Update Cursor
wim 0:a332431006fb 409 _column++;
wim 0:a332431006fb 410 if (_column >= _nr_cols) {
wim 0:a332431006fb 411 _column = 0;
wim 0:a332431006fb 412 _row++;
wim 0:a332431006fb 413 if (_row >= _nr_rows) {
wim 0:a332431006fb 414 _row = 0;
wim 0:a332431006fb 415 }
wim 0:a332431006fb 416 }
wim 0:a332431006fb 417
wim 0:a332431006fb 418 // push new data to display
wim 0:a332431006fb 419 _pushBuffer();
wim 0:a332431006fb 420
wim 0:a332431006fb 421 return 0;
wim 0:a332431006fb 422 } //else
wim 0:a332431006fb 423
wim 0:a332431006fb 424 }
wim 0:a332431006fb 425
wim 0:a332431006fb 426
wim 0:a332431006fb 427 // Stream implementation functions
wim 0:a332431006fb 428 int HCMS2975::_getc(){
wim 0:a332431006fb 429 return -1;
wim 0:a332431006fb 430 }
wim 0:a332431006fb 431
wim 0:a332431006fb 432 #if(0)
wim 0:a332431006fb 433 /** Returns the version number of the library
wim 0:a332431006fb 434 * @return int version number
wim 0:a332431006fb 435 */
wim 0:a332431006fb 436 int HCMS2975::getVersion() {
wim 0:a332431006fb 437 return HCMS2975_VERSION
wim 0:a332431006fb 438 }
wim 0:a332431006fb 439 #endif