Subversion Repositories Code-Repo

Rev

Rev 147 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 147 Rev 154
Line 38... Line 38...
38
    result = I2C_Get_Status();
38
    result = I2C_Get_Status();
39
    while (!result) {
39
    while (!result) {
40
        result = I2C_Get_Status();
40
        result = I2C_Get_Status();
41
    }
41
    }
42
 
42
 
43
    LED_blinkRate(HT16K33_BLINK_OFF);
43
    LED_Blink_Rate(HT16K33_BLINK_OFF);
44
    LED_setBrightness(15);  // Max brightness
44
    LED_Set_Brightness(15);  // Max brightness
45
    LED_clear();
45
    LED_Clear();
46
    LED_writeDisplay();
46
    LED_Write_Display();
47
}
47
}
48
 
48
 
49
void LED_setBrightness(unsigned char c) {
49
void LED_Set_Brightness(unsigned char c) {
50
    unsigned char result;
50
    unsigned char result;
51
    
51
    
52
    if (c > 15) c = 15;
52
    if (c > 15) c = 15;
53
    c |= 0xE0;
53
    c |= 0xE0;
54
 
54
 
Line 57... Line 57...
57
    while (!result) {
57
    while (!result) {
58
        result = I2C_Get_Status();
58
        result = I2C_Get_Status();
59
    }
59
    }
60
}
60
}
61
 
61
 
62
void LED_blinkRate(unsigned char c) {
62
void LED_Blink_Rate(unsigned char c) {
63
    unsigned char buffer;
63
    unsigned char buffer;
64
 
64
 
65
    if (c > 3) c = 0;
65
    if (c > 3) c = 0;
66
 
66
 
67
    buffer = HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (c << 1);
67
    buffer = HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (c << 1);
Line 71... Line 71...
71
    while (!buffer) {
71
    while (!buffer) {
72
        buffer = I2C_Get_Status();
72
        buffer = I2C_Get_Status();
73
    }
73
    }
74
}
74
}
75
 
75
 
76
void LED_writeDisplay() {
76
void LED_Write_Display() {
77
    unsigned char result;
77
    unsigned char result;
78
    
78
    
79
    led_data_p->display_buffer[0] = 0x00;  // Start at address 0x00
79
    led_data_p->display_buffer[0] = 0x00;  // Start at address 0x00
80
    I2C_Master_Send(led_data_p->i2c_address, 17, led_data_p->display_buffer);
80
    I2C_Master_Send(led_data_p->i2c_address, 17, led_data_p->display_buffer);
81
 
81
 
Line 83... Line 83...
83
    while (!result) {
83
    while (!result) {
84
        result = I2C_Get_Status();
84
        result = I2C_Get_Status();
85
    }
85
    }
86
}
86
}
87
 
87
 
88
void LED_clear() {
88
void LED_Clear() {
89
    unsigned char c;
89
    unsigned char c;
90
    for (c = 0; c < 17; c++) {
90
    for (c = 0; c < 17; c++) {
91
        led_data_p->display_buffer[c] = 0;
91
        led_data_p->display_buffer[c] = 0;
92
    }
92
    }
93
}
93
}
94
 
94
 
95
void LED_drawColon(unsigned char c) {
95
void LED_Draw_Colon(unsigned char c) {
96
    if (c) {
96
    if (c) {
97
        led_data_p->display_buffer[5] = 0xFF;
97
        led_data_p->display_buffer[5] = 0xFF;
98
    } else {
98
    } else {
99
        led_data_p->display_buffer[5] = 0;
99
        led_data_p->display_buffer[5] = 0;
100
    }
100
    }
101
}
101
}
102
 
102
 
103
void LED_writeDigitRaw(unsigned char loc, unsigned char bitmask) {
103
void LED_Write_Digit_Raw(unsigned char loc, unsigned char bitmask) {
104
    if (loc > 4) return;
104
    if (loc > 4) return;
105
    led_data_p->display_buffer[(loc<<1)+1] = bitmask;
105
    led_data_p->display_buffer[(loc<<1)+1] = bitmask;
106
}
106
}
107
 
107
 
108
void LED_writeDigitNum(unsigned char loc, unsigned char num, unsigned char dot) {
108
void LED_Write_Digit_Num(unsigned char loc, unsigned char num, unsigned char dot) {
109
    if (loc > 4) return;
109
    if (loc > 4) return;
110
    if (loc > 1) loc++;
110
    if (loc > 1) loc++;
111
    LED_writeDigitRaw(loc, numbertable[num] | dot << 7);
111
    LED_Write_Digit_Raw(loc, numbertable[num] | dot << 7);
112
}
112
}
113
 
113
 
114
void LED_writeDigitAlpha(unsigned char loc, unsigned char alpha, unsigned char dot) {
114
void LED_Write_Digit_Alpha(unsigned char loc, unsigned char alpha, unsigned char dot) {
115
    if (loc > 4) return;
115
    if (loc > 4) return;
116
    if (loc > 1) loc++;
116
    if (loc > 1) loc++;
117
    LED_writeDigitRaw(loc, alphatable[alpha] | dot << 7);
117
    LED_Write_Digit_Raw(loc, alphatable[alpha] | dot << 7);
118
}
118
}
119
 
119
 
120
void LED_writeNum(unsigned int i) {
120
void LED_Write_Num(unsigned int i) {
121
    LED_writeDigitNum(0, (i%10000)/1000, 0);
121
    LED_Write_Digit_Num(0, (i%10000)/1000, 0);
122
    LED_writeDigitNum(1, (i%1000)/100, 0);
122
    LED_Write_Digit_Num(1, (i%1000)/100, 0);
123
    LED_writeDigitNum(2, (i%100)/10, 0);
123
    LED_Write_Digit_Num(2, (i%100)/10, 0);
124
    LED_writeDigitNum(3, i%10, 0);
124
    LED_Write_Digit_Num(3, i%10, 0);
125
 
125
 
126
    if (i < 10) {
126
    if (i < 10) {
127
        LED_writeDigitRaw(0, 0);
127
        LED_Write_Digit_Raw(0, 0);
128
        LED_writeDigitRaw(1, 0);
128
        LED_Write_Digit_Raw(1, 0);
129
        LED_writeDigitRaw(3, 0);
129
        LED_Write_Digit_Raw(3, 0);
130
    } else if (i < 100) {
130
    } else if (i < 100) {
131
        LED_writeDigitRaw(0, 0);
131
        LED_Write_Digit_Raw(0, 0);
132
        LED_writeDigitRaw(1, 0);
132
        LED_Write_Digit_Raw(1, 0);
133
    } else if (i < 1000) {
133
    } else if (i < 1000) {
134
        LED_writeDigitRaw(0, 0);
134
        LED_Write_Digit_Raw(0, 0);
135
    }
135
    }
136
    LED_writeDisplay();
136
    LED_Write_Display();
137
}
137
}
138
138