Alphanumeric display for iHvZ

Files at this revision

API Documentation at this revision

Comitter:
etherealflaim
Date:
Sat Dec 11 22:33:15 2010 +0000
Child:
1:d5692deaa688
Commit message:
12/11/10 Joshua Durham

Changed in this revision

AlphaNumDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
AlphaNumDisplay.hpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AlphaNumDisplay.cpp	Sat Dec 11 22:33:15 2010 +0000
@@ -0,0 +1,76 @@
+#include "mbed.h"
+#include "AlphaNumDisplay.hpp"
+
+unsigned char AlphaNumDisplay::m_alphadisplay[][11]= { // < Table of symbols
+        {0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0 }, // 0
+        {1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 }, // 1
+        {0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 }, // 2
+        {0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1 }, // 3
+        {1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1 }, // 4
+        {0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1 }, // 5
+        {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1 }, // 6
+        {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, // 7
+        {0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 }, // 8
+        {0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1 }, // 9
+        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // blank
+        {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1 }, // A
+        {1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1 }, // B
+        {0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, // C
+        {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1 }, // D
+        {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, // E
+        {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1 }, // F
+        {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1 }, // G
+        {1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1 }, // H
+        {0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1 }, // I
+        {1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1 }, // J
+        {1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1 }, // K
+        {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, // L
+        {0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1 }, // M
+        {1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1 }, // N
+        {0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1 }, // O
+        {0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 }, // P
+        {0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1 }, // Q
+        {0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1 }, // R
+        {0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1 }, // S
+        {0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 }, // T
+        {1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1 }, // U
+        {1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1 }, // V
+        {1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, // W
+        {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, // X
+        {1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1 }, // Y
+        {0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 }, // Z
+        {1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0 }, // *
+        {1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0 }  // check mark   
+    };
+    
+    AlphaNumDisplay::AlphaNumDisplay(PinName HT = p13, PinName HM = p10, PinName HB = p8,
+        PinName VTL = p11, PinName VBL = p9, PinName VTM = p15, PinName VBM = p6, 
+        PinName VTR = p14, PinName VBR = p5, PinName DTL = p12, PinName DTR = p7)
+    : m_HTop(HT), m_HMiddle(HM), m_HBottom(HB), m_VTopLeft(VTL), m_VBottomLeft(VBL),
+        m_VTopMiddle(VTM),  m_VBottomMiddle(VBM),  m_VTopRight(VTR),  m_VBottomRight(VBR),
+        m_DTopLeft(DTL), m_DTopRight(DTR) 
+    {
+    }
+      
+    void AlphaNumDisplay::DisplayChar(unsigned char c) {
+        unsigned char index = ALPHA_NUM_CLEAR_I;
+        if(c == ALPHA_NUM_CHECK) index = ALPHA_NUM_CHECK_I;
+        if(c == ALPHA_NUM_CLEAR) index = ALPHA_NUM_CLEAR_I;
+        if(c == ALPHA_NUM_STAR)  index = ALPHA_NUM_STAR_I;
+        if(c < 10)               index = c + ALPHA_NUM_ZERO_I;
+        if(c >= '0' && c <= '9') index = c - '0' + ALPHA_NUM_ZERO_I;
+        if(c >= 'a' && c <= 'z') index = c - 'a' + ALPHA_NUM_A_I;
+        if(c >= 'A' && c <= 'Z') index = c - 'A' + ALPHA_NUM_A_I;
+    
+        m_HTop = AlphaNumDisplay::m_alphadisplay[index][0];
+        m_HMiddle = AlphaNumDisplay::m_alphadisplay[index][1];
+        m_HBottom = AlphaNumDisplay::m_alphadisplay[index][2];
+        m_VTopLeft = AlphaNumDisplay::m_alphadisplay[index][3];
+        m_VBottomLeft = AlphaNumDisplay::m_alphadisplay[index][4];
+        m_VTopMiddle = AlphaNumDisplay::m_alphadisplay[index][5];
+        m_VBottomMiddle = AlphaNumDisplay::m_alphadisplay[index][6];
+        m_VTopRight = AlphaNumDisplay::m_alphadisplay[index][7];
+        m_VBottomRight = AlphaNumDisplay::m_alphadisplay[index][8];
+        m_DTopLeft = AlphaNumDisplay::m_alphadisplay[index][9];
+        m_DTopRight = AlphaNumDisplay::m_alphadisplay[index][10];        
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AlphaNumDisplay.hpp	Sat Dec 11 22:33:15 2010 +0000
@@ -0,0 +1,43 @@
+#ifndef _AlphaNumDisplayH
+#define _AlphaNumDisplayH
+
+#include "mbed.h"
+#define ALPHA_NUM_SYMBOLS 39
+#define ALPHA_NUM_CHECK '^'
+#define ALPHA_NUM_CHECK_I 38
+#define ALPHA_NUM_STAR '*'
+#define ALPHA_NUM_STAR_I 37
+#define ALPHA_NUM_CLEAR ' '
+#define ALPHA_NUM_CLEAR_I 10
+#define ALPHA_NUM_A_I 11
+#define ALPHA_NUM_ZERO_I 0
+
+class AlphaNumDisplay {
+
+private:
+    // Display bars
+    DigitalOut m_HTop;                          //< Top Horizontal Bar 
+    DigitalOut m_HMiddle;                       //< Middle Horizontal Bar
+    DigitalOut m_HBottom;                       //< Bottom Horizontal Bar
+    DigitalOut m_VTopLeft;                      //< Top Left Vertical Bar
+    DigitalOut m_VBottomLeft;                   //< Bottom Left Vertical Bar
+    DigitalOut m_VTopMiddle;                    //< Top Middle Vertical Bar
+    DigitalOut m_VBottomMiddle;                 //< Bottom Middle Vertical Bar
+    DigitalOut m_VTopRight;                     //< Top Right Vertical Bar
+    DigitalOut m_VBottomRight;                  //< Bottom Right Vertical Bar
+    DigitalOut m_DTopLeft;                      //<Top left to bottom right
+    DigitalOut m_DTopRight;                     //< Bottom left to top right
+    static unsigned char m_alphadisplay[][11];  //<Table of symbols
+    
+public:
+    // Constructor:
+    AlphaNumDisplay(PinName HT, PinName HM, PinName HB, PinName VTL,
+                    PinName VBL, PinName VTM, PinName VBM, PinName VTR,
+                    PinName VBR, PinName DTL, PinName DTR);
+    
+    void DisplayChar(unsigned char c); //< Displays the character
+
+
+};    
+
+#endif
\ No newline at end of file