Use stepping instead of branching using modulus
Modulus operations are very costly and generally should be avoided. They also take a few bytes. This version is actually a quite faster.
This commit is contained in:
@@ -944,14 +944,14 @@ static void RenderStill() {
|
|||||||
|
|
||||||
const uint8_t METER_PAD_LEFT = 3;
|
const uint8_t METER_PAD_LEFT = 3;
|
||||||
|
|
||||||
for (int i = 0; i < 121; i++) {
|
memset(&gFrameBuffer[2][METER_PAD_LEFT], 0b00010000, 121);
|
||||||
if (i % 10 == 0) {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
for (int i = 0; i < 121; i+=5) {
|
||||||
} else if (i % 5 == 0) {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000;
|
||||||
} else {
|
|
||||||
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00010000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 121; i+=10) {
|
||||||
|
gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121);
|
uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121);
|
||||||
|
Reference in New Issue
Block a user