ALO-095BWNN-J9 aitendo OLED 96x64 SPI model Ver1.04
Revision 4:b68843c0269c, committed 2011-01-14
- Comitter:
- TETSUYA
- Date:
- Fri Jan 14 02:49:09 2011 +0000
- Parent:
- 3:eab8d193745a
- Child:
- 5:730724f253a4
- Commit message:
Changed in this revision
spioled96x64.cpp | Show annotated file Show diff for this revision Revisions of this file |
spioled96x64.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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); + + } +} +*/
--- a/spioled96x64.h Wed Jan 12 07:54:58 2011 +0000 +++ b/spioled96x64.h Fri Jan 14 02:49:09 2011 +0000 @@ -9,6 +9,8 @@ #include "ascii_font6x8.h" #include "small_font.h" +//#define __USE_GAC__ // use SSD1331/1332 Graphi Accelaration Command + #define Dis_X_MAX 96-1 // Max X axial direction in screen #define Dis_Y_MAX 64-1 // Max Y axial direction in screen #define X_WitchASC 6 // character's width @@ -21,6 +23,17 @@ #define CS_WH 3 #define CS_WHx36 4 + + +#define GAC_FILL_ENABLE_DISABLE 0x26 // 塗りつぶし可否コマンド +#define GAC_DRAW_RECTANGLE 0x22 // Rectangle cmd +/* +#define GAC_COPY_AREA 0x23 // Copy Area +#define GAC_SCROLL_SETUP 0x27 +#define GAC_SCROLL_STOP 0x2E +#define GAC_SCROLL_START 0x2F +*/ + class SPIOLED96x64 : public Stream { public: // constructor @@ -52,6 +65,12 @@ void line( int x0,int y0,int x1,int y1, unsigned int fore_col ,int pat ); void circle (int radius, int x, int y , unsigned int col, int fill); void Pattern(int x,int y,int width, int height, unsigned int *p); + void GACEnable(int enable); + /* + void Copy(int src_x1,int src_y1,int src_x2,int src_y2, int dst_x,int dst_y); + void ScrollSet(int a, int b, int c, int d , int frame_interval); + void Scroll(int enable); + */ protected: // Stream implementation functions virtual int _putc( int c ); @@ -62,6 +81,7 @@ unsigned int Char_Color; // character's color unsigned int BGround_Color; + int GAC_Useflag; int x_locate; int y_locate; int chr_size;