iforce2d Chris / Mbed 2 deprecated ubxDistanceMeter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers u8g_dev_t6963_128x64.c Source File

u8g_dev_t6963_128x64.c

00001 /*
00002 
00003   u8g_dev_t6963_128x64.c
00004   
00005   Tested with Varitronix MGLS240128TZ
00006   
00007   Universal 8bit Graphics Library
00008   
00009   Copyright (c) 2013, olikraus@gmail.com
00010   All rights reserved.
00011 
00012   Redistribution and use in source and binary forms, with or without modification, 
00013   are permitted provided that the following conditions are met:
00014 
00015   * Redistributions of source code must retain the above copyright notice, this list 
00016     of conditions and the following disclaimer.
00017     
00018   * Redistributions in binary form must reproduce the above copyright notice, this 
00019     list of conditions and the following disclaimer in the documentation and/or other 
00020     materials provided with the distribution.
00021 
00022   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00023   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00024   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00025   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00027   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00028   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
00029   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00030   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00031   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00032   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00033   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00034   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00035   
00036         
00037   Application Notes for the MGLS 240x128
00038     www.baso.no/content/pdf/T6963C_Application.pdf
00039   
00040   Hitachi App Notes:
00041     https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
00042 
00043   Notes:
00044     The font selection pins should generate the 8x8 font.
00045     For the MGLS240128TZ only FS1 is available on pin 18.
00046     FS1 must be low to generate the 8x8 font.
00047   
00048   
00049 */
00050 
00051 #include "u8g.h"
00052 
00053 #define WIDTH 128
00054 #define HEIGHT 64
00055 #define PAGE_HEIGHT 16
00056 
00057 
00058 /* text is not used, so settings are not relevant */
00059 static const uint8_t u8g_dev_t6963_128x64_init_seq[] PROGMEM = {
00060   U8G_ESC_CS(0),             /* disable chip */
00061   U8G_ESC_ADR(0),           /* data mode */
00062   U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
00063 
00064   U8G_ESC_CS(1),             /* enable chip */
00065   U8G_ESC_DLY(50),         /* delay 50 ms */
00066 
00067   U8G_ESC_ADR(0),               /* data mode */
00068   0x000,                                /* low byte */
00069   0x000,                                /* height byte */
00070   U8G_ESC_ADR(1),               /* instruction mode */
00071   0x021,                                /* set cursor position */
00072   
00073   U8G_ESC_ADR(0),               /* data mode */
00074   0x000,                                /* low byte */
00075   0x000,                                /* height byte */
00076   U8G_ESC_ADR(1),               /* instruction mode */
00077   0x022,                                /* set offset */
00078 
00079   U8G_ESC_ADR(0),               /* data mode */
00080   0x000,                                /* low byte */
00081   0x000,                                /* height byte */
00082   U8G_ESC_ADR(1),               /* instruction mode */
00083   0x040,                     /* text home */
00084 
00085   U8G_ESC_ADR(0),               /* data mode */
00086   WIDTH/8,                              /* low byte */
00087   0x000,                                /* height byte */
00088   U8G_ESC_ADR(1),               /* instruction mode */
00089   0x041,                     /* text columns */
00090 
00091   U8G_ESC_ADR(0),               /* data mode */
00092   0x000,                                /* low byte */
00093   0x000,                                /* height byte */
00094   U8G_ESC_ADR(1),               /* instruction mode */
00095   0x042,                     /* graphics home */
00096 
00097   U8G_ESC_ADR(0),               /* data mode */
00098   WIDTH/8,                      /* low byte */
00099   0x000,                                /* height byte */
00100   U8G_ESC_ADR(1),               /* instruction mode */
00101   0x043,                     /* graphics columns */
00102   
00103   // mode set
00104   // 0x080: Internal CG, OR Mode
00105   // 0x081: Internal CG, EXOR Mode
00106   // 0x083: Internal CG, AND Mode
00107   // 0x088: External CG, OR Mode
00108   // 0x089: External CG, EXOR Mode
00109   // 0x08B: External CG, AND Mode
00110   U8G_ESC_ADR(1),               /* instruction mode */
00111   0x080,                                /* mode register: OR Mode, Internal Character Mode */
00112   
00113   U8G_ESC_ADR(1),               /* instruction mode */
00114   // display mode
00115   // 0x090: Display off
00116   // 0x094: Graphic off, text on, cursor off, blink off
00117   // 0x096: Graphic off, text on, cursor on, blink off
00118   // 0x097: Graphic off, text on, cursor on, blink on
00119   // 0x098: Graphic on, text off, cursor off, blink off
00120   // 0x09a: Graphic on, text off, cursor on, blink off
00121   // ...
00122   // 0x09c: Graphic on, text on, cursor off, blink off
00123   // 0x09f: Graphic on, text on, cursor on, blink on
00124   0x098,                                /* mode register: Display Mode, Graphics on, Text off, Cursor off */
00125   
00126   U8G_ESC_ADR(0),               /* data mode */
00127   0x000,                                /* low byte */
00128   0x000,                                /* height byte */
00129   U8G_ESC_ADR(1),               /* instruction mode */
00130   0x024,                                /* set adr pointer */
00131   
00132 
00133   U8G_ESC_DLY(100),         /* delay 100 ms */
00134   
00135   U8G_ESC_ADR(0),               /* data mode */
00136   U8G_ESC_CS(0),             /* disable chip */
00137   U8G_ESC_END                /* end of sequence */
00138 };
00139 
00140 uint8_t u8g_dev_t6963_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
00141 {
00142   switch(msg)
00143   {
00144     case U8G_DEV_MSG_INIT:
00145       u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);    
00146       u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_128x64_init_seq);
00147       break;
00148     case U8G_DEV_MSG_STOP:
00149       break;
00150     case U8G_DEV_MSG_PAGE_NEXT:
00151       {
00152         uint8_t y, i;
00153         uint16_t disp_ram_adr;
00154         uint8_t *ptr;
00155         u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
00156 
00157         
00158     u8g_SetAddress(u8g, dev, 0);           /* data mode */
00159         u8g_SetChipSelect(u8g, dev, 1);
00160         y = pb->p.page_y0;
00161         ptr = pb->buf;
00162         disp_ram_adr = WIDTH/8;
00163         disp_ram_adr *= y;
00164         for( i = 0; i < PAGE_HEIGHT; i ++ )
00165         {
00166           u8g_SetAddress(u8g, dev, 0);           /* data mode */
00167           u8g_WriteByte(u8g, dev, disp_ram_adr&255 );      /* address low byte */
00168           u8g_WriteByte(u8g, dev, disp_ram_adr>>8 );      /* address hight byte */
00169           u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
00170           u8g_WriteByte(u8g, dev, 0x024 );      /* set adr ptr */
00171       
00172           u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);    
00173       
00174           ptr += WIDTH/8;
00175           disp_ram_adr += WIDTH/8;
00176         }
00177     u8g_SetAddress(u8g, dev, 0);           /* data mode */
00178         u8g_SetChipSelect(u8g, dev, 0);
00179       }
00180       break;
00181   }
00182   return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
00183 }
00184 
00185 // U8G_PB_DEV(u8g_dev_t6963_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_128x64_fn, U8G_COM_T6963);
00186 
00187 uint8_t u8g_dev_t6963_128x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ; 
00188 u8g_pb_t u8g_dev_t6963_128x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_t6963_128x64_2x_bw_buf}; 
00189 u8g_dev_t u8g_dev_t6963_128x64_8bit = { u8g_dev_t6963_128x64_fn, &u8g_dev_t6963_128x64_2x_bw_pb, U8G_COM_T6963 };
00190 
00191 
00192