// // 96x64 OLED driver for Raspberry Pi // xkozima@myu.ac.jp #ifndef OLED_H #define OLED_H #include #include "raspGPIO.h" #include "raspSPI.h" #define OLED_DC_GPIO 17 // RPi から DC への GPIO ピン #define OLED_RST_GPIO 22 // RPi から RST への GPIO ピン class OLED { public: // OLED 初期化("/dev/spidev0.0", 8000000); void init(); void init(const char *spiDevice); void init(const char *spiDevice, int clock); // 画面クリア(0: 黒,0xffff: 白, etc.) void clear(unsigned short color); // 点を描画 void point(int x, int y, unsigned short color); // 線を描画 void line(int x1, int y1, int x2, int y2, unsigned short color); // 長方形を描画((fill)? 塗りつぶし: 輪郭のみ) void rect(int x, int y, int w, int h, unsigned short color, int fill); // 円を描画((fill)? 塗りつぶし: 輪郭のみ) void circle(int x, int y, int r, unsigned short color, int fill); // 楕円を描画(rx/ry: 半径,(fill)? 塗りつぶし: 輪郭のみ) void ellipse(int x, int y, int rx, int ry, unsigned short color, int fill); // 画像を描画(16bit(RGB565) or 24bit) void image(int x, int y, int w, int h, unsigned short *image16); void image(int x, int y, int w, int h, const unsigned short *image16); void image(int x, int y, int w, int h, unsigned char *image24); void image(int x, int y, int w, int h, const unsigned char *image24); // ASCII 文字列を描画 void text(int x, int y, char *string, unsigned short color); // ASCII 文字列を描画(背景色も指定) void text(int x, int y, char *string, unsigned short colorF, unsigned short colorB); // 16bit(RGB565) 色情報を 24bit 色情報から生成 unsigned short color(int r, int g, int b); private: SPI spi; void sendCommand1(unsigned char cmdOne); void sendCommandN(unsigned char *cmd, int length); void sendDataN(unsigned char *data, int length); void sendBuffer(unsigned char *buffer, int length); bool reversal; bool filling; }; #endif