<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=42&amp;t=12638&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2019-10-27T22:05:48+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=42&amp;t=12638&amp;mode</id>
<entry>
<author><name><![CDATA[Hass-pol]]></name></author>
<updated>2019-10-27T22:05:48+01:00</updated>
<published>2019-10-27T22:05:48+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=222726#p222726</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=222726#p222726"/>
<title type="html"><![CDATA[Re: Problem z OLED 1,3&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=222726#p222726"><![CDATA[
Witam, czy ktoś z posiadaczy biblioteki MK_GLCD rozwiązał problem sterownika SH1106 ? Z informacji w Internecie różnica powinna być kosmetyczna - w stosunku do SSD1306 - niemniej przez tą kosmetykę przesiedziałem dobre dwa dni, bez skutku. Szukam rozwiązania dla I2C. Próbowałem podstawiać typową inicjację dla SH1106, jednak bez sukcesu.<br />Nie będę wklejał biblioteki MK_GLCD, ale może ktoś podpowie który element inicjacji w SDD1306 powinienem podmienić ? <br /><br />Wyświetlacz działa - sprawdzałem na bibliotece U8glib - pod Adruino, ale biblioteka MK_GLCD jest lepsza i wolałbym a niej pracować.<br /><br />[syntax=c]/*<br />   u8g_dev_sh1106_128x64.c<br />   Universal 8bit Graphics Library<br />   Copyright (c) 2011, olikraus@gmail.com<br />   All rights reserved.<br />   Redistribution and use in source and binary forms, with or without modification,<br />   are permitted provided that the following conditions are met:<br /> * Redistributions of source code must retain the above copyright notice, this list<br />    of conditions and the following disclaimer.<br /> * Redistributions in binary form must reproduce the above copyright notice, this<br />    list of conditions and the following disclaimer in the documentation and/or other<br />    materials provided with the distribution.<br />   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND<br />   CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES,<br />   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF<br />   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE<br />   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR<br />   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,<br />   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT<br />   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;<br />   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER<br />   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,<br />   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br />   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br />   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br /> */<br /><br />/* 初衷: 惠特128x64使用的SH1106芯片,这使得SSD1306总有些奇怪的情况.<br /> * 这里包含修改: 提供一个写入sh1106函数,使用&#91;U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE)&#93;调用<br /> */<br /><br />#include &quot;u8g.h&quot;<br /><br />#define WIDTH 128 //SH1106 -- 132x64, different from sh1106, But in here only use 128(col2-col129)<br />#define HEIGHT 64<br />#define PAGE_HEIGHT 8<br /><br />/* init with HuiTec 1.3' SH1106 I2C OLED Module<br /> * It use the display module: QG-2864KLBLG01 By Allvision technology<br /> */<br />static const uint8_t u8g_dev_sh1106_128x64_huitec_init_seq&#91;&#93; PROGMEM = {<br />    U8G_ESC_CS(0),           /* disable chip */<br />    U8G_ESC_ADR(0),         /* instruction mode */<br />    U8G_ESC_RST(1),         /* do reset low pulse with (1*16)+2 milliseconds */<br />    U8G_ESC_CS(1),           /* enable chip */<br /><br />    /* Start Enter Set,First off display */<br />    0x0ae,                  // display off,when all this have done,we light on the display again:)<br />    <br />    /* Set Lower Column Address: (00H - 0FH) */<br />    <br />    0x002,            //Set lower column address(from col2 for 128x64,that's specal)<br />    <br />    /* Set Higher Column Address: (10H - 1FH) */<br />     0x010,         //Set hight column address,there just begin with start,this is the &#91;0 0 0 1 X X X X&#93;, so the small will be &#91;0001 0000&#93;=10H.<br />    <br />    /* Set Display Start Line: (40H - 7FH)<br />       Specifies line address (refer to Figure. 8) to determine the initial display line or COM0. The RAM display data becomes the<br />       top line of OLED screen. It is followed by the higher number of lines in ascending order, corresponding to the duty cycle. When this command changes the line address, the smooth scrolling or page change takes place.<br />     */<br />    0x040,          //Set display start line just from 40H:)<br /><br />    /* Set Page Address: (B0H - B7H)<br />       Specifies page address to load display RAM data to page address register. Any RAM data bit can be accessed when its page address and column address are specified. The display remains unchanged even when the page address is changed.<br />     */<br />    0x0b0,          //We Start just from B0H:)<br /><br />    /* Set Contrast Control Register: (Double Bytes Command)<br />       This command is to set contrast setting of the display. The chip has 256 contrast steps from 00 to FF. The segment output current increases as the contrast step value increases.<br />       Segment output current setting: ISEG = a/256 X IREF X scale factor<br />       Where: a is contrast step; IREF is reference current equals 12.5μA; Scale factor = 16.*/<br />    0x081, //Enter The Contrast Control Mode Set: (81H)<br />    0x080, //Contrast Data Register Set: (00H - FFH),default value is 80H(means nothing change)<br /><br />    /*  Set Segment Re-map: (A0H - A1H)<br />       Change the relationship between RAM column address and segment driver. The order of segment driver output pads can be<br />       reversed by software. This allows flexible IC layout during OLED module assembly. For details, refer to the column address section of Figure. 8. When display data is written or read, the column address is incremented by 1 as shown in Figure.<br />     */<br />    0x0a1, //Value can be A0H(normal direction-the right rotates) or A1H(reverse direction-the left rotates),The Chip Default is A1H,But The HuiTec Module use A1H as deafult,And if you A0H for HuiTec Module,EveryThing will filp:)<br /><br />    /* Set Normal/Reverse Display: (A6H -A7H)<br />       Reverses the display ON/OFF status without rewriting the contents of the display data RAM.<br />     */<br />    0x0a6, //Value can be A6H(normal display, the RAM data is high, being OLED ON potential) or A7H(reverse display, the RAM data is low, being OLED ON potential), Chip Default is A6H<br /><br />    /* Set Multiplex Ration: (Double Bytes Command)<br />       This command switches default 64 multiplex modes to any multiplex ratio from 1 to 64. The output pads COM0-COM63 will be switched to corresponding common signal.<br />     */<br />    0x0a8,   //Enter Multiplex Ration Mode,not sure what's this for:)<br />    0x03f,  //Set the Multiplex Ration Data, 0x00F(1) - 0x03F(64), default value is 0x03f(64)<br /><br />    /* Set DC-DC OFF/ON: (Double Bytes Command)<br />       This command is to control the DC-DC voltage converter. The converter will be turned on by issuing this command then display ON command. The panel display must be off while issuing this command.<br />     */<br />    0x0ad, //Enter DC-DC Control Mode Set,The other name is called &#91;set charge pump enable mode:)&#93;<br />    0x08b, //DC-DC ON/OFF Mode Set: 8AH(off),8BH(on), default value is 8BH(on),maens dont use extern VCC.<br /><br />    /* Set Pump voltage value<br />       Specifies output voltage (VPP) of the internal charger pump.<br />     */<br />    0x031, //Specifies output voltage (VPP) of the internal charger pump(30H-33H).The value include: {30H: 6.4V,31H: 7.4V,32H: 8.0V,33H: 9.0V},default in chip is 32H,for the HuiTec Module them use 30H.as i test seems them all be okay.<br /><br />    /* Set Common Output Scan Direction<br />       This command sets the scan direction of the common output allowing layout flexibility in OLED module design. In addition, the display will have immediate effect once this command is issued. That is, if this command is sent during normal display, the graphic display will be vertically flipped.<br />     */<br />    0x0c8, //Value Can be C0H or C8H,C0H Means Scan from COM0 to COM &#91;N -1&#93;.C8H Means Scan from COM &#91;N -1&#93; to COM0.CHIP default is C0H,but HuiTec Module use C8H<br /><br />    /* Set Display Offset: (Double Bytes Command)<br />       This is a double byte command. The next command specifies the mapping of display start line to one of COM0-63 (it is assumed that COM0 is the display start line, that equals to 0). For example, to move the COM16 towards the COM0 direction for 16 lines, the 6-bit data in the second byte should be given by 010000. To move in the opposite direction by 16 lines, the 6-bit data should be given by (64-16), so the second byte should be 100000.<br />     */<br />    0x0d3, //Enter Display Offset Mode Set: (D3H)<br />    0x000, //Display Offset Data Set: (00H~3FH),Default is 00H<br /><br />    /* Set Display Clock Divide Ratio/Oscillator Frequency: (Double Bytes Command)<br />       This command is used to set the frequency of the internal display clocks (DCLKs). It is defined as the divide ratio (Value<br />       from 1 to 16) used to divide the oscillator frequency. POR is 1. Frame frequency is determined by divide ratio, number of display clocks per row, MUX ratio and oscillator frequency.<br />     */<br />    0x0d5, //Enter Divide Ratio/Oscillator Frequency Mode Set: (D5H)<br />    0x080, //Divide Ratio/Oscillator Frequency Data Set: (00H - FFH), The Chip Default is 50H, The HuiTec Module default is 80H,Means Divide Ration is 1,oscillator frequency is +15%(1000B).<br /><br />    /*  Set Dis-charge/Pre-charge Period: (Double Bytes Command)<br />        This command is used to set the duration of the pre-charge period. The interval is counted in number of DCLK. POR is 2 DCLKs.<br />     */<br />    0x0d9, //Enter Pre-charge Period Mode Set: (D9H)<br />    0x01f, //Dis-charge/Pre-charge Period Data Set: (00H - FFH),Default is 22H(2 DCLKs,2 DCLKs),USE 1FH for long lifetime (maybe)<br /><br />    /* Set Common pads hardware configuration: (Double Bytes Command) */<br />    0x0da, //Enter Common Pads Hardware Configuration Mode Set: (DAH)<br />    0x012, //Sequential/Alternative Mode Set: (02H,12H),Default is 12H(COM62, 60 - 2, 0,SEG0, 1 - 130, 131,COM1, 3 - 61, 63)<br /><br />    /* Set VCOM Deselect Level: (Double Bytes Command)<br />       This command is to set the common pad output voltage level at deselect stage.<br />     */<br />    0x0db, //Enter VCOM Deselect Level Mode Set: (DBH)<br />    0x040, //VCOM Deselect Level Data Set: (00H - FFH),HuiTec Module use 40H(B=0.1), VCOM = B x VREF = (0.1 + 64 X 0.006415) X VREF<br /><br />    /* Display ON */<br />    0x0af, //Display ON OLED(AFH)<br /><br />    U8G_ESC_CS(0),           /* disable chip */<br />    U8G_ESC_END              /* end of sequence */<br />};<br /><br /><br />/* select one init sequence here */<br />#define u8g_dev_sh1106_128x64_init_seq u8g_dev_sh1106_128x64_huitec_init_seq<br /><br />static const uint8_t u8g_dev_sh1106_128x64_data_start&#91;&#93; PROGMEM = {<br />    U8G_ESC_ADR(0),         /* instruction mode */<br />    U8G_ESC_CS(1),           /* enable chip */<br />    0x010,              /* set upper 4 bit of the col adr to 0 */<br />    <br />    /* In the 128x64 display,We start with col2,and end with 122 */<br />    0x002,              /* set lower 4 bit of the col adr to 2  */<br />    U8G_ESC_END              /* end of sequence */<br />};<br /><br />static const uint8_t u8g_dev_sh1106_sleep_on&#91;&#93; PROGMEM = {<br />    U8G_ESC_ADR(0),         /* instruction mode */<br />    U8G_ESC_CS(1),           /* enable chip */<br />    0x0ae,              /* display off */<br />    U8G_ESC_CS(1),           /* disable chip */<br />    U8G_ESC_END              /* end of sequence */<br />};<br /><br />static const uint8_t u8g_dev_sh1106_sleep_off&#91;&#93; PROGMEM = {<br />    U8G_ESC_ADR(0),         /* instruction mode */<br />    U8G_ESC_CS(1),           /* enable chip */<br />    0x0af,              /* display on */<br />    <br />    /* Power Stabilized (100ms Delay Recommended) */<br />    U8G_ESC_DLY(100),     /* delay 100 ms */<br />    U8G_ESC_CS(1),           /* disable chip */<br />    U8G_ESC_END              /* end of sequence */<br />};<br /><br />//@slboat 入口看起来是...初始化的入口功能<br />uint8_t u8g_dev_sh1106_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg){<br />    //@slboat msg是个枚举的小玩意<br />    switch (msg) {<br />    case U8G_DEV_MSG_INIT:<br />        u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_init_seq);<br />        break;<br />    case U8G_DEV_MSG_STOP:<br />        break;<br />    case U8G_DEV_MSG_PAGE_NEXT:<br />    {<br />        u8g_pb_t *pb = (u8g_pb_t *)(dev-&gt;dev_mem);<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);<br />        u8g_WriteByte(u8g, dev, 0x0b0 | pb-&gt;p.page); /* select current page (sh1106) */<br />        u8g_SetAddress(u8g, dev, 1);           /* data mode */<br />        if (u8g_pb_WriteBuffer(pb, u8g, dev) == 0)<br />            return 0;<br />        u8g_SetChipSelect(u8g, dev, 0);<br />    }<br />    break;<br />    case U8G_DEV_MSG_SLEEP_ON:<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_sleep_on);<br />        return 1;<br />    case U8G_DEV_MSG_SLEEP_OFF:<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_sleep_off);<br />        return 1;<br />    }<br />    return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);<br />}<br /><br />uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg){<br />    switch (msg) {<br />    case U8G_DEV_MSG_INIT:<br />        //why use U8G_SPI_CLK_CYCLE_300NS?<br />        u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_init_seq);<br />        break;<br />    case U8G_DEV_MSG_STOP:<br />        break;<br />    case U8G_DEV_MSG_PAGE_NEXT:<br />    {<br />        u8g_pb_t *pb = (u8g_pb_t *)(dev-&gt;dev_mem);<br /><br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);<br />        u8g_WriteByte(u8g, dev, 0x0b0 | (pb-&gt;p.page * 2)); /* select current page (sh1106) */<br />        u8g_SetAddress(u8g, dev, 1);           /* data mode */<br />        u8g_WriteSequence(u8g, dev, pb-&gt;width, pb-&gt;buf);<br />        u8g_SetChipSelect(u8g, dev, 0);<br /><br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);<br />        u8g_WriteByte(u8g, dev, 0x0b0 | (pb-&gt;p.page * 2 + 1)); /* select current page (sh1106) */<br />        u8g_SetAddress(u8g, dev, 1);           /* data mode */<br />        u8g_WriteSequence(u8g, dev, pb-&gt;width, (uint8_t *)(pb-&gt;buf) + pb-&gt;width);<br />        u8g_SetChipSelect(u8g, dev, 0);<br />    }<br />    break;<br />    case U8G_DEV_MSG_SLEEP_ON:<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_sleep_on);<br />        return 1;<br />    case U8G_DEV_MSG_SLEEP_OFF:<br />        u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_sleep_off);<br />        return 1;<br />    }<br />    return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);<br />}<br /><br />U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);<br />U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);<br />U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);<br /><br />uint8_t   u8g_dev_sh1106_128x64_2x_buf&#91;WIDTH * 2&#93; U8G_NOCOMMON;<br />u8g_pb_t  u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};<br />u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &amp;u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };<br />u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &amp;u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };<br />u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &amp;u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };[/syntax]<br /><br /><br />Program (cały) .c<br />[syntax=c]*  lcd.h<br /> *<br /> *  Created by Michael Köhler on 22.12.16.<br /> *  Copyright 2016 Skie-Systems. All rights reserved.<br /> *<br /> *  lib for OLED-Display with ssd1306/ssd1309/sh1106-Controller<br /> *  first dev-version only for I2C-Connection<br /> *  at ATMega328P like Arduino Uno<br /> *<br /> *  at GRAPHICMODE lib needs static SRAM for display:<br /> *  DISPLAY-WIDTH * DISPLAY-HEIGHT + 2 bytes<br /> *<br /> *  at TEXTMODE lib need static SRAM for display:<br /> *  2 bytes (cursorPosition)<br /> */<br /><br />#include &quot;lcd.h&quot;<br />#include &quot;font.h&quot;<br />#include &lt;string.h&gt;<br /><br />#if defined SPI<br />#include &lt;util/delay.h&gt;<br />#endif<br /><br />static struct {<br />    uint8_t x;<br />    uint8_t y;<br />} cursorPosition;<br /><br />static uint8_t charMode = NORMALSIZE;<br />#if defined GRAPHICMODE<br />#include &lt;stdlib.h&gt;<br />static uint8_t displayBuffer&#91;DISPLAY_HEIGHT/8&#93;&#91;DISPLAY_WIDTH&#93;;<br />#elif defined TEXTMODE<br />#else<br />#error &quot;No valid displaymode! Refer lcd.h&quot;<br />#endif<br /><br /><br />const uint8_t init_sequence &#91;&#93; PROGMEM = {    // Initialization Sequence<br />    LCD_DISP_OFF,    // Display OFF (sleep mode)<br />    0x20, 0b00,      // Set Memory Addressing Mode<br />    // 00=Horizontal Addressing Mode; 01=Vertical Addressing Mode;<br />    // 10=Page Addressing Mode (RESET); 11=Invalid<br />    0xB0,            // Set Page Start Address for Page Addressing Mode, 0-7<br />    0xC8,            // Set COM Output Scan Direction<br />0x02,// 0x00,            // --set low column address<br />    0x10,            // --set high column address<br />    0x40,            // --set start line address<br />    0x81, 0x3F,      // Set contrast control register<br />    0xA0,            // Set Segment Re-map. A0=address mapped; A1=address 127 mapped.<br />    0xA6,            // Set display mode. A6=Normal; A7=Inverse<br />    0xA8, DISPLAY_HEIGHT-1, // Set multiplex ratio(1 to 64)<br />    0xA4,            // Output RAM to Display<br /> // 0xA4=Output follows RAM content; 0xA5,Output ignores RAM content<br />    0xD3, 0x00,      // Set display offset. 00 = no offset<br />    0xD5,            // --set display clock divide ratio/oscillator frequency<br />    0xF0,            // --set divide ratio<br />    0xD9, 0x22,      // Set pre-charge period<br />    0xDA, 0x12,      // Set com pins hardware configuration<br />    0xDB,            // --set vcomh<br />    0x20,            // 0x20,0.77xVcc<br />    0x8D, 0x14,      // Set DC-DC enable<br />      <br />};<br />#pragma mark LCD COMMUNICATION<br /><br />void lcd_command(uint8_t cmd&#91;&#93;, uint8_t size) {<br />#if defined I2C<br />    i2c_start((LCD_I2C_ADR &lt;&lt; 1) | 0);<br />    i2c_byte(0x00);    // 0x00 for command, 0x40 for data<br />    for (uint8_t i=0; i&lt;size; i++) {<br />        i2c_byte(cmd&#91;i&#93;);<br />    }<br />    i2c_stop();<br />#elif defined SPI<br />LCD_PORT &amp;= ~(1 &lt;&lt; CS_PIN);<br />LCD_PORT &amp;= ~(1 &lt;&lt; DC_PIN);<br />for (uint8_t i=0; i&lt;size; i++) {<br />        SPDR = cmd&#91;i&#93;;<br />        while(!(SPSR &amp; (1&lt;&lt;SPIF)));<br />    }<br />    LCD_PORT |= (1 &lt;&lt; CS_PIN);<br />#endif<br />}<br />void lcd_data(uint8_t data&#91;&#93;, uint16_t size) {<br />#if defined I2C<br />    i2c_start((LCD_I2C_ADR &lt;&lt; 1) | 0);<br />    i2c_byte(0x40);    // 0x00 for command, 0x40 for data<br />    for (uint16_t i = 0; i&lt;size; i++) {<br />        i2c_byte(data&#91;i&#93;);<br />    }<br />    i2c_stop();<br />#elif defined SPI<br />LCD_PORT &amp;= ~(1 &lt;&lt; CS_PIN);<br />LCD_PORT |= (1 &lt;&lt; DC_PIN);<br />for (uint16_t i = 0; i&lt;size; i++) {<br />        SPDR = data&#91;i&#93;;<br />        while(!(SPSR &amp; (1&lt;&lt;SPIF)));<br />    }<br />    LCD_PORT |= (1 &lt;&lt; CS_PIN);<br />#endif<br />}<br />#pragma mark -<br />#pragma mark GENERAL FUNCTIONS<br />void lcd_init(uint8_t dispAttr){<br />#if defined I2C<br />    i2c_init();<br />#elif defined SPI<br />DDRB |= (1 &lt;&lt; PB2)|(1 &lt;&lt; PB3)|(1 &lt;&lt; PB5);<br />    SPCR = (1 &lt;&lt; SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;SPR0);<br />    LCD_DDR |= (1 &lt;&lt; CS_PIN)|(1 &lt;&lt; DC_PIN)|(1 &lt;&lt; RES_PIN);<br />    LCD_PORT |= (1 &lt;&lt; CS_PIN)|(1 &lt;&lt; DC_PIN)|(1 &lt;&lt; RES_PIN);<br />    LCD_PORT &amp;= ~(1 &lt;&lt; RES_PIN);<br />    _delay_ms(10);<br />    LCD_PORT |= (1 &lt;&lt; RES_PIN);<br />#endif<br /><br />    uint8_t commandSequence&#91;sizeof(init_sequence)+1&#93;;<br />    for (uint8_t i = 0; i &lt; sizeof (init_sequence); i++) {<br />        commandSequence&#91;i&#93; = (pgm_read_byte(&amp;init_sequence&#91;i&#93;));<br />    }<br />    commandSequence&#91;sizeof(init_sequence)&#93;=(dispAttr);<br />    lcd_command(commandSequence, sizeof(commandSequence));<br />    lcd_clrscr();<br />}<br />void lcd_gotoxy(uint8_t x, uint8_t y){<br />    if( x &gt; (DISPLAY_WIDTH/sizeof(FONT&#91;0&#93;)) || y &gt; (DISPLAY_HEIGHT/8-1)) return;// out of display<br />    x = x * sizeof(FONT&#91;0&#93;);<br />    cursorPosition.x=x;<br />    cursorPosition.y=y;<br />#if defined (SSD1306) || defined (SSD1309)<br />    uint8_t commandSequence&#91;&#93; = {0xb0+y, 0x21, x, 0x7f};<br />#elif defined SH1106<br />    uint8_t commandSequence&#91;&#93; = {0xb0+y, 0x21, 0x00+((2+x) &amp; (0x0f)), 0x10+( ((2+x) &amp; (0xf0)) &gt;&gt; 4 ), 0x7f};<br />#endif<br />    lcd_command(commandSequence, sizeof(commandSequence));<br />}<br /><br />void lcd_clrscr(void){<br />#ifdef GRAPHICMODE<br />    for (uint8_t i = 0; i &lt; DISPLAY_HEIGHT/8; i++){<br />        memset(displayBuffer&#91;i&#93;, 0x00, sizeof(displayBuffer&#91;i&#93;));<br />        lcd_gotoxy(0,i);<br />        lcd_data(displayBuffer&#91;i&#93;, sizeof(displayBuffer&#91;i&#93;));<br />    }<br />#elif defined TEXTMODE<br />    uint8_t displayBuffer&#91;DISPLAY_WIDTH&#93;;<br />    memset(displayBuffer, 0x00, sizeof(displayBuffer));<br />    for (uint8_t i = 0; i &lt; DISPLAY_HEIGHT/8; i++){<br />        lcd_gotoxy(0,i);<br />        lcd_data(displayBuffer, sizeof(displayBuffer));<br />    }<br />#endif<br />    lcd_home();<br />}<br />void lcd_home(void){<br />    lcd_gotoxy(0, 0);<br />}<br />void lcd_invert(uint8_t invert){<br />    uint8_t commandSequence&#91;1&#93;;<br />    if (invert != YES) {<br />        commandSequence&#91;0&#93; = 0xA6;<br />    } else {<br />        commandSequence&#91;0&#93; = 0xA7;<br />    }<br />    lcd_command(commandSequence, 1);<br />}<br />void lcd_sleep(uint8_t sleep){<br />    uint8_t commandSequence&#91;1&#93;;<br />    if (sleep != YES) {<br />        commandSequence&#91;0&#93; = 0xAF;<br />    } else {<br />        commandSequence&#91;0&#93; = 0xAE;<br />    }<br />    lcd_command(commandSequence, 1);<br />}<br />void lcd_set_contrast(uint8_t contrast){<br />    uint8_t commandSequence&#91;2&#93; = {0x81, contrast};<br />    lcd_command(commandSequence, sizeof(commandSequence));<br />}<br />void lcd_putc(char c){<br />    switch (c) {<br />        case '\b':<br />            // backspace<br />            lcd_gotoxy(cursorPosition.x-charMode, cursorPosition.y);<br />            lcd_putc(' ');<br />            lcd_gotoxy(cursorPosition.x-charMode, cursorPosition.y);<br />            break;<br />        case '\t':<br />            // tab<br />            if( (cursorPosition.x+charMode*4) &lt; (DISPLAY_WIDTH/ sizeof(FONT&#91;0&#93;)-charMode*4) ){<br />                lcd_gotoxy(cursorPosition.x+charMode*4, cursorPosition.y);<br />            }else{<br />                lcd_gotoxy(DISPLAY_WIDTH/ sizeof(FONT&#91;0&#93;), cursorPosition.y);<br />            }<br />            break;<br />        case '\n':<br />            // linefeed<br />            if(cursorPosition.y &lt; (DISPLAY_HEIGHT/8-1)){<br />                lcd_gotoxy(cursorPosition.x, cursorPosition.y+charMode);<br />            }<br />            break;<br />        case '\r':<br />            // carrige return<br />            lcd_gotoxy(0, cursorPosition.y);<br />            break;<br />        default:<br />            // char doesn't fit in line<br />            if( (cursorPosition.x &gt;= DISPLAY_WIDTH-sizeof(FONT&#91;0&#93;)) || (c &lt; ' ') ) break;<br />            // mapping char<br />            c -= ' ';<br />            if (c &gt;= pgm_read_byte(&amp;special_char&#91;0&#93;&#91;1&#93;) ) {<br />                char temp = c;<br />                c = 0xff;<br />                for (uint8_t i=0; pgm_read_byte(&amp;special_char&#91;i&#93;&#91;1&#93;) != 0xff; i++) {<br />                    if ( pgm_read_byte(&amp;special_char&#91;i&#93;&#91;0&#93;)-' ' == temp ) {<br />                        c = pgm_read_byte(&amp;special_char&#91;i&#93;&#91;1&#93;);<br />                        break;<br />                    }<br />                }<br />                if ( c == 0xff ) break;<br />            }<br />            // print char at display<br />#ifdef GRAPHICMODE<br />            if (charMode == DOUBLESIZE) {<br />                uint16_t doubleChar&#91;sizeof(FONT&#91;0&#93;)&#93;;<br />                uint8_t dChar;<br />                if ((cursorPosition.x+2*sizeof(FONT&#91;0&#93;))&gt;DISPLAY_WIDTH) break;<br />                <br />                for (uint8_t i=0; i &lt; sizeof(FONT&#91;0&#93;); i++) {<br />                    doubleChar&#91;i&#93; = 0;<br />                    dChar = pgm_read_byte(&amp;(FONT&#91;(uint8_t)c&#93;&#91;i&#93;));<br />                    for (uint8_t j=0; j&lt;8; j++) {<br />                        if ((dChar &amp; (1 &lt;&lt; j))) {<br />                            doubleChar&#91;i&#93; |= (1 &lt;&lt; (j*2));<br />                            doubleChar&#91;i&#93; |= (1 &lt;&lt; ((j*2)+1));<br />                        }<br />                    }<br />                }<br />                for (uint8_t i = 0; i &lt; sizeof(FONT&#91;0&#93;); i++)<br />                {<br />                    // load bit-pattern from flash<br />                    displayBuffer&#91;cursorPosition.y+1&#93;&#91;cursorPosition.x+(2*i)&#93; = doubleChar&#91;i&#93; &gt;&gt; 8;<br />                    displayBuffer&#91;cursorPosition.y+1&#93;&#91;cursorPosition.x+(2*i)+1&#93; = doubleChar&#91;i&#93; &gt;&gt; 8;<br />                    displayBuffer&#91;cursorPosition.y&#93;&#91;cursorPosition.x+(2*i)&#93; = doubleChar&#91;i&#93; &amp; 0xff;<br />                    displayBuffer&#91;cursorPosition.y&#93;&#91;cursorPosition.x+(2*i)+1&#93; = doubleChar&#91;i&#93; &amp; 0xff;<br />                }<br />                cursorPosition.x += sizeof(FONT&#91;0&#93;)*2;<br />            } else {<br />            if ((cursorPosition.x+sizeof(FONT&#91;0&#93;))&gt;DISPLAY_WIDTH) break;<br />            <br />                for (uint8_t i = 0; i &lt; sizeof(FONT&#91;0&#93;); i++)<br />                {<br />                    // load bit-pattern from flash<br />                    displayBuffer&#91;cursorPosition.y&#93;&#91;cursorPosition.x+i&#93; =pgm_read_byte(&amp;(FONT&#91;(uint8_t)c&#93;&#91;i&#93;));<br />                }<br />                cursorPosition.x += sizeof(FONT&#91;0&#93;);<br />            }<br />#elif defined TEXTMODE<br />            if (charMode == DOUBLESIZE) {<br />                uint16_t doubleChar&#91;sizeof(FONT&#91;0&#93;)&#93;;<br />                uint8_t dChar;<br />                if ((cursorPosition.x+2*sizeof(FONT&#91;0&#93;))&gt;DISPLAY_WIDTH) break;<br />                <br />                for (uint8_t i=0; i &lt; sizeof(FONT&#91;0&#93;); i++) {<br />                    doubleChar&#91;i&#93; = 0;<br />                    dChar = pgm_read_byte(&amp;(FONT&#91;(uint8_t)c&#93;&#91;i&#93;));<br />                    for (uint8_t j=0; j&lt;8; j++) {<br />                        if ((dChar &amp; (1 &lt;&lt; j))) {<br />                            doubleChar&#91;i&#93; |= (1 &lt;&lt; (j*2));<br />                            doubleChar&#91;i&#93; |= (1 &lt;&lt; ((j*2)+1));<br />                        }<br />                    }<br />                }<br />                uint8_t data&#91;sizeof(FONT&#91;0&#93;)*2&#93;;<br />                for (uint8_t i = 0; i &lt; sizeof(FONT&#91;0&#93;); i++)<br />                {<br />                    // print font to ram, print 6 columns<br />                    data&#91;i&lt;&lt;1&#93;=(doubleChar&#91;i&#93; &amp; 0xff);<br />                    data&#91;(i&lt;&lt;1)+1&#93;=(doubleChar&#91;i&#93; &amp; 0xff);<br />                }<br />                lcd_data(data, sizeof(FONT&#91;0&#93;)*2);<br />                <br />#if defined (SSD1306) || defined (SSD1309)<br />                uint8_t commandSequence&#91;&#93; = {0xb0+cursorPosition.y+1,<br />                    0x21,<br />                    cursorPosition.x,<br />                    0x7f};<br />#elif defined SH1106<br />                uint8_t commandSequence&#91;&#93; = {0xb0+cursorPosition.y+1,<br />                    0x21,<br />                    0x00+((2+cursorPosition.x) &amp; (0x0f)),<br />                    0x10+( ((2+cursorPosition.x) &amp; (0xf0)) &gt;&gt; 4 ),<br />                    0x7f};<br />#endif<br />                lcd_command(commandSequence, sizeof(commandSequence));<br />                <br />                for (uint8_t i = 0; i &lt; sizeof(FONT&#91;0&#93;); i++)<br />                {<br />                    // print font to ram, print 6 columns<br />                    data&#91;i&lt;&lt;1&#93;=(doubleChar&#91;i&#93; &gt;&gt; 8);<br />                    data&#91;(i&lt;&lt;1)+1&#93;=(doubleChar&#91;i&#93; &gt;&gt; 8);<br />                }<br />                lcd_data(data, sizeof(FONT&#91;0&#93;)*2);<br />                <br />                commandSequence&#91;0&#93; = 0xb0+cursorPosition.y;<br />#if defined (SSD1306) || defined (SSD1309)<br />                commandSequence&#91;2&#93; = cursorPosition.x+(2*sizeof(FONT&#91;0&#93;));<br />#elif defined SH1106<br />                commandSequence&#91;2&#93; = 0x00+((2+cursorPosition.x+(2*sizeof(FONT&#91;0&#93;))) &amp; (0x0f));<br />                commandSequence&#91;3&#93; = 0x10+( ((2+cursorPosition.x+(2*sizeof(FONT&#91;0&#93;))) &amp; (0xf0)) &gt;&gt; 4 );<br />#endif<br />                lcd_command(commandSequence, sizeof(commandSequence));<br />                cursorPosition.x += sizeof(FONT&#91;0&#93;)*2;<br />            } else {<br />                uint8_t data&#91;sizeof(FONT&#91;0&#93;)&#93;;<br />                if ((cursorPosition.x+sizeof(FONT&#91;0&#93;))&gt;DISPLAY_WIDTH) break;<br />                <br />            for (uint8_t i = 0; i &lt; sizeof(FONT&#91;0&#93;); i++)<br />                {<br />                    // print font to ram, print 6 columns<br />                    data&#91;i&#93;=(pgm_read_byte(&amp;(FONT&#91;(uint8_t)c&#93;&#91;i&#93;)));<br />                }<br />                lcd_data(data, sizeof(FONT&#91;0&#93;));<br />                cursorPosition.x += sizeof(FONT&#91;0&#93;);<br />            }<br />#endif<br />            break;<br />    }<br />    <br />}<br />void lcd_charMode(uint8_t mode){<br />    charMode = mode;<br />}<br />void lcd_puts(const char* s){<br />    while (*s) {<br />        lcd_putc(*s++);<br />    }<br />}<br />void lcd_puts_p(const char* progmem_s){<br />    register uint8_t c;<br />    while ((c = pgm_read_byte(progmem_s++))) {<br />        lcd_putc(c);<br />    }<br />}<br />#ifdef GRAPHICMODE<br />#pragma mark -<br />#pragma mark GRAPHIC FUNCTIONS<br />void lcd_drawPixel(uint8_t x, uint8_t y, uint8_t color){<br />    if( x &gt; DISPLAY_WIDTH-1 || y &gt; (DISPLAY_HEIGHT-1)) return; // out of Display<br />    if( color == WHITE){<br />        displayBuffer&#91;(y / 8)&#93;&#91;x&#93; |= (1 &lt;&lt; (y % 8));<br />    } else {<br />        displayBuffer&#91;(y / 8)&#93;&#91;x&#93; &amp;= ~(1 &lt;&lt; (y % 8));<br />    }<br />}<br />void lcd_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color){<br />    if( x1 &gt; DISPLAY_WIDTH-1 ||<br />       x2 &gt; DISPLAY_WIDTH-1 ||<br />       y1 &gt; DISPLAY_HEIGHT-1 ||<br />       y2 &gt; DISPLAY_HEIGHT-1) return;<br />    int dx =  abs(x2-x1), sx = x1&lt;x2 ? 1 : -1;<br />    int dy = -abs(y2-y1), sy = y1&lt;y2 ? 1 : -1;<br />    int err = dx+dy, e2; /* error value e_xy */<br />    <br />    while(1){<br />        lcd_drawPixel(x1, y1, color);<br />        if (x1==x2 &amp;&amp; y1==y2) break;<br />        e2 = 2*err;<br />        if (e2 &gt; dy) { err += dy; x1 += sx; } /* e_xy+e_x &gt; 0 */<br />        if (e2 &lt; dx) { err += dx; y1 += sy; } /* e_xy+e_y &lt; 0 */<br />    }<br />}<br />void lcd_drawRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color){<br />    if( px1 &gt; DISPLAY_WIDTH-1 ||<br />       px2 &gt; DISPLAY_WIDTH-1 ||<br />       py1 &gt; DISPLAY_HEIGHT-1 ||<br />       py2 &gt; DISPLAY_HEIGHT-1) return;<br />    lcd_drawLine(px1, py1, px2, py1, color);<br />    lcd_drawLine(px2, py1, px2, py2, color);<br />    lcd_drawLine(px2, py2, px1, py2, color);<br />    lcd_drawLine(px1, py2, px1, py1, color);<br />}<br />void lcd_fillRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color){<br />    if( px1 &gt; px2){<br />        uint8_t temp = px1;<br />        px1 = px2;<br />        px2 = temp;<br />        temp = py1;<br />        py1 = py2;<br />        py2 = temp;<br />    }<br />    for (uint8_t i=0; i&lt;=(py2-py1); i++){<br />        lcd_drawLine(px1, py1+i, px2, py1+i, color);<br />    }<br />}<br />void lcd_drawCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color){<br />    if( ((center_x + radius) &gt; DISPLAY_WIDTH-1) ||<br />       ((center_y + radius) &gt; DISPLAY_HEIGHT-1) ||<br />       center_x &lt; radius ||<br />       center_y &lt; radius) return;<br />    int16_t f = 1 - radius;<br />    int16_t ddF_x = 1;<br />    int16_t ddF_y = -2 * radius;<br />    int16_t x = 0;<br />    int16_t y = radius;<br />    <br />    lcd_drawPixel(center_x  , center_y+radius, color);<br />    lcd_drawPixel(center_x  , center_y-radius, color);<br />    lcd_drawPixel(center_x+radius, center_y  , color);<br />    lcd_drawPixel(center_x-radius, center_y  , color);<br />    <br />    while (x&lt;y) {<br />        if (f &gt;= 0) {<br />            y--;<br />            ddF_y += 2;<br />            f += ddF_y;<br />        }<br />        x++;<br />        ddF_x += 2;<br />        f += ddF_x;<br />        <br />        lcd_drawPixel(center_x + x, center_y + y, color);<br />        lcd_drawPixel(center_x - x, center_y + y, color);<br />        lcd_drawPixel(center_x + x, center_y - y, color);<br />        lcd_drawPixel(center_x - x, center_y - y, color);<br />        lcd_drawPixel(center_x + y, center_y + x, color);<br />        lcd_drawPixel(center_x - y, center_y + x, color);<br />        lcd_drawPixel(center_x + y, center_y - x, color);<br />        lcd_drawPixel(center_x - y, center_y - x, color);<br />    }<br />}<br />void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color) {<br />    for(uint8_t i=0; i&lt;= radius;i++){<br />        lcd_drawCircle(center_x, center_y, i, color);<br />    }<br />}<br />void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t *picture, uint8_t width, uint8_t height, uint8_t color){<br />    uint8_t i,j, byteWidth = (width+7)/8;<br />    for (j = 0; j &lt; height; j++) {<br />        for(i=0; i &lt; width;i++){<br />            if(pgm_read_byte(picture + j * byteWidth + i / 8) &amp; (128 &gt;&gt; (i &amp; 7))){<br />                lcd_drawPixel(x+i, y+j, color);<br />            } else {<br />                lcd_drawPixel(x+i, y+j, !color);<br />            }<br />        }<br />    }<br />}<br />void lcd_display() {<br />#if defined (SSD1306) || defined (SSD1309)<br />    lcd_gotoxy(0,0);<br />    lcd_data(&amp;displayBuffer&#91;0&#93;&#91;0&#93;, DISPLAY_WIDTH*DISPLAY_HEIGHT/8);<br />#elif defined SH1106<br />    for (uint8_t i = 0; i &lt; DISPLAY_HEIGHT/8; i++){<br />        lcd_gotoxy(0,i);<br />        lcd_data(displayBuffer&#91;i&#93;, sizeof(displayBuffer&#91;i&#93;));<br />    }<br />#endif<br />}<br />#endif[/syntax]<br /><br />ta sama biblioteka .h<br />[syntax=c]/*<br /> * This file is part of lcd library for ssd1306/ssd1309/sh1106 oled-display.<br /> *<br /> * lcd library for ssd1306/ssd1309/sh1106 oled-display is free software: you can redistribute it and/or modify<br /> * it under the terms of the GNU General Public License as published by<br /> * the Free Software Foundation, either version 3 of the License, or any later version.<br /> *<br /> * lcd library for ssd1306/ssd1309/sh1106 oled-display is distributed in the hope that it will be useful,<br /> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br /> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br /> * GNU General Public License for more details.<br /> *<br /> * You should have received a copy of the GNU General Public License<br /> * along with Foobar.  If not, see &lt;http://www.gnu.org/licenses/&gt;.<br /> *<br /> * Diese Datei ist Teil von lcd library for ssd1306/ssd1309/sh1106 oled-display.<br /> *<br /> * lcd library for ssd1306/ssd1309/sh1106 oled-display ist Freie Software: Sie können es unter den Bedingungen<br /> * der GNU General Public License, wie von der Free Software Foundation,<br /> * Version 3 der Lizenz oder jeder späteren<br /> * veröffentlichten Version, weiterverbreiten und/oder modifizieren.<br /> *<br /> * lcd library for ssd1306/ssd1309/sh1106 oled-display wird in der Hoffnung, dass es nützlich sein wird, aber<br /> * OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite<br /> * Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.<br /> * Siehe die GNU General Public License für weitere Details.<br /> *<br /> * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem<br /> * Programm erhalten haben. Wenn nicht, siehe &lt;http://www.gnu.org/licenses/&gt;.<br /> *<br /> *  lcd.h<br /> *<br /> *  Created by Michael Köhler on 22.12.16.<br /> *  Copyright 2016 Skie-Systems. All rights reserved.<br /> *<br /> *  lib for OLED-Display with ssd1306/ssd1309/sh1106-Controller<br /> *  first dev-version only for I2C-Connection<br /> *  at ATMega328P like Arduino Uno<br /> *<br /> *  at GRAPHICMODE lib needs SRAM for display<br /> *  DISPLAY-WIDTH * DISPLAY-HEIGHT + 2 bytes<br /> */<br /><br />#ifndef LCD_H<br />#define LCD_H<br /><br />#ifdef __cplusplus<br />extern &quot;C&quot; {<br />#endif<br />    <br />#if (__GNUC__ * 100 + __GNUC_MINOR__) &lt; 303<br />#error &quot;This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !&quot;<br />#endif<br />    <br />#include &lt;inttypes.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />/* TODO: define bus */<br />#define I2C// I2C or SPI<br />    /* TODO: define displaycontroller */<br />#define SH1106                 // or SSD1306, check datasheet of your display<br />    /* TODO: define displaymode */<br />#define TEXTMODE                // TEXTMODE for only text to display,<br />    // GRAPHICMODE for text and graphic<br />    /* TODO: define font */<br />#define FONT            ssd1306oled_font// set font here, refer font-name at font.h/font.c<br />    <br />    /* TODO: define I2C-adress for display */<br />    <br />    // using 7-bit-adress for lcd-library<br />    // if you use your own library for twi check I2C-adress-handle<br />#define LCD_I2C_ADR         (0x78 &gt;&gt; 1)    // 7 bit slave-adress without r/w-bit<br />    // r/w-bit are set/unset by library<br />    // e.g. 8 bit slave-adress:<br />    // 0x78 = adress 0x3C with cleared r/w-bit (write-mode)<br /><br />    <br />#ifdef I2C<br />#include &quot;i2c.h&quot;// library for I2C-communication<br />    // if you want to use other lib for I2C<br />    // edit i2c_xxx commands in this library<br />    // i2c_start(), i2c_byte(), i2c_stop()<br />    <br />#elif defined SPI<br />// if you want to use your other lib/function for SPI replace SPI-commands<br />#define LCD_PORTPORTB<br />#define LCD_DDRDDRB<br />#define RES_PINPB0<br />#define DC_PINPB1<br />#define CS_PINPB2<br /><br />#endif<br /><br />#ifndef YES<br />#define YES        1<br />#endif<br /><br />#define NORMALSIZE 1<br />#define DOUBLESIZE 2<br />    <br />#define LCD_DISP_OFF        0xAE<br />#define LCD_DISP_ON        0xAF<br />    <br />#define WHITE            0x01<br />#define BLACK            0x00<br />    <br />#define DISPLAY_WIDTH        128<br />#define DISPLAY_HEIGHT        64<br />    <br />    <br />    <br />    void lcd_command(uint8_t cmd&#91;&#93;, uint8_t size);    // transmit command to display<br />    void lcd_data(uint8_t data&#91;&#93;, uint16_t size);    // transmit data to display<br />    void lcd_init(uint8_t dispAttr);<br />    void lcd_home(void);                            // set cursor to 0,0<br />    void lcd_invert(uint8_t invert);        // invert display<br />    void lcd_sleep(uint8_t sleep);            // display goto sleep (power off)<br />    void lcd_set_contrast(uint8_t contrast);    // set contrast for display<br />    void lcd_puts(const char* s);            // print string, \n-terminated, from ram on screen (TEXTMODE)<br />    // or buffer (GRAPHICMODE)<br />    void lcd_puts_p(const char* progmem_s);        // print string from flash on screen (TEXTMODE)<br />    // or buffer (GRAPHICMODE)<br />    <br />    void lcd_clrscr(void);                // clear screen (and buffer at GRFAICMODE)<br />    void lcd_gotoxy(uint8_t x, uint8_t y);        // set curser at pos x, y. x means character,<br />    // y means line (page, refer lcd manual)<br />    void lcd_putc(char c);                // print character on screen at TEXTMODE<br />    // at GRAPHICMODE print character to buffer<br />    void lcd_charMode(uint8_t mode);            // set size of chars<br />#if defined GRAPHICMODE<br />    void lcd_drawPixel(uint8_t x, uint8_t y, uint8_t color);<br />    void lcd_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);<br />    void lcd_drawRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);<br />    void lcd_fillRect(uint8_t px1, uint8_t py1, uint8_t px2, uint8_t py2, uint8_t color);<br />    void lcd_drawCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);<br />    void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);<br />    void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t picture&#91;&#93;, uint8_t width, uint8_t height, uint8_t color);<br />    void lcd_display(void);                // copy buffer to display RAM<br />#endif<br />    <br />#ifdef __cplusplus<br />}<br />#endif<br />#endif /*  LCD_H  */[/syntax]<br /><br />inna biblioteka. .c<br />[syntax=c]// Functions for SSD1306/SSD1106 OLED Driver<br />// Version 4.0 by Nigel Mercier, based on code by dariuskrail<br /><br />#include &quot;SH1106.h&quot;<br />#include &quot;font5.h&quot;<br />#include &quot;font6R.h&quot;<br />#include &quot;functions.h&quot;<br /><br />// SSD1307:<br />// StartCol = 0;<br />// DisplayRAMColSize = 128;<br />// SH1106:<br />// StartCol = 2;<br />// DisplayRAMColSize = 132;<br /><br />// ** Functions **<br />// Display Internal functions<br /><br />void initDisplay(void)<br />{<br />  DisplayRST = 0 ;  // reset display (RST is active LOW)<br />  delayX25ms(1) ;   // minimum 10uS<br />  DisplayRST = 1 ;  // release reset<br /><br />  sendCmd(0xAE) ;    // turn off OLED panel                                           &#91;#11&#93;<br /><br />  sendCmd(0xC8) ;    // set COM scan direction 0-n &#91;POR = C0, C8&#93;                     &#91;#13&#93;<br />  sendCmd(0xA1) ;    // set SEG/Column left/right re-map &#91;POR = A0, A1&#93;                &#91;#6&#93;<br />//  sendCmd(0xA4) ;    // Entire Display Force On &#91;POR = A4, A5 force on&#93;                &#91;#7&#93;<br />  <br />  clsDisplay() ;     // clear RAM data and zero cursor<br />  setContrast(128) ; // POR value = 0x80<br />  sendCmd(0xAF) ;    // turn on OLED panel                                        &#91;#11&#93;<br />  delayX25ms(4) ;    // at least 100mS after 0xAF command<br />}<br /><br />void sendCmd(byte cmdOut)<br />{ // Write a command to Display<br />   DisplayD_C = 0 ;     // set A0 low, select Command mode DisplayD_C = 0 for this byte<br />   writeSD(cmdOut) ;    // Clock out command bits<br />   DisplayD_C = 1 ;     // set A0 high, select Data mode DisplayD_C = 1 for next ...<br />}<br /><br />void sendData(byte dataOut)<br />{ // Write data to Display, DisplayD_C = 1 set after sendCmd()<br />  //  DisplayD_C = 1 ;     // set A0 high, select Data mode DisplayD_C = 1<br />  writeSD(dataOut) ;   // Clock out data bits<br />}<br /><br />void writeSD(byte byteOut)<br />{ // Clocks out data to the SSD1306/SSD1106 controller<br />  signed short int bitcnt ;<br />  for (bitcnt = 8 ; bitcnt &gt; 0 ; bitcnt--)<br />  {<br />    DisplayCLK = 0 ;           // Set clock low<br />    DisplaySDI = byteOut.B7 ;  // transfer current bit 7 of byteOut to DisplaySDI pin<br />    DisplayCLK = 1 ;           // clock data bit on the rising edge of DisplayCLK<br />    byteOut = byteOut &lt;&lt; 1 ;   // logical shift left: get next bit to b7<br />  }<br />}<br /><br />void sendGlyphs(const byte *pRow, byte size)<br />{ //Send any font row to print character<br />  byte count ;<br />  for (count = 0 ; count &lt; size ; count++)  // Send row to print the character<br />  {<br />  sendData((pRow&#91;count&#93;)) ;<br />  }<br />  sendData(0x00);  // 1 pixel horizontal space after character<br />}<br /><br />// Display Screen Controls<br /><br />void setContrast(unsigned char contr)<br />{ <br />  sendCmd(0x81) ;    // set contrast control register                             &#91;#5&#93;<br />  sendCmd(contr) ;   //<br />}<br /><br />void cursorY(unsigned char add)<br />{ //Set page address for Page Addressing Mode<br />  sendCmd(0xB0 | add) ;<br />}<br /><br />void cursorX(unsigned char add)<br />{ //Set column adress for Page Addressing Mode<br />  add = add+sXOffset ;<br />  sendCmd(0x10 | (add&gt;&gt;4)) ; //  shift high 4<br />  sendCmd(0x0F &amp; add) ;      // low 4<br />}<br /><br />void cursorXY(byte x, byte y)<br />{ // Position cursor to column, line<br />  cursorY(y) ; // Y axis = line 0-7<br />  cursorX(x) ; // X axis = column 0 - (sWidth - 1)<br />}<br /><br />void onDisplay(void)<br />{<br />  sendCmd(0xAF) ;                     // turn on OLED panel<br />}<br /><br />void offDisplay(void)<br />{<br />  sendCmd(0xAE) ;                     // turn off OLED panel<br />}<br /><br />void clsDisplay(void)<br />{ // Erase the entire display DDRAM and set cursor home (0,0)<br />  byte line;<br />  offDisplay() ;                      // turn off OLED panel<br />  for (line = 8 ; line &gt; 0 ; line--)  // 8 lines of Display DDRAM<br />  { clLnDisplay(8 - line) ; }         // erase each in turn, home cursor to line<br />  onDisplay() ;                       // turn on OLED panel<br />}<br /><br />void clLnDisplay(byte yline)<br />{ // Clear single line 0-7 on display, cursor to line start<br />  byte ram ;<br />  cursorXY(0, yline)    ;            // Cursor Home<br />  for (ram=sWidth ; ram&gt;0 ; ram--)   // sWidth DDRAM addresses in each line<br />  { sendData(0); }                   // clear RAM<br />  cursorXY(0, yline) ;               // Cursor Home<br />}<br /><br />void rptPix(byte pix, byte blank, byte percent)<br />{ // repeat pixel across Display for percent - show bar graph<br />  byte count ;<br />  int width ;<br />  width = (sWidth*percent)/100 ; // screen width x fill level<br />  for (count=0; count&lt;sWidth; count++)  // loop for width<br />  {<br />   if ((count &lt;= width)||(count &gt; (sWidth - 2)))<br />   {  sendData(pix) ; }  // send 'pix' glyph to display<br />   else<br />   {  sendData(blank) ;} // send 'blank' glyph to display<br />  }<br />}<br /><br />void barDisplay(byte barG)<br />{// water bargraph on line 7  <br />  cursorXY(0, 7) ;<br />  rptPix(0b11111111, 0b10000001, barG);  // Draw line, then blanks<br />}<br /><br />// Display FONTS:<br />// 5x8 (1-line, full 7-bit ASCII from space)<br />// 34x48 (6 lines, numerals only, ASCII 48 - 57) Calibri Bold 54<br /><br />// Font5 functions (5x8)<br /><br />void charFont5(byte character) // MODIFY IF FONT RANGE CHANGED<br />{ // Prepare to write byte to Font5, via sendGlyphs<br />  if (character == ' ')  // munge ' ' to empty ';' character<br />   { character = ';' ; }<br />  if ((character&lt;'.')||(character&gt;'Z')) // reduced font5 table, CAPS only<br />   { return ; }    // Exit function if character out of ASCII range<br />  //Index to row of the character in font5 table, then send glyphs<br />  sendGlyphs(font5&#91;character - '.'&#93;, sizeof font5&#91;0&#93;);<br />}<br /><br />void strFont5(byte s&#91;&#93;)<br />{ // Write Variable or Contatant string to Font5<br />  while(*s) {charFont5(*s++);} // Points to character, or terminator<br />}<br /><br />void strFont5XY(byte s&#91;&#93;, byte x, byte y)<br />{ // Write (V or C) string to Font5 @ XY<br />  cursorXY(x,y);<br />  strFont5(s);<br />}<br /><br />void byteFont5XY(byte num, byte x, byte y)<br />{ // display byte value at XY<br />  char txt4&#91;4&#93;;<br />  ByteToStr(num, txt4);<br />  strFont5XY(txt4, x, y);<br />}<br /><br />void intFont5XY(int num, byte x, byte y)<br />{ // display int value at XY<br />  char txt7&#91;7&#93;;<br />  IntToStr(num, txt7);<br />  strFont5XY(txt7, x, y);<br />}<br /><br />void byteFont5(byte num)<br />{ // display byte value at cursor<br />  char txt4&#91;4&#93;;<br />  ByteToStr(num, txt4);<br />  strFont5(txt4);<br />}<br /><br />void digitFont5(byte digit) // send single digit to Display<br />{<br />  charFont5(digit + '0');<br />}<br /><br />void digitFont5XY(byte digit, byte x, byte y) // send single digit to Display @ x, y<br />{<br />  cursorXY(x,y);<br />  digitFont5(digit) ;<br />}<br /><br />// End of Font5 functions<br /><br />// Font6R functions (34x48) numerals only<br /><br />void charfont6Ra(byte character)<br />{ // Prepare top 22 bytes for Display, via sendGlyphs (numerals, space and '.' only)<br />  //if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }    // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Ra&#91;character - '0'&#93;, sizeof font6Ra&#91;0&#93;);<br />}<br /><br />void charfont6Rb(byte character)<br />{ // Prepare middle1 22 bytes for Display, via sendGlyphs<br />  // if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }    // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Rb&#91;character - '0'&#93;, sizeof font6Rb&#91;0&#93;);<br />}<br /><br />void charfont6Rc(byte character)<br />{ // Prepare middle2 22 bytes for Display, via sendGlyphs<br />  // if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }     // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Rc&#91;character - '0'&#93;, sizeof font6Rc&#91;0&#93;);<br />}<br /><br />void charfont6Rd(byte character)<br />{ // Prepare lower 22 bytes for Display, via sendGlyphs<br />  // if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }   // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Rd&#91;character - '0'&#93;, sizeof font6Rd&#91;0&#93;);<br />}<br /><br />void charfont6Re(byte character)<br />{ // Prepare lower 22 bytes for Display, via sendGlyphs<br />  // if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }   // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Re&#91;character - '0'&#93;, sizeof font6Re&#91;0&#93;);<br />}<br /><br />void charfont6Rf(byte character)<br />{ // Prepare lower 22 bytes for Display, via sendGlyphs<br />  // if (character==' ') {character='/';} // Munge ' ' into '/' for blank glyph<br />  if ((character&lt;'0')||(character&gt;'9'))<br />  { return ; }   // Exit function if character out of numeric range<br />  //Index to row of the character in font6R table, then send glyphs<br />  sendGlyphs(font6Rf&#91;character - '0'&#93;, sizeof font6Rf&#91;0&#93;);<br />}<br /><br />void strfont6Ra(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Ra<br />  while(*s) {charfont6Ra(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6Rb(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Rb<br />  while(*s) {charfont6Rb(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6Rc(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Rc<br />  while(*s) {charfont6Rc(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6Rd(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Rd<br />  while(*s) {charfont6Rd(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6Re(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Rd<br />  while(*s) {charfont6Re(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6Rf(byte s&#91;&#93;)<br />{ // Write (V or C) string to font6Rd<br />  while(*s) {charfont6Rf(*s++);} // Points to character, or terminator<br />}<br /><br />void strfont6RXY(byte s&#91;&#93;, byte x, byte y)<br />{ // Write (V or C) string to font6R @ XY<br />  cursorXY(x, y) ;<br />    strfont6Ra(s) ;<br />  cursorXY(x, y+1) ;<br />    strfont6Rb(s) ;<br />  cursorXY(x, y+2) ;<br />    strfont6Rc(s) ;<br />  cursorXY(x, y+3) ;<br />    strfont6Rd(s) ;<br />  cursorXY(x, y+4) ;<br />    strfont6Re(s) ;<br />  cursorXY(x, y+5) ;<br />    strfont6Rf(s) ;<br />}<br />// End of font6R functions<br /><br />// Misc init command repository<br /><br />   // sendCmd(0x0F &amp; sXOffset) ; // set low column address to any offset              &#91;#1&#93;<br />//  sendCmd(0x10) ;            // set high column address to 0                      &#91;#2&#93;<br />  // sendCmd(0xD9) ;   // set pre-charge period &#91;#16&#93;<br />  // sendCmd(0x25) ; // default is 22<br />  // sendCmd(0xDB) ;   // set Vcom Deselect Level &#91;#18&#93;<br />  // sendCmd(0x20) ; // set Vcom Deselect Level &#91;POR = 35&#93;<br />  // sendCmd(0xF1) ;        // Set Pre-Charge as 15 Clocks &amp; Discharge as 1 Clock<br />  // clsDisplay ;<br />  <br />  <br />  //  sendCmd(0x32) ;    // set Charge Pump voltage 0x32 = 8V                              &#91;#3&#93;<br />//  sendCmd(0xAD) ;    // DC-DC Control Mode                                            &#91;#10&#93;<br />//    sendCmd(0x8B) ;  // DC-DC Set ON<br /><br />// sendCmd(0x8D) ;    // set SSD1306 Charge Pump enable/disable &#91;see supplement&#93;<br />//   sendCmd(0x14) ;  // enable charge pump on SSD1306<br /><br /><br />  /*<br />  sendCmd(0xA8) ;    // set multiplex ratio (1 to 64)                             &#91;#9&#93;<br />    sendCmd(0x3F) ;  // &#91;POR = 3F&#93; 1/64 duty<br />  sendCmd(0xD3) ;    // set display offset Shift Mapping RAM Counter (0x00~0x3F) &#91;#14&#93;<br />    sendCmd(0x00) ;  // &#91;POR = 0&#93; not offset<br />  sendCmd(0x40) ;    // set start line to 0                                       &#91;#4&#93;<br />  sendCmd(0xA0) ;    // set SEG/Column left re-map &#91;POR = A0&#93;                     &#91;#6&#93;<br />  sendCmd(0xC0) ;    // set COM scan direction 0-n &#91;POR = C0&#93;                     &#91;#13&#93;<br />  sendCmd(0xDA) ;    // set com pins hardware configuration                       &#91;#17&#93;<br />    sendCmd(0x12) ;  // &#91;POR = 12&#93;<br />  sendCmd(0x81) ;    // set contrast control register                             &#91;#5&#93;<br />    sendCmd(0xF0) ;  //  80 &#91;POR&#93;<br /><br />  sendCmd(0xA6) ;    // set normal display A6 &#91;POR&#93; (reverse = A7)                &#91;#8&#93;<br />  sendCmd(0xD5) ;    // set display clock divide ratio/oscillator frequency       &#91;#15&#93;<br />    sendCmd(0x50) ;  // set divide ratio 0, Set Clock*/[/syntax]<br /><br />.h<br />[syntax=c]// Header for SSD1306/SSD1106 OLED Driver<br />// Version 4.0 by Nigel Mercier<br /><br />#include &quot;typedefs.h&quot;       // typedef unsigned short int byte ;<br />#include &quot;defs MK4 PCB.h&quot;   // port assignments for PCB MK4<br /><br />#define sWidth 128      // screen width<br />#define sXOffset 2      // x offset<br /><br /><br />// ** Function Prototypes **<br /><br />// Display Internal functions<br />void initDisplay(void) ;     // initialise the display<br />void sendCmd(byte) ;         // write a command to display<br />void sendData(byte) ;        // write data to display<br />void writeSD(byte);          // clock out serial data to the display controller<br /><br />// Display Control<br /><br />void onDisplay(void) ;      // turn on OLED panel<br />void offDisplay(void) ;     // turn off OLED panel<br />void clsDisplay(void) ;     // erase the display DDRAM and set cursor home (0,0)<br />void clLnDisplay(byte) ;    // clear line on display, cursor to line start<br />void cursorXY(byte, byte) ; // position cursor to column, line<br />void setContrast(byte) ;    // set contrast<br /><br />// Display<br />void rptPix(byte, byte, byte) ; // repeat pixel across Display - show bar graph<br />void barDisplay(byte) ;         // display bar graph<br />void charFont5(byte);           // Write byte in font 5, via sendGlyphs<br />void strFont5(byte &#91;&#93;);         // Write Variable or Contstant string in font 5<br />void strFont5XY(byte &#91;&#93;, byte, byte);  // Write (V or C) string in font 5 @XY<br />void strFont6RXY(byte &#91;&#93;, byte, byte); // Write (V or C) string in font 22 @XY<br />void byteFont5(byte) ;                 // Write 3 characters of byte in font 5<br />void intFont5XY(int, byte, byte) ;     // Write 5 characters of int in font 5<br />void byteFont5XY(byte, byte, byte);    // Write 3 characters of byte in font 5 @XY<br />void digitFont5(byte) ;                // Send single digit to Display<br />void digitFont5XY(byte, byte, byte) ;  // Send single digit to Display @XY<br /><br />// private functions for reference<br />// void sendGlyphs(const byte *, byte);  //Send any font row to print character[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=213">Hass-pol</a> — 27 paź 2019, o 22:05</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[luki]]></name></author>
<updated>2015-08-14T20:46:03+01:00</updated>
<published>2015-08-14T20:46:03+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137317#p137317</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137317#p137317"/>
<title type="html"><![CDATA[Re: Problem z OLED 1,3&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137317#p137317"><![CDATA[
Dokładnie tak problem już rozwiązany Dzięki Gufim za szybką pomoc na PW mogę dalej pracować nad zegarkiem okazuję się że w tych większych wyświetlaczach jest podobny do SSD1306 kontroler mianowicie SH1106 i ma on trochę inną rozdzielczość i trzeba zmienić funkcję wysyłającą dane z bufora do wyświetlacza.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=273">luki</a> — 14 sie 2015, o 20:46</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gufim]]></name></author>
<updated>2015-08-14T20:44:49+01:00</updated>
<published>2015-08-14T20:44:49+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137316#p137316</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137316#p137316"/>
<title type="html"><![CDATA[Re: Problem z OLED 1,3&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137316#p137316"><![CDATA[
Witam może to pomoże<br />[syntax=c]void ssd1306_display( void )<br />{<br />ssd1306_cmd( SSD1306_SETLOWCOLUMN  | 0x0 );<br />ssd1306_cmd( SSD1306_SETHIGHCOLUMN | 0x0 );<br />ssd1306_cmd( SSD1306_SETSTARTLINE  | 0x0 );<br /><br />// ***************************** SSD1306 *****************************************************************<br />#if USE_SH1106 == 0     // 0 - SSD1306   1 - SH1106<br />#if USE_CS == 1<br />      CS_HI;<br />#endif<br /><br />      DC_HI;<br /><br />#if USE_CS == 1<br />      CS_LO;<br />#endif<br /><br />      for ( uint16_t i = 0 ; i &lt; ( SSD1306_WIDTH * SSD1306_HEIGHT / 8) ; i++ )<br />      {<br />      SPIwrite( ssd1306_buf&#91;i&#93; );<br />      }<br /><br />#if USE_CS == 1<br />      CS_HI;<br />#endif<br />#endif<br /><br />// ********************************* SH1106 *****************************************************************<br />#if USE_SH1106 == 1     // 0 - SSD1306   1 - SH1106<br />uint8_t height=64;<br />uint8_t width=132;<br />uint8_t m_row = 0;<br />uint8_t m_col = 2;<br /><br />height &gt;&gt;= 3;<br />width &gt;&gt;= 3;<br /><br />int p = 0;<br /><br />uint8_t i, j, k =0;<br /><br />for ( i = 0; i &lt; height; i++)<br />{<br /><br />// *************** send a bunch of data in one xmission ********************************************<br />ssd1306_cmd(0xB0 + i + m_row);     //set page address<br />        ssd1306_cmd(m_col &amp; 0xF);          //set lower column address<br />        ssd1306_cmd(0x10 | (m_col &gt;&gt; 4));  //set higher column address<br /><br />        for( j = 0; j &lt; 8; j++)<br />        {<br /><br />#if USE_CS == 1<br />      CS_HI;<br />#endif<br /><br />      DC_HI;<br /><br />#if USE_CS == 1<br />      CS_LO;<br />#endif<br /><br />            for ( k = 0; k &lt; width; k++, p++)<br />            {<br />            SPIwrite( ssd1306_buf&#91;p&#93; );<br />            }<br /><br />#if USE_CS == 1<br />      CS_HI;<br />#endif<br />        }<br />}<br />#endif<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=126">gufim</a> — 14 sie 2015, o 20:44</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[luki]]></name></author>
<updated>2015-08-14T18:59:07+01:00</updated>
<published>2015-08-14T18:59:07+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137292#p137292</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137292#p137292"/>
<title type="html"><![CDATA[Problem z OLED 1,3&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12638&amp;p=137292#p137292"><![CDATA[
Witam<br /><br />Mam problem z uruchomienie OLED 1,3&quot; (SSD1306) wyświetlacz nowy, korzystam z bibliotek z poradników.<br />Wyświetlacz sterowany po SPI.<br />Biblioteka jak i program prawidłowa ponieważ gdy podepnę wyświetlacz 0,96&quot; wszystko działa tak jak trzeba po przełączeniu na 1,3&quot; bez zmiany wsadu mam taki oto efekt:<br /><div style="width: 583px; height: 471px; margin: 0 auto; padding-left: 26px; padding-top: 48px; background: url('https://www.atnel.pl/download/atnel_tv.png') no-repeat;"> <strong>iframe</strong> </div><br />Cały bufor wyświetlany jest i nadpisywany tylko na 1/8 wyświetlacza gdy w inicjalizacji zmienię ofset to cały pasek przesuwa się odpowiednio więc uszkodzenie sterowania pikseli można wykluczyć.<br />OLED 0,96&quot;<br /><a href="https://obrazkiforum.atnel.pl/273/0e72d25d01cfe999439033edd6541b22.jpg"  class="postlink"><img src="https://obrazkiforum.atnel.pl/thumb/273/0e72d25d01cfe999439033edd6541b22.jpg" alt="Obrazek" /></a><br /><br />Dodam że problem występuje zrówno na oryginalnej płytce jak i na tej od Gufima.<br />Gdy na jego płytce był przylutowany 0,9&quot; też wszystko działo co potwierdza poprawność wszystkich połączeń.<br />Moim zdaniem trzeba coś zmienić/dodać w inicjalizacji.<br />Filmik dokładnie pokazuję jaki mam efekt.<br /><br />Kodów nie wklejam ponieważ są one przepisane zgodnie z poradnikami gdyby były by tam jakieś błędy to na obydwu wyświetlaczach powinien być taki sam efekt (moim zdaniem).<br />Procek to ATMEGA328P <br />Oscylator wew 8MHz<br /><br />Proszę o pomoc <br />Pozdrawiam Luki<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=273">luki</a> — 14 sie 2015, o 18:59</p><hr />
]]></content>
</entry>
</feed>