Software driver for Luminex LCD-S401M16KR LCD Numeric Display Modules 4 Digit 0.17" 7 Seg Reflective

Committer:
sam_grove
Date:
Fri May 09 16:21:33 2014 +0000
Revision:
3:eb13032e5355
Parent:
2:40d866178150
another change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:69395ca729e6 1 /**
sam_grove 0:69395ca729e6 2 * @file S401M16KR.h
sam_grove 0:69395ca729e6 3 * @brief Device driver - Luminex S401M16KR 4 character 7 segment LCD
sam_grove 0:69395ca729e6 4 * @author sam grove & __________
sam_grove 0:69395ca729e6 5 * @version 1.0
sam_grove 0:69395ca729e6 6 * @see http://www.lumex.com/specs/LCD-S401M16KR.pdf
sam_grove 0:69395ca729e6 7 *
sam_grove 0:69395ca729e6 8 * Copyright (c) 2013
sam_grove 0:69395ca729e6 9 *
sam_grove 0:69395ca729e6 10 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:69395ca729e6 11 * you may not use this file except in compliance with the License.
sam_grove 0:69395ca729e6 12 * You may obtain a copy of the License at
sam_grove 0:69395ca729e6 13 *
sam_grove 0:69395ca729e6 14 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:69395ca729e6 15 *
sam_grove 0:69395ca729e6 16 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:69395ca729e6 17 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:69395ca729e6 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:69395ca729e6 19 * See the License for the specific language governing permissions and
sam_grove 0:69395ca729e6 20 * limitations under the License.
sam_grove 0:69395ca729e6 21 */
sam_grove 0:69395ca729e6 22
sam_grove 0:69395ca729e6 23 #ifndef S401M16KR_H
sam_grove 0:69395ca729e6 24 #define S401M16KR_H
sam_grove 0:69395ca729e6 25
sam_grove 0:69395ca729e6 26 #include "mbed.h"
sam_grove 0:69395ca729e6 27
sam_grove 0:69395ca729e6 28 /** Using the Luminex S401M16KR on a Freescale FRDM-KL46Z
sam_grove 0:69395ca729e6 29 *
sam_grove 0:69395ca729e6 30 * Example:
sam_grove 0:69395ca729e6 31 * @code
sam_grove 0:69395ca729e6 32 * #include "mbed.h"
sam_grove 0:69395ca729e6 33 * #include "S401M16KR.h"
sam_grove 0:69395ca729e6 34 *
sam_grove 0:69395ca729e6 35 * S401M16KR lcd(PTD0, PTE4, PTB23, PTB22, PTC17, PTB21, PTB7, PTB8, PTE5, PTC18, PTB10, PTB11);
sam_grove 0:69395ca729e6 36 *
sam_grove 0:69395ca729e6 37 * int main()
sam_grove 0:69395ca729e6 38 * {
sam_grove 0:69395ca729e6 39 * int cnt = 0;
sam_grove 0:69395ca729e6 40 *
sam_grove 0:69395ca729e6 41 * time_t rawtime = time(NULL);
sam_grove 0:69395ca729e6 42 * struct tm *timeinfo = localtime(&rawtime);
sam_grove 0:69395ca729e6 43 * lcd.init();
sam_grove 0:69395ca729e6 44 * lcd.enable();
sam_grove 0:69395ca729e6 45 *
sam_grove 0:69395ca729e6 46 * while(1)
sam_grove 0:69395ca729e6 47 * {
sam_grove 0:69395ca729e6 48 * lcd.displayTime(12,45);
sam_grove 0:69395ca729e6 49 * wait(1.0f);
sam_grove 0:69395ca729e6 50 * lcd.displayTime(timeinfo);
sam_grove 0:69395ca729e6 51 * wait(1.0f);
sam_grove 0:69395ca729e6 52 * lcd.displayText("1234");
sam_grove 0:69395ca729e6 53 * wait(1.0f);
sam_grove 0:69395ca729e6 54 * lcd.displayTemp(26);
sam_grove 0:69395ca729e6 55 * wait(1.0f);
sam_grove 0:69395ca729e6 56 * lcd.printf("%s", asctime(timeinfo));
sam_grove 0:69395ca729e6 57 * wait(1.0f);
sam_grove 0:69395ca729e6 58 * lcd.printf("%d: Hello World\n", cnt++);
sam_grove 0:69395ca729e6 59 * wait(1.0f);
sam_grove 0:69395ca729e6 60 * lcd.puts("Goodbye");
sam_grove 0:69395ca729e6 61 * wait(1.0f);
sam_grove 0:69395ca729e6 62 * }
sam_grove 0:69395ca729e6 63 * }
sam_grove 0:69395ca729e6 64 * @endcode
sam_grove 0:69395ca729e6 65 */
sam_grove 0:69395ca729e6 66
sam_grove 0:69395ca729e6 67 /**
sam_grove 0:69395ca729e6 68 * @class S401M16KR
sam_grove 0:69395ca729e6 69 * @brief API for the Luminex S401M16KR 4 character 7 segment LCD
sam_grove 0:69395ca729e6 70 */
sam_grove 0:69395ca729e6 71 class S401M16KR
sam_grove 0:69395ca729e6 72 {
sam_grove 0:69395ca729e6 73 private:
sam_grove 0:69395ca729e6 74
sam_grove 0:69395ca729e6 75
sam_grove 0:69395ca729e6 76 public:
sam_grove 0:69395ca729e6 77
sam_grove 0:69395ca729e6 78 /** Create the S401M16KR object - pins not dynamically selectable
sam_grove 0:69395ca729e6 79 */
sam_grove 0:69395ca729e6 80 S401M16KR();
sam_grove 0:69395ca729e6 81
sam_grove 0:69395ca729e6 82 /** Create the S401M16KR object
sam_grove 0:69395ca729e6 83 * @param com0 - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 84 * @param com1 - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 85 * @param com2 - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 86 * @param com3 - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 87 * @param _1d_1e_1g_1f - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 88 * @param dp1_1c_1b_1a - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 89 * @param _2d_2e_2g_2f - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 90 * @param dp2_2c_2b_2a - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 91 * @param _3d_3e_3g_3f - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 92 * @param dp3_3c_3b_3a - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 93 * @param _4d_4e_4g_4f - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 94 * @param col_4c_4b_4a - Pin connected from LCD to MCU
sam_grove 0:69395ca729e6 95 */
sam_grove 0:69395ca729e6 96 S401M16KR(PinName com0, PinName com1, PinName com2, PinName com3
sam_grove 0:69395ca729e6 97 ,PinName _1d_1e_1g_1f, PinName dp1_1c_1b_1a, PinName _2d_2e_2g_2f, PinName dp2_2c_2b_2a
sam_grove 0:69395ca729e6 98 ,PinName _3d_3e_3g_3f, PinName dp3_3c_3b_3a, PinName _4d_4e_4g_4f, PinName col_4c_4b_4a);
sam_grove 0:69395ca729e6 99
sam_grove 0:69395ca729e6 100 /** Clear state variables and initilize the dependant objects
sam_grove 0:69395ca729e6 101 * could be made private and called from constructor if not needed
sam_grove 0:69395ca729e6 102 */
sam_grove 0:69395ca729e6 103 void init(void) const;
sam_grove 0:69395ca729e6 104
sam_grove 0:69395ca729e6 105 /** Turn on peripheral power and clocking
sam_grove 0:69395ca729e6 106 */
sam_grove 0:69395ca729e6 107 void enable(void) const;
sam_grove 0:69395ca729e6 108
sam_grove 0:69395ca729e6 109 /** Turn off peripheral power and clocking
sam_grove 0:69395ca729e6 110 */
sam_grove 0:69395ca729e6 111 void disable(void) const;
sam_grove 0:69395ca729e6 112
sam_grove 0:69395ca729e6 113 /** Scroll the display for text larger than 4 characters
sam_grove 0:69395ca729e6 114 */
sam_grove 0:69395ca729e6 115 void scrollSpeed(const float ms) const;
sam_grove 0:69395ca729e6 116
sam_grove 0:69395ca729e6 117 /** Write the time to the display
sam_grove 0:69395ca729e6 118 * @param hours - time of day in hours
sam_grove 0:69395ca729e6 119 * @param minutes - time of day in minutes
sam_grove 0:69395ca729e6 120 */
sam_grove 0:69395ca729e6 121 void displayTime(const int hours, const int minutes) const;
sam_grove 0:69395ca729e6 122
sam_grove 0:69395ca729e6 123 /** Write the time to the display
sam_grove 0:69395ca729e6 124 * @param time - the time of day as stored in struct tm
sam_grove 0:69395ca729e6 125 */
sam_grove 0:69395ca729e6 126 void displayTime(const struct tm time) const;
sam_grove 0:69395ca729e6 127
sam_grove 0:69395ca729e6 128 /** Write text to the display
sam_grove 0:69395ca729e6 129 * @param str - A string to write
sam_grove 0:69395ca729e6 130 * @param scroll - If the string is too long scroll the contents if true
sam_grove 0:69395ca729e6 131 */
sam_grove 0:69395ca729e6 132 void displayText(const char *str, const int scroll = 0) const;
sam_grove 0:69395ca729e6 133
sam_grove 0:69395ca729e6 134 /** Write temperature to the display
sam_grove 0:69395ca729e6 135 * @param temperature - a temperature value to display
sam_grove 0:69395ca729e6 136 * @param fahrenheit - If 0 the temperature is formatted as celcius (C) otherwise (T)
sam_grove 0:69395ca729e6 137 */
sam_grove 0:69395ca729e6 138 void displayTemp(const float temperature, const int fahrenheit = 0);
sam_grove 0:69395ca729e6 139
sam_grove 0:69395ca729e6 140 /** Write a formatted string to the display
sam_grove 0:69395ca729e6 141 * @param format - The string + format specifiers
sam_grove 0:69395ca729e6 142 * @param ... - additional arguments
sam_grove 0:69395ca729e6 143 * @return - the amount of characters that will be displayed
sam_grove 0:69395ca729e6 144 */
sam_grove 0:69395ca729e6 145 int printf(const char *format, ...);
sam_grove 0:69395ca729e6 146
sam_grove 0:69395ca729e6 147 /** Write a string to the display
sam_grove 0:69395ca729e6 148 * @param s - a string to be displayed
sam_grove 0:69395ca729e6 149 * @return - the amount of characters that will be displayed
sam_grove 0:69395ca729e6 150 */
sam_grove 0:69395ca729e6 151 int puts(const char *s);
sam_grove 0:69395ca729e6 152 };
sam_grove 0:69395ca729e6 153
sam_grove 3:eb13032e5355 154 #endif