7-Segment Display Driver class, via an 8-bit shift register (such as the 74HC595)

Fork of 7SegSRDriver by Paul Law

Revision:
2:5f76214d096c
Parent:
1:e55f543bc06b
diff -r e55f543bc06b -r 5f76214d096c 7SegSRDriver.h
--- a/7SegSRDriver.h	Sun May 01 17:34:00 2011 +0000
+++ b/7SegSRDriver.h	Tue Jun 06 13:50:47 2017 +0000
@@ -1,25 +1,3 @@
-/* mbed 7-Segment Display Driver Library (via an 8bit Shift Register)
- * Copyright (c) 2011 Paul Law
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
 #ifndef LIB_SSEGSRDRIVER_H
 #define LIB_SSEGSRDRIVER_H
 
@@ -28,75 +6,86 @@
 #define SSegSRDriver_COMN_ANODE 0
 #define SSegSRDriver_COMN_CATHODE 1
 
-//Char defs: 0123456789AbCdEF
-const unsigned char SSegSRDriver_chardefs[16] = {0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 };
+const unsigned char nbr_envoye[11] = {0x3f, 0x30 , 0x6d, 0x79, 0x72, 0x5b, 0x5f, 0x33, 0x7f, 0x7b, 0x00};
+const unsigned char nbr_envoye_2[11] = {0x3f, 0x30 , 0x6d, 0x79, 0x72, 0x5b, 0x5f, 0x33, 0x7f, 0x7b, 0x00};
+const unsigned char nbr_envoye_3[11] = {0x3f, 0x30 , 0x6d, 0x79, 0x72, 0x5b, 0x5f, 0x33, 0x7f, 0x7b, 0x00};
+const unsigned char nbr_envoye_4[11] = {0x3f, 0x30 , 0x6d, 0x79, 0x72, 0x5b, 0x5f, 0x33, 0x7f, 0x7b, 0x00};
 
-/** 7-Segment Display Driver class, via a 8-bit shift register (such as the 74HC595)
- *
- * Display should be hooked up to shift register as follows:
- * Q0 : Decimal Point, Q1-Q7 : Segments a-g
- *
- * Example:
- * @code
- * #include "mbed.h"
- * #include "7SegSRDriver.h"
- *
- * SSegSRDriver display(p27,p25,p26, SSegSRDriver_COMN_ANODE);
- *
- * int main() {
- *     while (1) {
- *         // Show the chars 0-9 then A-F, flashing the decimal point on and off
- *         for (int i=0; i<16; i++) {
- *             display.write(i,i%2 == 0);
- *             wait(1);
- *         }
- *     }
- * }
- * @endcode
- */
-class SSegSRDriver {
+
+/**************************************************                 CHRONOMETRE                   ****************************************************/
+
+
+class SSegSRDriver_chronometre {
 
 public:
 
-    /** Create a 7-Segment Display Driver object connected to a 8-bit shift register on the given DigitalOut pins
-     *
-     * @param srData Shift Register Data pin (DigitalOut)
-     * @param srClock Shift Register Clock pin (DigitalOut)
-     * @param srLatch Shift Register Latch pin (DigitalOut)
-     * @param disp_type Display Type: Common Anode/Cathode (SSegSRDriver_COMN_ANODE (0) or SSegSRDriver_COMN_CATHODE (1))
-     */
-    SSegSRDriver(PinName srData, PinName srClock, PinName srLatch, bool disp_type);
-
-    /** Change the type of 7-Segment Display
-     *
-     * @param disp_type Display Type: Common Anode/Cathode (SSegSRDriver_COMN_ANODE (0) or SSegSRDriver_COMN_CATHODE (1))
-     */
-    void set_type(bool disp_type);
+    SSegSRDriver_chronometre(PinName srData, PinName srClock, PinName srLatch, bool disp_type);
+    void write_chronometre(unsigned char number, bool dp);   
+    void write_chronometre_2(unsigned char number_deux, bool dp); //
+    void write_chronometre_3(unsigned char number_trois, bool dp);
+    void write_chronometre_4(unsigned char number_quatre, bool dp);
+    
+    void bus_chronometre_1(unsigned char number);   // inustruction pour le bus 1 de 0 a 8 bit 
+    void bus_chronometre_2(unsigned char number_deux);   // inustruction pour le bus 2 de 0 a 8 bit
+    void bus_chronometre_3(unsigned char number_trois);
+    void bus_chronometre_4(unsigned char number_quatre); 
+    void clear();  
     
-    /** Sets the currently shown digit on the display
-     *
-     * @param number The digit to display (0-15) to show numbers 0-9 and letters A-F
-     */
-    void write(unsigned char number); 
+private:
+
+    DigitalOut _srData;
+    DigitalOut _srClock;
+    DigitalOut _srLatch;
+    bool _disp_type;
+};
+
+
+/**************************************************                 DOMICILE                   ****************************************************/
+
+
+class SSegSRDriver_domicile {
+
+public:
+
+    SSegSRDriver_domicile(PinName srData, PinName srClock, PinName srLatch, bool disp_type);
+
+    void set_type(bool disp_type);
+    void write_domicile(unsigned char number, bool dp);   
+    void write_domicile_2(unsigned char number_deux, bool dp); 
+    void write_domicile_3(unsigned char number_trois, bool dp);
+    
+    void bus_domicile_1(unsigned char number);   // inustruction pour le bus 1 de 0 a 8 bit 
+    void bus_domicile_2(unsigned char number_deux);   // inustruction pour le bus 2 de 0 a 8 bit
+    void bus_domicile_3(unsigned char number_trois); 
+    void clear();  
     
-    /** Sets the currently shown digit on the display along with the decimal place
-     *
-     * @param number The digit to display (0-15) to show numbers 0-9 and letters A-F
-     * @param dp If the decimal place should be lit (0:Off, 1:On)
-     */
-    void write(unsigned char number, bool dp);   
+private:
+
+    DigitalOut _srData;
+    DigitalOut _srClock;
+    DigitalOut _srLatch;
+    bool _disp_type;
+};
+
+
+/**************************************************                 VISITEUR                   ****************************************************/
+
+
+class SSegSRDriver_visiteur {
+
+public:
+
+    SSegSRDriver_visiteur(PinName srData, PinName srClock, PinName srLatch, bool disp_type);
+
+    void set_type(bool disp_type);
+    void write_visiteur(unsigned char number, bool dp);   
+    void write_visiteur_2(unsigned char number_deux, bool dp); 
+    void write_visiteur_3(unsigned char number_trois, bool dp);
     
-    /** Sets the segments of the display directly
-     * Segments are lit by binary flags where LSB is the decimal point, then segments a-g up to the MSB
-     * e.g. to light segments e, f and the decimal place = 01100001
-     *
-     * @param bValue The segments to light
-     */
-    void write_raw(unsigned char number);   // Write directly to the display - Q0/Q1-Q7
-    
-    /** Turn all segments of the display off
-     */
-    void clear();   // Clears the display
+    void bus_visiteur_1(unsigned char number);   // inustruction pour le bus 1 de 0 a 8 bit 
+    void bus_visiteur_2(unsigned char number_deux);   // inustruction pour le bus 2 de 0 a 8 bit
+    void bus_visiteur_3(unsigned char number_trois); 
+    void clear();  
     
 private: