diff --git a/esp32_firmware/esp32_cam_uart_stream/esp32_cam_uart_stream.ino b/esp32_firmware/esp32_cam_uart_stream/esp32_cam_uart_stream.ino index 1758b62..48c4ec3 100644 --- a/esp32_firmware/esp32_cam_uart_stream/esp32_cam_uart_stream.ino +++ b/esp32_firmware/esp32_cam_uart_stream/esp32_cam_uart_stream.ino @@ -156,14 +156,8 @@ void loop() { delay(50); } -bool IsDarkBit(uint8_t bit){ - bool result = bit < 128; - - if (invert){ - result = !result; - } - - return result; +inline bool IsDarkBit(const uint8_t bit) { + return (invert ^ (bit < 128)); } void DitherImage(camera_fb_t* fb) { @@ -180,4 +174,4 @@ void DitherImage(camera_fb_t* fb) { fb->buf[(y+1*fb->width) + x+1] = fb->buf[(y+1*fb->width) + x+1] + quant_error * 1 / 16; } } -} \ No newline at end of file +}