キッチンタイマーのプログラムです

Dependencies:   mbed SevenSegLed Sound_pwmToDig SwAnalog

回路やプログラムについての詳しい説明は、下記のblogにまとめました。 http://suupen-make.blogspot.jp/2013/11/lpc1114fn28mbedkitchen-timer.html

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Mon Nov 25 05:53:25 2013 +0000
Parent:
1:f638c70e028c
Commit message:
This program is a kitchen Timer of using LPC1114FN28.

Changed in this revision

SevenSegLed.lib Show annotated file Show diff for this revision Revisions of this file
Sound.lib Show diff for this revision Revisions of this file
Sound_pwmToDig.lib Show annotated file Show diff for this revision Revisions of this file
SwAnalog2input.lib Show annotated file Show diff for this revision Revisions of this file
SwDigital.lib Show diff for this revision Revisions of this file
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
diff -r f638c70e028c -r 269bb751dd19 SevenSegLed.lib
--- a/SevenSegLed.lib	Sun Jan 15 04:22:00 2012 +0000
+++ b/SevenSegLed.lib	Mon Nov 25 05:53:25 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/suupen/code/SevenSegLed/#cca0fd8ccb97
+http://mbed.org/users/suupen/code/SevenSegLed/#33e035f6a337
diff -r f638c70e028c -r 269bb751dd19 Sound.lib
--- a/Sound.lib	Sun Jan 15 04:22:00 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/suupen/code/Sound/#c342b5349740
diff -r f638c70e028c -r 269bb751dd19 Sound_pwmToDig.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sound_pwmToDig.lib	Mon Nov 25 05:53:25 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/suupen/code/Sound_pwmToDig/#7e1945a135d7
diff -r f638c70e028c -r 269bb751dd19 SwAnalog2input.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SwAnalog2input.lib	Mon Nov 25 05:53:25 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/suupen/code/SwAnalog/#ebaa87e67cef
diff -r f638c70e028c -r 269bb751dd19 SwDigital.lib
--- a/SwDigital.lib	Sun Jan 15 04:22:00 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/suupen/code/SwDigital/#af5fbc75b7bf
diff -r f638c70e028c -r 269bb751dd19 main.cpp
--- a/main.cpp	Sun Jan 15 04:22:00 2012 +0000
+++ b/main.cpp	Mon Nov 25 05:53:25 2013 +0000
@@ -1,95 +1,98 @@
 //#define debug
 //===========================================================================
-// mbed seven segment LED PCB board example program
+// LPC1114FN28(mbed) kitchen timer 
 //
 // kitchen timer
 //
-// V1.0 120109
-// V1.1 120115 bug fix (40min ihyo no settei de merody ga naranai)
-// 
 // <schematic>
-// 1.seven segment numeric LED Display : OSL40562-LR
-//       http://akizukidenshi.com/download/OSL40562-LR.pdf
+// 1.seven segment numeric LED Display : OSL40562-IRA
+//       http://akizukidenshi.com/download/OSL40562-IRA.pdf
 //
-//  OSL40562-LR                           Resister        mbed
-//  Pin No     Function                   [ohm]           Function
+//  OSL40562-IRA                          Resister        LPC1114FN28
+//  Pin No     Function                   [ohm]           PinNo
 //  ---------------------------------------------------------------------------
-//   1         segment E                   200            P13 
-//   2         segment D                   200            P12
-//   3         segment Dp                  200            P11
-//   4         segment C                   200            p10
-//   5         segment G                   200            P9
-//   6         common  4                   -              P8  
-//   7         segment B                   200            P5
-//   8         common  3                   -              P6 
-//   9         common  2                   -              p7
-//  10         segment F                   200            p18
-//  11         segment A                   200            P19 
-//  12         common  1                    -             p20
+//   1         segment E                   680            dp28 
+//   2         segment D                   680            dp27
+//   3         segment Dp                  680            dp26
+//   4         segment C                   680            dp25
+//   5         segment G                   680            dp18
+//   6         common  4                   -              dp17  
+//   7         segment B                   680            dp11
+//   8         common  3                   -              dp13 
+//   9         common  2                   -              dp14
+//  10         segment F                   680            dp5
+//  11         segment A                   680            dp6 
+//  12         common  1                    -             dp4
 // 
 // 2.sound speaker
 //                                               /
 //   mbed                 --------------      --/
-//   p21(pwmOut)     -----| R:0[ohm]   |-----|  |  speaker(8[ohm])
+//   dp1(pwmOut)     -----| R:100[ohm] |-----|  |  speaker(8[ohm])
 //                        --------------     |  |
 //                                           |  |
-//   p22(DigitalOut) ------------------------|  |
-//                                            --\
+//   dp2(pwmOut)     ------------------------|  |
+//      (digitalOut)                          --\
 //                                               \
 // 3.sw
-//                sw6(left sw)
-//                ---- 
-//    p25 --------o  o----------- GND
-//
-//                sw5(up sw)
-//                ---- 
-//    p26 --------o  o----------- GND
-//
-//                sw4(down sw)
-//                ---- 
-//    p27 --------o  o----------- GND
+//   -.- Vcc(+3.3[V])
+//    |                                               |--------------------> dp9(ADinput)
+//    |   ---------       ---------       ---------   |   ---------
+//    .---| Rsw2  |---.---| Rsw1  |---.---| Rsw0  |---.---| Rout  |----|
+//    |   ---------   |   ---------   |   ---------   |   ---------    |
+//    |     ----      |     -----     |     -----     |                |
+//    |-----o  o------.-----o  o------.-----o  o------|              -----
+//           LeftSW         DowmSW           UpSW                  GND(0[V])
+// 
+//  Rsw2 : 8.2[kohm], Rsw1 = 3.9[kohm], Rsw0 = 2.0[kohm], Rout = 1.0[kohm] (R no seido ha +-1[%])
 //
-//                sw3(right sw)
-//                ---- 
-//    p28 --------o  o----------- GND
+//   -.- Vcc(+3.3[V])
+//    |                                               |--------------------> dp10(ADinput)
+//    |   ---------       ---------       ---------   |   ---------
+//    .---| Rsw2  |---.---| Rsw1  |---.---| Rsw0  |---.---| Rout  |----|
+//    |   ---------   |   ---------   |   ---------   |   ---------    |
+//    |     ----      |     -----     |     -----     |                |
+//    |-----o  o------.-----o  o------.-----o  o------|              -----
+//          RightSW          BSW           ASW                      GND(0[V])
+// 
+//  Rsw2 : 8.2[kohm], Rsw1 = 3.9[kohm], Rsw0 = 2.0[kohm], Rout = 1.0[kohm] (R no seido ha +-1[%])
 //
-//                sw2(b sw)
-//                ---- 
-//    p29 --------o  o----------- GND
-//
-//                sw1(a sw)
-//                ---- 
-//    p30 --------o  o----------- GND
-//
-// V1.0 2011/12/11 
+// V1.0 131106
 // 
 //
 //===========================================================================
 #include "mbed.h"
+
+//#define DBG
+
+#ifdef DBG
+Serial pc(dp16, dp15);
+#endif //DBG
+
+
 #include "SevenSegLed.h"
 #include "Sound.h"
-#include "SwDigital.h"
+#include "SwAnalog.h"
 
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
-DigitalOut led4(LED4);
+
+
 
 Ticker timeout100ms;     // 100ms interrupt
 
-Sound sound(p21, p22);
-SwDigital sw(p25, p26, p27, p28, p29, p30); // left, up, down, right, b, a
+Sound sound(dp1, dp2);    // pwm, pwm(digitalOut)
+
+
+SwAnalog sw(dp9, dp10);
 enum{
-    leftSw,
     upSw,
     downSw,
-    rightSw,
+    leftSw,
+    aSw,
     bSw,
-    aSw
+    rightSw
 };
 
-//SevenSegLed sevenSegLed(1, 1, p19, p7, p10, p12, p13, p20, p9, p11, p18, p5, p6, p8);   // OSL40562-LR(schematic bug)
-SevenSegLed sevenSegLed(1, 1, p19, p5, p10, p12, p13, p18, p9, p11, p20, p7, p6, p8);   // OSL40562-LR(seikiban)
+SevenSegLed sevenSegLed(0, 1, dp6, dp11, dp25, dp27, dp28, dp5, dp18, dp26, dp4, dp14, dp13, dp17);   // OSL40562-IRA
+
 
 uint8_t D_7seg[4] = {0, 0, 0, 0};
 uint8_t D_dot[4] = {0, 1, 0, 0};
@@ -113,12 +116,24 @@
 uint8_t F_flip100ms;    // 100ms keika goto ni 0 or 1 
 uint8_t F_flip500ms;    // 500ms keika goto ni 0 or 1
 
+
+// "beep" merody data
+    const Sound::sound_t BEEP[] = {
+    {1,0x95,200,100},
+    {1,0xFF,10,0}    // end
+    };
+
 void beep(void){
 // tone1 
-    Sound::sound_t oto = {1,0x95,200,100};
-    sound.sound_sound(oto);
+//    Sound::sound_t oto = {1,0x95,200,100};
+//    sound.sound_sound(oto);
+  
+ 
+    sound.sound_enso((Sound::sound_t*)BEEP);
+    sound.sound_enso(true);
 }
 
+
 // "westminster chime" merody data
     const Sound::sound_t WESTMINSTER[] =     {
     //  onkai,hatuon jikan[ms]
@@ -295,6 +310,8 @@
     }
 
 }
+
+
 //============================
 // timer set
 //============================
@@ -358,6 +375,8 @@
 //==========================
 void sevenSegDisplay(void){
     int16_t work;
+
+
     
     switch(M_timer){
     case stop:
@@ -498,6 +517,7 @@
 
 }
 
+
 //================================
 // main
 //================================
@@ -505,24 +525,31 @@
     timeout100ms.attach(&interrupt100ms, 0.1);  // 10ms interrupt
 
     while(1) {
+    
+
         // sw level and edge data refresh
+
         sw.refreshEdgeData();
-    
+
+
         timerSeni();
         timerSet();
+
         sevenSegDisplay();
-/*
+ 
         // debug code
-        if((sw.checkEdgeOn(leftSw) == 1)
-         ||(sw.checkEdgeOn(rightSw) == 1)
-         ||(sw.checkEdgeOn(upSw) == 1)
-         ||(sw.checkEdgeOn(downSw) == 1)
-         ||(sw.checkEdgeOn(aSw) == 1)
-         ||(sw.checkEdgeOn(bSw) == 1)
-        ){
-            led1 = !led1;
-        }
- */       
+#if 0
+            pc.printf("%01d %01d %01d    %01d %01d %01d\r\n",
+            sw.checkLevel(0),
+            sw.checkLevel(1),
+            sw.checkLevel(2),
+            sw.checkLevel(3),
+            sw.checkLevel(4),
+            sw.checkLevel(5)
+           
+            );
+#endif      
  
     }
 }
+
diff -r f638c70e028c -r 269bb751dd19 mbed.bld
--- a/mbed.bld	Sun Jan 15 04:22:00 2012 +0000
+++ b/mbed.bld	Mon Nov 25 05:53:25 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file