1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

直接)XIAO ESP32C6+SSD1306、「回復のアイテム」を表示して遊ぶ。

Last updated at Posted at 2025-04-19

いろいろ、注意

  • 過去の記事を読んでね!!!

目的

OLEDのテスト
ハートがどこかに表示される
(まだ、アドレスの事は、やってないので?)

結果

o_coq874.jpg

プログラム




//有機ELのSSD1306で豆腐を召喚
//秋月のOLEDとアイテンドウのOLEDのアドレスは3c
//SSD1306_int_cls_Heart_XIAO_ESP32C6_1


//ヘッダー
#include <Arduino.h>
#include <Wire.h>


//定義
#define COMMAND_MODE               0x80 // continuation bit is set!
#define DATA_MODE                  0x40

#define SET_MEMORY_ADDRESSING_MODE 0x20 // takes one byte as given above
#define HORIZONTAL_ADDRESSING_MODE 0x00


//I2Cに配列を転送する
void write_s(uint8_t *str1, uint8_t len1) {

  Wire.beginTransmission(  0x3c  );

  for (int icount = 0; icount < len1; icount++) {

    //一文字出力
    Wire.write(*str1 ++);

  }//for

  Wire.endTransmission();

}//write_s


//セットメモリーアドレシングモード
void setMemoryAddressingMode()
{
  uint8_t databytes[4] = {COMMAND_MODE, SET_MEMORY_ADDRESSING_MODE, COMMAND_MODE, HORIZONTAL_ADDRESSING_MODE};
  write_s(databytes, 4);
}//setMemoryAddressingMode


//初期化
void setup() {

  //I2Cの初期化
  Wire.begin(D9,D10); //XIAO ESP32C6+SSD1306
  //Wire.begin(D10,D9); //XIAO ESP32C6+GROVE
  delay(200);

  //SSD1306の初期化スペル(魔法)
  //0x80,0x8D,0x80,0x14,0x80,0xAF
  write_s( (uint8_t*) "\200\215\200\024\200\257", 6);
  delay(100);

  //セットメモリーアドレシングモード (画面の終端に来たら画面の先頭に)
  setMemoryAddressingMode();

  //データの配列の定義
  uint8_t databytes[2] = {DATA_MODE,0x00};

  //画面のクリア
  databytes[1] = 0x00;
  for (int icount = 0; icount < ((128/8)*64); icount++) {
    write_s(databytes, 2);
  }//for

  //8x8のHeartの表画
  databytes[1] = 0b01100110;write_s(databytes, 2);// ..  ..
  databytes[1] = 0b10101111;write_s(databytes, 2);//. . ....
  databytes[1] = 0b10111111;write_s(databytes, 2);//. ......
  databytes[1] = 0b11011111;write_s(databytes, 2);//.. .....
  databytes[1] = 0b01111110;write_s(databytes, 2);// ......
  databytes[1] = 0b01111110;write_s(databytes, 2);// ......
  databytes[1] = 0b00111100;write_s(databytes, 2);//  ....
  databytes[1] = 0b00011000;write_s(databytes, 2);//   ..
 
}//setup


//メインループ
void loop() {
  delay(3); //dummy
}//loop



1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?