Skip to content

Instantly share code, notes, and snippets.

@shikarunochi
Created July 7, 2018 15:52
Show Gist options
  • Save shikarunochi/0584fe45294e1321a6f719c2122ba8ff to your computer and use it in GitHub Desktop.
Save shikarunochi/0584fe45294e1321a6f719c2122ba8ff to your computer and use it in GitHub Desktop.
#include <oled.h>
#include <misakiUTF16.h>
#include <SoftwareSerial.h>
#include <SPI.h>
unsigned char animation_offsetY=0;
// ビットパターン表示
// d: 8ビットパターンデータ
//
void bitdisp(byte x, byte y, uint8_t d ) {
for (byte i=0; i<8;i++) {
if (d & 0x80>>i) {
if(x + i < 128 && y < 64){
drawPixel(x + i ,y , 1);
}
}
}
}
// フォントパターンを画面に表示する
// 引数
// x,y 表示位置
// pUTF8 表示する文字列
// ※半角文字は全角文字に置き換えを行う
//
void drawJPChar(byte x, byte y, char * pUTF8) {
int n;
uint16_t pUTF16[40];
byte buf[20][8]; //160x8ドットのバナー表示パターン
n = Utf8ToUtf16(pUTF16, pUTF8); // UTF8からUTF16に変換する
// バナー用パターン作成
for (byte i=0; i < n; i++) {
getFontDataByUTF16(&buf[i][0], utf16_HantoZen(pUTF16[i])); // フォントデータの取得
}
// ドット表示
for (byte i=0; i < 8; i++) {
for (byte j=0; j < n; j++){
bitdisp(x + (j * 8) ,y + i , buf[j][i]);
}
}
}
void setup() {
while (!Serial);
delay(500);
Serial.begin(115200);
SPI.begin();
ssd1306_configure();
clearAll();
drawJPChar(0,0,"教育漢字1006文字");
drawJPChar(0,8,"小学校で習う漢字が");
drawJPChar(0,16,"8x8ドットで表示可能です!");
drawJPChar(0,24,"みさきフォントすごい!");
drawJPChar(0,32,"あいうえおかきくけこさしすせそ");
ssd1306_drawBuffer(0, 0, 128,64, mbuf);
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment