git test

Dependencies:   mbed

Committer:
kobajin
Date:
Sat Mar 17 04:38:25 2018 +0000
Revision:
2:65c48a2e85dc
Parent:
1:3dfd9c4c2520
Child:
3:4b96ddad43ab
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
masan 1:3dfd9c4c2520 1 //git test
kobajin 2:65c48a2e85dc 2 //test test
shimogamo 0:d54c76ac1184 3 #include "mbed.h"
shimogamo 0:d54c76ac1184 4
shimogamo 0:d54c76ac1184 5 DigitalOut dig_1(p15);
shimogamo 0:d54c76ac1184 6 DigitalOut dig_2(p27);
shimogamo 0:d54c76ac1184 7 DigitalOut dig_3(p28);
shimogamo 0:d54c76ac1184 8 DigitalOut dig_4(p21);
shimogamo 0:d54c76ac1184 9
shimogamo 0:d54c76ac1184 10 DigitalOut seg_a(p30);
shimogamo 0:d54c76ac1184 11 DigitalOut seg_b(p26);
shimogamo 0:d54c76ac1184 12 DigitalOut seg_c(p13);
shimogamo 0:d54c76ac1184 13 DigitalOut seg_d(p11);
shimogamo 0:d54c76ac1184 14 DigitalOut seg_e(p10);
shimogamo 0:d54c76ac1184 15 DigitalOut seg_f(p29);
shimogamo 0:d54c76ac1184 16 DigitalOut seg_g(p14);
shimogamo 0:d54c76ac1184 17 DigitalOut seg_dp(p12);
shimogamo 0:d54c76ac1184 18
shimogamo 0:d54c76ac1184 19
shimogamo 0:d54c76ac1184 20 #define N_0 (0x03)
shimogamo 0:d54c76ac1184 21 #define N_1 (0x9f)
shimogamo 0:d54c76ac1184 22 #define N_2 (0x25)
shimogamo 0:d54c76ac1184 23 #define N_3 (0x0d)
shimogamo 0:d54c76ac1184 24 #define N_4 (0x99)
shimogamo 0:d54c76ac1184 25 #define N_5 (0x49)
shimogamo 0:d54c76ac1184 26 #define N_6 (0x41)
shimogamo 0:d54c76ac1184 27 #define N_7 (0x1b)
shimogamo 0:d54c76ac1184 28 #define N_8 (0x01)
shimogamo 0:d54c76ac1184 29 #define N_9 (0x09)
shimogamo 0:d54c76ac1184 30 const char segData[10] = {N_0, N_1, N_2, N_3, N_4, N_5, N_6, N_7, N_8, N_9,};
shimogamo 0:d54c76ac1184 31
shimogamo 0:d54c76ac1184 32 void segDataSet(unsigned char num){
shimogamo 0:d54c76ac1184 33 unsigned char work;
shimogamo 0:d54c76ac1184 34
shimogamo 0:d54c76ac1184 35 work = segData[num];
shimogamo 0:d54c76ac1184 36
shimogamo 0:d54c76ac1184 37 seg_a = (work & 0x80) ? 0 : 1;
shimogamo 0:d54c76ac1184 38 seg_b = (work & 0x40) ? 0 : 1;
shimogamo 0:d54c76ac1184 39 seg_c = (work & 0x20) ? 0 : 1;
shimogamo 0:d54c76ac1184 40 seg_d = (work & 0x10) ? 0 : 1;
shimogamo 0:d54c76ac1184 41 seg_e = (work & 0x08) ? 0 : 1;
shimogamo 0:d54c76ac1184 42 seg_f = (work & 0x04) ? 0 : 1;
shimogamo 0:d54c76ac1184 43 seg_g = (work & 0x02) ? 0 : 1;
shimogamo 0:d54c76ac1184 44 seg_dp = (work & 0x01) ? 0 : 1;
shimogamo 0:d54c76ac1184 45 }
shimogamo 0:d54c76ac1184 46
shimogamo 0:d54c76ac1184 47
shimogamo 0:d54c76ac1184 48 int main(){
shimogamo 0:d54c76ac1184 49 unsigned int cnt = 0;
shimogamo 0:d54c76ac1184 50 unsigned char sel = 1;
shimogamo 0:d54c76ac1184 51
shimogamo 0:d54c76ac1184 52 while(1){
shimogamo 0:d54c76ac1184 53 for(int i=0; i<1000; i++){
shimogamo 0:d54c76ac1184 54 dig_1 = 1;
shimogamo 0:d54c76ac1184 55 dig_2 = 1;
shimogamo 0:d54c76ac1184 56 dig_3 = 1;
shimogamo 0:d54c76ac1184 57 dig_4 = 1;
shimogamo 0:d54c76ac1184 58 switch(sel){
shimogamo 0:d54c76ac1184 59 case 1: dig_1 = 0;
shimogamo 0:d54c76ac1184 60 segDataSet((char)(cnt % 10));
shimogamo 0:d54c76ac1184 61 break;
shimogamo 0:d54c76ac1184 62 case 2: dig_2 = 0;
shimogamo 0:d54c76ac1184 63 segDataSet((char)(cnt / 10) % 10);
shimogamo 0:d54c76ac1184 64 seg_dp = 1;
shimogamo 0:d54c76ac1184 65 break;
shimogamo 0:d54c76ac1184 66 case 3: dig_3 = 0;
shimogamo 0:d54c76ac1184 67 segDataSet((char)(cnt / 100) % 10);
shimogamo 0:d54c76ac1184 68 break;
shimogamo 0:d54c76ac1184 69 case 4: dig_4 = 0;
shimogamo 0:d54c76ac1184 70 segDataSet((char)(cnt / 1000));
shimogamo 0:d54c76ac1184 71 break;
shimogamo 0:d54c76ac1184 72 }
shimogamo 0:d54c76ac1184 73 sel++;
shimogamo 0:d54c76ac1184 74 if(sel==5) sel=1;
shimogamo 0:d54c76ac1184 75 wait_ms(1);
shimogamo 0:d54c76ac1184 76 }
shimogamo 0:d54c76ac1184 77 //cnt++; if(cnt==10000)cnt=0;
shimogamo 0:d54c76ac1184 78 cnt = 0 + (int)(rand()*(9999-0+1.0)/(1.0+RAND_MAX));
shimogamo 0:d54c76ac1184 79 //wait_ms(10);
shimogamo 0:d54c76ac1184 80 }
shimogamo 0:d54c76ac1184 81 }