Toyomasa Watarai / BubbleDisplay

Dependents:   QDSP-6064-hello

Fork of BubbleDisplay by Michael Dushkoff

Files at this revision

API Documentation at this revision

Comitter:
mdu7078
Date:
Thu Mar 26 07:20:46 2015 +0000
Child:
1:0dd75913f211
Commit message:
Completed BubbleDisplay driver with lookup table for various characters that can be displayed on the device and basic access functions.

Changed in this revision

bubble.cpp Show annotated file Show diff for this revision Revisions of this file
bubble.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bubble.cpp	Thu Mar 26 07:20:46 2015 +0000
@@ -0,0 +1,161 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * This drives the popular QDSP6064 bubble display.  *
+ *                                                   *
+ * Created by: Michael Dushkoff (mad1841@rit.edu)    *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "bubble.h"
+
+/*
+ * 
+ */
+void BubbleDisplay::init(PinName m0, PinName m1, PinName m2, PinName m3,
+                  PinName m4, PinName m5, PinName m6, PinName m7,
+                  PinName m8, PinName m9, PinName m10, PinName m11){
+    // Set up pins
+    _cat1 = new DigitalOut(m0);
+    _anE = new DigitalOut(m1);
+    _anC = new DigitalOut(m2);
+    _cat3 = new DigitalOut(m3);
+    _anDP = new DigitalOut(m4);
+    _cat4 = new DigitalOut(m5);
+    _anG = new DigitalOut(m6);
+    _anD = new DigitalOut(m7);
+    _anF = new DigitalOut(m8);
+    _cat2 = new DigitalOut(m9);
+    _anB = new DigitalOut(m10);
+    _anA = new DigitalOut(m11);
+    
+    // Initialize the Ticker
+    _freq = DEF_DISPL_FREQ;
+    _cycler.attach(this,&BubbleDisplay::cycle,1.0/(_freq));
+    
+    // Set the initial display number
+    _seg = 0;
+    
+    // Set the initial character values
+    _chrs[0] = dispTabl[0];
+    _chrs[1] = dispTabl[0];
+    _chrs[2] = dispTabl[0];
+    _chrs[3] = dispTabl[0];
+}
+
+/*
+ * This is the default BubbleDisplay constructor that
+ * maps the pins in a simple way for the LPC11U24.
+ */ 
+BubbleDisplay::BubbleDisplay(){
+    init(p21,p22,p23,p24,p25,p26,p36,p35,p34,p33,p30,p29);
+}
+
+/*
+ * This allows a user to map the pins of the bubble display
+ * to any possible pin that they desire.
+ */
+BubbleDisplay::BubbleDisplay(PinName m0, PinName m1, PinName m2, PinName m3,
+              PinName m4, PinName m5, PinName m6, PinName m7,
+              PinName m8, PinName m9, PinName m10, PinName m11){
+    init(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11);
+}
+
+/*
+ * Default destructor
+ */
+BubbleDisplay::~BubbleDisplay(){
+    // Clean up all of our pointers
+    delete _cat1;
+    delete _anE;
+    delete _anC;
+    delete _cat3;
+    delete _anDP;
+    delete _cat4;
+    delete _anG;
+    delete _anD;
+    delete _anF;
+    delete _cat2;
+    delete _anB;
+    delete _anA;
+}
+
+/*
+ * This sets the cycle frequency to a specific value instead of the
+ * default 10kHz.
+ */
+ void BubbleDisplay::setFreq(double freq){
+     // Detach the cycler and then reattach it with the new frequency
+     _freq=freq;
+     _cycler.detach();
+     _cycler.attach(this,&BubbleDisplay::cycle,1.0/(_freq));
+}
+
+/*
+ * This cycles through the four seven segment displays on the
+ * bubble display by switching on and off the correct cathodes.
+ */
+void BubbleDisplay::cycle(){
+    // Set anodes to current display
+    (*_anDP) = ((dispTabl[_chrs[_seg]] >> 7) & (0x01));
+    (*_anA) = ((dispTabl[_chrs[_seg]] >> 6) & (0x01));
+    (*_anB) = ((dispTabl[_chrs[_seg]] >> 5) & (0x01));
+    (*_anC) = ((dispTabl[_chrs[_seg]] >> 4) & (0x01));
+    (*_anD) = ((dispTabl[_chrs[_seg]] >> 3) & (0x01));
+    (*_anE) = ((dispTabl[_chrs[_seg]] >> 2) & (0x01));
+    (*_anF) = ((dispTabl[_chrs[_seg]] >> 1) & (0x01));
+    (*_anG) = ((dispTabl[_chrs[_seg]] >> 0) & (0x01));
+    
+    switch(_seg){
+        case 0:
+            // Switch appropriate cathodes
+            (*_cat1) = 0;
+            (*_cat2) = 1;
+            (*_cat3) = 1;
+            (*_cat4) = 1;
+            _seg = 1;
+            break;
+        case 1:
+            // Switch appropriate cathodes
+            (*_cat1) = 1;
+            (*_cat2) = 0;
+            (*_cat3) = 1;
+            (*_cat4) = 1;
+            _seg = 2;
+            break;
+        case 2:
+            // Switch appropriate cathodes
+            (*_cat1) = 1;
+            (*_cat2) = 1;
+            (*_cat3) = 0;
+            (*_cat4) = 1;
+            _seg = 3;
+            break;
+        default:
+            // Switch appropriate cathodes
+            (*_cat1) = 1;
+            (*_cat2) = 1;
+            (*_cat3) = 1;
+            (*_cat4) = 0;
+            _seg = 0;
+            break;
+    }
+}
+
+/*
+ * This writes a sequence of characters from left to right
+ * to the seven-segment displays.
+ */
+void BubbleDisplay::write(char c1, char c2, char c3, char c4){
+    _chrs[0] = c1;
+    _chrs[1] = c2;
+    _chrs[2] = c3;
+    _chrs[3] = c4;
+}
+
+/*
+ * This writes a sequence of characters from left to right
+ * to the seven-segment displays.
+ */
+void BubbleDisplay::write(char* c){
+    _chrs[0] = c[0];
+    _chrs[1] = c[1];
+    _chrs[2] = c[2];
+    _chrs[3] = c[3];
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bubble.h	Thu Mar 26 07:20:46 2015 +0000
@@ -0,0 +1,220 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * This drives the popular QDSP6064 bubble display.  *
+ *                                                   *
+ * Created by: Michael Dushkoff (mad1841@rit.edu)    *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef BUBBLE_DISPLAY_H
+#define BUBBLE_DISPLAY_H
+
+#include "mbed.h"
+
+// Definitions
+#define DEF_DISPL_FREQ (10000.0) // 10kHz display frequency
+
+// LUT for character to display
+const char dispTabl[] = {
+    0x7E, // 0
+    0x30, // 1
+    0x6D, // 2
+    0x79, // 3
+    0x33, // 4
+    0x5B, // 5
+    0x5F, // 6
+    0x70, // 7
+    0x7F, // 8
+    0x7B, // 9
+    0x77, // 10  "A"
+    0x1F, // 11  "B"
+    0x4E, // 12  "C"
+    0x3D, // 13  "D"
+    0x4F, // 14  "E"
+    0x47, // 15  "F"
+    0x00, // 16  NO DISPLAY
+    0x00, // 17  NO DISPLAY
+    0x00, // 18  NO DISPLAY
+    0x00, // 19  NO DISPLAY
+    0x00, // 20  NO DISPLAY
+    0x00, // 21  NO DISPLAY
+    0x00, // 22  NO DISPLAY
+    0x00, // 23  NO DISPLAY
+    0x00, // 24  NO DISPLAY
+    0x00, // 25  NO DISPLAY
+    0x00, // 26  NO DISPLAY
+    0x00, // 27  NO DISPLAY
+    0x00, // 28  NO DISPLAY
+    0x00, // 29  NO DISPLAY
+    0x00, // 30  NO DISPLAY
+    0x00, // 31  NO DISPLAY
+    0x00, // 32 ' '
+    0x00, // 33 '!'  NO DISPLAY
+    0x22, // 34 '"'
+    0x00, // 35 '#'  NO DISPLAY
+    0x00, // 36 '$'  NO DISPLAY
+    0x00, // 37 '%'  NO DISPLAY
+    0x00, // 38 '&'  NO DISPLAY
+    0x20, // 39 '''
+    0x4E, // 40 '('
+    0x78, // 41 ')'
+    0x00, // 42 '*'  NO DISPLAY
+    0x00, // 43 '+'  NO DISPLAY
+    0x04, // 44 ','
+    0x01, // 45 '-'
+    0x80, // 46 '.'  Decimal
+    0x00, // 47 '/'  NO DISPLAY
+    0x7E, // 48 '0'
+    0x30, // 49 '1'
+    0x6D, // 50 '2'
+    0x79, // 51 '3'
+    0x33, // 52 '4'
+    0x5B, // 53 '5'
+    0x5F, // 54 '6'
+    0x70, // 55 '7'
+    0x7F, // 56 '8'
+    0x7B, // 57 '9'
+    0x00, // 58 ':'  NO DISPLAY
+    0x00, // 59 ';'  NO DISPLAY
+    0x00, // 60 '<'  NO DISPLAY
+    0x00, // 61 '='  NO DISPLAY
+    0x00, // 62 '>'  NO DISPLAY
+    0x00, // 63 '?'  NO DISPLAY
+    0x00, // 64 '@'  NO DISPLAY
+    0x77, // 65 'A'
+    0x1F, // 66 'B'
+    0x4E, // 67 'C'
+    0x3D, // 68 'D'
+    0x4F, // 69 'E'
+    0x47, // 70 'F'
+    0x5E, // 71 'G'
+    0x37, // 72 'H'
+    0x30, // 73 'I'
+    0x38, // 74 'J'
+    0x00, // 75 'K'  NO DISPLAY
+    0x0E, // 76 'L'
+    0x00, // 77 'M'  NO DISPLAY
+    0x15, // 78 'N'
+    0x7E, // 79 'O'
+    0x67, // 80 'P'
+    0x73, // 81 'Q'
+    0x05, // 82 'R'
+    0x5B, // 83 'S'
+    0x0F, // 84 'T'
+    0x3E, // 85 'U'
+    0x00, // 86 'V'  NO DISPLAY
+    0x00, // 87 'W'  NO DISPLAY
+    0x00, // 88 'X'  NO DISPLAY
+    0x3B, // 89 'Y'
+    0x00, // 90 'Z'  NO DISPLAY
+    0x4E, // 91 '['
+    0x00, // 92 '\'  NO DISPLAY
+    0x78, // 93 ']'
+    0x00, // 94 '^'  NO DISPLAY
+    0x80, // 95 '_'
+    0x02, // 96 '`'
+    0x77, // 97 'a' SAME AS CAP
+    0x1F, // 98 'b' SAME AS CAP
+    0x0D, // 99 'c'
+    0x3D, // 100 'd' SAME AS CAP
+    0x6F, // 101 'e'
+    0x47, // 102 'f' SAME AS CAP
+    0x5E, // 103 'g' SAME AS CAP
+    0x17, // 104 'h'
+    0x10, // 105 'i'
+    0x38, // 106 'j' SAME AS CAP
+    0x00, // 107 'k'  NO DISPLAY
+    0x30, // 108 'l'
+    0x00, // 109 'm'  NO DISPLAY
+    0x15, // 110 'n' SAME AS CAP
+    0x1D, // 111 'o'
+    0x67, // 112 'p' SAME AS CAP
+    0x73, // 113 'q' SAME AS CAP
+    0x05, // 114 'r' SAME AS CAP
+    0x5B, // 115 's' SAME AS CAP
+    0x0F, // 116 't' SAME AS CAP
+    0x1C, // 117 'u'
+    0x00, // 118 'b'  NO DISPLAY
+    0x00, // 119 'w'  NO DISPLAY
+    0x00, // 120 'x'  NO DISPLAY
+    0x00, // 121 'y'  NO DISPLAY
+    0x00, // 122 'z'  NO DISPLAY
+    0x00, // 123 '0b'  NO DISPLAY
+    0x00, // 124 '|'  NO DISPLAY
+    0x00, // 125 ','  NO DISPLAY
+    0x00, // 126 '~'  NO DISPLAY
+    0x00, // 127 'DEL'  NO DISPLAY
+};
+
+class BubbleDisplay{
+public:
+    /*
+     * This is the default BubbleDisplay constructor that
+     * maps the pins in a simple way for the LPC11U24.
+     */ 
+    BubbleDisplay();
+
+    /*
+     * This allows a user to map the pins of the bubble display
+     * to any possible pin that they desire.
+     */
+    BubbleDisplay(PinName m0, PinName m1, PinName m2, PinName m3,
+                  PinName m4, PinName m5, PinName m6, PinName m7,
+                  PinName m8, PinName m9, PinName m10, PinName m11);
+                  
+    /*
+     * Default destructor
+     */
+    ~BubbleDisplay();
+                  
+    /*
+     * This sets the cycle frequency to a specific value instead of the
+     * default 10kHz.
+     */
+     void setFreq(double freq);
+    
+    /*
+     * This writes a sequence of characters from left to right
+     * to the seven-segment displays.
+     */
+    void write(char c1, char c2, char c3, char c4);
+    
+    /*
+     * This writes a sequence of characters from left to right
+     * to the seven-segment displays.
+     */
+    void write(char* c);
+private:
+    /*
+     * This is a constructor helper function
+     */
+    void init(PinName m0, PinName m1, PinName m2, PinName m3,
+                  PinName m4, PinName m5, PinName m6, PinName m7,
+                  PinName m8, PinName m9, PinName m10, PinName m11);
+    
+    /*
+     * This cycles through the four seven segment displays on the
+     * bubble display by switching on and off the correct cathodes.
+     */
+    void cycle();
+    
+    /* Private variables */
+    Ticker _cycler;
+    double _freq; // The cycle frequency
+    char _seg; // The current display number
+    // All of the pins
+    DigitalOut* _cat1;
+    DigitalOut* _anE;
+    DigitalOut* _anC;
+    DigitalOut* _cat3;
+    DigitalOut* _anDP;
+    DigitalOut* _cat4;
+    DigitalOut* _anG;
+    DigitalOut* _anD;
+    DigitalOut* _anF;
+    DigitalOut* _cat2;
+    DigitalOut* _anB;
+    DigitalOut* _anA;
+    // Segement values
+    char _chrs[4];
+};
+
+#endif
\ No newline at end of file