0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ch32v003funのexamples/i2c_oledで、8ピクセル右にズレて描画されることがある問題

Posted at

症状

ch32v003funを使ってOLEDに画像を表示しようと思い、examplesを参考にしました。i2c_oledという、ずばりのものがあります。最初は気が付かなかったのですが、左側の隙間がちょっと広いときがあります。よく調べてみると、ssd1306_drawImage()関数で画像を描画すると、8ピクセルだけ右にズレた位置から描画が始まってました。

対処方法

examples/i2c_oled/ssd1306.hを修正します。アドレス計算が間違っていました。

--- a/examples/i2c_oled/ssd1306.h
+++ b/examples/i2c_oled/ssd1306.h
@@ -265,7 +265,7 @@ void ssd1306_drawImage(uint8_t x, uint8_t y, const unsigned char* input, uint8_t
                        uint8_t input_byte = input[byte + line * bytes_to_draw];
 
                        for (pixel = 0; pixel < 8; pixel++) {
-                               x_absolute = x + 8 * (bytes_to_draw - byte) + pixel;
+                               x_absolute = x + 8 * (bytes_to_draw - 1 - byte) + pixel;
                                if (x_absolute >= SSD1306_W) {
                                        break;
                                }

おわりに

Issueを出しましたが今のところ反応がないですね。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?