Initial version for Modtronix LCD2S I2C and SPI serial LCD displays. For details, see http://modtronix.com/products-serial-lcd-board/
Diff: lcd2s.cpp
- Revision:
- 1:429b7d3f7b95
- Parent:
- 0:cea36bae632b
- Child:
- 2:fe0c1e27f362
--- a/lcd2s.cpp Sat Aug 01 05:16:38 2015 +0000 +++ b/lcd2s.cpp Tue Aug 04 18:54:37 2015 +1000 @@ -1,1 +1,69 @@ -//New File \ No newline at end of file +/** + * File: lcd2s.cpp + * + * Author: Modtronix Engineering - www.modtronix.com + * + * Description: + * + * Software License Agreement: + * This software has been written or modified by Modtronix Engineering. The code + * may be modified and can be used free of charge for commercial and non commercial + * applications. If this is modified software, any license conditions from original + * software also apply. Any redistribution must include reference to 'Modtronix + * Engineering' and web link(www.modtronix.com) in the file header. + * + * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, + * IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE + * COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + */ +#include "mbed.h" +#include "lcd2s.h" + +// DEFINES //////////////////////////////////////////////////////////////////// + + +// GLOBAL VARIABLES /////////////////////////////////////////////////////////// +#if (LCD2S_USE_MALLOC == 0) +uint8_t buf[80]; +uint32_t dirtyRows[4]; +#endif + +// Function Prototypes //////////////////////////////////////////////////////// + + +LCD2S::LCD2S(uint8_t rows/* = 4*/, uint8_t columns/* = 20*/) { + contrast = 200; + brightness = 200; + this->rows = rows; + this->columns = columns; + bufSize = rows * columns; + cursor_row = cursor_col = 0; + +#if (LCD2S_USE_MALLOC == 1) + buf = new uint8_t[bufSize)]; + dirtyRows = new uint32_t(rows); +#endif + + pBuf = buf; + pDirtyRows = dirtyRows; + memset(pBuf, ' ', sizeof(buf)); + memset(pDirtyRows, 0, 4 * rows); +} + +void LCD2S::clearDisplay() { + memset(pBuf, ' ', sizeof(buf)); + memset(pDirtyRows, 0xff, 4 * rows); +} + +void LCD2S::setCursor(int8_t row, int8_t col) { + cursor_row = row-1; + if(cursor_row > rows) + cursor_row = rows-1; + + cursor_col = col-1; + if(cursor_col > columns) + cursor_col = columns-1; +}; +