Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
u8g_dev_ks0108_128x64.c
00001 /* 00002 00003 u8g_dev_ks0108_128x64.c 00004 00005 Universal 8bit Graphics Library 00006 00007 Copyright (c) 2011, olikraus@gmail.com 00008 All rights reserved. 00009 00010 Redistribution and use in source and binary forms, with or without modification, 00011 are permitted provided that the following conditions are met: 00012 00013 * Redistributions of source code must retain the above copyright notice, this list 00014 of conditions and the following disclaimer. 00015 00016 * Redistributions in binary form must reproduce the above copyright notice, this 00017 list of conditions and the following disclaimer in the documentation and/or other 00018 materials provided with the distribution. 00019 00020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00021 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00022 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00025 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00030 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00031 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00032 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 00035 ADDRESS = 0 (Command Mode) 00036 0x03f Display On 00037 0x0c0 Start Display at line 0 00038 0x040 | y write to y address (y:0..63) 00039 0x0b8 | x write to page [0..7] 00040 00041 00042 u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset) 00043 u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE) 00044 00045 */ 00046 00047 #include "u8g.h" 00048 00049 #define WIDTH 128 00050 #define HEIGHT 64 00051 #define PAGE_HEIGHT 8 00052 00053 static const uint8_t u8g_dev_ks0108_128x64_init_seq[] PROGMEM = { 00054 U8G_ESC_CS(0), /* disable chip */ 00055 U8G_ESC_ADR(0), /* instruction mode */ 00056 U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */ 00057 U8G_ESC_CS(1), /* enable chip 1 */ 00058 0x03f, /* display on */ 00059 0x0c0, /* start at line 0 */ 00060 U8G_ESC_DLY(20), /* delay 20 ms */ 00061 U8G_ESC_CS(2), /* enable chip 2 */ 00062 0x03f, /* display on */ 00063 0x0c0, /* start at line 0 */ 00064 U8G_ESC_DLY(20), /* delay 20 ms */ 00065 U8G_ESC_CS(0), /* disable all chips */ 00066 U8G_ESC_END /* end of sequence */ 00067 }; 00068 00069 00070 uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) 00071 { 00072 00073 switch(msg) 00074 { 00075 case U8G_DEV_MSG_INIT: 00076 u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE); 00077 u8g_WriteEscSeqP(u8g, dev, u8g_dev_ks0108_128x64_init_seq); 00078 break; 00079 case U8G_DEV_MSG_STOP: 00080 break; 00081 case U8G_DEV_MSG_PAGE_NEXT: 00082 { 00083 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); 00084 00085 u8g_SetAddress(u8g, dev, 0); /* command mode */ 00086 u8g_SetChipSelect(u8g, dev, 2); 00087 u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */ 00088 u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */ 00089 u8g_SetAddress(u8g, dev, 1); /* data mode */ 00090 u8g_WriteSequence(u8g, dev, 64, pb->buf); 00091 u8g_SetChipSelect(u8g, dev, 0); 00092 00093 u8g_SetAddress(u8g, dev, 0); /* command mode */ 00094 u8g_SetChipSelect(u8g, dev, 1); 00095 u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */ 00096 u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */ 00097 u8g_SetAddress(u8g, dev, 1); /* data mode */ 00098 u8g_WriteSequence(u8g, dev, 64, 64+(uint8_t *)pb->buf); 00099 u8g_SetChipSelect(u8g, dev, 0); 00100 00101 } 00102 break; 00103 } 00104 return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); 00105 } 00106 00107 U8G_PB_DEV(u8g_dev_ks0108_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_PARALLEL); 00108 U8G_PB_DEV(u8g_dev_ks0108_128x64_fast, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_FAST_PARALLEL); 00109 00110 00111
Generated on Tue Jul 12 2022 17:30:57 by
 1.7.2
 1.7.2