diff --git a/MikuOled.cpp b/MikuOled.cpp index 8b284bb..672441f 100755 --- a/MikuOled.cpp +++ b/MikuOled.cpp @@ -1,7 +1,8 @@ - #include "MikuDuino.h" #include "Wire.h" #include "MikuOled.h" +#include +#include /* * MikuPi.cpp: @@ -14,6 +15,23 @@ * */ +int UTF8toGB2312(char *sourcebuf,char *destbuf) +{ + iconv_t cd; + size_t sourcelen,destlen; + sourcelen=strlen(sourcebuf)+1; + destlen=sourcelen*4; + if ((cd = iconv_open("gb2312","utf-8")) ==0) + return -1; + if(-1 == iconv(cd,&sourcebuf,&sourcelen,&destbuf,&destlen)) + { + perror("iconv"); + return -2; + } + iconv_close(cd); + return 0; +} + uint8 Miku_Oled::buf[OLED_BUFFER_LENGTH+1]; const char logo[]={ @@ -98,6 +116,7 @@ Miku_Oled::Miku_Oled() { buffer=buf+1; buf[0]=0x40; + encoding=GB2312; showLogo(); } @@ -106,6 +125,11 @@ void Miku_Oled::oled_sendCommand(int c) Wire.write((uint8)0,(uint8)c); } +void Miku_Oled::setEncoding(uint8 code) +{ + encoding=code; +} + void Miku_Oled::begin() { Wire.begin(); @@ -185,15 +209,22 @@ void Miku_Oled::drawPoint(uint8 x,uint8 y,uint8 c) buffer[p]|=(uint8)(1<