mbed demo and driver of 14 segment 4 digit Starburst LED display

Dependencies:   mbed

Committer:
wim
Date:
Thu Nov 10 19:29:32 2011 +0000
Revision:
0:85a63648158b
First release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:85a63648158b 1 /* Starburst - display driver for 14 segment starburst display
wim 0:85a63648158b 2 *
wim 0:85a63648158b 3 * Copyright (c) 2011 Wim Huiskamp
wim 0:85a63648158b 4 *
wim 0:85a63648158b 5 * Released under the MIT License: http://mbed.org/license/mit
wim 0:85a63648158b 6 *
wim 0:85a63648158b 7 * version 0.2 Initial Release
wim 0:85a63648158b 8 */
wim 0:85a63648158b 9 #ifndef _STARBURST_H
wim 0:85a63648158b 10 #define _STARBURST_H
wim 0:85a63648158b 11
wim 0:85a63648158b 12 //Useful stuff to simplify porting of some third party software
wim 0:85a63648158b 13 #include <stdarg.h>
wim 0:85a63648158b 14 //#include <string.h>
wim 0:85a63648158b 15
wim 0:85a63648158b 16
wim 0:85a63648158b 17 /*****************************************************************************/
wim 0:85a63648158b 18 /********************* DEFINITIONS FOR STARBURST ***************************/
wim 0:85a63648158b 19 /*****************************************************************************/
wim 0:85a63648158b 20
wim 0:85a63648158b 21 // Definitions
wim 0:85a63648158b 22 #define STAR_NR_DIGITS 4
wim 0:85a63648158b 23 #define STAR_CHR_MIN 32
wim 0:85a63648158b 24 #define STAR_CHR_MAX 127
wim 0:85a63648158b 25 #define STAR_NR_CHARS (STAR_CHR_MAX - STAR_CHR_MIN + 1)
wim 0:85a63648158b 26
wim 0:85a63648158b 27 // Masks
wim 0:85a63648158b 28 //#define CHR_MSK 0x3F
wim 0:85a63648158b 29 #define SYM_MSK 0xC0
wim 0:85a63648158b 30
wim 0:85a63648158b 31 #define D3_MSK 0x80
wim 0:85a63648158b 32 #define D3_ON 0x80
wim 0:85a63648158b 33 #define D3_OFF 0x00
wim 0:85a63648158b 34 #define D3_IDX 0
wim 0:85a63648158b 35
wim 0:85a63648158b 36 #define DP_MSK 0x40
wim 0:85a63648158b 37 #define DP_ON 0x40
wim 0:85a63648158b 38 #define DP_OFF 0x00
wim 0:85a63648158b 39 #define DP_IDX 1
wim 0:85a63648158b 40
wim 0:85a63648158b 41 #define D1_MSK 0xC0
wim 0:85a63648158b 42 #define D1_RED 0x80
wim 0:85a63648158b 43 #define D1_GRN 0x40
wim 0:85a63648158b 44 #define D1_YEL 0xC0
wim 0:85a63648158b 45 #define D1_OFF 0x00
wim 0:85a63648158b 46 #define D1_IDX 2
wim 0:85a63648158b 47
wim 0:85a63648158b 48 // Enums
wim 0:85a63648158b 49 enum BiLED {BI_OFF, BI_RED, BI_GRN, BI_YEL}; // Bicolour LED states
wim 0:85a63648158b 50
wim 0:85a63648158b 51
wim 0:85a63648158b 52 /** Create a starburst object connected to the proper SPI pins
wim 0:85a63648158b 53 *
wim 0:85a63648158b 54 * @param Pinname mosi, miso, sck, ce to connect to
wim 0:85a63648158b 55 * @brief
wim 0:85a63648158b 56 */
wim 0:85a63648158b 57 class Starburst {
wim 0:85a63648158b 58
wim 0:85a63648158b 59 public:
wim 0:85a63648158b 60 Starburst(SPI &spi, PinName CE, PinName nOE);
wim 0:85a63648158b 61 void set_dp(bool dp);
wim 0:85a63648158b 62 void set_led(bool led);
wim 0:85a63648158b 63 void set_bi_led(BiLED bi_led);
wim 0:85a63648158b 64 void putc(int location, char byte);
wim 0:85a63648158b 65 void putc(char disp_char);
wim 0:85a63648158b 66 void printf (char * format, ...);
wim 0:85a63648158b 67 void scroll_printf (char * format, ...);
wim 0:85a63648158b 68
wim 0:85a63648158b 69 void locate(uint8_t column);
wim 0:85a63648158b 70 void cls(void);
wim 0:85a63648158b 71 // void set_char_flash_state(bool flash_state, uint8_t char_pos);
wim 0:85a63648158b 72 // void set_all_flash_states(uint8_t flash_bits);
wim 0:85a63648158b 73 // void set_brightness(uint8_t brightness);
wim 0:85a63648158b 74 void set_blink_mode(bool enable);
wim 0:85a63648158b 75 // void set_flash_mode(bool enable);
wim 0:85a63648158b 76 void set_scroll_mode(bool enable);
wim 0:85a63648158b 77
wim 0:85a63648158b 78
wim 0:85a63648158b 79 protected:
wim 0:85a63648158b 80 SPI &_spi;
wim 0:85a63648158b 81 DigitalOut _ShiftLatch;
wim 0:85a63648158b 82 DigitalOut _nOE;
wim 0:85a63648158b 83
wim 0:85a63648158b 84 Ticker _mpx, _blnk, _scrl;
wim 0:85a63648158b 85 // int _row;
wim 0:85a63648158b 86 int _column;
wim 0:85a63648158b 87 char _digit_segments[STAR_NR_DIGITS][2];
wim 0:85a63648158b 88
wim 0:85a63648158b 89 char _scroll_display_string[64];
wim 0:85a63648158b 90 int _scroll_string_len;
wim 0:85a63648158b 91 int _scroll_ptr;
wim 0:85a63648158b 92 bool _scroll;
wim 0:85a63648158b 93
wim 0:85a63648158b 94 bool _blink, _blinkstate;
wim 0:85a63648158b 95 // bool _flash;
wim 0:85a63648158b 96
wim 0:85a63648158b 97 void _init();
wim 0:85a63648158b 98 void _mpx_digits();
wim 0:85a63648158b 99 void _mpx_start();
wim 0:85a63648158b 100 void _blink_tick();
wim 0:85a63648158b 101 void _blink_start();
wim 0:85a63648158b 102 void _scroll_tick();
wim 0:85a63648158b 103 void _scroll_start();
wim 0:85a63648158b 104 };
wim 0:85a63648158b 105
wim 0:85a63648158b 106
wim 0:85a63648158b 107 #endif
wim 0:85a63648158b 108 /*****************************************************************************/
wim 0:85a63648158b 109 /****************************** END OF FILE ********************************/
wim 0:85a63648158b 110 /*****************************************************************************/