J.W. BRUCE / TTU_CSC1300

Dependents:   CSC1300_EduBaseV2_Lab0 mbed_blinky EduBaseV2_Lab0 mbed_blinky ... more

Committer:
jwbruce
Date:
Mon Jun 29 17:15:27 2020 +0000
Revision:
2:b1b9fba116c2
Parent:
1:62c831ab7306
Child:
3:8f43225dc286
added some "doxygen" to the .h file to better document the classes functions and attributes.  More dox will be forthcoming.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jwbruce 0:1201a9a37799 1 // macros, defines, globals,and prototypes for the TTU_F031 library
jwbruce 0:1201a9a37799 2
jwbruce 0:1201a9a37799 3 #ifndef TTU_CSC1300_H
jwbruce 0:1201a9a37799 4 #define TTU_CSC1300_H
jwbruce 0:1201a9a37799 5
jwbruce 0:1201a9a37799 6 #include "mbed.h"
jwbruce 0:1201a9a37799 7
jwbruce 0:1201a9a37799 8 /*************************************************************************
jwbruce 0:1201a9a37799 9 *
jwbruce 0:1201a9a37799 10 * DEFINES and MACROS
jwbruce 0:1201a9a37799 11 *
jwbruce 0:1201a9a37799 12 **************************************************************************/
jwbruce 0:1201a9a37799 13 #define FALSE 0
jwbruce 0:1201a9a37799 14 #define TRUE (~FALSE)
jwbruce 0:1201a9a37799 15 #define BIT0 0x00000001
jwbruce 0:1201a9a37799 16 #define BIT1 0x00000002
jwbruce 0:1201a9a37799 17 #define BIT2 0x00000004
jwbruce 0:1201a9a37799 18 #define BIT3 0x00000008
jwbruce 0:1201a9a37799 19
jwbruce 0:1201a9a37799 20 #define SEG_A 0xFE
jwbruce 0:1201a9a37799 21 #define SEG_B 0xFD
jwbruce 0:1201a9a37799 22 #define SEG_C 0xFB
jwbruce 0:1201a9a37799 23 #define SEG_D 0xF7
jwbruce 0:1201a9a37799 24 #define SEG_E 0xEF
jwbruce 0:1201a9a37799 25 #define SEG_F 0xDF
jwbruce 0:1201a9a37799 26 #define SEG_G 0xBF
jwbruce 0:1201a9a37799 27 #define SEG_DP 0x7F
jwbruce 0:1201a9a37799 28
jwbruce 0:1201a9a37799 29 #define PATTERN_BLANK 0xFF
jwbruce 0:1201a9a37799 30 #define PATTERN_0 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F)
jwbruce 0:1201a9a37799 31 #define PATTERN_1 (SEG_B & SEG_C)
jwbruce 0:1201a9a37799 32 #define PATTERN_2 (SEG_A & SEG_B & SEG_D & SEG_E & SEG_G)
jwbruce 0:1201a9a37799 33 #define PATTERN_3 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_G)
jwbruce 0:1201a9a37799 34 #define PATTERN_4 (SEG_B & SEG_C & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 35 #define PATTERN_5 (SEG_A & SEG_C & SEG_D & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 36 #define PATTERN_6 (SEG_A & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 37 #define PATTERN_7 (SEG_A & SEG_B & SEG_C)
jwbruce 0:1201a9a37799 38 #define PATTERN_8 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 39 #define PATTERN_9 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 40 #define PATTERN_A (SEG_A & SEG_B & SEG_C & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 41 #define PATTERN_B (SEG_C & SEG_D & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 42 #define PATTERN_C (SEG_A & SEG_D & SEG_E & SEG_F)
jwbruce 0:1201a9a37799 43 #define PATTERN_D (SEG_B & SEG_C & SEG_D & SEG_E & SEG_G)
jwbruce 0:1201a9a37799 44 #define PATTERN_E (SEG_A & SEG_D & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 45 #define PATTERN_F (SEG_A & SEG_E & SEG_F & SEG_G)
jwbruce 0:1201a9a37799 46
jwbruce 0:1201a9a37799 47 /*************************************************************************
jwbruce 0:1201a9a37799 48 *
jwbruce 0:1201a9a37799 49 * HW to peripheral pin mappings
jwbruce 0:1201a9a37799 50 *
jwbruce 0:1201a9a37799 51 **************************************************************************/
jwbruce 0:1201a9a37799 52 #define SCL_PIN PA_9
jwbruce 0:1201a9a37799 53 #define SDA_PIN PA_10
jwbruce 0:1201a9a37799 54 #define LED0_PIN PA_12
jwbruce 0:1201a9a37799 55 #define LED1_PIN PB_0
jwbruce 0:1201a9a37799 56 #define LED3_PIN PB_7
jwbruce 0:1201a9a37799 57 #define PWM1_PIN PB_1
jwbruce 0:1201a9a37799 58 #define LED2_PIN PF_0
jwbruce 0:1201a9a37799 59 #define CS_SD_PIN PF_1
jwbruce 0:1201a9a37799 60 #define SPK_PIN PA_8
jwbruce 0:1201a9a37799 61 #define CS_LCD_PIN PA_11
jwbruce 0:1201a9a37799 62 #define MOSI_PIN PB_5
jwbruce 0:1201a9a37799 63 #define MISO_PIN PB_4
jwbruce 0:1201a9a37799 64 #define SCLK_PIN PB_3
jwbruce 0:1201a9a37799 65 #define LGT_SENS_PIN PA_0
jwbruce 0:1201a9a37799 66 #define POT_PIN PA_1
jwbruce 0:1201a9a37799 67 #define TEMP_SENS_PIN PA_3
jwbruce 0:1201a9a37799 68 #define PWM2_PIN PA_4
jwbruce 0:1201a9a37799 69 #define SW4_PIN PA_5
jwbruce 0:1201a9a37799 70 #define SW5_PIN PA_6
jwbruce 0:1201a9a37799 71 #define CS_7SEG_PIN PA_7
jwbruce 0:1201a9a37799 72 #define TX_PIN PA_12
jwbruce 0:1201a9a37799 73 #define RX_PIN PA_15
jwbruce 0:1201a9a37799 74
jwbruce 0:1201a9a37799 75 /*************************************************************************
jwbruce 0:1201a9a37799 76 *
jwbruce 0:1201a9a37799 77 * Other useful defines
jwbruce 0:1201a9a37799 78 *
jwbruce 0:1201a9a37799 79 **************************************************************************/
jwbruce 0:1201a9a37799 80 #define I2C_SPEED_STD 100000
jwbruce 0:1201a9a37799 81 #define I2C_SPEED_FAST 400000
jwbruce 0:1201a9a37799 82 #define I2C_SPEED_FASTPLUS 1000000
jwbruce 0:1201a9a37799 83
jwbruce 0:1201a9a37799 84 #define SPI_SPEED_100KBPS 100000
jwbruce 0:1201a9a37799 85 #define SPI_SPEED_500KBPS 500000
jwbruce 0:1201a9a37799 86 #define SPI_SPEED_1MBPS 1000000
jwbruce 0:1201a9a37799 87
jwbruce 0:1201a9a37799 88 /*************************************************************************
jwbruce 0:1201a9a37799 89 *
jwbruce 0:1201a9a37799 90 * USEFUL MACROS
jwbruce 0:1201a9a37799 91 *
jwbruce 0:1201a9a37799 92 *************************************************************************/
jwbruce 0:1201a9a37799 93
jwbruce 0:1201a9a37799 94 /*************************************************************************
jwbruce 0:1201a9a37799 95 *
jwbruce 0:1201a9a37799 96 * G L O B A L V A R I A B L E S
jwbruce 0:1201a9a37799 97 *
jwbruce 0:1201a9a37799 98 *************************************************************************/
jwbruce 0:1201a9a37799 99 extern SPI spi;
jwbruce 0:1201a9a37799 100 //extern I2C i2c;
jwbruce 0:1201a9a37799 101 extern Serial pc;
jwbruce 0:1201a9a37799 102
jwbruce 0:1201a9a37799 103 // create the LEDs
jwbruce 0:1201a9a37799 104 extern DigitalOut led0;
jwbruce 0:1201a9a37799 105 extern DigitalOut led1;
jwbruce 0:1201a9a37799 106 extern DigitalOut led2;
jwbruce 0:1201a9a37799 107 /* only uncomment the following line if your Nucleo32 F031K6
jwbruce 0:1201a9a37799 108 ** has removed the solder jumper SB18 on the underside
jwbruce 0:1201a9a37799 109 */
jwbruce 1:62c831ab7306 110 // extern DigitalOut led3;
jwbruce 0:1201a9a37799 111
jwbruce 0:1201a9a37799 112 // create the speaker
jwbruce 0:1201a9a37799 113 extern DigitalOut speaker;
jwbruce 0:1201a9a37799 114
jwbruce 0:1201a9a37799 115 //create the chip-selects
jwbruce 0:1201a9a37799 116 extern DigitalOut cs_sd;
jwbruce 0:1201a9a37799 117 extern DigitalOut cs_lcd;
jwbruce 0:1201a9a37799 118 extern DigitalOut cs_7seg;
jwbruce 0:1201a9a37799 119
jwbruce 0:1201a9a37799 120 // create the switches
jwbruce 0:1201a9a37799 121 extern DigitalIn sw4;
jwbruce 0:1201a9a37799 122 extern DigitalIn sw5;
jwbruce 0:1201a9a37799 123
jwbruce 0:1201a9a37799 124 // create the analog sensors
jwbruce 0:1201a9a37799 125 extern AnalogIn lightSensor;
jwbruce 0:1201a9a37799 126 extern AnalogIn pot;
jwbruce 0:1201a9a37799 127 extern AnalogIn tempSensor;
jwbruce 0:1201a9a37799 128
jwbruce 0:1201a9a37799 129 /*************************************************************************
jwbruce 0:1201a9a37799 130 *
jwbruce 0:1201a9a37799 131 * P R O T O T Y P E S
jwbruce 0:1201a9a37799 132 *
jwbruce 0:1201a9a37799 133 *************************************************************************/
jwbruce 0:1201a9a37799 134 void init_spi(int i_spiBaud);
jwbruce 0:1201a9a37799 135 //void init_i2c(int i_i2cBaud);
jwbruce 0:1201a9a37799 136 void init_serial(int i_serialBaud);
jwbruce 0:1201a9a37799 137 void init_leds(void);
jwbruce 0:1201a9a37799 138 void init_all(void);
jwbruce 0:1201a9a37799 139
jwbruce 0:1201a9a37799 140 /* TEXTLCD
jwbruce 0:1201a9a37799 141 *
jwbruce 0:1201a9a37799 142 * A TextLCD library targeted the F031K6 + Edubase-V2 combination
jwbruce 0:1201a9a37799 143 * implmements a 16x2 HD44780 LCD module using a 4-bit inteface
jwbruce 0:1201a9a37799 144 * connected via a 74HC595 using the chip's SPI
jwbruce 0:1201a9a37799 145 *
jwbruce 0:1201a9a37799 146 * This work is based upon the TextLCD mbed library by Simon Ford
jwbruce 0:1201a9a37799 147 * found at https://os.mbed.com/users/simon/code/TextLCD/
jwbruce 0:1201a9a37799 148 *
jwbruce 0:1201a9a37799 149 * Copyright (c) 2007-2010, sford, http://mbed.org
jwbruce 0:1201a9a37799 150 * Copyright (c) 2020, jwbruce (jwbruce@tntech.edu)
jwbruce 0:1201a9a37799 151 *
jwbruce 0:1201a9a37799 152 * Permission is hereby granted, free of charge, to any person obtaining a copy
jwbruce 0:1201a9a37799 153 * of this software and associated documentation files (the "Software"), to deal
jwbruce 0:1201a9a37799 154 * in the Software without restriction, including without limitation the rights
jwbruce 0:1201a9a37799 155 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jwbruce 0:1201a9a37799 156 * copies of the Software, and to permit persons to whom the Software is
jwbruce 0:1201a9a37799 157 * furnished to do so, subject to the following conditions:
jwbruce 0:1201a9a37799 158 *
jwbruce 0:1201a9a37799 159 * The above copyright notice and this permission notice shall be included in
jwbruce 0:1201a9a37799 160 * all copies or substantial portions of the Software.
jwbruce 0:1201a9a37799 161 *
jwbruce 0:1201a9a37799 162 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jwbruce 0:1201a9a37799 163 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jwbruce 0:1201a9a37799 164 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jwbruce 0:1201a9a37799 165 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jwbruce 0:1201a9a37799 166 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jwbruce 0:1201a9a37799 167 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jwbruce 0:1201a9a37799 168 * THE SOFTWARE.
jwbruce 0:1201a9a37799 169 */
jwbruce 0:1201a9a37799 170
jwbruce 2:b1b9fba116c2 171 /** A TextLCD interface for driving a HD44780 LCD character
jwbruce 2:b1b9fba116c2 172 * module connected via a 74HC595 using the F031K6 SPI peripheral.
jwbruce 2:b1b9fba116c2 173 * Specifically, the Nucleo32 F031K6 boards plugged into the Edubase-V2
jwbruce 2:b1b9fba116c2 174 * via the adapter used at Tennessee Tech.
jwbruce 0:1201a9a37799 175 *
jwbruce 0:1201a9a37799 176 * Supports only the 16x2 display on the EduBase-V2 board
jwbruce 0:1201a9a37799 177 *
jwbruce 0:1201a9a37799 178 * @code
jwbruce 0:1201a9a37799 179 * #include "mbed.h"
jwbruce 2:b1b9fba116c2 180 * #include "TTU_CSC1300.h"
jwbruce 0:1201a9a37799 181 *
jwbruce 0:1201a9a37799 182 * TextLCD lcd(TextLCD::LCD_CURSOR_ON_BLINKING_ON); // select your cursor style
jwbruce 0:1201a9a37799 183 *
jwbruce 0:1201a9a37799 184 * int main() {
jwbruce 0:1201a9a37799 185 * lcd.printf("Hello World!\n");
jwbruce 0:1201a9a37799 186 * }
jwbruce 0:1201a9a37799 187 * @endcode
jwbruce 0:1201a9a37799 188 */
jwbruce 0:1201a9a37799 189 class TextLCD : public Stream {
jwbruce 0:1201a9a37799 190 public:
jwbruce 0:1201a9a37799 191
jwbruce 0:1201a9a37799 192 typedef enum {
jwbruce 0:1201a9a37799 193 LCD_CURSOR_OFF_BLINKING_OFF = 0,
jwbruce 0:1201a9a37799 194 LCD_CURSOR_OFF_BLINKING_ON = 0x01,
jwbruce 0:1201a9a37799 195 LCD_CURSOR_ON_BLINKING_OFF = 0x02,
jwbruce 0:1201a9a37799 196 LCD_CURSOR_ON_BLINKING_ON = 0x03,
jwbruce 0:1201a9a37799 197 LCD_CURSOR_DEFAULT = 0x03
jwbruce 0:1201a9a37799 198 } LCDCursor;
jwbruce 0:1201a9a37799 199
jwbruce 2:b1b9fba116c2 200 /** Constructor to create a TextLCD interface
jwbruce 2:b1b9fba116c2 201 *
jwbruce 2:b1b9fba116c2 202 * @param cur Desired behavior of LCD cursor
jwbruce 2:b1b9fba116c2 203 *
jwbruce 2:b1b9fba116c2 204 * @see setCursor()
jwbruce 2:b1b9fba116c2 205 * @see TextLCD::LCD_CURSOR_OFF_BLINKING_OFF No cursor and no blinking block
jwbruce 2:b1b9fba116c2 206 * @see TextLCD::LCD_CURSOR_OFF_BLINKING_ON No cursor and but blinking block
jwbruce 2:b1b9fba116c2 207 * @see TextLCD::LCD_CURSOR_ON_BLINKING_OFF Underline cursor and no blinking block
jwbruce 2:b1b9fba116c2 208 * @see TextLCD::LCD_CURSOR_ON_BLINKING_ON Both underlinecursor and blinking block
jwbruce 2:b1b9fba116c2 209 */
jwbruce 0:1201a9a37799 210 TextLCD(LCDCursor cur); // default constructor
jwbruce 0:1201a9a37799 211
jwbruce 0:1201a9a37799 212 #if DOXYGEN_ONLY
jwbruce 2:b1b9fba116c2 213 /** Write a character to the LCD at the current cursor location
jwbruce 0:1201a9a37799 214 *
jwbruce 0:1201a9a37799 215 * @param c The character to write to the display
jwbruce 2:b1b9fba116c2 216 *
jwbruce 2:b1b9fba116c2 217 * @see setLocation()
jwbruce 0:1201a9a37799 218 */
jwbruce 0:1201a9a37799 219 int putc(int c);
jwbruce 0:1201a9a37799 220
jwbruce 2:b1b9fba116c2 221 /** Write a formated string to the LCD at the curren cursor location
jwbruce 0:1201a9a37799 222 *
jwbruce 0:1201a9a37799 223 * @param format A printf-style format string, followed by the
jwbruce 0:1201a9a37799 224 * variables to use in formating the string.
jwbruce 2:b1b9fba116c2 225 *
jwbruce 2:b1b9fba116c2 226 * @note A string is denoted whthin double-quotes.
jwbruce 0:1201a9a37799 227 */
jwbruce 0:1201a9a37799 228 int printf(const char* format, ...);
jwbruce 0:1201a9a37799 229 #endif
jwbruce 0:1201a9a37799 230
jwbruce 2:b1b9fba116c2 231 /** Locate cursor to a screen row and column
jwbruce 0:1201a9a37799 232 *
jwbruce 0:1201a9a37799 233 * @param row The vertical position from the top, indexed from 0
jwbruce 2:b1b9fba116c2 234 * @param column The horizontal position from the left, indexed from 0
jwbruce 0:1201a9a37799 235 */
jwbruce 0:1201a9a37799 236 void setLocation(int column, int row);
jwbruce 0:1201a9a37799 237
jwbruce 0:1201a9a37799 238 /** Clear the screen and locate to 0,0 */
jwbruce 0:1201a9a37799 239 void cls();
jwbruce 0:1201a9a37799 240
jwbruce 2:b1b9fba116c2 241 /** Right a single character to a specific location
jwbruce 2:b1b9fba116c2 242 *
jwbruce 2:b1b9fba116c2 243 * @param row The vertical position from the top, indexed from 0
jwbruce 2:b1b9fba116c2 244 * @param column The horizontal position from the left, indexed from 0
jwbruce 2:b1b9fba116c2 245 * @param c The character to display on-screen
jwbruce 2:b1b9fba116c2 246 *
jwbruce 2:b1b9fba116c2 247 * @note A character is denoted within single-quotes (apostrophes)
jwbruce 2:b1b9fba116c2 248 */
jwbruce 0:1201a9a37799 249 void setCharacter(int row, int column, int c);
jwbruce 2:b1b9fba116c2 250
jwbruce 2:b1b9fba116c2 251 /** Change the LCD cursor mode
jwbruce 2:b1b9fba116c2 252 *
jwbruce 2:b1b9fba116c2 253 * @param c A LCDCursor type denoted the cursor and blink
jwbruce 2:b1b9fba116c2 254 *
jwbruce 2:b1b9fba116c2 255 * @see TextLCD::LCD_CURSOR_OFF_BLINKING_OFF No cursor and no blinking block
jwbruce 2:b1b9fba116c2 256 * @see TextLCD::LCD_CURSOR_OFF_BLINKING_ON No cursor and but blinking block
jwbruce 2:b1b9fba116c2 257 * @see TextLCD::LCD_CURSOR_ON_BLINKING_OFF Underline cursor and no blinking block
jwbruce 2:b1b9fba116c2 258 * @see TextLCD::LCD_CURSOR_ON_BLINKING_ON Both underlinecursor and blinking block
jwbruce 2:b1b9fba116c2 259 */
jwbruce 0:1201a9a37799 260 void setCursor(LCDCursor c);
jwbruce 0:1201a9a37799 261
jwbruce 0:1201a9a37799 262 protected:
jwbruce 0:1201a9a37799 263
jwbruce 0:1201a9a37799 264 // Stream implementation functions
jwbruce 0:1201a9a37799 265 virtual int _putc(int value);
jwbruce 0:1201a9a37799 266 virtual int _getc();
jwbruce 0:1201a9a37799 267
jwbruce 0:1201a9a37799 268 int address(int column, int row);
jwbruce 0:1201a9a37799 269 void writeNibble(char incoming, unsigned char rs);
jwbruce 0:1201a9a37799 270 void writeCommand(int command);
jwbruce 0:1201a9a37799 271 void writeData(int data);
jwbruce 0:1201a9a37799 272
jwbruce 0:1201a9a37799 273 int _column;
jwbruce 0:1201a9a37799 274 int _row;
jwbruce 0:1201a9a37799 275 int _maxColumns;
jwbruce 0:1201a9a37799 276 int _maxRows;
jwbruce 0:1201a9a37799 277 int _cursorState;
jwbruce 0:1201a9a37799 278
jwbruce 0:1201a9a37799 279 };
jwbruce 0:1201a9a37799 280
jwbruce 0:1201a9a37799 281
jwbruce 0:1201a9a37799 282 /* F031K6 + Edubase-V2 7-segment LED Library
jwbruce 0:1201a9a37799 283 * for the 4 seven-segment LEDs inteface connected via two 74HC595s using SPI
jwbruce 0:1201a9a37799 284 *
jwbruce 0:1201a9a37799 285 * Copyright (c) 2020, jwbruce (jwbruce@tntech.edu)
jwbruce 0:1201a9a37799 286 *
jwbruce 0:1201a9a37799 287 * Permission is hereby granted, free of charge, to any person obtaining a copy
jwbruce 0:1201a9a37799 288 * of this software and associated documentation files (the "Software"), to deal
jwbruce 0:1201a9a37799 289 * in the Software without restriction, including without limitation the rights
jwbruce 0:1201a9a37799 290 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jwbruce 0:1201a9a37799 291 * copies of the Software, and to permit persons to whom the Software is
jwbruce 0:1201a9a37799 292 * furnished to do so, subject to the following conditions:
jwbruce 0:1201a9a37799 293 *
jwbruce 0:1201a9a37799 294 * The above copyright notice and this permission notice shall be included in
jwbruce 0:1201a9a37799 295 * all copies or substantial portions of the Software.
jwbruce 0:1201a9a37799 296 *
jwbruce 0:1201a9a37799 297 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jwbruce 0:1201a9a37799 298 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jwbruce 0:1201a9a37799 299 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jwbruce 0:1201a9a37799 300 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jwbruce 0:1201a9a37799 301 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jwbruce 0:1201a9a37799 302 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jwbruce 0:1201a9a37799 303 * THE SOFTWARE.
jwbruce 0:1201a9a37799 304 */
jwbruce 0:1201a9a37799 305
jwbruce 0:1201a9a37799 306 /** A 7-segment LED interface for driving 4 connected seven-segment LEDs
jwbruce 0:1201a9a37799 307 *
jwbruce 0:1201a9a37799 308 * @code
jwbruce 0:1201a9a37799 309 * #include "mbed.h"
jwbruce 0:1201a9a37799 310 * #include "TextLCD.h"
jwbruce 0:1201a9a37799 311 *
jwbruce 0:1201a9a37799 312 * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7
jwbruce 0:1201a9a37799 313 *
jwbruce 0:1201a9a37799 314 * int main() {
jwbruce 0:1201a9a37799 315 * lcd.printf("Hello World!\n");
jwbruce 0:1201a9a37799 316 * }
jwbruce 0:1201a9a37799 317 * @endcode
jwbruce 0:1201a9a37799 318 */
jwbruce 0:1201a9a37799 319 class SSLED {
jwbruce 0:1201a9a37799 320 public:
jwbruce 0:1201a9a37799 321
jwbruce 0:1201a9a37799 322 typedef enum {
jwbruce 0:1201a9a37799 323 LED_PATTERN_0 = ~0x3F,
jwbruce 0:1201a9a37799 324 LED_PATTERN_1 = ~0x06,
jwbruce 0:1201a9a37799 325 LED_PATTERN_2 = ~0x5B,
jwbruce 0:1201a9a37799 326 LED_PATTERN_3 = ~0x4F,
jwbruce 0:1201a9a37799 327 LED_PATTERN_4 = ~0x66,
jwbruce 0:1201a9a37799 328 LED_PATTERN_5 = ~0x6D,
jwbruce 0:1201a9a37799 329 LED_PATTERN_6 = ~0x7D,
jwbruce 0:1201a9a37799 330 LED_PATTERN_7 = ~0x07,
jwbruce 0:1201a9a37799 331 LED_PATTERN_8 = ~0x7F,
jwbruce 0:1201a9a37799 332 LED_PATTERN_9 = ~0x6F,
jwbruce 0:1201a9a37799 333 LED_PATTERN_A = ~0x77,
jwbruce 0:1201a9a37799 334 LED_PATTERN_B = ~0x7C,
jwbruce 0:1201a9a37799 335 LED_PATTERN_C = ~0x39,
jwbruce 0:1201a9a37799 336 LED_PATTERN_D = ~0x5E,
jwbruce 0:1201a9a37799 337 LED_PATTERN_E = ~0x79,
jwbruce 0:1201a9a37799 338 LED_PATTERN_F = ~0x71,
jwbruce 0:1201a9a37799 339 LED_PATTERN_G = ~0x40,
jwbruce 0:1201a9a37799 340 LED_PATTERN_H = ~0x76,
jwbruce 0:1201a9a37799 341 LED_PATTERN_I = ~0x30,
jwbruce 0:1201a9a37799 342 LED_PATTERN_J = ~0x1E,
jwbruce 0:1201a9a37799 343 LED_PATTERN_L = ~0x38,
jwbruce 0:1201a9a37799 344 LED_PATTERN_N = ~0x54,
jwbruce 0:1201a9a37799 345 LED_PATTERN_O = ~0x3F,
jwbruce 0:1201a9a37799 346 LED_PATTERN_P = ~0x73,
jwbruce 0:1201a9a37799 347 LED_PATTERN_Q = ~0x67,
jwbruce 0:1201a9a37799 348 LED_PATTERN_R = ~0x50,
jwbruce 0:1201a9a37799 349 LED_PATTERN_S = LED_PATTERN_5,
jwbruce 0:1201a9a37799 350 LED_PATTERN_T = ~0x78,
jwbruce 0:1201a9a37799 351 LED_PATTERN_U = ~0x1C,
jwbruce 0:1201a9a37799 352 LED_PATTERN_V = ~0x2A,
jwbruce 0:1201a9a37799 353 LED_PATTERN_Y = ~0x6E,
jwbruce 0:1201a9a37799 354 LED_PATTERN_BLANK = ~0x00,
jwbruce 0:1201a9a37799 355 LED_PATTERN_SPACE = LED_PATTERN_BLANK,
jwbruce 0:1201a9a37799 356 LED_PATTERN_DASH = ~0x40,
jwbruce 0:1201a9a37799 357 LED_PATTERN_DEGREES = ~0xC3,
jwbruce 0:1201a9a37799 358 LED_PATTERN_DECIMALPT = ~0x80,
jwbruce 0:1201a9a37799 359 LED_PATTERN_QUESTION = ~0x53
jwbruce 0:1201a9a37799 360 } LEDPattern;
jwbruce 0:1201a9a37799 361
jwbruce 0:1201a9a37799 362 /** Declare a 7-segment LED interface */
jwbruce 0:1201a9a37799 363 // constructor
jwbruce 0:1201a9a37799 364 SSLED(int display, int pattern);
jwbruce 0:1201a9a37799 365
jwbruce 0:1201a9a37799 366 /** Write a pattern to a chosen display */
jwbruce 0:1201a9a37799 367 void setDisplay(int display, int pattern); // change patterns to blank and write the displays
jwbruce 0:1201a9a37799 368 };
jwbruce 0:1201a9a37799 369
jwbruce 0:1201a9a37799 370
jwbruce 0:1201a9a37799 371
jwbruce 0:1201a9a37799 372 #endif