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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Thu Nov 10 19:29:32 2011 +0000
Commit message:
First release

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
starburst.cpp Show annotated file Show diff for this revision Revisions of this file
starburst.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 85a63648158b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 10 19:29:32 2011 +0000
@@ -0,0 +1,190 @@
+#include "mbed.h"
+#include "starburst.h"
+
+#define MOSI p5
+#define MISO p6
+#define SCK  p7
+#define CE   p8
+#define nOE  p21
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut heartbeatLED(LED4);
+
+SPI spi(MOSI, MISO, SCK);           // mosi, miso, sclk
+Starburst starburst(spi, CE, nOE);  // Multiplexed Starburst Display, SPI controlled
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+// Variables for Heartbeat and Status monitoring
+Ticker heartbeat;
+bool heartbeatflag=false;
+
+void show_menu() {
+    pc.printf("0: Exit\n\r");
+    pc.printf("1: Show Menu\n\r");    
+    pc.printf("2: Send TEST\n\r"); 
+    pc.printf("3: Send 1234\n\r");                
+    pc.printf("4: Blink On\n\r");    
+    pc.printf("5: Blink Off\n\r");        
+    pc.printf("6: Scroll On\n\r");                    
+    pc.printf("7: Scroll Off\n\r");                        
+//    pc.printf("A: sendMessage\n\r");                
+//    pc.printf("B: parseLFRNG\n\r");                    
+//    pc.printf("P: parseMessage\n\r");                        
+    pc.printf("\n\r");                
+}
+
+
+
+
+void show_LEDS () {
+  static int state = 0;
+ 
+  switch (state) {
+   case 0: 
+        myled1 = 1;
+        myled2 = 0;
+        myled3 = 0;
+        state = 1;
+        break;
+   case 1: 
+        myled1 = 0;
+        myled2 = 1;
+        myled3 = 0;
+        state = 2;
+        break;
+   case 2:     
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 1;
+        state = 0;
+        break;
+   }
+}
+
+
+
+
+// Heartbeat monitor
+void pulse() {
+  heartbeatLED = !heartbeatLED;
+  
+  starburst.set_led(heartbeatLED); 
+
+  if (heartbeatLED)
+    starburst.set_bi_led(BI_RED);
+  else
+    starburst.set_bi_led(BI_GRN);
+//    starburst.set_bi_led(BI_YEL);
+
+}
+
+void heartbeat_start() {
+  heartbeat.attach(&pulse, 0.5);
+  heartbeatflag = true;
+}
+
+void heartbeat_stop() {
+  heartbeat.detach();
+  heartbeatflag = false;
+}
+
+
+
+int main() {
+  bool running=true;
+  char command;
+  int count = 0;
+  
+    pc.printf("Hello World!\n\r");
+
+    heartbeat_start();
+
+    show_LEDS();
+
+    show_menu();
+    
+  
+    starburst.locate(0);                                                                               
+    starburst.printf("BILL"); 
+    
+//    starburst.scroll_printf ("Hello World. The correct answer is %d ", 123456);       
+    starburst.scroll_printf ("Hello World ");       
+             
+    while(running) {
+          
+      // pc.printf("_str_len = %d, _scroll_ptr= %d \n\r", starburst._scroll_string_len, starburst._scroll_ptr);           
+    
+       if(pc.readable()) {
+         command = pc.getc();       
+         pc.printf("command= %c \n\r", command);         
+         show_LEDS();         
+
+         switch (command) {
+          case '0' :
+                     pc.printf("Done\n\r");                    
+                     running = false;  
+                     break;
+          
+          case '1' :
+                     show_menu();
+                     break;
+                    
+          case '2' :
+                     pc.printf("TEST\n\r");          
+                     
+                     starburst.locate(0);                                                                               
+                     starburst.printf("TEST");                                                                               
+                     break;
+          
+          case '3' :
+                     pc.printf("1234\n\r");          
+
+                     starburst.locate(0);                                                                                                                                                                      
+                     starburst.printf("%4d", 1234);                                              
+                     break;
+          
+          case '4' :
+                     pc.printf("Blink On\n\r");                    
+
+                     starburst.set_blink_mode(true);          
+                     break;
+
+          case '5' :
+                     pc.printf("Blink Off\n\r");                    
+
+                     starburst.set_blink_mode(false);                    
+                     break;
+
+          case '6' :
+                     pc.printf("Scroll On\n\r");                    
+
+                     starburst.set_scroll_mode(true);                      
+                     break;
+
+          case '7' :
+                     pc.printf("Scroll Off\n\r");                    
+
+                     starburst.set_scroll_mode(false);                       
+                     break;
+
+
+          case 'A' :
+                     break;
+
+          case 'B' :
+                   
+                     break;
+
+          case 'P' :
+          
+                    break;
+                              
+        } //switch
+      }//if
+    }//while
+
+    pc.printf("Bye World!\n\r");                       
+}//main
diff -r 000000000000 -r 85a63648158b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 10 19:29:32 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
diff -r 000000000000 -r 85a63648158b starburst.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/starburst.cpp	Thu Nov 10 19:29:32 2011 +0000
@@ -0,0 +1,571 @@
+/* Starburst - display driver for 14 segment starburst display
+ *
+ * Copyright (c) 2011 Wim Huiskamp
+ *
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * version 0.2 Initial Release
+*/
+#include "mbed.h"
+#include "starburst.h"
+
+/*****************************************************************************/
+/*********************  DEFINITIONS FOR STARBURST  ***************************/
+/*****************************************************************************/
+
+// Definitions
+const char digit_select[STAR_NR_DIGITS] = {0x01, 0x02, 0x04, 0x08};     //digit select
+const char char_segm[STAR_NR_CHARS][2] = {
+                                     {0x00, 0x00},  // space (32)
+                                     {0x06, 0x00},  // !
+                                     {0x22, 0x00},  // "
+                                     {0xC7, 0x12},  // #
+
+                                     {0xED, 0x12},  // $
+                                     {0x24, 0x24},  // %
+                                     {0x5D, 0x0B},  // &                                    
+                                     {0x02, 0x00},  // '                                                                        
+
+                                     {0x39, 0x00},  // (                                   
+                                     {0x0F, 0x00},  // )                                     
+                                     {0xC0, 0x3F},  // *                                                                         
+                                     {0xC0, 0x12},  // +                                                                        
+
+                                     {0x04, 0x00},  // ,
+                                     {0xC0, 0x00},  // -
+                                     {0x04, 0x00},  // .                                    
+                                     {0x00, 0x24},  // /                                                                        
+
+                                     {0x3F, 0x24},  // 0
+                                     {0x06, 0x00},  // 1
+                                     {0xDB, 0x00},  // 2                                    
+                                     {0xCF, 0x00},  // 3                                                                      
+
+                                     {0xE6, 0x00},  // 4
+                                     {0xED, 0x00},  // 5
+                                     {0xFD, 0x00},  // 6                                    
+                                     {0x07, 0x00},  // 7                                                                       
+
+                                     {0xFF, 0x00},  // 8
+                                     {0xEF, 0x00},  // 9
+
+                                     {0x00, 0x00},  // :
+                                     {0x00, 0x00},  // ;                                     
+                                     {0x00, 0x0C},  // <
+                                     {0xC8, 0x00},  // =
+                                     {0x00, 0x21},  // >
+                                     {0x83, 0x10},  // ?                                     
+                                     {0xDF, 0x00},  // @  (64)                                   
+                                     
+                                     {0xF7, 0x00},  // A  (65)
+                                     {0xCF, 0x12},  // B
+                                     {0x39, 0x00},  // C
+                                     {0x0F, 0x12},  // D
+
+                                     {0xF9, 0x00},  // E
+                                     {0xF1, 0x00},  // F
+                                     {0xBD, 0x00},  // G                                    
+                                     {0xF6, 0x00},  // H                                                                        
+
+                                     {0x09, 0x12},  // I
+                                     {0x1E, 0x00},  // J
+                                     {0x70, 0x0C},  // K                                    
+                                     {0x38, 0x00},  // L                                                                        
+
+                                     {0x36, 0x05},  // M
+                                     {0x36, 0x09},  // N
+                                     {0x3F, 0x00},  // O                                    
+                                     {0xF3, 0x00},  // P                                                                        
+
+                                     {0x3F, 0x08},  // Q
+                                     {0xF3, 0x08},  // R
+                                     {0xED, 0x00},  // S                                    
+                                     {0x01, 0x12},  // T                                                                       
+
+                                     {0x3E, 0x00},  // U
+                                     {0x30, 0x24},  // V
+                                     {0x36, 0x28},  // W                                    
+                                     {0x00, 0x2D},  // X                                                                       
+
+                                     {0x00, 0x15},  // Y
+                                     {0x09, 0x24},  // Z  (90)
+
+                                     {0x39, 0x00},  // [
+                                     {0x00, 0x09},  // '\'                                     
+                                     {0x0F, 0x00},  // ]
+                                     {0x00, 0x28},  // ^
+                                     {0x08, 0x00},  // _
+                                     {0x00, 0x01},  // '                                     
+                                                                          
+                                     {0xF7, 0x00},  // A replacing a
+                                     {0xCF, 0x12},  // B
+                                     {0x39, 0x00},  // C
+                                     {0x0F, 0x12},  // D
+
+                                     {0xF9, 0x00},  // E
+                                     {0xF1, 0x00},  // F
+                                     {0xBD, 0x00},  // G                                    
+                                     {0xF6, 0x00},  // H                                                                        
+
+                                     {0x09, 0x12},  // I
+                                     {0x1E, 0x00},  // J
+                                     {0x70, 0x0C},  // K                                    
+                                     {0x38, 0x00},  // L                                                                        
+
+                                     {0x36, 0x05},  // M
+                                     {0x36, 0x09},  // N
+                                     {0x3F, 0x00},  // O                                    
+                                     {0xF3, 0x00},  // P                                                                        
+
+                                     {0x3F, 0x08},  // Q
+                                     {0xF3, 0x08},  // R
+                                     {0xED, 0x00},  // S                                    
+                                     {0x01, 0x12},  // T                                                                       
+
+                                     {0x3E, 0x00},  // U
+                                     {0x30, 0x24},  // V
+                                     {0x36, 0x28},  // W                                    
+                                     {0x00, 0x2D},  // X                                                                       
+
+                                     {0x00, 0x15},  // Y
+                                     {0x09, 0x24},  // Z replacing z
+
+                                     {0x39, 0x00},  // {
+                                     {0x00, 0x12},  // |                                     
+                                     {0x0F, 0x00},  // }
+                                     {0xD2, 0x00},  // ~
+                                     {0x00, 0x00}}; // DEL (127)                                  
+
+/** Create a starburst object connected to the proper SPI pins
+ *
+ * @param  Pinname mosi, miso, sck, ce to connect to 
+ * @brief 
+*/
+Starburst::Starburst(SPI &spi, PinName CE, PinName nOE) : _spi(spi), _ShiftLatch(CE), _nOE(nOE) {
+  _init();
+}
+
+/** Display ASCII character at selected cursor location
+ *
+ * @param  int location cursor location, valid range is 0 - NR_DIGITS
+ * @param  char byte to display, valid range is (char) 32 - (char) 127
+ * @brief 
+*/
+void Starburst::putc(int location, char byte) {
+  int charcode = (int) byte;
+  
+  // Check valid range
+  if ((charcode < STAR_CHR_MIN) | (charcode > STAR_CHR_MAX)) {
+    charcode = 0; 
+  }
+  else {
+    charcode = charcode - STAR_CHR_MIN;
+  };
+
+  // Check valid range
+  if ((location < 0) | (location > (STAR_NR_DIGITS-1))) {
+    location = 0; 
+  };
+
+  // Lookup segmentcode for the character and store in digit's location while protecting the symbol bits       
+  _digit_segments[location][1] = (_digit_segments[location][1] & SYM_MSK) | char_segm[charcode][1];     //segments H-N, LEDs
+  _digit_segments[location][0] =                                            char_segm[charcode][0];     //segments A-G2
+}      
+
+
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       putc
+ |
+ |  Description:    Displays specified character on the display at current
+ |                  cursor position. Increments cursor.
+ |                  Position on the display (0 to 3, Leftmost = 0)
+ |
+ |  Parameters:     disp_char - single character to display
+ |                    - ASCII characters: 128 values between 0-127
+ |                    - UDC character, 15 possible UDC values from 128-142 (not supported yet)
+ |
+ |  Returns:        Nothing
+ |
+\*---------------------------------------------------------------------------*/
+void Starburst::putc(char disp_char) {
+
+    // Write selected character to display at current position
+    putc(_column, disp_char);  
+    
+    // Incr and wrap around cursorposition
+    _column++; 
+    _column = _column % STAR_NR_DIGITS;    
+}
+
+/** Display colon symbol
+ *
+ * @param  bool dp colon on or off
+ * @brief 
+*/
+void Starburst::set_dp(bool dp) {
+  
+  if (dp) {
+    _digit_segments[DP_IDX][1] = (_digit_segments[DP_IDX][1] & ~DP_MSK) | DP_ON;
+  }
+  else {
+    _digit_segments[DP_IDX][1] = (_digit_segments[DP_IDX][1] & ~DP_MSK);  
+  };
+}      
+
+/** Display LED symbol
+ *
+ * @param  bool led LED on or off
+ * @brief 
+*/
+void Starburst::set_led(bool led) {
+  
+  if (led) {
+    _digit_segments[D3_IDX][1] = (_digit_segments[D3_IDX][1] & ~D3_MSK) | D3_ON;
+  }
+  else {
+    _digit_segments[D3_IDX][1] = (_digit_segments[D3_IDX][1] & ~D3_MSK);  
+  };
+}      
+
+
+/** Display Bi-Color LED symbol
+ *
+ * @param  int Bicolor LED off, Red, Green or Yellow
+ * @brief 
+*/
+void Starburst::set_bi_led(BiLED bi_led) {
+
+  switch (bi_led) {
+    case BI_OFF:   
+            _digit_segments[D1_IDX][1] = (_digit_segments[D1_IDX][1] & ~D1_MSK);    
+            break;  
+    case BI_RED:
+            _digit_segments[D1_IDX][1] = (_digit_segments[D1_IDX][1] & ~D1_MSK) | D1_RED;           
+            break;      
+    case BI_GRN:
+            _digit_segments[D1_IDX][1] = (_digit_segments[D1_IDX][1] & ~D1_MSK) | D1_GRN;        
+            break;         
+    case BI_YEL:
+            _digit_segments[D1_IDX][1] = (_digit_segments[D1_IDX][1] & ~D1_MSK) | D1_YEL;        
+            break;
+  };                               
+}      
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       printf
+ |
+ |  Description:    Displays specified string on the display at current
+ |                  cursor position. Increments cursor.
+ |                  Max stringlen is 64 chars.
+ |
+ |  Parameters:     format - format string
+ |                  args   - data
+ |
+ |  Returns:        Nothing
+ |
+\*---------------------------------------------------------------------------*/
+void Starburst::printf (char * format, ...) {
+   char display_string[64];
+   int rv, string_len, i;   
+   va_list args;
+   va_start (args, format);
+
+   rv=vsprintf (display_string, format, args);
+   va_end (args);   
+// printf("printing:'%s'\n", display_string);
+
+   // loop round, writing characters
+   string_len = strlen(display_string);   // obtain length of string
+   for (i = 0; i < string_len; i++) {
+     putc(display_string[i]);
+   };
+
+   // return rv;
+}
+
+
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       _scroll_printf
+ |
+ |  Description:    Stores specified string in the scroll buffer.
+ |                  The string will be automatically displayed in a scrolling fashion.
+ |                  Max stringlen is 64 chars.
+ |
+ |  Parameters:     format - format string
+ |                  args   - data
+ |
+ |  Returns:        Nothing
+ |
+\*---------------------------------------------------------------------------*/
+void Starburst::scroll_printf (char * format, ...) {
+   int rv;
+   va_list args;
+   va_start (args, format);
+
+   rv=vsprintf (_scroll_display_string, format, args);
+   va_end (args);   
+// printf("printing:'%s'\n", _scroll_display_string);
+   
+//   _scroll_string_len = rv;   // obtain length of string
+   _scroll_string_len = strlen(_scroll_display_string);   // obtain length of string
+
+//   _scroll = (_scroll_string_len != 0);
+   _scroll = false;   // Initially scroll is disabled
+   _scroll_ptr = 0;  
+
+   // return rv;
+}
+
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       locate
+ |
+ |  Description:    Set the cursor address where the next character will be written. 
+ |
+ |  Parameters:     Cursor Column address
+ |
+ |  Returns:        Nothing
+ |
+\*---------------------------------------------------------------------------*/
+void Starburst::locate(uint8_t column) {
+
+//    _row = row % STAR_NR_ROWS;
+    _column = column % STAR_NR_DIGITS;
+}
+
+
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       cls
+ |
+ |  Description:    Clears the displayed data and flash RAM, but not the user
+ |                  defined characters.
+ |
+ |  Parameters:     None
+ |
+ |  Returns:        Nothing
+ |
+\*---------------------------------------------------------------------------*/
+void Starburst::cls(void) {
+  int location;
+
+  for (location=0; location<STAR_NR_DIGITS; location++)
+    putc(location, ' ');
+
+  // Reset cursor 
+  locate(0);
+}
+
+/** Activate Blinking Display
+ *
+ * @param  bool enable Blink on or off
+ * @brief 
+*/
+void Starburst::set_blink_mode(bool enable) {
+  _blink = enable;
+}  
+
+
+/** Activate Scrolling Display
+ *
+ * @param  bool enable Scroll On or Off
+ * @brief 
+*/
+void Starburst::set_scroll_mode(bool enable) {
+
+  if (enable) {
+    // Scroll only when a scroll string is available
+    _scroll = (_scroll_string_len != 0);
+  }
+  else {
+    _scroll = false;  
+  }  
+
+  // Init starting idx in scroll string
+  _scroll_ptr = 0;    
+}  
+
+
+
+                                     
+/** Multiplex Call to activate next digit, Called by timer interrupt at 75Hz per digit
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_mpx_digits() {
+  static int digit_idx = 0;
+
+  // Select the device by setting chip select low
+  _ShiftLatch = 0;
+
+  if (_blink) {
+    // Blink activated 
+    if (_blinkstate) {
+      // Data visible, Send data
+      _spi.write( digit_select[digit_idx]);        //digit select
+      _spi.write(_digit_segments[digit_idx][1]);   //segments H-N, LEDs
+      _spi.write(_digit_segments[digit_idx][0]);   //segments A-G2
+    }
+    else {
+      // Data blanked, Send cleared digits
+      _spi.write( digit_select[digit_idx]);        //digit select
+      _spi.write(_digit_segments[digit_idx][1] & SYM_MSK);   //segments H-N, LEDs
+      _spi.write(0x00);                                      //segments A-G2
+    }
+  }
+  else {
+    // Blink not activated   
+    // Send data
+    _spi.write( digit_select[digit_idx]);        //digit select
+    _spi.write(_digit_segments[digit_idx][1]);   //segments H-N, LEDs
+    _spi.write(_digit_segments[digit_idx][0]);   //segments A-G2        
+  }    
+
+  // latch the value in the device
+  _ShiftLatch = 1;
+  
+  digit_idx++;
+  if (digit_idx==STAR_NR_DIGITS) digit_idx=0;
+}
+
+
+/** Attach Multiplex Call to timer interrupt
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_mpx_start() {
+  _mpx.attach(this, &Starburst::_mpx_digits, 0.013 / STAR_NR_DIGITS); // Update each digit at 75 Hz
+}
+
+
+/** Blinker Call to toggle _blinkstate, Called by timer interrupt at 2 Hz
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_blink_tick() {
+  _blinkstate = !_blinkstate;
+  
+}
+
+
+/** Attach Blink Call to timer interrupt
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_blink_start() {
+  _blnk.attach(this, &Starburst::_blink_tick, 0.25); // Blink at 2 Hz
+}
+
+
+/** Scroll Call to scroll display text, Called by timer interrupt at 2 Hz
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_scroll_tick() {
+  int tmp_ptr, idx; 
+
+  // scroll text
+  if (_scroll) {
+     tmp_ptr = _scroll_ptr;
+     
+     // write next set of characters in display
+     for (idx = 0; idx < STAR_NR_DIGITS; idx++) {     
+       putc(idx, _scroll_display_string[tmp_ptr]);   // write next char in display
+       
+       tmp_ptr++;                                    // incr the ptr, wrap around if needed       
+       tmp_ptr = tmp_ptr % _scroll_string_len;       
+     };
+       
+//WRONG
+//     _scroll_ptr = _scroll_ptr++ % _scroll_string_len; // incr start idx in scroll string for next time
+     
+//WRONG     
+//     _scroll_ptr = (_scroll_ptr++) % _scroll_string_len; // incr start idx in scroll string for next time     
+
+//OK
+     _scroll_ptr++;
+     _scroll_ptr = _scroll_ptr % _scroll_string_len; // incr start idx in scroll string for next time     
+
+
+//OK     
+//     _scroll_ptr = (_scroll_ptr + 1) % _scroll_string_len; // incr start idx in scroll string for next time          
+  }
+  
+}
+
+
+/** Attach Scroll Call to timer interrupt
+ *
+ * @param  
+ * @brief 
+*/
+void Starburst::_scroll_start() {
+//  _scrl.attach(this, &Starburst::_scroll_tick, 0.75); // Scroll at 1.5 Hz
+  _scrl.attach(this, &Starburst::_scroll_tick, 0.5); // Scroll at 2 Hz  
+}
+
+
+
+void Starburst::_init() {
+
+  // Disable Display
+  _nOE = 1;
+  _ShiftLatch = 1;
+
+  // Setup the spi for 8 bit data, low steady state clock,
+  // rising edge capture, with a 1MHz clock rate  
+  _spi.format(8,0);
+  _spi.frequency(500000);
+//   _spi.frequency(1000000);
+
+  // Select the device by setting chip select low
+  _ShiftLatch = 0;
+
+  // Send data to Clear all
+  _spi.write(0x00);  //digit select
+  _spi.write(0x00);  //segments H-N, LEDs
+  _spi.write(0x00);  //segments A-G2
+        
+  // Latch the value in the device
+  _ShiftLatch = 1;
+
+  _blink=false; // Blink display
+  _blinkstate=false;  
+  
+//  _flash=false; // Flash digit  
+  
+  //Enable display 
+  _nOE = 0;
+
+
+  // Clear display 
+  cls();
+  // Reset cursor 
+  locate(0);
+
+  //Enable blinking timer
+  _blink_start();
+
+  //Enable scroll timer
+  _scroll_start();
+
+  //Enable multiplexing timer
+  _mpx_start();
+}
+   
+
+/*****************************************************************************/
+/******************************  END OF FILE  ********************************/
+/*****************************************************************************/
diff -r 000000000000 -r 85a63648158b starburst.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/starburst.h	Thu Nov 10 19:29:32 2011 +0000
@@ -0,0 +1,110 @@
+/* Starburst - display driver for 14 segment starburst display
+ *
+ * Copyright (c) 2011 Wim Huiskamp
+ *
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * version 0.2 Initial Release
+*/
+#ifndef _STARBURST_H
+#define _STARBURST_H
+
+//Useful stuff to simplify porting of some third party software
+ #include <stdarg.h>
+//#include <string.h>
+
+
+/*****************************************************************************/
+/*********************  DEFINITIONS FOR STARBURST  ***************************/
+/*****************************************************************************/
+
+// Definitions
+#define STAR_NR_DIGITS 4  
+#define STAR_CHR_MIN     32 
+#define STAR_CHR_MAX    127 
+#define STAR_NR_CHARS  (STAR_CHR_MAX - STAR_CHR_MIN + 1)
+
+// Masks
+//#define CHR_MSK   0x3F 
+#define SYM_MSK   0xC0 
+
+#define D3_MSK    0x80  
+#define D3_ON     0x80  
+#define D3_OFF    0x00  
+#define D3_IDX       0  
+
+#define DP_MSK    0x40  
+#define DP_ON     0x40  
+#define DP_OFF    0x00  
+#define DP_IDX       1  
+
+#define D1_MSK    0xC0  
+#define D1_RED    0x80  
+#define D1_GRN    0x40  
+#define D1_YEL    0xC0  
+#define D1_OFF    0x00  
+#define D1_IDX       2 
+
+// Enums
+enum BiLED {BI_OFF, BI_RED, BI_GRN, BI_YEL};   // Bicolour LED states
+
+
+/** Create a starburst object connected to the proper SPI pins
+ *
+ * @param  Pinname mosi, miso, sck, ce to connect to 
+ * @brief 
+*/
+class Starburst {
+
+public:
+  Starburst(SPI &spi, PinName CE, PinName nOE);
+  void set_dp(bool dp);    
+  void set_led(bool led);
+  void set_bi_led(BiLED bi_led);
+  void putc(int location, char byte);
+  void putc(char disp_char);
+  void printf (char * format, ...);
+  void scroll_printf (char * format, ...);
+   
+  void locate(uint8_t column);
+  void cls(void);
+//  void set_char_flash_state(bool flash_state, uint8_t char_pos);
+//  void set_all_flash_states(uint8_t flash_bits);
+//  void set_brightness(uint8_t brightness);  
+  void set_blink_mode(bool enable);  
+//  void set_flash_mode(bool enable);          
+  void set_scroll_mode(bool enable);  
+
+          
+protected:
+  SPI &_spi;
+  DigitalOut _ShiftLatch;
+  DigitalOut _nOE;
+    
+  Ticker _mpx, _blnk, _scrl;
+//    int _row;
+  int _column; 
+  char _digit_segments[STAR_NR_DIGITS][2];    
+
+  char _scroll_display_string[64];
+  int  _scroll_string_len;  
+  int  _scroll_ptr;  
+  bool _scroll;      
+
+  bool _blink, _blinkstate;  
+//  bool _flash;        
+  
+  void _init();
+  void _mpx_digits();
+  void _mpx_start();
+  void _blink_tick();   
+  void _blink_start();   
+  void _scroll_tick();       
+  void _scroll_start();         
+};
+
+
+#endif
+/*****************************************************************************/
+/******************************  END OF FILE  ********************************/
+/*****************************************************************************/