Dependencies:   EthernetNetIf NTPClient_NetServices mbed

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Sun Dec 11 00:24:18 2011 +0000
Commit message:

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
NTP.c Show annotated file Show diff for this revision Revisions of this file
NTP.h Show annotated file Show diff for this revision Revisions of this file
NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
TLC5940.lib Show annotated file Show diff for this revision Revisions of this file
Types.h Show annotated file Show diff for this revision Revisions of this file
display.c Show annotated file Show diff for this revision Revisions of this file
display.h Show annotated file Show diff for this revision Revisions of this file
dotmatrix.c Show annotated file Show diff for this revision Revisions of this file
dotmatrix.h Show annotated file 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
tokei.c Show annotated file Show diff for this revision Revisions of this file
tokei.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTP.c	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,58 @@
+/***********************************************************************/
+/*                                                                     */
+/*    NTP.c                                                            */
+/*                                                                     */
+/***********************************************************************/
+#define _NTP_C
+
+#include "mbed.h"
+#include "NTPClient.h"
+#include "EthernetNetIf.h"
+#include "NTP.h"
+
+EthernetNetIf eth; 
+NTPClient ntp;
+
+/******************************************************************************
+Name       : Ethernet no initialize
+Parameters : none
+Returns    : -1:NG 0:OK
+Description: -
+******************************************************************************/
+int8_t ntp_ethernetInitial(void){
+
+  printf("Start\n");
+  printf("Setting up...\n");
+  
+ 
+    EthernetErr ethErr = eth.setup();
+    if(ethErr)
+    {
+        printf("Error %d in setup.\n", ethErr);
+        return -1;
+    }
+    return 0;
+}
+
+/******************************************************************************
+Name       : Ethernet no initialize
+Parameters : none
+Returns    : -1:NG 0:OK
+Description: -
+******************************************************************************/
+void ntp_ntpDataGet(void){
+  time_t ctTime;
+  ctTime = time(NULL);  
+  printf("Current time is (UTC): %s\n", ctime(&ctTime));  
+
+    Host server(IpAddr(), 123, "ntp.nict.jp");
+//  Host server(IpAddr(), 123, "ntp1.jst.mfeed.ad.jp" );
+//  Host server(IpAddr(), 123, "0.uk.pool.ntp.org");
+  
+  ntp.setTime(server);
+    
+  ctTime = time(NULL);  
+  printf("\nTime is now (UTC): %s\n", ctime(&ctTime)); 
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTP.h	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,35 @@
+/***********************************************************************/
+/*                                                                     */
+/*    NTP.h                                                            */
+/*                                                                     */
+/***********************************************************************/
+#ifndef _NTP_H
+#define _NTP_H
+
+#include "Types.h"
+
+
+/*****************************Macro definition********************************/
+
+
+/******************************Function declaration***************************/
+int8_t ntp_ethernetInitial(void);
+void ntp_ntpDataGet(void);
+
+/*****************************Global variable*********************************/
+#ifdef _NTP_C
+    #define    EXTERN
+    #define    GLOBAL_VARIABLE_DEFINE
+#else
+    #define    EXTERN extern
+#endif
+
+
+
+
+#undef    _NTP_C
+#undef    EXTERN
+#undef    GLOBAL_VARIABLE_DEFINE
+
+
+#endif    // _NTP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TLC5940.lib	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/suupen/code/TLC5940/#ead2ebe1dc77
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Types.h	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,114 @@
+/*----------------------------------------------------------------------------*/
+/* File Information                                                           */
+/*----------------------------------------------------------------------------*/
+/* Name       : types.h                                                       */
+/* Type       : C Programming Language Header                                 */
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+#include "stdint.h"
+/*
+typedef char         int8_t;
+typedef unsigned char         uint8_t;
+typedef signed     short        int16_t;
+typedef unsigned short         uint16_t;
+typedef signed     int         int32_t;
+typedef unsigned int         uint32_t;
+typedef signed     long long     int64_t;
+typedef unsigned long long     uint64_t;
+*/
+//typedef bool                bool_t;
+typedef enum{TRUE, FALSE} bool_t;
+
+//=========================================================================
+//    byte bit access
+//=========================================================================
+typedef union{                    //    BYTE�^(BYTE/NIBBLE/BIT access)
+    uint8_t byte;                //    Byte access
+    struct{                        //    Nibble����
+        uint8_t lo : 4;        //        lower(Bit0 - 3)
+        uint8_t hi : 4;        //        upper(Bit4 - 7)
+    }nibble;
+    struct{                        //    Bit access
+        uint8_t b0 : 1;        //        Bit0
+        uint8_t b1 : 1;        //        Bit1
+        uint8_t b2 : 1;        //        Bit2
+        uint8_t b3 : 1;        //        Bit3
+        uint8_t b4 : 1;        //        Bit4
+        uint8_t b5 : 1;        //        Bit5
+        uint8_t b6 : 1;        //        Bit6
+        uint8_t b7 : 1;        //        Bit7
+    }bits;
+}byte_t;
+
+//=========================================================================
+//    word bit access
+//=========================================================================
+typedef union{                    //    WORD�^(WORD/BYTE/NIBBLE/BIT access)
+    uint16_t word;                //    Word access
+    struct{                        //    Byte access
+        uint8_t b0;            //        upper byte
+        uint8_t b1;            //        lower byte
+    }byte;
+    struct    {                    //    Nibble access
+        uint8_t n0 : 4;        //        lower byte low(Bit 0 -  3)
+        uint8_t n1 : 4;        //        lower byte up (Bit 4 -  7)
+        uint8_t n2 : 4;        //        upper byte low(Bit 8 - 11)
+        uint8_t n3 : 4;        //        upper byte up (Bit12 - 15)
+    }nibble;
+    struct{                        //    Bit acces
+        uint8_t b0 : 1;        //        Bit0
+        uint8_t b1 : 1;        //        Bit1
+        uint8_t b2 : 1;        //        Bit2
+        uint8_t b3 : 1;        //        Bit3
+        uint8_t b4 : 1;        //        Bit4
+        uint8_t b5 : 1;        //        Bit5
+        uint8_t b6 : 1;        //        Bit6
+        uint8_t b7 : 1;        //        Bit7
+        uint8_t b8 : 1;        //        Bit8
+        uint8_t b9 : 1;        //        Bit9
+        uint8_t b10: 1;        //        Bit10
+        uint8_t b11: 1;        //        Bit11
+        uint8_t b12: 1;        //        Bit12
+        uint8_t b13: 1;        //        Bit13
+        uint8_t b14: 1;        //        Bit14
+        uint8_t b15: 1;        //        Bit15
+    }bits;
+}word_t;
+
+
+//=========================================================================
+//    ascii code
+//=========================================================================
+#define Z_NUL (0x00)
+#define Z_SOH (0x01)
+#define Z_STX (0x02)
+#define Z_ETX (0x03)
+#define Z_EOT (0x04)
+#define Z_ENQ (0x05)
+#define Z_ACK (0x06)
+#define Z_BEL (0x07)
+
+#define Z_BS  (0x08)
+#define Z_HT  (0x09)
+#define Z_LF  (0x0A)
+#define Z_HM  (0x0B)
+#define Z_FF  (0x0C)
+#define Z_CR  (0x0D)
+#define Z_SO  (0x0E)
+#define Z_SI  (0x0F)
+
+#define Z_DLE (0x10)
+#define Z_DC1 (0x11)
+#define Z_DC2 (0x12)
+#define Z_DC3 (0x13)
+#define Z_DC4 (0x14)
+#define Z_NAK (0x15)
+#define Z_SYN (0x16)
+#define Z_ETB (0x17)
+
+
+#endif    /* __TYPES_H__*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/display.c	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,283 @@
+/***********************************************************************/
+/*                                                                     */
+/*    display.c                                                          */
+/*                                                                     */
+/***********************************************************************/
+#define _DISPLAY_C
+
+#include "display.h"
+
+/*****************************Macro definition********************************/
+
+/*****************************Global variable*********************************/
+
+/******************************Function declaration***************************/
+static bool_t display_positionCheck(_DISPLAYPOSITION *c);
+static bool_t display_colorCheck(_DISPLAYCOLOR *c);
+
+/******************************************************************************
+Name       : hyoji zahyo no hani check
+Parameters : none
+Returns    : nothing
+Description: D_display[][][] = 0x00
+******************************************************************************/
+static bool_t display_positionCheck(_DISPLAYPOSITION *p)
+{
+    bool_t ans = TRUE;
+
+    if((*p).x < Z_displayXMin){ans = FALSE;}
+    if((*p).x > Z_displayXMax){ans = FALSE;}
+    
+    if((*p).y < Z_displayXMin){ans = FALSE;}
+    if((*p).y > Z_displayXMax){ans = FALSE;}
+
+    return ans;
+}
+/******************************************************************************
+Name       : hyoji color no hani check
+Parameters : none
+Returns    : nothing
+Description: D_display[][][] = 0x00
+******************************************************************************/
+static bool_t display_colorCheck(_DISPLAYCOLOR *c)
+{
+    bool_t ans = TRUE;
+
+    if((*c).g < Z_colorMin){ans = FALSE;}
+    if((*c).g > Z_colorNull){ans = FALSE;}
+    
+    if((*c).r < Z_colorMin){ans = FALSE;}
+    if((*c).r > Z_colorNull){ans = FALSE;}
+
+    return ans;
+}
+
+/******************************************************************************
+Name       : display_clr()
+Parameters : none
+Returns    : nothing
+Description: D_display[][][] = 0x00
+******************************************************************************/
+void display_clr(void)
+{
+    uint8_t x,y;
+
+    for(x = 0; x <= Z_displayXMax; x++){
+        for(y = 0; y <= Z_displayYMax; y++){
+            D_display[Z_red][x][y] = 0;
+            D_display[Z_green][x][y] = 0;
+        }
+    }
+}
+
+/******************************************************************************
+Name       : display_pset(redGradiation,greenGradiation,x,y)
+Parameters : color   x    y
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_pset(_DISPLAYCOLOR c, _DISPLAYPOSITION p)
+{
+    if(( display_positionCheck(&p) == TRUE) 
+    && ( display_colorCheck(&c) == TRUE)
+    ){
+        if(c.r < Z_colorNull){
+            D_display[Z_red][p.x][p.y] = c.r;
+        }
+        if(c.g < Z_colorNull){
+            D_display[Z_green][p.x][p.y] = c.g;
+        }
+    }
+}
+
+/******************************************************************************
+Name       : display_pset(redGradiation,greenGradiation,x,y)
+Parameters : color   x    y
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_line(_DISPLAYCOLOR c, _DISPLAYPOSITION p0, _DISPLAYPOSITION p1)
+{
+    _DISPLAYPOSITION d;    // henka ryo
+    _DISPLAYPOSITION s; // hoko
+
+    uint8_t i;
+    int16_t E;
+
+    d.x = (p1.x > p0.x) ? p1.x - p0.x : p0.x - p1.x;
+    d.y = (p1.y > p0.y) ? p1.y - p0.y : p0.y - p1.y;
+
+    s.x = (p1.x > p0.x) ? 1 : -1;
+    s.y = (p1.y > p0.y) ? 1 : -1;
+
+    /* katamuki ga 1 yori chiisai baai */
+  if ( d.x > d.y ) {
+    E = -d.x;
+    for ( i = 0 ; i <= d.x ; i++ ) {
+      display_pset( c, p0 );
+      p0.x += s.x;
+      E += 2 * d.y;
+      if ( E >= 0 ) {
+        p0.y += s.y;
+        E -= 2 * d.x;
+      }
+    }
+  /* katamuki ga 1 ijo no baai */
+      } else {
+        E = -d.y;
+        for ( i = 0 ; i <= d.y ; i++ ) {
+            display_pset( c, p0 );
+            p0.y += s.y;
+            E += 2 * d.x;
+              if ( E >= 0 ) {
+                p0.x += s.x;
+                E -= 2 * d.y;
+              }
+        }
+    }
+
+}
+
+
+/******************************************************************************
+Name       : display_pset(redGradiation,greenGradiation,x,y)
+Parameters : color   x    y        l:genten kara no dot suu
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_lineLimit(_DISPLAYCOLOR c, _DISPLAYPOSITION p0, _DISPLAYPOSITION p1, uint8_t l)
+{
+    _DISPLAYPOSITION d;    // henka ryo
+    _DISPLAYPOSITION s; // hoko
+
+    uint8_t i;
+    int16_t E;
+
+    d.x = (p1.x > p0.x) ? p1.x - p0.x : p0.x - p1.x;
+    d.y = (p1.y > p0.y) ? p1.y - p0.y : p0.y - p1.y;
+
+    s.x = (p1.x > p0.x) ? 1 : -1;
+    s.y = (p1.y > p0.y) ? 1 : -1;
+
+    /* katamuki ga 1 yori tiisai baai */
+  if ( d.x > d.y ) {
+    E = -d.x;
+    if(d.x > (l - 1)){d.x = (l - 1);}
+    for ( i = 0 ; i <= d.x ; i++ ) {
+      display_pset( c, p0 );
+      p0.x += s.x;
+      E += 2 * d.y;
+      if ( E >= 0 ) {
+        p0.y += s.y;
+        E -= 2 * d.x;
+      }
+    }
+  /* katamuki ga 1 ijo no baai */
+      } else {
+        E = -d.y;
+        if(d.y > (l - 1)){d.y = (l - 1);}
+        for ( i = 0 ; i <= d.y ; i++ ) {
+            display_pset( c, p0 );
+            p0.y += s.y;
+            E += 2 * d.x;
+              if ( E >= 0 ) {
+                p0.x += s.x;
+                E -= 2 * d.y;
+              }
+        }
+    }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/******************************************************************************
+Name       : display_test()
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_test0(void)
+{
+    _DISPLAYCOLOR c = {15, 15};
+    _DISPLAYPOSITION p0 ={1, 1};
+    static _DISPLAYPOSITION p1 ={0, 15};
+    display_line(c, p0, p1);
+
+    if(++p1.x > Z_displayXMax){p1.x = Z_displayXMin;}
+
+}
+
+
+/******************************************************************************
+Name       : display_test()
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_test(void)
+{
+    uint8_t x,y;
+    
+    
+
+
+    for(x = 0; x < 16; x++){
+        for(y = 0; y < 16; y++){
+            D_display[Z_red][x][y] = y;
+        }
+    }
+    for(y = 0; y < 16; y++){
+        for(x = 0; x < 16; x++){
+            D_display[Z_green][x][y] = x;
+        }
+    }
+}
+/******************************************************************************
+Name       : display_test2()
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+void display_test2(void)
+{
+    uint8_t x,y;
+    static uint8_t c = 0;
+    static int8_t s= 1;
+    
+    c += s;
+    if(c > 15){
+        c = 15;
+        s = -1;
+    }
+    else if (c == 0){
+        s = 1;
+    }
+    
+    for(x = 0; x < 16; x++){
+        for(y = 0; y < 16; y++){
+//            if(++D_display[Z_red][x][y] > 15){D_display[Z_red][x][y] = 0;}
+            D_display[Z_green][x][y] = c;
+//            if(++D_display[Z_green][x][y] > 15){D_display[Z_green][x][y] = 0;}
+        }
+    }
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/display.h	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,78 @@
+/***********************************************************************/
+/*                                                                     */
+/*    display.h                                                          */
+/*                                                                     */
+/***********************************************************************/
+#ifndef _DISPLAY_H
+#define _DISPLAY_H
+
+#include "Types.h"
+
+/*****************************Macro definition********************************/
+#define Z_colorNo (2)
+#define Z_red   (0)
+#define Z_green (1)
+
+#define Z_colorMin (0)
+#define Z_colorMax (99)
+#define Z_colorNull (100)
+
+#define Z_displayXMin    (0)
+#define Z_displayYMin    (0)
+#define Z_displayXMax    (15)
+#define Z_displayYMax    (15)
+
+typedef struct{
+    int16_t x;
+    int16_t y;
+}_DISPLAYPOSITION;
+
+typedef struct{
+    int16_t r;        // red color data
+    int16_t g;        // green color data
+}_DISPLAYCOLOR;
+
+/******************************Function declaration***************************/
+void display_clr(void);
+void display_test0(void);
+void display_test(void);
+void display_test2(void);
+
+void display_pset(_DISPLAYCOLOR c, _DISPLAYPOSITION p);
+void display_line(_DISPLAYCOLOR c, _DISPLAYPOSITION p0, _DISPLAYPOSITION p1);
+void display_lineLimit(_DISPLAYCOLOR c, _DISPLAYPOSITION p0, _DISPLAYPOSITION p1, uint8_t l);
+
+
+/*****************************Global variable*********************************/
+#ifdef _DISPLAY_C
+    #define    EXTERN
+    #define    GLOBAL_VARIABLE_DEFINE
+#else
+    #define    EXTERN extern
+#endif
+
+// hyoji data sakusei yo
+EXTERN uint8_t D_display[Z_colorNo][Z_displayXMax + 1][Z_displayYMax + 1];
+    // [Color][Horizontal][Vertical]
+    // [Color] Z_green (0)    Z_red(1)
+    // 
+    // Horizontal : X        Vertical : Y
+    // [X][Y]       X00,X01,-X14,X15
+    //            Y00
+    //            Y01
+    //            |
+    //            Y14
+    //            Y15
+    // 
+    //             byte data no imi
+    //             0:off    1:min - 15:max
+    // 
+
+// hyoji data kakutei yo
+EXTERN uint8_t B_display[Z_colorNo][Z_displayXMax + 1][Z_displayYMax + 1];
+
+#undef    _DISPLAY_C
+#undef    EXTERN
+#undef    GLOBAL_VARIABLE_DEFINE
+
+#endif    // _DISPLAY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dotmatrix.c	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,386 @@
+/*****************************************************
+* dot matrix led drive
+*
+*       Display : LT5016M1(16*16 dot matrix LED red&green led) http://akizukidenshi.com/catalog/g/gI-00039/
+*       LED Driver : TLC5940  http://focus.ti.com/lit/ds/slvs515c/slvs515c.pdf
+*
+* V0.0 : 110529A_dotMatrixClock.zip
+* V0.1 : 110601A_demo.zip
+*           fuyo code sakujo (dosa ha V0.0 to onazi)                   
+*****************************************************/
+#define _DOTMATRIX_C
+
+#define DBG
+
+#include "Types.h"
+#include "mbed.h"
+#include "dotmatrix.h"
+#include "display.h"
+#ifdef DBG
+#include "TLC5940.h"
+#endif //DBG
+
+static uint16_t DT_grayData[100]; //100kaicho data wo TLC5940 no grayData(4096kaicho)ni henkan suru data table
+
+/******************************Function declaration***************************/
+#ifndef DBG
+static void tlc5940DotCorrection(void);
+static void tlc5940SpiInitalize(void);
+static void tlc5940GrayDataClear(void);
+#endif //DBG
+static void tlc5940GrayDataDisplayAndSend(int8_t rowNo);
+static void dotmatrix_displayDataTransform(void);
+
+/*****************************Macro definition********************************/
+#ifdef DBG
+    TLC5940 tlc5940(p5, p6, p7, p19, p22, p21, 2);
+#else //~DBG
+// TLC5940 control
+SPI spi(p5, p6, p7);    //SIN (p6), SCLK,GSCLK(p7)
+
+DigitalOut XLAT(p19);
+DigitalOut BLANK(p22);
+DigitalOut VPRG(p21);
+#endif  // DBG
+
+// TD62783APG  (dot matrix ROW1 - ROW16 drive)
+DigitalOut ROW1(p16);
+DigitalOut ROW2(p15);
+DigitalOut ROW3(p14);
+DigitalOut ROW4(p13);
+DigitalOut ROW5(p12);
+DigitalOut ROW6(p11);
+DigitalOut ROW7(p10);
+DigitalOut ROW8(p9);
+
+DigitalOut ROW9(p23);
+DigitalOut ROW10(p24);
+DigitalOut ROW11(p25);
+DigitalOut ROW12(p26);
+DigitalOut ROW13(p27);
+DigitalOut ROW14(p28);
+DigitalOut ROW15(p29);
+DigitalOut ROW16(p30);
+
+#define Z_ROWMIN (0)
+#define Z_ROWMAX (15)    // ROW Max (ROWNo = 0 to 15)
+
+/*****************************Global variable*********************************/
+// dot matrix led grayscale data
+uint16_t D_dotDisplay[2][16][16];
+/*
+[color][x][y]:
+color 0:red data    1:green data
+x : 0 - 15
+y : 0 - 15
+
+data : 0 - 4095
+*/
+
+
+
+
+
+/******************************************************************************
+Name       : dot matrix output
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_output(void) {
+    static int8_t cnt = Z_ROWMAX;
+
+
+
+    if (++cnt > Z_ROWMAX) {
+        F_kakikae = 1;
+        cnt = Z_ROWMIN;
+         dotmatrix_displayDataTransform();    // hyoji data henkan
+        F_kakikae = 0;
+    }
+
+    // ROW All Off
+    ROW1 = 0;
+    ROW2 = 0;
+    ROW3 = 0;
+    ROW4 = 0;
+    ROW5 = 0;
+    ROW6 = 0;
+    ROW7 = 0;
+    ROW8 = 0;
+    ROW9 = 0;
+    ROW10 = 0;
+    ROW11 = 0;
+    ROW12 = 0;
+    ROW13 = 0;
+    ROW14 = 0;
+    ROW15 = 0;
+    ROW16 = 0;
+    
+ 
+
+
+    // ROW out
+    switch (cnt) {
+        case 0:
+            ROW1 = 1;
+            break;
+        case 1:
+            ROW2 = 1;
+            break;
+        case 2:
+            ROW3 = 1;
+            break;
+        case 3:
+            ROW4 = 1;
+            break;
+        case 4:
+            ROW5 = 1;
+            break;
+        case 5:
+            ROW6 = 1;
+            break;
+        case 6:
+            ROW7 = 1;
+            break;
+        case 7:
+            ROW8 = 1;
+            break;
+        case 8:
+            ROW9 = 1;
+            break;
+        case 9:
+            ROW10 = 1;
+            break;
+        case 10:
+            ROW11 = 1;
+            break;
+        case 11:
+            ROW12 = 1;
+            break;
+        case 12:
+            ROW13 = 1;
+            break;
+        case 13:
+            ROW14 = 1;
+            break;
+        case 14:
+            ROW15 = 1;
+            break;
+        case 15:
+            ROW16 = 1;
+            break;
+         default:
+            cnt = 0;
+            break;
+    }
+
+  // display data set
+  // ROW = Hi no atoni Column output
+    tlc5940GrayDataDisplayAndSend(cnt);
+
+}
+
+/******************************************************************************
+Name       : TLC5940 initalize
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_initialize(void){
+#ifndef DBG
+    tlc5940DotCorrection();
+    tlc5940SpiInitalize();
+    tlc5940GrayDataClear();
+#endif // DBG
+}
+
+/******************************************************************************
+Name       : Display data set demo initialize
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_demoInitialize(void) {
+    for(int8_t y = 0; y < 16; y++){
+        for(int8_t x = 0; x < 16; x++){
+            D_dotDisplay[0][x][y] = (4095 * x) / 15;
+            D_dotDisplay[1][x][y] = (4095 * y) / 15;
+        }
+    }
+}
+/******************************************************************************
+Name       : Display data set demo
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_demo(void) {
+
+    static int8_t x = 0;
+    static int8_t y = 0;
+    
+     for(x = 0; x < 16; x++){
+        for(y = 0; y < 16; y++){
+            D_dotDisplay[0][x][y] += 3;
+            D_dotDisplay[1][x][y] += 3;
+        }
+    }
+}
+
+#ifndef DBG
+/******************************************************************************
+Name       : TLC5940 dot correction initalize
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void tlc5940DotCorrection(void) {
+    VPRG = 1;
+    spi.format(6,0);
+    spi.frequency(30000000);
+
+
+//    VPRG = 1;
+
+    for (int i = 0; i < (16 * 2); i++) {
+        int whoami = spi.write(63);
+    }
+
+    XLAT = 1;
+    XLAT = 0;
+}
+#endif //DBG
+
+#ifndef DBG
+/******************************************************************************
+Name       : SPI Initalize (for TLC5960 control)
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void tlc5940SpiInitalize(void) {
+    spi.format(12,0);
+    spi.frequency(30000000);
+
+    VPRG = 0;
+}
+#endif //DBG
+
+#ifndef DBG
+/******************************************************************************
+Name       : TLC5940 Gray Data clear
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void tlc5940GrayDataClear(void) {
+
+    VPRG = 0;
+    
+    for (int i = 0; i < (16 * 2); i++) {
+        int whoami = spi.write(0);
+    }
+
+    XLAT = 1;
+    XLAT = 0;
+}
+#endif //DBG
+
+/******************************************************************************
+Name       : TLC5940 Gray Data Display & next data send
+Parameters : rowNo 0 - 15
+Returns    : nothing
+Description: 
+******************************************************************************/
+#ifdef DBG
+static void tlc5940GrayDataDisplayAndSend(int8_t rowNo){
+
+    uint8_t x;
+    int8_t sendRowNo = rowNo + 1;
+    uint16_t D_gray[2][16];
+    
+    if(sendRowNo > 15){sendRowNo = 0;}
+    // green data send
+    for(x = 0; x < 16; x++){
+        D_gray[1][x] = D_dotDisplay[1][x][sendRowNo];
+    }
+    // red data send
+    for(x = 0; x < 16; x++){
+        D_gray[0][x] = D_dotDisplay[0][15 - x][sendRowNo];
+    }
+
+    tlc5940.grayDataSetAndDisplay((uint16_t*)D_gray);
+    
+}    
+#else //~DBG
+static void tlc5940GrayDataDisplayAndSend(int8_t rowNo){
+
+    int8_t sendRowNo = rowNo + 1;
+
+    int8_t x; // display data no x    0 - 15
+
+    #define Z_GSCLKNUM (340)    // GRAYSCALE PWM sousin yo clock  4096(PWM) / 12bit(sousin) = 341
+    #define Z_GRAYDATA (16 * 2)
+    
+    
+    BLANK = 1;
+    BLANK = 0;
+
+
+  
+    
+    VPRG = 0;
+
+    if(sendRowNo > 15){sendRowNo = 0;}
+
+    for(int i = 0; i < (Z_GSCLKNUM - Z_GRAYDATA); i++){
+        // grayscale pwm clock only
+        spi.write(0);
+    }
+    
+    // grayscale pwm clock & color data clock
+    // green data send
+    for(x = 0; x < 16; x++){
+        spi.write(D_dotDisplay[1][15 - x][sendRowNo]);
+    }
+    // red data send
+    for(x = 0; x < 16; x++){
+        spi.write(D_dotDisplay[0][x][sendRowNo]);
+    }
+   
+    XLAT = 1;
+    XLAT = 0;
+}
+#endif //DBG
+
+
+/******************************************************************************
+Name       : display data kaicho wo TLC5940 Gray Data ni henkan suru data table ti no sakusei
+Parameters : none 
+Returns    : nothing
+Description: 
+******************************************************************************/
+void dotmatrix_grayDataKansan(void){
+
+    for(uint32_t i = 0; i < 100; i++){
+         DT_grayData[i] = (uint16_t)((i * i * 10) / 40);
+    }
+}
+
+/******************************************************************************
+Name       : display data transform to TLC5940 Gray Data
+Parameters : none 
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void dotmatrix_displayDataTransform(void){
+ 
+    // D_display[][][] no 15grayScaleData wo 4096grayScale Data ni henkan
+    for(uint8_t x = 0; x < 16; x++){
+        for(uint8_t y = 0; y < 16; y++){
+        D_dotDisplay[Z_dotGreen][x][y]     = DT_grayData[B_display[Z_green][x][y]];
+        D_dotDisplay[  Z_dotRed][x][y]     = DT_grayData[B_display[  Z_red][x][y]];
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dotmatrix.h	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,70 @@
+/***********************************************************************/
+/*                                                                     */
+/*    dotmatrix.h                                                        */
+/*                                                                     */
+/***********************************************************************/
+#ifndef _DOTMATRIX_H
+#define _DOTMATRIX_H
+
+#include "Types.h"
+/*****************************Macro definition********************************/
+#define Z_dotGreen    (1)
+#define Z_dotRed    (0)
+
+/******************************Function declaration***************************/
+/******************************************************************************
+Name       : dot matrix output
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_output(void);
+
+/******************************************************************************
+Name       : TLC5940 initalize
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_initialize(void);
+
+/******************************************************************************
+Name       : Display data set demo initialize
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_demoInitialize(void);
+
+/******************************************************************************
+Name       : Display data set demo
+Parameters : none
+Returns    : nothing
+Description: extren call
+******************************************************************************/
+void dotmatrix_demo(void);
+
+/******************************************************************************
+Name       : display data kaicho wo TLC5940 Gray Data ni henkan suru data table ti no sakusei
+Parameters : none 
+Returns    : nothing
+Description: 
+******************************************************************************/
+void dotmatrix_grayDataKansan(void);
+
+/*****************************Global variable*********************************/
+#ifdef _DOTMATRIX_C
+    #define    EXTERN
+    #define    GLOBAL_VARIABLE_DEFINE
+#else
+    #define    EXTERN extern
+#endif
+
+EXTERN uint8_t F_kakikae;   // 0:kakikae OK 1:kakikae NG
+
+#undef    _DOTMATRIX_C
+#undef    EXTERN
+#undef    GLOBAL_VARIABLE_DEFINE
+
+
+#endif    // _DOTMATRIX_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,59 @@
+/*****************************************************
+* dot matrix clock
+*
+*       Display : LT5016M1(16*16 dot matrix LED red&green led) http://akizukidenshi.com/catalog/g/gI-00039/
+*       LED Driver : TLC5940  http://focus.ti.com/lit/ds/slvs515c/slvs515c.pdf
+*
+* V0.0 : 110621A_110621dotMatrixClock.zip
+*        sample program                    
+*****************************************************/
+#include "mbed.h"
+#include "dotmatrix.h"
+#include "tokei.h"
+#include "NTP.h"
+
+Timer timer;
+
+/************************************
+* main
+************************************/
+int main() {
+
+    uint32_t tstart;
+    uint32_t tend;
+    
+    // Ethernet initial
+    int8_t ether = ntp_ethernetInitial();
+    if(ether == -1){
+        return(-1);
+    }
+    
+    // first ntp data get
+    ntp_ntpDataGet();
+
+//demo (UTC + 15houre(nippon jikan hosei)
+//        ji            fun        byo  hosei
+//set_time((11 * 3600) + (59 * 60) + 55 + 54000); 
+
+
+    // hyoji data sakusei timming yo timer
+    timer.start();
+    tstart = timer.read_ms();
+
+    dotmatrix_initialize();
+    dotmatrix_grayDataKansan();
+
+
+    while (1) {
+
+        // 10ms keika sitara hyoji data wo sakusei        
+        tend = timer.read_ms();
+        if((tend - tstart) >= 10){
+            tstart = tend;
+            tokei_main();
+       }
+
+        dotmatrix_output();
+   }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tokei.c	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,769 @@
+/***********************************************************************/
+/*                                                                     */
+/*    tokei.c                                                          */
+/*                                                                     */
+/***********************************************************************/
+#define _TOKEI_C
+
+#include "mbed.h"
+#include "math.h"
+
+#include "tokei.h"
+#include "display.h"
+#include "dotmatrix.h"
+#include "NTPClient.h"
+#include "NTP.h"
+
+//#define DBG
+
+/*****************************Macro definition********************************/
+
+/*****************************Global variable*********************************/
+
+/******************************Function declaration***************************/
+static void tokei_jikokuKeiji(_JIKOKU *j);
+static void tokei_byoHyoji(_JIKOKU j);
+static void tokei_funHyoji(_JIKOKU j);
+static void tokei_jiHyoji(_JIKOKU j);
+static void tokei_amPmHyoji(_JIKOKU j);
+static _DISPLAYPOSITION tokei_byoIti(uint8_t sec);
+static _DISPLAYPOSITION tokei_jiIti(uint8_t ji, uint8_t min);
+static void tokei_mojibanByo(void);
+static void tokei_mojibanJi(void);
+
+
+/******************************************************************************
+Name       : jikoku keiji
+Parameters : none
+Returns    : nothing
+Description: 100ms call
+******************************************************************************/
+
+void tokei_main(void)
+{
+
+    tokei_jikokuKeiji(&D_genzaiJikoku);
+    
+    // genzai jikoku hyoji
+    tokei_funHyoji(D_genzaiJikoku);
+    tokei_byoHyoji(D_genzaiJikoku);     // fun no dot wo henko suru no de tokei_funHyoji()no ato ni jittko
+    tokei_jiHyoji(D_genzaiJikoku);
+    
+    // mojiban hyoji
+    tokei_amPmHyoji(D_genzaiJikoku);
+    tokei_mojibanByo();
+    tokei_mojibanJi();
+    
+    // TLC5940 heno kakikae wo siteinaitoki ni hyoji data kosin
+    if(F_kakikae == 0){
+        // hyoji data kakikae OK
+        for(uint8_t x = 0; x < 16; x++){
+            for(uint8_t y = 0; y < 16; y++){
+                B_display[Z_green][x][y] = D_display[Z_green][x][y];
+                B_display[Z_red][x][y] = D_display[Z_red][x][y];
+            }
+        }
+    }
+}
+
+/******************************************************************************
+Name       : jikoku keiji (debug)
+Parameters : none
+Returns    : nothing
+Description: 10ms call
+******************************************************************************/
+#ifndef DBG
+static void tokei_jikokuKeiji(_JIKOKU *j)
+{
+    static uint8_t secBuffer = 0;
+    time_t ctTime;
+    struct tm *jst_time;
+    
+    _JIKOKU wk = *j;
+
+
+    ctTime = time(NULL);
+    ctTime += 32400;
+    jst_time = localtime(&ctTime);
+
+    
+    wk.sec  = jst_time->tm_sec;
+    wk.min  = jst_time->tm_min;
+    wk.hour = jst_time->tm_hour;
+    
+    // dammy ms data setup
+    if(wk.msec < 99){wk.msec++;}
+    if(secBuffer != wk.sec){
+        wk.msec = 0;
+        secBuffer = wk.sec;
+    }
+    
+    *j = wk;
+    
+/* NTP wo tukawanai toki no code
+    _JIKOKU wk = *j;
+
+    wk.msec++;
+    if(wk.msec > 99){
+        wk.msec = 0;
+        wk.sec++;
+        if(wk.sec > 59){
+            wk.sec = 0;
+            wk.min++;
+            if(wk.min > 59){
+                wk.min = 0;
+                wk.hour++;
+                if(wk.hour > 23){
+                    wk.hour = 0;
+                }
+            }
+        }
+    }
+    *j = wk;
+*/
+}
+#else // DBG
+static void tokei_jikokuKeiji(_JIKOKU *j)
+{
+   _JIKOKU wk = *j;
+
+    wk.msec++;
+    if(wk.msec > 99){
+        wk.msec = 0;
+        wk.sec++;
+        if(wk.sec > 59){
+            wk.sec = 0;
+            wk.min++;
+            if(wk.min > 59){
+                wk.min = 0;
+                wk.hour++;
+                if(wk.hour > 23){
+                    wk.hour = 0;
+                }
+            }
+        }
+    }
+    *j = wk;
+}
+#endif // DBG
+
+/******************************************************************************
+Name       : byo hyoji
+Parameters : none
+Returns    : nothing
+Description: 10ms ika no syuki de call
+******************************************************************************/
+static void tokei_byoHyoji(_JIKOKU j)
+{
+    uint8_t c = j.sec;
+    uint8_t i;
+    int8_t red;
+
+    _DISPLAYPOSITION iti;
+    _DISPLAYCOLOR color;
+
+    // kako no tento kasyo wo 1s goto ni 1dankai zutu syoto
+    for(i = 0; i < 60; i++){
+        
+        iti = tokei_byoIti(i);
+        if((j.msec % 10) == 0){
+            if(D_display[Z_green][iti.x][iti.y] > 0){
+                D_display[Z_green][iti.x][iti.y] -=1;
+            }
+        }
+
+        uint8_t j1 = j.min + 1;
+        if(j1 > 60){j1 = 0;}
+        if((D_display[Z_green][iti.x][iti.y] > 0) && ((j.min != i) && ((j1 != i )))){
+            // red to green ga kasanaru tokoto ha red wo genko suru 
+            // (genzai ji to 59s kara 0s deno senko hyoji no red ha genko kara jogai) 
+            red = D_display[Z_red][iti.x][iti.y] - D_display[Z_green][iti.x][iti.y];
+            if(red < 0){
+                red = 0;
+            }
+            D_display[Z_red][iti.x][iti.y] = (uint8_t)red;
+         }
+    }
+    
+    // genzai no byo iti wo 100ms goto ni 1dankai zutu tento
+    iti = tokei_byoIti(c);
+
+    color.r = Z_colorNull;
+    color.g = ((uint16_t)j.msec * Z_colorMax) / 99;
+    display_pset(color, iti);
+    
+}
+
+/******************************************************************************
+Name       : fun hyoji(byo to onaji iti ni hyoji)
+Parameters : none
+Returns    : nothing
+Description: 10msec ika no syuki de call
+******************************************************************************/
+static void tokei_funHyoji(_JIKOKU j)
+{
+    static uint8_t clearflag = 0;    // 59min to 0min clear flag
+    uint8_t c = j.min;
+
+//    static _JIKOKU zenkaiJikoku = {0, 0, 1, 0};
+
+    _DISPLAYPOSITION iti;
+    _DISPLAYCOLOR color;
+    
+    // 0min no toki no clear yo
+    _DISPLAYPOSITION p0;
+    _DISPLAYPOSITION p1;
+
+
+    // 1jikan keika go no fun dot clear
+    switch(clearflag){
+    case 0:
+        if(c == 59){clearflag = 1;}
+        break;
+    case 1:
+        if(c == 0){
+            color.g = Z_colorNull;
+            if(j.sec == 0){
+                color.r = Z_colorMax - ((uint16_t)j.msec * Z_colorMax) / 99;
+            }
+            else{
+                color.r = 0;
+                clearflag = 0;
+            }
+            p0.x = 0;
+            p0.y = 0;
+            p1.x = 15;
+            p1.y = 0;
+            display_line(color, p0, p1);
+            p0.x = 15;
+            p0.y = 0;
+            p1.x = 15;
+            p1.y = 15;
+            display_line(color, p0, p1);
+            p0.x = 15;
+            p0.y = 15;
+            p1.x = 0;
+            p1.y = 15;
+            display_line(color, p0, p1);
+            p0.x = 0;
+            p0.y = 15;
+            p1.x = 0;
+            p1.y = 0;
+            display_line(color, p0, p1);
+        }
+    default:
+        // nothing
+        break;      
+    }
+    
+    // fun dot no reflesh
+    for(uint8_t i = 0; i < c; i++){
+        iti = tokei_byoIti(i);
+        color.r = Z_colorMax;
+        color.g = Z_colorNull;
+        display_pset(color, iti);
+    }
+ 
+    // genzai no byo iti wo 1s goto ni 1dankai zutu tento
+    iti = tokei_byoIti(c);
+
+    if((j.sec & 0x01) == 0){
+        // genzai fun no tenmetu hyoji
+        color.r = Z_colorMax - ((uint16_t)j.msec * Z_colorMax) / 99;
+    }
+    else{
+        color.r = ((uint16_t)j.msec * Z_colorMax) / 99;
+    }
+
+    color.g = Z_colorNull;
+    display_pset(color, iti);
+    
+    // 59s to 0s deno tugi no fun dot senko hyoji
+    if(j.sec == 59){
+        uint8_t ctugi = c + 1;
+        if(ctugi > 59){
+            ctugi = 0;
+        }
+        iti = tokei_byoIti(ctugi);
+        color.r = ((uint16_t)j.msec * Z_colorMax) / 99;
+    
+        color.g = Z_colorNull;
+        display_pset(color, iti);
+    }
+}
+
+/******************************************************************************
+Name       : ji hyoji(chusin yori 5syume de hyoji) 3dot 1jikan
+Parameters : none
+Returns    : nothing
+Description: 1jikan ika no syuki de call
+******************************************************************************/
+static void tokei_jiHyoji(_JIKOKU j)
+{
+    static uint8_t clearflag = 0;
+
+    uint8_t ji;
+    uint8_t jiIti;
+    _DISPLAYPOSITION iti;
+    _DISPLAYCOLOR color;
+    
+    // 0ji no clear yo
+    _DISPLAYCOLOR c = {0, 0};
+    _DISPLAYPOSITION p0;
+    _DISPLAYPOSITION p1;
+
+    // 24hour to 12hour 
+    ji = j.hour;
+    if(ji > 11){ji -= 12;}
+
+
+    // ji dot clear syori (59min to 0min clear)
+    switch(clearflag){
+    case 0:
+        if(ji == 11){clearflag = 1;}
+        break;
+    case 1:
+        if(ji == 0){
+            if(j.sec == 0){
+                color.r = Z_colorMax - ((uint16_t)j.msec * Z_colorMax) / 99;
+                color.g = color.r;
+            }
+            else{
+                color.r = 0;
+                color.g = 0;
+                clearflag = 0;
+            }
+            
+            p0.x = 3;
+            p0.y = 3;
+            p1.x = 12;
+            p1.y = 3;
+            display_line(color, p0, p1);
+            p0.x = 12;
+            p0.y = 3;
+            p1.x = 12;
+            p1.y = 12;
+            display_line(color, p0, p1);
+            p0.x = 12;
+            p0.y = 12;
+            p1.x = 3;
+            p1.y = 12;
+            display_line(color, p0, p1);
+            p0.x = 3;
+            p0.y = 12;
+            p1.x = 3;
+            p1.y = 3;
+            display_line(color, p0, p1);
+        }
+    default:
+        // nothing
+        break;
+    }    
+
+    // kako no ji dot wo tento
+    color.r = Z_colorMax;
+    color.g = color.r;
+    for(uint8_t jiKako = 0; jiKako < ji; jiKako++){
+        for(uint8_t minKako = 0; minKako < 60; minKako += 20){
+            iti = tokei_jiIti(jiKako, minKako);
+            display_pset(color, iti);
+        }
+    }
+    for(uint8_t minKako = 0; minKako < j.min; minKako += 20){
+        iti = tokei_jiIti(ji, minKako);
+        display_pset(color, iti);
+    }
+    
+    //*************************
+    // genzai ji no dot tenmetu
+    //*************************
+    iti = tokei_jiIti(ji, j.min);
+    if((j.sec & 0x01) == 0){
+        // genzai ji no tenmetu hyoji
+        color.r = Z_colorMax - ((uint16_t)j.msec * Z_colorMax) / 99;
+        color.g = color.r;
+    }
+    else{
+        color.r = ((uint16_t)j.msec * Z_colorMax) / 99;
+        color.g = color.r;
+    }
+    
+    display_pset(color, iti);
+
+    //**********************************
+    // 20fun goto no  ji dot senko hyoji
+    //**********************************
+    if(j.sec == 59){
+        if((j.min == 19) || (j.min == 39) || (j.min == 59)){
+            uint8_t tugiFun = j.min + 1;
+            uint8_t tugiJi  = ji;
+            if(tugiFun > 59){
+                tugiFun = 0;
+                tugiJi++;
+                if(tugiJi > 11){tugiJi = 0;};
+            }    
+           
+            iti = tokei_jiIti(tugiJi, tugiFun);
+            color.r = ((uint16_t)j.msec * Z_colorMax) / 99;
+            color.g = color.r;
+    
+            display_pset(color, iti);
+        }
+    }
+}
+
+
+/******************************************************************************
+Name       : AM/PM hyoji
+Parameters : none
+Returns    : nothing
+Description: 1jikan ika no syuki de call
+******************************************************************************/
+static void tokei_amPmHyoji(_JIKOKU j)
+{
+    uint8_t ji = j.hour;
+    uint8_t ji12;
+    _DISPLAYPOSITION iti;
+    _DISPLAYCOLOR color;
+
+    if(ji < 12){ji12 = ji;}
+    else{ji12 = ji - 12;}
+
+    // AM/PM no hyoji
+    if(ji < 12){
+        color.g    = ji12 * 5 + 39;
+        color.r = Z_colorMin;
+    }
+    else{
+        color.g = Z_colorMin;
+        color.r    = ji12 * 5 + 39;
+    }
+        
+    iti.x = 7;
+    iti.y = 7;
+    display_pset(color, iti);
+    iti.x = 8;
+    iti.y = 7;
+    display_pset(color, iti);
+    iti.x = 7;
+    iti.y = 8;
+    display_pset(color, iti);
+    iti.x = 8;
+    iti.y = 8;
+    display_pset(color, iti);
+    
+
+}
+
+/******************************************************************************
+Name       : moji ban (byo bubun)
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void tokei_mojibanByo(void)
+{
+    _DISPLAYPOSITION iti,iti2;
+    _DISPLAYCOLOR color;
+
+    // base line
+    color.r = Z_colorMin;
+    color.g = 50;
+
+    iti.x = 1;
+    iti.y = 1;
+    iti2.x = 14;
+    iti2.y = 1;
+    display_line(color, iti, iti2);
+
+    iti.x = 14;
+    iti.y = 1;
+    iti2.x = 14;
+    iti2.y = 14;
+    display_line(color, iti, iti2);
+
+    iti.x = 14;
+    iti.y = 14;
+    iti2.x = 1;
+    iti2.y = 14;
+    display_line(color, iti, iti2);
+
+    iti.x = 1;
+    iti.y = 14;
+    iti2.x = 1;
+    iti2.y = 1;
+    display_line(color, iti, iti2);
+
+
+    // 0fun
+    iti.x = 1;
+    iti.y = 1;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 5fun
+    iti.x = 5;
+    iti.y = 1;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 10fun
+    iti.x = 10;
+    iti.y = 1;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 15fun
+    iti.x = 14;
+    iti.y = 1;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 20fun
+    iti.x = 14;
+    iti.y = 5;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 25fun
+    iti.x = 14;
+    iti.y = 10;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 30fun
+    iti.x = 14;
+    iti.y = 14;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 35fun
+    iti.x = 10;
+    iti.y = 14;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 40fun
+    iti.x = 5;
+    iti.y = 14;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 45fun
+    iti.x = 1;
+    iti.y = 14;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 50fun
+    iti.x = 1;
+    iti.y = 10;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 55fun
+    iti.x = 1;
+    iti.y = 5;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+}
+
+/******************************************************************************
+Name       : moji ban (ji bubun)
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static void tokei_mojibanJi(void)
+{
+    _DISPLAYPOSITION iti,iti2;
+    _DISPLAYCOLOR color;
+
+    // base line
+    color.r = Z_colorMin;
+    color.g = 50;
+
+    iti.x = 4;
+    iti.y = 4;
+    iti2.x = 11;
+    iti2.y = 4;
+    display_line(color, iti, iti2);
+
+    iti.x = 11;
+    iti.y = 4;
+    iti2.x = 11;
+    iti2.y = 11;
+    display_line(color, iti, iti2);
+
+    iti.x = 11;
+    iti.y = 11;
+    iti2.x = 4;
+    iti2.y = 11;
+    display_line(color, iti, iti2);
+
+    iti.x = 4;
+    iti.y = 11;
+    iti2.x = 4;
+    iti2.y = 4;
+    display_line(color, iti, iti2);
+
+    // 0ji
+    iti.x = 4;
+    iti.y = 4;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 1ji
+    iti.x = 6;
+    iti.y = 4;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 2ji
+    iti.x = 9;
+    iti.y = 4;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 3ji
+    iti.x = 11;
+    iti.y = 4;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 4ji
+    iti.x = 11;
+    iti.y = 6;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 5ji
+    iti.x = 11;
+    iti.y = 9;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 6ji
+    iti.x = 11;
+    iti.y = 11;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 7ji
+    iti.x = 9;
+    iti.y = 11;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 8ji
+    iti.x = 6;
+    iti.y = 11;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 9ji
+    iti.x = 4;
+    iti.y = 11;
+    color.r = Z_colorMax;
+    color.g = Z_colorMin;
+    display_pset(color, iti);
+
+    // 10ji
+    iti.x = 4;
+    iti.y = 9;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+    // 12ji
+    iti.x = 4;
+    iti.y = 6;
+    color.r = Z_colorMax;
+    color.g = Z_colorMax;
+    display_pset(color, iti);
+
+}
+
+/******************************************************************************
+Name       : byo iti zahyo no sansyutu
+Parameters : none
+Returns    : nothing
+Description: 
+******************************************************************************/
+static _DISPLAYPOSITION tokei_byoIti(uint8_t sec)
+{
+    _DISPLAYPOSITION iti;
+
+    // genzai no byo iti wo 100ms goto ni 1dankai zutu tento
+    if(sec <= 14){
+        iti.x = sec;
+        iti.y = 0;
+    }
+    else if(sec <= 29){
+        iti.x = 15;
+        iti.y = sec % 15;
+    }
+    else if(sec <= 44){
+        iti.x = 15 - (sec % 15);
+        iti.y = 15;
+    }
+    else{
+        iti.x = 0;
+        iti.y = 15 - (sec % 15);
+    }
+    return iti;
+}
+
+/******************************************************************************
+Name       : ji iti zahyo no sansyutu
+Parameters : ji : 0 - 11, min : 0 - 59
+Returns    : nothing
+Description: 
+******************************************************************************/
+static _DISPLAYPOSITION tokei_jiIti(uint8_t ji, uint8_t min)
+{
+    uint8_t jiIti;
+    _DISPLAYPOSITION iti;
+    // genzai no ji iti wo tento
+    jiIti = (ji * 3) + (min / 20);
+    if(jiIti <= 8){
+        iti.x = jiIti + 3;
+        iti.y = 3;
+    }
+    else if(jiIti <= 17){
+        iti.x = 12;
+        iti.y = (jiIti % 9) + 3;
+    }
+    else if(jiIti <= 26){
+        iti.x = 12 - (jiIti % 9) ;
+        iti.y = 12;
+    }
+    else{
+        iti.x = 3;
+        iti.y = 12 - (jiIti % 9);
+    }
+    
+    return iti;
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tokei.h	Sun Dec 11 00:24:18 2011 +0000
@@ -0,0 +1,44 @@
+/***********************************************************************/
+/*                                                                     */
+/*    tokei.h                                                            */
+/*                                                                     */
+/***********************************************************************/
+#ifndef _TOKEI_H
+#define _TOKEI_H
+
+#include "Types.h"
+/*****************************Macro definition********************************/
+
+
+typedef struct{
+        uint8_t msec;      // ms      0 - 99    (10/1 [ms/bit])
+        uint8_t sec;       // s       0 - 59    (1/1 [s/bit])
+        uint8_t min;       // min     0 - 59    (1/1 [min/bit])
+        uint8_t hour;      // hour    0 - 23    (1/1 [hour/bit])
+} _JIKOKU;
+
+/******************************Function declaration***************************/
+void tokei_main(void);
+
+/*****************************Global variable*********************************/
+#ifdef _TOKEI_C
+    #define    EXTERN
+    #define    GLOBAL_VARIABLE_DEFINE
+#else
+    #define    EXTERN extern
+#endif
+
+EXTERN _JIKOKU D_genzaiJikoku
+#ifdef GLOBAL_VARIABLE_DEFINE
+ = {0, 0, 0, 0}
+// = {0, 0, 0, 0}
+#endif
+;
+
+
+#undef    _TOKEI_C
+#undef    EXTERN
+#undef    GLOBAL_VARIABLE_DEFINE
+
+
+#endif    // _TOKEI_H