Displays distance to start location on OLED screen.

Dependencies:   mbed

Committer:
iforce2d
Date:
Wed Mar 07 12:49:14 2018 +0000
Revision:
0:972874f31c98
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iforce2d 0:972874f31c98 1 /*
iforce2d 0:972874f31c98 2
iforce2d 0:972874f31c98 3 u8g_dev_sbn1661_122x32.c
iforce2d 0:972874f31c98 4
iforce2d 0:972874f31c98 5 WG12232 display with 2xSBN1661 / SED1520 controller (122x32 display)
iforce2d 0:972874f31c98 6 At the moment only available in the Arduino Environment
iforce2d 0:972874f31c98 7
iforce2d 0:972874f31c98 8 Universal 8bit Graphics Library
iforce2d 0:972874f31c98 9
iforce2d 0:972874f31c98 10 Copyright (c) 2011, olikraus@gmail.com
iforce2d 0:972874f31c98 11 All rights reserved.
iforce2d 0:972874f31c98 12
iforce2d 0:972874f31c98 13 Redistribution and use in source and binary forms, with or without modification,
iforce2d 0:972874f31c98 14 are permitted provided that the following conditions are met:
iforce2d 0:972874f31c98 15
iforce2d 0:972874f31c98 16 * Redistributions of source code must retain the above copyright notice, this list
iforce2d 0:972874f31c98 17 of conditions and the following disclaimer.
iforce2d 0:972874f31c98 18
iforce2d 0:972874f31c98 19 * Redistributions in binary form must reproduce the above copyright notice, this
iforce2d 0:972874f31c98 20 list of conditions and the following disclaimer in the documentation and/or other
iforce2d 0:972874f31c98 21 materials provided with the distribution.
iforce2d 0:972874f31c98 22
iforce2d 0:972874f31c98 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
iforce2d 0:972874f31c98 24 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
iforce2d 0:972874f31c98 25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iforce2d 0:972874f31c98 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
iforce2d 0:972874f31c98 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
iforce2d 0:972874f31c98 28 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
iforce2d 0:972874f31c98 29 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iforce2d 0:972874f31c98 30 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
iforce2d 0:972874f31c98 31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
iforce2d 0:972874f31c98 32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
iforce2d 0:972874f31c98 33 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
iforce2d 0:972874f31c98 34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
iforce2d 0:972874f31c98 35 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iforce2d 0:972874f31c98 36
iforce2d 0:972874f31c98 37
iforce2d 0:972874f31c98 38 */
iforce2d 0:972874f31c98 39
iforce2d 0:972874f31c98 40 #include "u8g.h"
iforce2d 0:972874f31c98 41
iforce2d 0:972874f31c98 42 #define WIDTH 122
iforce2d 0:972874f31c98 43 #define HEIGHT 32
iforce2d 0:972874f31c98 44 #define PAGE_HEIGHT 8
iforce2d 0:972874f31c98 45
iforce2d 0:972874f31c98 46
iforce2d 0:972874f31c98 47 static const uint8_t u8g_dev_sbn1661_122x32_init_seq[] PROGMEM = {
iforce2d 0:972874f31c98 48 U8G_ESC_CS(0), /* disable chip */
iforce2d 0:972874f31c98 49 U8G_ESC_ADR(0), /* instruction mode */
iforce2d 0:972874f31c98 50 U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds */
iforce2d 0:972874f31c98 51 U8G_ESC_CS(1), /* enable chip 1 */
iforce2d 0:972874f31c98 52 0x0af, /* display on */
iforce2d 0:972874f31c98 53 0x0c0, /* display start at line 0 */
iforce2d 0:972874f31c98 54 0x0a0, /* a0: ADC forward, a1: ADC reverse */
iforce2d 0:972874f31c98 55 0x0a9, /* a8: 1/16, a9: 1/32 duty */
iforce2d 0:972874f31c98 56 U8G_ESC_CS(2), /* enable chip 2 */
iforce2d 0:972874f31c98 57 0x0af, /* display on */
iforce2d 0:972874f31c98 58 0x0c0, /* display start at line 0 */
iforce2d 0:972874f31c98 59 0x0a0, /* a0: ADC forward, a1: ADC reverse */
iforce2d 0:972874f31c98 60 0x0a9, /* a8: 1/16, a9: 1/32 duty */
iforce2d 0:972874f31c98 61
iforce2d 0:972874f31c98 62 U8G_ESC_CS(0), /* disable chip */
iforce2d 0:972874f31c98 63
iforce2d 0:972874f31c98 64
iforce2d 0:972874f31c98 65 U8G_ESC_END /* end of sequence */
iforce2d 0:972874f31c98 66 };
iforce2d 0:972874f31c98 67
iforce2d 0:972874f31c98 68 uint8_t u8g_dev_sbn1661_122x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
iforce2d 0:972874f31c98 69 {
iforce2d 0:972874f31c98 70 switch(msg)
iforce2d 0:972874f31c98 71 {
iforce2d 0:972874f31c98 72 case U8G_DEV_MSG_INIT:
iforce2d 0:972874f31c98 73 u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
iforce2d 0:972874f31c98 74 u8g_WriteEscSeqP(u8g, dev, u8g_dev_sbn1661_122x32_init_seq);
iforce2d 0:972874f31c98 75 break;
iforce2d 0:972874f31c98 76 case U8G_DEV_MSG_STOP:
iforce2d 0:972874f31c98 77 break;
iforce2d 0:972874f31c98 78 case U8G_DEV_MSG_PAGE_NEXT:
iforce2d 0:972874f31c98 79 {
iforce2d 0:972874f31c98 80 u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
iforce2d 0:972874f31c98 81
iforce2d 0:972874f31c98 82 u8g_SetAddress(u8g, dev, 0); /* command mode */
iforce2d 0:972874f31c98 83 u8g_SetChipSelect(u8g, dev, 1);
iforce2d 0:972874f31c98 84 u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
iforce2d 0:972874f31c98 85 u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
iforce2d 0:972874f31c98 86 u8g_SetAddress(u8g, dev, 1); /* data mode */
iforce2d 0:972874f31c98 87 u8g_WriteSequence(u8g, dev, WIDTH/2, pb->buf);
iforce2d 0:972874f31c98 88
iforce2d 0:972874f31c98 89 u8g_SetAddress(u8g, dev, 0); /* command mode */
iforce2d 0:972874f31c98 90 u8g_SetChipSelect(u8g, dev, 2);
iforce2d 0:972874f31c98 91 u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
iforce2d 0:972874f31c98 92 u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
iforce2d 0:972874f31c98 93 u8g_SetAddress(u8g, dev, 1); /* data mode */
iforce2d 0:972874f31c98 94 u8g_WriteSequence(u8g, dev, WIDTH/2, WIDTH/2+(uint8_t *)pb->buf);
iforce2d 0:972874f31c98 95
iforce2d 0:972874f31c98 96 u8g_SetChipSelect(u8g, dev, 0);
iforce2d 0:972874f31c98 97
iforce2d 0:972874f31c98 98 }
iforce2d 0:972874f31c98 99 break;
iforce2d 0:972874f31c98 100 case U8G_DEV_MSG_CONTRAST:
iforce2d 0:972874f31c98 101 break;
iforce2d 0:972874f31c98 102 }
iforce2d 0:972874f31c98 103 return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
iforce2d 0:972874f31c98 104 }
iforce2d 0:972874f31c98 105
iforce2d 0:972874f31c98 106 /* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
iforce2d 0:972874f31c98 107 U8G_PB_DEV(u8g_dev_sbn1661_122x32 , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sbn1661_122x32_fn, u8g_com_arduino_no_en_parallel_fn);
iforce2d 0:972874f31c98 108