1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| #include "common.h"
unsigned char smgw[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; unsigned char smgd[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00}; char smgbuf[8],num = 0;
void select_channel(char channel) { switch(channel) { case 4: P2 = P2&0x1f|0x80; break; case 5: P2 = P2&0x1f|0xa0; break; case 6: P2 = P2&0x1f|0xc0; break; case 7: P2 = P2&0x1f|0xe0; break; } }
void init() { char i; for(i = 0;i<8;i++) smgbuf[i] = 10; P0 = 0xff; select_channel(4); P2&= 0x1f; P0 = 0x00; select_channel(5); P2&= 0x1f; init_timer(); }
void init_timer() { AUXR = AUXR&0x33|0x10; IE2 = 0x04; T2H = 0xf8; T2L = 0x2f; EA = 1; TMOD = 0x01; TH1 = 0; TL1 = 0; TR1 = 0; }
void display() { num++; if(num >= 8) num = 0; P0 = 0xff; select_channel(7); P2&= 0x1f; P0 = 0x00; select_channel(6); P0 = smgw[num]; P2&= 0x1f; P0 = 0xff; select_channel(7); P0 = ~smgd[smgbuf[num]]; P2&= 0x1f; }
|