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_uc1701_mini12864.c
00001 /* 00002 00003 u8g_dev_uc1701_mini12864.c (dealextreme) 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 */ 00036 00037 #include "u8g.h" 00038 00039 #define WIDTH 128 00040 #define HEIGHT 64 00041 #define PAGE_HEIGHT 8 00042 00043 static const uint8_t u8g_dev_uc1701_mini12864_init_seq[] PROGMEM = { 00044 U8G_ESC_CS(0), /* disable chip */ 00045 U8G_ESC_ADR(0), /* instruction mode */ 00046 U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */ 00047 U8G_ESC_CS(1), /* enable chip */ 00048 00049 0x0e2, /* soft reset */ 00050 0x040, /* set display start line to 0 */ 00051 0x0a0, /* ADC set to reverse */ 00052 0x0c8, /* common output mode */ 00053 0x0a6, /* display normal, bit val 0: LCD pixel off. */ 00054 0x0a2, /* LCD bias 1/9 */ 00055 0x02f, /* all power control circuits on */ 00056 0x0f8, /* set booster ratio to */ 00057 0x000, /* 4x */ 00058 0x023, /* set V0 voltage resistor ratio to large */ 00059 0x081, /* set contrast */ 00060 0x027, /* contrast value */ 00061 0x0ac, /* indicator */ 00062 0x000, /* disable */ 00063 0x0af, /* display on */ 00064 00065 U8G_ESC_DLY(100), /* delay 100 ms */ 00066 0x0a5, /* display all points, ST7565 */ 00067 U8G_ESC_DLY(100), /* delay 100 ms */ 00068 U8G_ESC_DLY(100), /* delay 100 ms */ 00069 0x0a4, /* normal display */ 00070 U8G_ESC_CS(0), /* disable chip */ 00071 U8G_ESC_END /* end of sequence */ 00072 }; 00073 00074 static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = { 00075 U8G_ESC_ADR(0), /* instruction mode */ 00076 U8G_ESC_CS(1), /* enable chip */ 00077 0x010, /* set upper 4 bit of the col adr to 0 */ 00078 0x000, /* set lower 4 bit of the col adr to 4 */ 00079 U8G_ESC_END /* end of sequence */ 00080 }; 00081 00082 uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) 00083 { 00084 switch(msg) 00085 { 00086 case U8G_DEV_MSG_INIT: 00087 u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); 00088 u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq); 00089 break; 00090 case U8G_DEV_MSG_STOP: 00091 break; 00092 case U8G_DEV_MSG_PAGE_NEXT: 00093 { 00094 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); 00095 u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start); 00096 u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page */ 00097 u8g_SetAddress(u8g, dev, 1); /* data mode */ 00098 if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 ) 00099 return 0; 00100 u8g_SetChipSelect(u8g, dev, 0); 00101 } 00102 break; 00103 case U8G_DEV_MSG_CONTRAST: 00104 u8g_SetChipSelect(u8g, dev, 1); 00105 u8g_SetAddress(u8g, dev, 0); /* instruction mode */ 00106 u8g_WriteByte(u8g, dev, 0x081); 00107 u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); 00108 u8g_SetChipSelect(u8g, dev, 0); 00109 return 1; 00110 } 00111 return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); 00112 } 00113 00114 uint8_t u8g_dev_uc1701_mini12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) 00115 { 00116 switch(msg) 00117 { 00118 case U8G_DEV_MSG_INIT: 00119 u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); 00120 u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq); 00121 break; 00122 case U8G_DEV_MSG_STOP: 00123 break; 00124 case U8G_DEV_MSG_PAGE_NEXT: 00125 { 00126 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); 00127 00128 u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start); 00129 u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page */ 00130 u8g_SetAddress(u8g, dev, 1); /* data mode */ 00131 u8g_WriteSequence(u8g, dev, pb->width, pb->buf); 00132 u8g_SetChipSelect(u8g, dev, 0); 00133 00134 u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start); 00135 u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page */ 00136 u8g_SetAddress(u8g, dev, 1); /* data mode */ 00137 u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); 00138 u8g_SetChipSelect(u8g, dev, 0); 00139 } 00140 break; 00141 case U8G_DEV_MSG_CONTRAST: 00142 u8g_SetChipSelect(u8g, dev, 1); 00143 u8g_SetAddress(u8g, dev, 0); /* instruction mode */ 00144 u8g_WriteByte(u8g, dev, 0x081); 00145 u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); 00146 u8g_SetChipSelect(u8g, dev, 0); 00147 return 1; 00148 } 00149 return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); 00150 } 00151 00152 U8G_PB_DEV(u8g_dev_uc1701_mini12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_SW_SPI); 00153 U8G_PB_DEV(u8g_dev_uc1701_mini12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_HW_SPI); 00154 00155 uint8_t u8g_dev_uc1701_mini12864_2x_buf[WIDTH*2] U8G_NOCOMMON ; 00156 u8g_pb_t u8g_dev_uc1701_mini12864_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1701_mini12864_2x_buf}; 00157 u8g_dev_t u8g_dev_uc1701_mini12864_2x_sw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_SW_SPI }; 00158 u8g_dev_t u8g_dev_uc1701_mini12864_2x_hw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_HW_SPI }; 00159
Generated on Tue Jul 12 2022 17:30:57 by
1.7.2