Hey, hab eine WordClock gebaut und klappt auch wunderbar, allerdings scheine ich die FPS die die Matrix bringt ohne PWM und Multiplexing, also die reine FPS falsch zu berechnen, da sie augenscheinlich geringer ist. Der wichtige Code
1 | #define MATRIX_PWM_MAX 16 |
2 | #define MATRIX_COLUMNS 11 |
3 | #define MATRIX_ROWS 10 |
4 | |
5 | /* timer setup */ |
6 | /* usage 8bit timer0 without prescaler to interrupt on every overflow to |
7 | update the matrix */ |
8 | TCCR0 = _BV(CS00); |
9 | TCNT0 = 0; |
10 | TIMSK |= _BV(TOIE0); |
11 | |
12 | |
13 | /* used to multiplex the matrix including PWM */ |
14 | ISR(TIMER0_OVF_vect) |
15 | {
|
16 | if (pwm_count == 0 && column_count == 0) {
|
17 | matrix_frame_t *new_frame = (matrix_frame_cb == NULL) ? matrix_off() : |
18 | matrix_frame_cb(); |
19 | |
20 | if (new_frame != NULL) |
21 | current_frame = new_frame; |
22 | } |
23 | |
24 | if (pwm_count == 0 && current_frame->pwm > 0) {
|
25 | matrix_set_rows(0); |
26 | matrix_set_columns(((uint16_t) 1 << (15 - column_count)) | |
27 | ((column_count == 0) ? ((current_frame->corners & 0xF) << 1) : 0)); |
28 | matrix_set_rows(current_frame->columns[column_count]); |
29 | } else if (pwm_count == current_frame->pwm) {
|
30 | matrix_set_columns(0); |
31 | } |
32 | |
33 | if (pwm_count == MATRIX_PWM_MAX - 1) {
|
34 | pwm_count = 0; |
35 | (column_count == MATRIX_COLUMNS - 1) ? column_count = 0 : |
36 | ++column_count; |
37 | } else {
|
38 | ++pwm_count; |
39 | } |
40 | } |
PWM_MAX bei 8MHz sollte dann ja sein:
1 | #define MATRIX_FPS ((uint8_t) ((float) F_CPU / 256 / MATRIX_COLUMNS / MATRIX_PWM_MAX)) |
Danke und Grüße Oli
