Skip to content

Commit cc8fdbc

Browse files
committed
Merge branch 'led_matrix_opt'
Former-commit-id: 2b29830
2 parents 742cfc0 + e916147 commit cc8fdbc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

libraries/LED_Matrix/examples/Blink/Blink.ino

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,21 @@ void display_char(int letter) {
131131
}
132132
}
133133

134+
#define LED_MATRIX_PORT0_MASK ((1 << 3) | (1 << 4) | (1 << 11) | (1 << 12) | (1 << 13) | (1 << 15))
135+
#define LED_MATRIX_PORT2_MASK ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 12) | (1 << 13))
136+
134137
void turnLed(int idx, bool on) {
135-
size_t pin_anode = pins[idx][0] + led_zero_index;
136-
size_t pin_catode = pins[idx][1] + led_zero_index;
138+
R_PORT0->PCNTR1 &= ~((uint32_t) LED_MATRIX_PORT0_MASK);
139+
R_PORT2->PCNTR1 &= ~((uint32_t) LED_MATRIX_PORT2_MASK);
137140

138-
for (int i = led_zero_index; i < led_zero_index + leds_howmany; i++) {
139-
//if (i != pin_anode && i != pin_catode) {
140-
pinMode(i, INPUT);
141-
//}
142-
}
143141
if (on) {
144-
pinMode(pin_anode, OUTPUT);
145-
pinMode(pin_catode, OUTPUT);
146-
digitalWrite(pin_anode, HIGH);
147-
digitalWrite(pin_catode, LOW);
142+
bsp_io_port_pin_t pin_a = g_pin_cfg[pins[idx][0] + led_zero_index].pin;
143+
R_PFS->PORT[pin_a >> 8].PIN[pin_a & 0xFF].PmnPFS =
144+
IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_HIGH;
145+
146+
bsp_io_port_pin_t pin_c = g_pin_cfg[pins[idx][1] + led_zero_index].pin;
147+
R_PFS->PORT[pin_c >> 8].PIN[pin_c & 0xFF].PmnPFS =
148+
IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_LOW;
148149
}
149150
}
150151

0 commit comments

Comments
 (0)