suu pen / SevenSegLed

Dependents:   kitchenTimer_Clock kitchenTimer LPC1114FN28_kitchenTimer_Clock SevenSegmentLedSample ... more

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Mon Nov 25 05:48:43 2013 +0000
Parent:
2:cca0fd8ccb97
Child:
5:a7ba72bf10ba
Commit message:
The Library has been modified for use in LPC1114FN28

Changed in this revision

SevenSegLed.cpp Show annotated file Show diff for this revision Revisions of this file
SevenSegLed.h Show annotated file Show diff for this revision Revisions of this file
--- a/SevenSegLed.cpp	Fri Dec 02 14:03:00 2011 +0000
+++ b/SevenSegLed.cpp	Mon Nov 25 05:48:43 2013 +0000
@@ -15,13 +15,19 @@
 
 /** Create a seven segment led object connected to the specified DigtalOutput pin
  */
+#ifdef USECOM4
+SevenSegLed::SevenSegLed(uint8_t commonPole, uint8_t smooth, PinName seg_a, PinName seg_b, PinName seg_c, PinName seg_d, PinName seg_e, PinName seg_f, PinName seg_g, PinName seg_p,
+                         PinName com_1, PinName com_2, PinName com_3, PinName com_4):
+    _seg_a(seg_a), _seg_b(seg_b), _seg_c(seg_c), _seg_d(seg_d), _seg_e(seg_e), _seg_f(seg_f), _seg_g(seg_g), _seg_p(seg_p),
+     _com_1(com_1), _com_2(com_2), _com_3(com_3), _com_4(com_4){
+#else // ~USECOM4
 SevenSegLed::SevenSegLed(uint8_t commonPole, uint8_t smooth, PinName seg_a, PinName seg_b, PinName seg_c, PinName seg_d, PinName seg_e, PinName seg_f, PinName seg_g, PinName seg_p,
                          PinName com_1, PinName com_2, PinName com_3, PinName com_4, PinName com_5, PinName com_6, PinName com_7, PinName com_8):
     _seg_a(seg_a), _seg_b(seg_b), _seg_c(seg_c), _seg_d(seg_d), _seg_e(seg_e), _seg_f(seg_f), _seg_g(seg_g), _seg_p(seg_p),
      _com_1(com_1), _com_2(com_2), _com_3(com_3), _com_4(com_4), _com_5(com_5), _com_6(com_6), _com_7(com_7), _com_8(com_8){
-
+#endif // USECOM4
     
-    timer.attach_us(this, &SevenSegLed::segmentGrayDataKosin, 10000);       // led smooth control 10ms timer inttruupt
+//    timer.attach_us(this, &SevenSegLed::segmentGrayDataKosin, 10000);       // led smooth control 10ms timer inttruupt
     
     // data table set of Brightness
     // DT_pwmGray[] = i ^ 2
@@ -31,10 +37,12 @@
     
     // check connect com_x
     D_comNull = Z_ketaSuu;
+#ifndef USECOM4    
     if(com_8 == NC){D_comNull--;}
     if(com_7 == NC){D_comNull--;}
     if(com_6 == NC){D_comNull--;}
     if(com_5 == NC){D_comNull--;}
+#endif //USECOM4
     if(com_4 == NC){D_comNull--;}
     if(com_3 == NC){D_comNull--;}
     if(com_2 == NC){D_comNull--;}
@@ -158,6 +166,7 @@
       
  
         // dynamic shuturyoku shori
+ segmentGrayDataKosin();
         output();
 }
 
@@ -170,6 +179,7 @@
 void SevenSegLed::comAllClear(void){
     
     switch (D_comNull){
+#ifndef USECOM4
     case 8:                 // com_1 - com_8is all connect
         _com_8 = D_commonOff;
         //break;
@@ -182,6 +192,7 @@
     case 5:                 // com_6 Null
         _com_5 = D_commonOff;
         //break;
+#endif // USECOM4
     case 4:                 // com_5 Null
         _com_4 = D_commonOff;
         //break;                                
@@ -249,12 +260,10 @@
 
     if(M_seg >= D_comNull){M_seg = 0;}
 
-    // com, seg syokika
+   //com, seg syokika
     comAllClear();
     segAllClear();
-    
- 
-
+  
     // common output
     if(D_comNull != 0){
         // If the terminal output processing
@@ -271,6 +280,7 @@
         case 3:
             _com_4 = D_commonOn;
             break;
+#ifndef USECOM4
         case 4:
             _com_5 = D_commonOn;
             break;
@@ -283,6 +293,7 @@
         case 7:
             _com_8 = D_commonOn;
             break;                                                
+#endif // USECOM4
         default:
             break;
         }
@@ -294,8 +305,9 @@
     }
 
 
-    // com, seg syokika
-    comAllClear();
-    segAllClear();
+//    com, seg syokika
+//    comAllClear();
+//    segAllClear();
     M_seg++;
+
 }
--- a/SevenSegLed.h	Fri Dec 02 14:03:00 2011 +0000
+++ b/SevenSegLed.h	Mon Nov 25 05:48:43 2013 +0000
@@ -119,10 +119,11 @@
  * @endcode
  */
 
-
+#define USECOM4
 
 #include "types.h"
 
+
 class SevenSegLed {
 public:
 
@@ -134,10 +135,14 @@
     * @param seg_a - seg_p DigitalOut pin to connect to.    To provide members with an array of uint8_t digit minutes.
     * @param com_1 - com_8 DigitalOut pin to connect to.    To provide members with an array of uint8_t digit minutes. 8 digits maximum   
     */
+#ifdef USECOM4
+    SevenSegLed(uint8_t commonPole, uint8_t smooth, PinName seg_a, PinName seg_b, PinName seg_c, PinName seg_d, PinName seg_e, PinName seg_f, PinName seg_g, PinName seg_p,
+                PinName com_1 = NC, PinName com_2 = NC, PinName com_3 = NC, PinName com_4 = NC);
+#else // ~USECOM4
     SevenSegLed(uint8_t commonPole, uint8_t smooth, PinName seg_a, PinName seg_b, PinName seg_c, PinName seg_d, PinName seg_e, PinName seg_f, PinName seg_g, PinName seg_p,
                 PinName com_1 = NC, PinName com_2 = NC, PinName com_3 = NC, PinName com_4 = NC,
                 PinName com_5 = NC, PinName com_6 = NC, PinName com_7 = NC, PinName com_8 = NC);
-    
+#endif // USECOM4    
     /** Data set to the seven segment LED display
     * @param number Array variable address pointer of Numerical data 0 - 9,A - F : The figures show, 0x10:off
     * @param dot    Array variable address pointer of dot data  0:off 1:on
@@ -153,11 +158,19 @@
 
 //  pin set_seg, _com;
     DigitalOut _seg_a, _seg_b, _seg_c, _seg_d, _seg_e, _seg_f, _seg_g, _seg_p;
+#ifdef USECOM4
+    DigitalOut _com_1, _com_2, _com_3, _com_4;
+#else //~USECOM4
     DigitalOut _com_1, _com_2, _com_3, _com_4, _com_5, _com_6, _com_7, _com_8;
+#endif // USECOM4
     
-    Ticker timer;
+   Ticker timer;
 
+#ifdef USECOM4
+#define Z_ketaSuu (4)   // 7segment no keta suu
+#else //USECOM4
 #define Z_ketaSuu (8)   // 7segment no keta suu
+#endif // USECOM4
 #define Z_segSuu  (8)   // 7segmetn no segment suu (a,b,...,g,Dp)
 #define Z_grayMax (100)  // grayData max 100 kaicho
 #define Z_pwmGrayMax (100) // pwm max (led heno pwm syuturyoku no max)