ALO-095BWNN-J9 aitendo OLED 96x64 SPI model Ver1.04
Revision 2:e331851128c1, committed 2011-01-12
- Comitter:
- TETSUYA
- Date:
- Wed Jan 12 07:47:32 2011 +0000
- Parent:
- 1:343d26b058d7
- Child:
- 3:eab8d193745a
- Commit message:
- Ver 1.01
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ascii_font6x8.h Wed Jan 12 07:47:32 2011 +0000 @@ -0,0 +1,109 @@ +#ifndef __ascii_font6x8__ +#define __ascii_font6x8__ +/* + 6*8hbgú{êrbg}bvtHg k6x8 period À1 + Copyright(C) 2000-2006 Num Kadoma + x[XɼptHgðWJ +*/ +// 0x20~7fÜÅÌ0x60oCgÌf[^ (eÊ240byte) +// ANZX·éY¦ÉÓ(LN^R[h-0x20ÅÎÛtHgÉÈé) +static const char FontLookup_ABC[0x60][6] = { + { 0x00,0x00,0x00,0x00,0x00,0x00 } , /*SPC */ + { 0x00,0x00,0x5F,0x00,0x00,0x00 } , /* ! */ + { 0x04,0x03,0x04,0x03,0x00,0x00 } , /* " */ + { 0x28,0x7E,0x14,0x3F,0x0A,0x00 } , /* # */ + { 0x24,0x2A,0x7F,0x2A,0x12,0x00 } , /* $ */ + { 0x23,0x13,0x08,0x64,0x62,0x00 } , /* % */ + { 0x30,0x4E,0x59,0x26,0x50,0x00 } , /* & */ + { 0x00,0x00,0x02,0x01,0x00,0x00 } , /* ' */ + { 0x00,0x00,0x1C,0x22,0x41,0x00 } , /* ( */ + { 0x41,0x22,0x1C,0x00,0x00,0x00 } , /* ) */ + { 0x22,0x14,0x08,0x14,0x22,0x00 } , /* * */ + { 0x08,0x08,0x3E,0x08,0x08,0x00 } , /* + */ + { 0x50,0x30,0x00,0x00,0x00,0x00 } , /* , */ + { 0x08,0x08,0x08,0x08,0x08,0x00 } , /* - */ + { 0x60,0x60,0x00,0x00,0x00,0x00 } , /* . */ + { 0x20,0x10,0x08,0x04,0x02,0x00 } , /* / */ + { 0x3E,0x51,0x49,0x45,0x3E,0x00 } , /* 0 */ + { 0x00,0x42,0x7F,0x40,0x00,0x00 } , /* 1 */ + { 0x62,0x51,0x49,0x49,0x46,0x00 } , /* 2 */ + { 0x22,0x41,0x49,0x49,0x36,0x00 } , /* 3 */ + { 0x18,0x14,0x12,0x7F,0x10,0x00 } , /* 4 */ + { 0x2F,0x45,0x45,0x45,0x39,0x00 } , /* 5 */ + { 0x3E,0x49,0x49,0x49,0x32,0x00 } , /* 6 */ + { 0x01,0x61,0x19,0x05,0x03,0x00 } , /* 7 */ + { 0x36,0x49,0x49,0x49,0x36,0x00 } , /* 8 */ + { 0x26,0x49,0x49,0x49,0x3E,0x00 } , /* 9 */ + { 0x00,0x36,0x36,0x00,0x00,0x00 } , /* : */ + { 0x00,0x56,0x36,0x00,0x00,0x00 } , /* ; */ + { 0x00,0x08,0x14,0x22,0x41,0x00 } , /* < */ + { 0x14,0x14,0x14,0x14,0x14,0x00 } , /* = */ + { 0x41,0x22,0x14,0x08,0x00,0x00 } , /* > */ + { 0x02,0x01,0x59,0x09,0x06,0x00 } , /* ? */ + { 0x3E,0x41,0x5D,0x55,0x2E,0x00 } , /* @ */ + { 0x60,0x1C,0x13,0x1C,0x60,0x00 } , /* A */ + { 0x7F,0x49,0x49,0x49,0x36,0x00 } , /* B */ + { 0x3E,0x41,0x41,0x41,0x22,0x00 } , /* C */ + { 0x7F,0x41,0x41,0x22,0x1C,0x00 } , /* D */ + { 0x7F,0x49,0x49,0x49,0x41,0x00 } , /* E */ + { 0x7F,0x09,0x09,0x09,0x01,0x00 } , /* F */ + { 0x1C,0x22,0x41,0x49,0x3A,0x00 } , /* G */ + { 0x7F,0x08,0x08,0x08,0x7F,0x00 } , /* H */ + { 0x00,0x41,0x7F,0x41,0x00,0x00 } , /* I */ + { 0x20,0x40,0x40,0x40,0x3F,0x00 } , /* J */ + { 0x7F,0x08,0x14,0x22,0x41,0x00 } , /* K */ + { 0x7F,0x40,0x40,0x40,0x00,0x00 } , /* L */ + { 0x7F,0x04,0x18,0x04,0x7F,0x00 } , /* M */ + { 0x7F,0x04,0x08,0x10,0x7F,0x00 } , /* N */ + { 0x3E,0x41,0x41,0x41,0x3E,0x00 } , /* O */ + { 0x7F,0x09,0x09,0x09,0x06,0x00 } , /* P */ + { 0x3E,0x41,0x51,0x21,0x5E,0x00 } , /* Q */ + { 0x7F,0x09,0x19,0x29,0x46,0x00 } , /* R */ + { 0x26,0x49,0x49,0x49,0x32,0x00 } , /* S */ + { 0x01,0x01,0x7F,0x01,0x01,0x00 } , /* T */ + { 0x3F,0x40,0x40,0x40,0x3F,0x00 } , /* U */ + { 0x03,0x1C,0x60,0x1C,0x03,0x00 } , /* V */ + { 0x0F,0x70,0x0F,0x70,0x0F,0x00 } , /* W */ + { 0x41,0x36,0x08,0x36,0x41,0x00 } , /* X */ + { 0x01,0x06,0x78,0x02,0x01,0x00 } , /* Y */ + { 0x61,0x51,0x49,0x45,0x43,0x00 } , /* Z */ + { 0x00,0x00,0x7F,0x41,0x41,0x00 } , /* [ */ + { 0x15,0x16,0x7C,0x16,0x11,0x00 } , /* \ */ + { 0x41,0x41,0x7F,0x00,0x00,0x00 } , /* ] */ + { 0x00,0x02,0x01,0x02,0x00,0x00 } , /* ^ */ + { 0x40,0x40,0x40,0x40,0x40,0x00 } , /* _ */ + { 0x00,0x01,0x02,0x00,0x00,0x00 } , /* ` */ + { 0x00,0x20,0x54,0x54,0x78,0x00 } , /* a */ + { 0x00,0x7F,0x44,0x44,0x38,0x00 } , /* b */ + { 0x00,0x38,0x44,0x44,0x28,0x00 } , /* c */ + { 0x00,0x38,0x44,0x44,0x7F,0x00 } , /* d */ + { 0x00,0x38,0x54,0x54,0x18,0x00 } , /* e */ + { 0x00,0x04,0x3E,0x05,0x01,0x00 } , /* f */ + { 0x00,0x08,0x54,0x54,0x3C,0x00 } , /* g */ + { 0x00,0x7F,0x04,0x04,0x78,0x00 } , /* h */ + { 0x00,0x00,0x7D,0x00,0x00,0x00 } , /* i */ + { 0x00,0x40,0x40,0x3D,0x00,0x00 } , /* j */ + { 0x00,0x7F,0x10,0x28,0x44,0x00 } , /* k */ + { 0x00,0x01,0x7F,0x00,0x00,0x00 } , /* l */ + { 0x7C,0x04,0x7C,0x04,0x78,0x00 } , /* m */ + { 0x00,0x7C,0x04,0x04,0x78,0x00 } , /* n */ + { 0x00,0x38,0x44,0x44,0x38,0x00 } , /* o */ + { 0x00,0x7C,0x14,0x14,0x08,0x00 } , /* p */ + { 0x00,0x08,0x14,0x14,0x7C,0x00 } , /* q */ + { 0x00,0x7C,0x08,0x04,0x04,0x00 } , /* r */ + { 0x00,0x48,0x54,0x54,0x24,0x00 } , /* s */ + { 0x00,0x04,0x3E,0x44,0x40,0x00 } , /* t */ + { 0x00,0x3C,0x40,0x40,0x7C,0x00 } , /* u */ + { 0x00,0x7C,0x20,0x10,0x0C,0x00 } , /* v */ + { 0x1C,0x60,0x1C,0x60,0x1C,0x00 } , /* w */ + { 0x00,0x6C,0x10,0x10,0x6C,0x00 } , /* x */ + { 0x00,0x4C,0x50,0x30,0x1C,0x00 } , /* y */ + { 0x00,0x44,0x64,0x54,0x4C,0x00 } , /* z */ + { 0x00,0x08,0x36,0x41,0x41,0x00 } , /* { */ + { 0x00,0x00,0x7F,0x00,0x00,0x00 } , /* | */ + { 0x41,0x41,0x36,0x08,0x00,0x00 } , /* } */ + { 0x08,0x04,0x08,0x10,0x08,0x00 } , /* ~ */ + { 0x00,0x00,0x00,0x00,0x00,0x00 } /*null*/ +}; + +#endif \ No newline at end of file
--- a/small_font.h Wed Jan 12 02:43:37 2011 +0000 +++ b/small_font.h Wed Jan 12 07:47:32 2011 +0000 @@ -2,102 +2,6 @@ // A~Z = 0x8260~0x8279 // a~z = 0x8281~0x829a -static const char FontLookup_ABC[][5] = -{ - { 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp - { 0x00, 0x00, 0x2f, 0x00, 0x00 }, // ! - { 0x00, 0x07, 0x00, 0x07, 0x00 }, // " - { 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // # - { 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $ - { 0xc4, 0xc8, 0x10, 0x26, 0x46 }, // % - { 0x36, 0x49, 0x55, 0x22, 0x50 }, // & - { 0x00, 0x05, 0x03, 0x00, 0x00 }, // ' - { 0x00, 0x1c, 0x22, 0x41, 0x00 }, // ( - { 0x00, 0x41, 0x22, 0x1c, 0x00 }, // ) - { 0x14, 0x08, 0x3E, 0x08, 0x14 }, // * - { 0x08, 0x08, 0x3E, 0x08, 0x08 }, // + - { 0x00, 0x00, 0x50, 0x30, 0x00 }, // , - { 0x10, 0x10, 0x10, 0x10, 0x10 }, // - - { 0x00, 0x60, 0x60, 0x00, 0x00 }, // . - { 0x20, 0x10, 0x08, 0x04, 0x02 }, // / - { 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0 - { 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1 - { 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2 - { 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3 - { 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4 - { 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5 - { 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6 - { 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7 - { 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8 - { 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9 - { 0x00, 0x36, 0x36, 0x00, 0x00 }, // : - { 0x00, 0x56, 0x36, 0x00, 0x00 }, // ; - { 0x08, 0x14, 0x22, 0x41, 0x00 }, // < - { 0x14, 0x14, 0x14, 0x14, 0x14 }, // = - { 0x00, 0x41, 0x22, 0x14, 0x08 }, // > - { 0x02, 0x01, 0x51, 0x09, 0x06 }, // ? - { 0x32, 0x49, 0x59, 0x51, 0x3E }, // @ - { 0x7E, 0x11, 0x11, 0x11, 0x7E }, // A - { 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B - { 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C - { 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D - { 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E - { 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F - { 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G - { 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H - { 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I - { 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J - { 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K - { 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L - { 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M - { 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N - { 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O - { 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P - { 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q - { 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R - { 0x46, 0x49, 0x49, 0x49, 0x31 }, // S - { 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T - { 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U - { 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V - { 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W - { 0x63, 0x14, 0x08, 0x14, 0x63 }, // X - { 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y - { 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z - { 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [ - { 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55 - { 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ] - { 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^ - { 0x40, 0x40, 0x40, 0x40, 0x40 }, // _ - { 0x00, 0x01, 0x02, 0x04, 0x00 }, // ' - { 0x20, 0x54, 0x54, 0x54, 0x78 }, // a - { 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b - { 0x38, 0x44, 0x44, 0x44, 0x20 }, // c - { 0x38, 0x44, 0x44, 0x48, 0x7F }, // d - { 0x38, 0x54, 0x54, 0x54, 0x18 }, // e - { 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f - { 0x0C, 0x52, 0x52, 0x52, 0x3E }, // g - { 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h - { 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i - { 0x20, 0x40, 0x44, 0x3D, 0x00 }, // j - { 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k - { 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l - { 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m - { 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n - { 0x38, 0x44, 0x44, 0x44, 0x38 }, // o - { 0x7C, 0x14, 0x14, 0x14, 0x08 }, // p - { 0x08, 0x14, 0x14, 0x18, 0x7C }, // q - { 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r - { 0x48, 0x54, 0x54, 0x54, 0x20 }, // s - { 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t - { 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u - { 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v - { 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w - { 0x44, 0x28, 0x10, 0x28, 0x44 }, // x - { 0x0C, 0x50, 0x50, 0x50, 0x3C }, // y - { 0x44, 0x64, 0x54, 0x4C, 0x44 } // z -}; - - const struct { unsigned short start, end; } font8table[92] = {
--- a/spioled96x64.cpp Wed Jan 12 02:43:37 2011 +0000 +++ b/spioled96x64.cpp Wed Jan 12 07:47:32 2011 +0000 @@ -1,475 +1,520 @@ -// ALO-095BWNN-J9 test program -// See also "http://www.aitendo.co.jp/product/2099" - - -#include "mbed.h" -#include "spioled96x64.h" - -//Serial pc(USBTX, USBRX); -#define countof(x) ( sizeof(x) / sizeof(x[0]) ) - - -// ã³ã³ã¹ãã©ã¯ã¿ -SPIOLED96x64::SPIOLED96x64(PinName cs_pin, PinName rst_pin, PinName a0_pin, PinName mosi_pin, PinName miso_pin, PinName sclk_pin) - : CS(cs_pin), RES(rst_pin), DC(a0_pin), spi(mosi_pin, miso_pin, sclk_pin) -{ - Init(); -} - -// ã¤ãã·ã£ã©ã¤ã¶ -void SPIOLED96x64::Init(void) -{ - - spi.format(8,3); //8bit frame and POL=1 /PHA=1(UpEdge Sampled) - spi.frequency(25000000); // modify later - - // reset - wait_ms(200); - RES = 0; //Reset active - wait_ms(200); - RES = 1; - - - // initialize sequence - RegWrite(0xae); //OLED display OFF - - //Row Address - RegWrite(0x75); /* Set Row Address */ - RegWrite(0x00); /* Start = 0 */ - RegWrite(0x3f); /* End = 63 */ - RegWrite(0x15); /* Set Column Address */ - RegWrite(0x00); /* Start = 0 */ - RegWrite(0x5F); /* End = 95 */ - - //Contrast - RegWrite(0xa0); //Set remap & data format 0111 0000 - RegWrite(0x74); // 65k Color/8bit buswidth/format1 - RegWrite(0xa1); //set display start row RAM - RegWrite(0x00); - RegWrite(0xa2); //set dispaly offset - RegWrite(0x00); - RegWrite(0xa4); //Set Display Mode - RegWrite(0xa8); //Set Multiplex Ratio - RegWrite(0x3f); - RegWrite(0xad); //Set Master Configuration - RegWrite(0x8f); //(External VCC Supply Selected) - RegWrite(0xB0); //Set Power Saving Mode - RegWrite(0x1a); - RegWrite(0xB1); //Set Phase 1 & 2 Period Adjustment - RegWrite(0x74); - RegWrite(0xb3); //Set Display Clock Divide Ratio / Oscillator Frequency - RegWrite(0xd0); - RegWrite(0x8A); //Set Second Pre-charge Speed of Color A - RegWrite(0x81); - RegWrite(0x8B); //Set Second Pre-charge Speed of Color B - RegWrite(0x82); - RegWrite(0x8C); //Set Second Pre-charge Speed of Color C - RegWrite(0x83); - RegWrite(0xBB); //Set Pre-charge Level - RegWrite(0x3e); - RegWrite(0xBE); //Set VCOMH - RegWrite(0x3e); - RegWrite(0x87); //Set Master Current Control - RegWrite(0x0f); - RegWrite(0x81); //Set Contrast Control for Color gAh - RegWrite(0x80); - RegWrite(0x82); //Set Contrast Control for Color gBh - RegWrite(0x80); - RegWrite(0x83); //Set Contrast Control for Color gCh - RegWrite(0x80); - RegWrite(0xaf); //display ON - - x_locate = 0; - y_locate = 0; - chr_size = CS_NORMAL; - Fill_Screen(0); -} - -// ã¬ã¸ã¹ã¿ã©ã¤ã -void SPIOLED96x64::RegWrite(unsigned char Command) -{ - DC = 0; // Command - CS = 0; // CS active(toggle OLED) - spi.write(Command); - CS = 1; -} - - -// ãã¼ã¿ã©ã¤ã -void SPIOLED96x64::DataWrite(unsigned char c) -{ - DC = 1; // DATA - CS = 0; // CS active(toggle OLED) - spi.write(c); - CS = 1; -} - -// 16ãããæ¸ã込㿠-void SPIOLED96x64::DataWrite_to(unsigned int Dat) -{ - DataWrite((unsigned char)((Dat >> 8)& 0x00ff)); - DataWrite((unsigned char)(Dat & 0x00ff)); -} - - - -// æå®åº§æ¨ã«æå®è²ã§ãããæç» -void SPIOLED96x64::Draw_Dot(int x,int y,unsigned int Color) -{ - if ( (x<0)||( x > Dis_X_MAX ) - ||(y<0)||( y > Dis_Y_MAX ) ) return ; - - RegWrite(0x15); - RegWrite((unsigned char)x); // Column Start Address - RegWrite((unsigned char)x); // Column End Address - RegWrite(0x75); - RegWrite((unsigned char)y); // Row Start Address - RegWrite((unsigned char)y); // Row End Address - DataWrite_to(Color); - DataWrite_to(Color); -} - - - -void SPIOLED96x64::ChangeFontColor(unsigned int color) -{ - Char_Color = color; -} -void SPIOLED96x64::ChangeBGColor(unsigned int color) -{ - BGround_Color = color; -} - - -// CS_NORMAL/CS_WIDE/CS_HIGH/CS_WH -void SPIOLED96x64::SetFontSize(int Csize) -{ - chr_size = Csize; -} -//ã縦横ã®åçå¤åéãè¿ã -void SPIOLED96x64::CS_Conv(int *lpx,int *lpy) -{ - switch( chr_size ){ - case CS_WIDE: - *lpx=2; - *lpy=1; - break; - case CS_HIGH: - *lpx=1; - *lpy=2; - break; - case CS_WH : - *lpx=2; - *lpy=2; - break; - case CS_WHx36 : - *lpx=6; - *lpy=6; - break; - case CS_NORMAL: - default: - *lpx=1; - *lpy=1; - break; - } - -} - -// å ¨è§ãã£ã©ã¯ã¿ã®æç»å¦ç -// ã¢ã¹ãã¼ãã£ã©ã¯ã¿ã®ä½ç½®æå®è¡¨ç¤º(5x7dotãã©ã³ã) -// ãã©ã³ãã®ç¹æ§ä¸ãæä¸ä½ãããããé ã«âæ¹åã«è¨è¿°ããã -void SPIOLED96x64::PutChar(int x,int y,unsigned int a) -{ - int i,j; - unsigned char Temp=0; - int lpx, lpy, k,l; - int xw; - j = 0; - i = 0; - - CS_Conv(&lpx, &lpy); - if ( a < 0x80 ) { xw = 5; if(a < 32)a=32; } // ASCII - else xw = X_Witch; // Kanji - - for(i=0; i<xw; i++){ - for ( l=0;l<lpx;l++){ - if ( a < 0x80 ) Temp = FontLookup_ABC[a-32][i]; // ASCII - else Temp = FontLookup[a][i]; // Kanji - - for(j=Y_Witch;j!=0;j--){ - for ( k=0;k<lpy;k++){ - if((Temp & 0x80)==0x80){ - Draw_Dot(x+(i*lpx)+l,y+(j*lpy)-k,Char_Color); - }else{ - Draw_Dot(x+(i*lpx)+l,y+(j*lpy)-k,BGround_Color); - } - } - Temp = Temp << 1; - } - } - } -} - - -// ç´ç²ä»®æ³é¢æ°ã§putcãå®ç¾ -int SPIOLED96x64::_putc( int c ) -{ - static bool kstate = false; - static unsigned int kbuf = 0; - unsigned int p; - int lpx, lpy, w; - - if(!kstate && ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc))){ - kstate = true; - kbuf = c; - return c; - } - - if(kstate){ // 2nd byte of shift-jis - kstate = false; - p = findface(kbuf << 8 | c); - w = X_Witch; - } else { - p = c; - w = 6; // åè§ã¯è¿æ¥ããã®ã§ãï¼ãããããã - } - PutChar( x_locate , y_locate ,p); - CS_Conv(&lpx, &lpy); - x_locate += (w*lpx); - - - /* - if(kstate== false){ - //ç»é¢å³ç«¯ã§ã®ã¯ãªããã³ã° - if(x_locate + (xsize - 1) >= Dis_X_MAX){ - x_locate = 0; - y_locate += Y_Witch; - if(y_locate >= Dis_Y_MAX) y_locate=0; - } - } - */ - return c; -} - -int SPIOLED96x64::_getc() -{ - return -1; -} -void SPIOLED96x64::puts( char *s ) -{ - unsigned char c; - while((c = *s++) != '\0') putc((int)c & 0xff); -} - - - -void SPIOLED96x64::locate(int column, int row) -{ - x_locate = column; - y_locate = row; -} - -int SPIOLED96x64::row() -{ - return y_locate; -} -int SPIOLED96x64::column() -{ - return x_locate; -} - -// SJISæ¼¢åã³ã¼ããã¼ãã«ããæå®ã®é åã¢ãã¬ã¹ãç®åºãã -unsigned int SPIOLED96x64::findface(unsigned short c) -{ - unsigned int p = 0; - int i, sum; - for(sum = i = 0; i < countof(font8table); i++){ - if(font8table[i].start <= c && c <= font8table[i].end){ - p = (sum + c - font8table[i].start); - break; - } - sum += font8table[i].end - font8table[i].start + 1; - } - return p; -} - -// RGB(555)ãRGB565å¤ã«å¤æ -// 00~1F(0~31) -unsigned int SPIOLED96x64::ColorConv(unsigned int R,unsigned int G,unsigned int B) -{ - unsigned int ret = 0; - unsigned int rv, gv, bv; - - if ( R > 0x1f ) rv= 0x1f; - else rv= (unsigned int)( R & 0x1F ); - if ( G > 0x1f ) gv= 0x3f; - else gv= (unsigned int)( (G<<1) & 0x3F ); - if ( B > 0x1f ) bv= 0x1f; - else bv= (unsigned int)( B & 0x1F ); - - ret = (bv << 11) + (gv << 5) + rv; - return ret; -} -// ç»é¢ã®æå®è²å¡ãã¤ã¶ãæå®é åã -void SPIOLED96x64::Box(int x1,int y1, int x2, int y2, unsigned int Color, int fill) -{ - 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++) - { - Draw_Dot(j,i,Color); - // DataWrite_to(Dot); - } - } - break; - } -} - -// ç»é¢ã®æå®è²å¡ãã¤ã¶ã -void SPIOLED96x64::Fill_Screen(unsigned int Color) -{ - BGround_Color = Color; - Box( 0,0, Dis_X_MAX, Dis_Y_MAX , Color , 1); -} - -// Bresenhamã®ç·åçºçã¢ã«ã´ãªãºã -// æ´æ°ã®ã¿ã«ããç·åæç» -// (x0,y0)-(x1,y1)ã¸ã®ã©ã¤ã³æç» åç §:http //www2.starcat.ne.jp/~fussy/algo/algo1-1.htm -// pat : 0:å®ç· 1:ç ´ç· -void SPIOLED96x64::line( int x0, int y0, int x1, int y1, unsigned int fore_col ,int pat ) -{ - int E,x,y; - int dx,dy,sx,sy,i; - int cl=1 ; - int clc=0; // ç ´ç·ç¨ã®ã«ã¦ã³ã¿ - - sx = ( x1 > x0 ) ? 1 : -1; // xã®ç§»åæ¹å - dx = ( x1 > x0 ) ? x1 - x0 : x0 - x1; // xã®ç§»åé - sy = ( y1 > y0 ) ? 1 : -1; // yã®ç§»åæ¹å - dy = ( y1 > y0 ) ? y1 - y0 : y0 - y1; // yã®ç§»åé - - x = x0; - y = y0; - - if( dx >= dy ) { - /* å¾ãã1以ä¸ã®å ´å */ - E = -dx; - for( i = 0; i <= dx; i++ ) { - switch( pat ) { - case 0: // å®ç· - cl = fore_col; - break; - default: // ç ´ç· - if ( clc>=3 ) { - if ( cl==fore_col ) cl=BGround_Color; - else cl=fore_col; - clc=0; - }else{ - clc++; - } - break; - } - - Draw_Dot(x,y,cl); - x += sx; - E += 2 * dy; - if( E >= 0 ) { - y += sy; - E -= 2 * dx; - } - } - }else{ - /* å¾ãã1ãã大ããå ´å */ - E = -dy; - for( i = 0; i <= dy; i++ ) { - switch( pat ) { - case 0: // å®ç· - cl = fore_col; - break; - default: // ç ´ç· - if ( clc>=3 ) { - if ( cl==fore_col ) cl=BGround_Color; - else cl=fore_col; - clc=0; - }else{ - clc++; - } - break; - } - - Draw_Dot(x,y,cl); - y += sy; - E += 2 * dx; - if( E >= 0 ) { - x += sx; - E -= 2 * dy; - } - } - } -} - -// ãããã§ãã¼(Miechener) ã®åæç» åè:http://dencha.ojaru.jp/programs_07/pg_graphic_09a1.html -// x,y : ä¸å¿ç¹ -// radius: åå¾ -void SPIOLED96x64::circle (int radius, int x, int y , unsigned int col, int fill) -{ - int cx, cy, d; - - d = 3 - 2 * radius; - cy = radius; - - // åæ座æ¨ããããããæç»ãã - Draw_Dot( x, radius+y, col ); // åº§æ¨ ( 0, R ); - Draw_Dot( x, -radius+y, col ); // åº§æ¨ ( 0, -R); - Draw_Dot( radius+x, y, col ); // åº§æ¨ ( R, 0 ); - Draw_Dot( -radius+x, y, col ); // åº§æ¨ (-R, 0); - if ( fill ) { - line( x, radius+y, x, -radius+y, col ,0 ); - line( radius+x, y, -radius+x, y, col ,0 ); - } - - for (cx = 0; cx <= cy; cx++){ - if (d >= 0) { - d += 10 + 4 * cx - 4 * cy; - cy--; - } else { - d += 6 + 4 * cx; - } - - // æç» - Draw_Dot( cy + x, cx + y, col); // 0-45 度ã®é - Draw_Dot( cx + x, cy + y, col); // 45-90 度ã®é - Draw_Dot( -cx + x, cy + y, col); // 90-135 度ã®é - Draw_Dot( -cy + x, cx + y, col); // 135-180 度ã®é - - Draw_Dot( -cy + x, -cx + y, col); // 180-225 度ã®é - Draw_Dot( -cx + x, -cy + y, col); // 225-270 度ã®é - Draw_Dot( cx + x, -cy + y, col); // 270-315 度ã®é - Draw_Dot( cy + x, -cx + y, col); // 315-360 度ã®é - - if ( fill ) { - line( cy + x, cx + y, cy + x, -cx + y, col ,0 ); - line( cx + x, cy + y, cx + x, -cy + y, col ,0 ); // 45-90 度ã®é - line( -cx + x, cy + y, -cx + x, cy + y, col ,0 ) ; // 90-135 度ã®é - line( -cy + x, cx + y, -cy + x, cx + y, col ,0 ); // 135-180 度ã®é - - line( -cy + x, -cx + y, -cy + x, cx + y, col ,0 ); // 180-225 度ã®é - line( -cx + x, -cy + y, -cx + x, cy + y, col ,0 ); // 225-270 度ã®é - line( cx + x, -cy + y, cx + x, cy + y, col ,0 ); // 270-315 度ã®é - line( cy + x, -cx + y, cy + x, cx + y, col ,0 ); // 315-360 度ã®é - } - - } -} - - +// ALO-095BWNN-J9 test program +// See also "http://www.aitendo.co.jp/product/2099" +// Ver1.00 Å®¬ +// Ver1.01 tHgðk6x8tHgÉÏXBè`gt@CàSpÆͪ£ +// tHg`æ[`ªPhbg·È®ÌðC³ +// CÓJ[p^[ð`æÅ«éæ¤ÉC³ + + +#include "mbed.h" +#include "spioled96x64.h" + +//Serial pc(USBTX, USBRX); +#define countof(x) ( sizeof(x) / sizeof(x[0]) ) + + +// RXgN^ +SPIOLED96x64::SPIOLED96x64(PinName cs_pin, PinName rst_pin, PinName a0_pin, PinName mosi_pin, PinName miso_pin, PinName sclk_pin) + : CS(cs_pin), RES(rst_pin), DC(a0_pin), spi(mosi_pin, miso_pin, sclk_pin) +{ + Init(); +} + +// CjVCU +void SPIOLED96x64::Init(void) +{ + + spi.format(8,3); //8bit frame and POL=1 /PHA=1(UpEdge Sampled) + spi.frequency(25000000); // modify later + //spi.frequency(42000000); // modify later + + // reset + wait_ms(200); + RES = 0; //Reset active + wait_ms(200); + RES = 1; + + + // initialize sequence + RegWrite(0xae); //OLED display OFF + + //Row Address + RegWrite(0x75); /* Set Row Address */ + RegWrite(0x00); /* Start = 0 */ + RegWrite(0x3f); /* End = 63 */ + RegWrite(0x15); /* Set Column Address */ + RegWrite(0x00); /* Start = 0 */ + RegWrite(0x5F); /* End = 95 */ + + //Contrast + RegWrite(0xa0); //Set remap & data format 0111 0000 + RegWrite(0x74); // 65k Color/8bit buswidth/format1 + RegWrite(0xa1); //set display start row RAM + RegWrite(0x00); + RegWrite(0xa2); //set dispaly offset + RegWrite(0x00); + RegWrite(0xa4); //Set Display Mode + RegWrite(0xa8); //Set Multiplex Ratio + RegWrite(0x3f); + RegWrite(0xad); //Set Master Configuration + RegWrite(0x8f); //(External VCC Supply Selected) + RegWrite(0xB0); //Set Power Saving Mode + RegWrite(0x1a); + RegWrite(0xB1); //Set Phase 1 & 2 Period Adjustment + RegWrite(0x74); + RegWrite(0xb3); //Set Display Clock Divide Ratio / Oscillator Frequency + RegWrite(0xd0); + RegWrite(0x8A); //Set Second Pre-charge Speed of Color A + RegWrite(0x81); + RegWrite(0x8B); //Set Second Pre-charge Speed of Color B + RegWrite(0x82); + RegWrite(0x8C); //Set Second Pre-charge Speed of Color C + RegWrite(0x83); + RegWrite(0xBB); //Set Pre-charge Level + RegWrite(0x3e); + RegWrite(0xBE); //Set VCOMH + RegWrite(0x3e); + RegWrite(0x87); //Set Master Current Control + RegWrite(0x0f); + RegWrite(0x81); //Set Contrast Control for Color gAh + RegWrite(0x80); + RegWrite(0x82); //Set Contrast Control for Color gBh + RegWrite(0x80); + RegWrite(0x83); //Set Contrast Control for Color gCh + RegWrite(0x80); + RegWrite(0xaf); //display ON + + x_locate = 0; + y_locate = 0; + chr_size = CS_NORMAL; + Fill_Screen(0); +} + +// WX^Cg +void SPIOLED96x64::RegWrite(unsigned char Command) +{ + DC = 0; // Command + CS = 0; // CS active(toggle OLED) + spi.write(Command); + CS = 1; +} +// }`oCg WX^Ýè +void SPIOLED96x64::RegWriteM(unsigned char *Command, int count) +{ + int i; + DC = 0; // Command + CS = 0; // CS active(toggle OLED) + for( i=0;i<count;i++){ + spi.write(*Command++); + } + CS = 1; +} + + +// f[^Cg +void SPIOLED96x64::DataWrite(unsigned char c) +{ + DC = 1; // DATA + CS = 0; // CS active(toggle OLED) + spi.write(c); + CS = 1; +} + +// 16rbg«Ý +void SPIOLED96x64::DataWrite_to(unsigned int Dat) +{ + DC = 1; // DATA + CS = 0; // CS active(toggle OLED) + spi.write((unsigned char)((Dat >> 8)& 0x00ff)); + spi.write((unsigned char)(Dat & 0x00ff)); + CS = 1; + /* + DataWrite((unsigned char)((Dat >> 8)& 0x00ff)); + DataWrite((unsigned char)(Dat & 0x00ff)); + */ +} + + + +// wèÀWÉwèFÅhbg`æ +void SPIOLED96x64::Draw_Dot(int x,int y,unsigned int Color) +{ + unsigned char cmd[7]={0x15,0x00,0x00,0x75,0x00,0x00,0x00}; + if ( ( x > Dis_X_MAX ) + ||( y > Dis_Y_MAX ) ) return ; + /* + RegWrite(0x15); + RegWrite((unsigned char)x); // Column Start Address + RegWrite((unsigned char)x); // Column End Address + RegWrite(0x75); + RegWrite((unsigned char)y); // Row Start Address + RegWrite((unsigned char)y); // Row End Address + */ + cmd[1] = (unsigned char)x; + cmd[2] = (unsigned char)x; + cmd[4] = (unsigned char)y; + cmd[5] = (unsigned char)y; + RegWriteM(cmd, 6); + DataWrite_to(Color); + //DataWrite_to(Color); +} + + + +void SPIOLED96x64::ChangeFontColor(unsigned int color) +{ + Char_Color = color; +} +void SPIOLED96x64::ChangeBGColor(unsigned int color) +{ + BGround_Color = color; +} + + +// CS_NORMAL/CS_WIDE/CS_HIGH/CS_WH +void SPIOLED96x64::SetFontSize(int Csize) +{ + chr_size = Csize; +} +//@c¡Ì{¦Ï»ÊðÔ· +void SPIOLED96x64::CS_Conv(int *lpx,int *lpy) +{ + switch( chr_size ){ + case CS_WIDE: + *lpx=2; + *lpy=1; + break; + case CS_HIGH: + *lpx=1; + *lpy=2; + break; + case CS_WH : + *lpx=2; + *lpy=2; + break; + case CS_WHx36 : + *lpx=6; + *lpy=6; + break; + case CS_NORMAL: + default: + *lpx=1; + *lpy=1; + break; + } + +} + +// SpLN^Ì`æ +// AXL[LN^ÌÊuwè\¦(5x7dottHg) +// tHgÌÁ«ãAÅãÊrbg©çɪûüÉLq³êé +void SPIOLED96x64::PutChar(int x,int y,unsigned int a) +{ + int i,j; + unsigned char Temp=0; + int lpx, lpy, k,l; + int xw; + j = 0; + i = 0; + + CS_Conv(&lpx, &lpy); + if ( a < 0x80 ) { xw = X_WitchASC; if(a < 32)a=32; } // ASCII + else xw = X_Witch; // Kanji + + for(i=0; i<xw; i++){ + for ( l=0;l<lpx;l++){ + if ( a < 0x80 ) Temp = FontLookup_ABC[a-32][i]; // ASCII(0x20~0x7f)==> 0x00~0x5f + else Temp = FontLookup[a][i]; // Kanji + + for(j=Y_Witch-1;j>=0;j--){ + for ( k=0;k<lpy;k++){ + Draw_Dot(x+(i*lpx)+l,y+((j+1)*lpy)-k, ((Temp & 0x80)==0x80) ? Char_Color : BGround_Color); + } + Temp = Temp << 1; + } + } + } +} + + +// ¼zÖÅputcðÀ» +int SPIOLED96x64::_putc( int c ) +{ + static bool kstate = false; + static unsigned int kbuf = 0; + unsigned int p; + int lpx, lpy, w; + + if(!kstate && ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc))){ + kstate = true; + kbuf = c; + return c; + } + + if(kstate){ // 2nd byte of shift-jis + kstate = false; + p = findface(kbuf << 8 | c); + w = X_Witch; + } else { + p = c; + w = X_WitchASC; // ¼pÍßÚ·éÌÅAPhbg ¯é + } + PutChar( x_locate , y_locate ,p); + CS_Conv(&lpx, &lpy); + x_locate += (w*lpx); + + + /* + if(kstate== false){ + //æÊE[ÅÌNbsO + if(x_locate + (xsize - 1) >= Dis_X_MAX){ + x_locate = 0; + y_locate += Y_Witch; + if(y_locate >= Dis_Y_MAX) y_locate=0; + } + } + */ + return c; +} + +int SPIOLED96x64::_getc() +{ + return -1; +} + +/* +void SPIOLED96x64::puts( char *s ) +{ + unsigned char c; + while((c = *s++) != '\0') putc((int)c & 0xff); +} +*/ + + +void SPIOLED96x64::locate(int column, int row) +{ + x_locate = column; + y_locate = row; +} + +int SPIOLED96x64::row() +{ + return y_locate; +} +int SPIOLED96x64::column() +{ + return x_locate; +} + +// SJIS¿R[he[u©çwèÌzñAhXðZo·é +unsigned int SPIOLED96x64::findface(unsigned short c) +{ + unsigned int p = 0; + int i, sum; + for(sum = i = 0; i < countof(font8table); i++){ + if(font8table[i].start <= c && c <= font8table[i].end){ + p = (sum + c - font8table[i].start); + break; + } + sum += font8table[i].end - font8table[i].start + 1; + } + return p; +} + +// qfa(555)ðRGB565lÉÏ· +// 00~1F(0~31) +unsigned int SPIOLED96x64::ColorConv(unsigned int R,unsigned int G,unsigned int B) +{ + unsigned int ret = 0; + unsigned int rv, gv, bv; + + if ( R > 0x1f ) rv= 0x1f; + else rv= (unsigned int)( R & 0x1F ); + if ( G > 0x1f ) gv= 0x3f; + else gv= (unsigned int)( (G<<1) & 0x3F ); + if ( B > 0x1f ) bv= 0x1f; + else bv= (unsigned int)( B & 0x1F ); + + ret = (bv << 11) + (gv << 5) + rv; + return ret; +} +// æÊÌwèFhèÂÔµwèÌæµ +void SPIOLED96x64::Box(int x1,int y1, int x2, int y2, unsigned int Color, int fill) +{ + 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++) + { + Draw_Dot(j,i,Color); + // DataWrite_to(Dot); + } + } + break; + } +} + +// æÊÌwèFhèÂÔµ +void SPIOLED96x64::Fill_Screen(unsigned int Color) +{ + BGround_Color = Color; + Box( 0,0, Dis_X_MAX, Dis_Y_MAX , Color , 1); +} + +// BresenhamÌüª¶ASY +// ®ÌÝÉæéüª`æ +// (x0,y0)-(x1,y1)ÖÌC`æ QÆ:http //www2.starcat.ne.jp/~fussy/algo/algo1-1.htm +// pat : 0:Àü 1:jü +void SPIOLED96x64::line( int x0, int y0, int x1, int y1, unsigned int fore_col ,int pat ) +{ + int E,x,y; + int dx,dy,sx,sy,i; + int cl=1 ; + int clc=0; // jüpÌJE^ + + sx = ( x1 > x0 ) ? 1 : -1; // xÌÚ®ûü + dx = ( x1 > x0 ) ? x1 - x0 : x0 - x1; // xÌÚ®Ê + sy = ( y1 > y0 ) ? 1 : -1; // yÌÚ®ûü + dy = ( y1 > y0 ) ? y1 - y0 : y0 - y1; // yÌÚ®Ê + + x = x0; + y = y0; + + if( dx >= dy ) { + /* X«ª1ȺÌê */ + E = -dx; + for( i = 0; i <= dx; i++ ) { + switch( pat ) { + case 0: // Àü + cl = fore_col; + break; + default: // jü + if ( clc>=3 ) { + if ( cl==fore_col ) cl=BGround_Color; + else cl=fore_col; + clc=0; + }else{ + clc++; + } + break; + } + + Draw_Dot(x,y,cl); + x += sx; + E += 2 * dy; + if( E >= 0 ) { + y += sy; + E -= 2 * dx; + } + } + }else{ + /* X«ª1æèå«¢ê */ + E = -dy; + for( i = 0; i <= dy; i++ ) { + switch( pat ) { + case 0: // Àü + cl = fore_col; + break; + default: // jü + if ( clc>=3 ) { + if ( cl==fore_col ) cl=BGround_Color; + else cl=fore_col; + clc=0; + }else{ + clc++; + } + break; + } + + Draw_Dot(x,y,cl); + y += sy; + E += 2 * dx; + if( E >= 0 ) { + x += sx; + E -= 2 * dy; + } + } + } +} + +// ~b`Fi[(Miechener) Ì~`æ Ql:http://dencha.ojaru.jp/programs_07/pg_graphic_09a1.html +// x,y : S_ +// radius: ¼a +void SPIOLED96x64::circle (int radius, int x, int y , unsigned int col, int fill) +{ + int cx, cy, d; + + d = 3 - 2 * radius; + cy = radius; + + // úÀWð 究ß`æ·é + Draw_Dot( x, radius+y, col ); // ÀW ( 0, R ); + Draw_Dot( x, -radius+y, col ); // ÀW ( 0, -R); + Draw_Dot( radius+x, y, col ); // ÀW ( R, 0 ); + Draw_Dot( -radius+x, y, col ); // ÀW (-R, 0); + if ( fill ) { + line( x, radius+y, x, -radius+y, col ,0 ); + line( radius+x, y, -radius+x, y, col ,0 ); + } + + for (cx = 0; cx <= cy; cx++){ + if (d >= 0) { + d += 10 + 4 * cx - 4 * cy; + cy--; + } else { + d += 6 + 4 * cx; + } + + // `æ + Draw_Dot( cy + x, cx + y, col); // 0-45 xÌÔ + Draw_Dot( cx + x, cy + y, col); // 45-90 xÌÔ + Draw_Dot( -cx + x, cy + y, col); // 90-135 xÌÔ + Draw_Dot( -cy + x, cx + y, col); // 135-180 xÌÔ + + Draw_Dot( -cy + x, -cx + y, col); // 180-225 xÌÔ + Draw_Dot( -cx + x, -cy + y, col); // 225-270 xÌÔ + Draw_Dot( cx + x, -cy + y, col); // 270-315 xÌÔ + Draw_Dot( cy + x, -cx + y, col); // 315-360 xÌÔ + + if ( fill ) { + line( cy + x, cx + y, cy + x, -cx + y, col ,0 ); + line( cx + x, cy + y, cx + x, -cy + y, col ,0 ); // 45-90 xÌÔ + line( -cx + x, cy + y, -cx + x, cy + y, col ,0 ) ; // 90-135 xÌÔ + line( -cy + x, cx + y, -cy + x, cx + y, col ,0 ); // 135-180 xÌÔ + + line( -cy + x, -cx + y, -cy + x, cx + y, col ,0 ); // 180-225 xÌÔ + line( -cx + x, -cy + y, -cx + x, cy + y, col ,0 ); // 225-270 xÌÔ + line( cx + x, -cy + y, cx + x, cy + y, col ,0 ); // 270-315 xÌÔ + line( cy + x, -cx + y, cy + x, cx + y, col ,0 ); // 315-360 xÌÔ + } + + } +} + +// Color Pattern +// pattern *P ÍqfaTUT(QoCg^)Ìf[^zñÅn· +void SPIOLED96x64::Pattern(int x,int y,int width, int height, unsigned int *p) +{ + + int i,j; + + for(i=0; i<width; i++){ + for(j=height-1;j>=0;j--){ + Draw_Dot(x+i,y+j,*p++); + } + } + +} + + + +
--- a/spioled96x64.h Wed Jan 12 02:43:37 2011 +0000 +++ b/spioled96x64.h Wed Jan 12 07:47:32 2011 +0000 @@ -1,74 +1,76 @@ -// ALO-095BWNN-J9 test program -// See also "http://www.aitendo.co.jp/product/2099" - - -#ifndef __SPIOLED96x64_H__ -#define __SPIOLED96x64_H__ - -#include "mbed.h" -#include "small_font.h" - -#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_Witch 8 // character's width -#define Y_Witch 8 // character's height - -#define CS_NORMAL 0 -#define CS_WIDE 1 -#define CS_HIGH 2 -#define CS_WH 3 -#define CS_WHx36 4 - -class SPIOLED96x64 : public Stream { -public: - // constructor - SPIOLED96x64(PinName cs_pin, PinName rst_pin, PinName a0_pin, PinName mosi_pin, PinName miso_pin, PinName sclk_pin); - #if DOXYGEN_ONLY - int putc(int c); - int printf(const char* format, ...); - #endif - void RegWrite(unsigned char Command); - void DataWrite(unsigned char c); - void DataWrite_to(unsigned int Dat); - - void Draw_Dot(int x,int y,unsigned int Color); - - void Box(int x1,int y1, int x2, int y2, unsigned int Color, int fill); - void Fill_Screen(unsigned int Color); - - void CS_Conv(int *lpx, int *lpy); - unsigned int ColorConv(unsigned int R,unsigned int G,unsigned int B); - void ChangeFontColor(unsigned int color); - void ChangeBGColor(unsigned int color); - void SetFontSize(int); - //void putc(unsigned char c); - void locate(int column, int row); - int row(); - int column(); - void puts( char *s ); - - 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); - -protected: - // Stream implementation functions - virtual int _putc( int c ); - virtual int _getc(); -private: - DigitalOut CS, RES, DC; - SPI spi; // mosi, miso, sclk - - unsigned int Char_Color; // character's color - unsigned int BGround_Color; - int x_locate; - int y_locate; - int chr_size; - void Init(void); - void PutChar(int x,int y,unsigned int a); - unsigned int findface(unsigned short c); - - -}; - - +// ALO-095BWNN-J9 test program +// See also "http://www.aitendo.co.jp/product/2099" + + +#ifndef __SPIOLED96x64_H__ +#define __SPIOLED96x64_H__ + +#include "mbed.h" +#include "ascii_font6x8.h" +#include "small_font.h" + +#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 +#define X_Witch 8 // character's width +#define Y_Witch 8 // character's height + +#define CS_NORMAL 0 +#define CS_WIDE 1 +#define CS_HIGH 2 +#define CS_WH 3 +#define CS_WHx36 4 + +class SPIOLED96x64 : public Stream { +public: + // constructor + SPIOLED96x64(PinName cs_pin, PinName rst_pin, PinName a0_pin, PinName mosi_pin, PinName miso_pin, PinName sclk_pin); + #if DOXYGEN_ONLY + int putc(int c); + int printf(const char* format, ...); + #endif + void RegWrite(unsigned char Command); + void RegWriteM(unsigned char *Command, int count); + void DataWrite(unsigned char c); + void DataWrite_to(unsigned int Dat); + + void Draw_Dot(int x,int y,unsigned int Color); + + void Box(int x1,int y1, int x2, int y2, unsigned int Color, int fill); + void Fill_Screen(unsigned int Color); + + void CS_Conv(int *lpx, int *lpy); + unsigned int ColorConv(unsigned int R,unsigned int G,unsigned int B); + void ChangeFontColor(unsigned int color); + void ChangeBGColor(unsigned int color); + void SetFontSize(int); + void locate(int column, int row); + int row(); + int column(); + //void puts( char *s ); + + 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); +protected: + // Stream implementation functions + virtual int _putc( int c ); + virtual int _getc(); +private: + DigitalOut CS, RES, DC; + SPI spi; // mosi, miso, sclk + + unsigned int Char_Color; // character's color + unsigned int BGround_Color; + int x_locate; + int y_locate; + int chr_size; + void Init(void); + void PutChar(int x,int y,unsigned int a); + unsigned int findface(unsigned short c); + + +}; + + #endif \ No newline at end of file