Adafruit ssd1331 OLED 96x64 SPI model
Fork of OledLib by
Diff: spioled96x64.cpp
- Revision:
- 4:b68843c0269c
- Parent:
- 3:eab8d193745a
- Child:
- 5:730724f253a4
--- a/spioled96x64.cpp Wed Jan 12 07:54:58 2011 +0000 +++ b/spioled96x64.cpp Fri Jan 14 02:49:09 2011 +0000 @@ -1,9 +1,13 @@ + + // ALO-095BWNN-J9 test program // See also "http://www.aitendo.co.jp/product/2099" // Ver1.00 初版完成 // Ver1.01 フォントをk6x8フォントに変更。定義Hファイルも全角とは分離 // フォント描画ルーチンが1ドットすくなく動くのを修正 // 任意カラーパターンを描画できるように修正 +// Ver1.02 SD1331/1332用 GACcommand対応 +// ただし現状ではRectangeしか機能しない模様 #include "mbed.h" @@ -88,6 +92,7 @@ y_locate = 0; chr_size = CS_NORMAL; Fill_Screen(0); + GAC_Useflag = 0; } // レジスタライト @@ -341,25 +346,54 @@ // 画面の指定色塗りつぶし指定領域し void SPIOLED96x64::Box(int x1,int y1, int x2, int y2, unsigned int Color, int fill) { - unsigned char i,j; + + if ( !GAC_Useflag ){ + unsigned char i,j; - switch( fill ) { - case 0: // box - line( x1, y1, x2, y1, Color, 0 ); - line( x2, y1, x2, y2, Color, 0 ); - line( x2, y2, x1, y2, Color, 0 ); - line( x1, y2, x1, y1, Color, 0 ); - break; - default: // fill - for(i=y1;i<=y2;i++) - { - for(j=x1;j<=x2;j++) + switch( fill ) { + case 0: // box + line( x1, y1, x2, y1, Color, 0 ); + line( x2, y1, x2, y2, Color, 0 ); + line( x2, y2, x1, y2, Color, 0 ); + line( x1, y2, x1, y1, Color, 0 ); + break; + default: // fill + for(i=y1;i<=y2;i++) { - Draw_Dot(j,i,Color); - // DataWrite_to(Dot); + for(j=x1;j<=x2;j++) + { + Draw_Dot(j,i,Color); + // DataWrite_to(Dot); + } } + break; } - break; + }else{ + // SSD1331/1332用 GAC(アクセラレートコマンド) + unsigned char cmd[11]={ 0 }; + + if ( ( x1 > Dis_X_MAX )||( y1 > Dis_Y_MAX ) + ||( x2 > Dis_X_MAX )||( y2 > Dis_Y_MAX ) ) return ; + + cmd[0] = GAC_FILL_ENABLE_DISABLE; // + cmd[1] = (unsigned char)fill; //( fill ) ? 0 : 0; + RegWriteM(cmd, 2); + + cmd[0] = GAC_DRAW_RECTANGLE; // + cmd[1] = (unsigned char)x1; + cmd[2] = (unsigned char)y1; + cmd[3] = (unsigned char)x2; + cmd[4] = (unsigned char)y2; + cmd[5] = (unsigned char)((Color>>11)&0x1f); // Outline Blue + cmd[6] = (unsigned char)((Color>>5 )&0x3f); // Outline Green + cmd[7] = (unsigned char)( Color &0x1f); // Outline Red + cmd[8] = (unsigned char)((Color>>11)&0x1f); // Outline Blue + cmd[9] = (unsigned char)((Color>>5 )&0x3f); // Outline Green + cmd[10]= (unsigned char)( Color &0x1f); // Outline Red + + RegWriteM(cmd, 11); + wait_ms( 1 ); + } } @@ -506,7 +540,7 @@ { int i,j; - + for(i=0; i<width; i++){ for(j=height-1;j>=0;j--){ Draw_Dot(x+i,y+j,*p++); @@ -514,6 +548,72 @@ } } +void SPIOLED96x64::GACEnable(int enable) +{ + GAC_Useflag = enable; +} +/* +// 任意領域のコピー +// SSD1332では機能しない模様... +void SPIOLED96x64::Copy(int src_x1,int src_y1,int src_x2,int src_y2, int dst_x,int dst_y) +{ + + if ( GAC_Useflag ){ + // SSD1331/1332用 GAC(アクセラレートコマンド) + unsigned char cmd[11]={ 0 }; + int p; + if ( ( src_x1 > Dis_X_MAX )||( src_y1 > Dis_Y_MAX ) + ||( src_x2 > Dis_X_MAX )||( src_y2 > Dis_Y_MAX ) ) return ; + //if ( dst_x > Dis_X_MAX )||( dst_y > Dis_Y_MAX ) return; + + + p=0; + cmd[p++] = GAC_COPY_AREA; // + cmd[p++] = (unsigned char)src_x1; + cmd[p++] = (unsigned char)src_y1; + cmd[p++] = (unsigned char)src_x2; + cmd[p++] = (unsigned char)src_y2; + cmd[p++] = (unsigned char)dst_x; + cmd[p++] = (unsigned char)dst_y; + + RegWriteM(cmd, p); + + } +} +// スクロール設定 +void SPIOLED96x64::ScrollSet(int a, int b, int c, int d , int frame_interval) +{ + if ( GAC_Useflag ){ + // SSD1331/1332用 GAC(アクセラレートコマンド) + unsigned char cmd[11]={ 0 }; + int p; + //if ( ( startline > Dis_Y_MAX+1 )||( (startline+lincount) > Dis_Y_MAX+1 ) ) return ; + if ( frame_interval > 3 ) frame_interval = 3; + + p=0; + cmd[p++] = GAC_SCROLL_SETUP; // + cmd[p++] = (unsigned char)a; + cmd[p++] = (unsigned char)b; + cmd[p++] = (unsigned char)c; + cmd[p++] = (unsigned char)d; + cmd[p++] = (unsigned char)frame_interval; + + RegWriteM(cmd, p); + + } + +} +void SPIOLED96x64::Scroll(int enable) +{ + if ( GAC_Useflag ){ + // SSD1331/1332用 GAC(アクセラレートコマンド) + unsigned char cmd = (enable) ? GAC_SCROLL_START : GAC_SCROLL_STOP; // + + RegWrite(cmd); + + } +} +*/