Commit 6d99c22
matrix: optimize turnLed function.
The main optimization eliminates the double MODER register write when on=true.
Previously: MODER &= ~(0xFFFFFF) then MODER |= pin_bits (two writes)
Now: MODER = 0 when off, or MODER = pin_bits when on (single write each)
Otherwise, the compiler is already doing a pretty good job.
Additional improvements:
- Remove unused idxToPin() function (was just returning idx)
- Remove unused reverse() function
- Use direct pin array access and bit shifts for efficiency
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>1 parent c3b24d0 commit 6d99c22
1 file changed
+10
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 115 | | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
123 | | - | |
124 | | - | |
| 119 | + | |
| 120 | + | |
125 | 121 | | |
| 122 | + | |
| 123 | + | |
126 | 124 | | |
127 | | - | |
128 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 133 | + | |
147 | 134 | | |
148 | 135 | | |
149 | 136 | | |
| |||
0 commit comments