XGraph_OLED128x64 für 128x32 pixel OLED

  • 1
  • 2
  • Page 1 of 2
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 17.01.2021 - 12:08  ·  #1
Ich habe mal versucht eines dieser Mini-OLED in Betrieb zu nehmen, meins hat 128x32 Pixel, nicht viel, aber es läuft soweit erst einmal mit der Demo "XGraph_OLED128x64".

Nur leider kann ich das dort nicht auf 32 Pixel umstellen, es klappt nicht.
Lasse ich es auf 64 Pixel fehlt jede zweite Zeile.

Weiß jemand wie ich das auf 32 Pixel umgestellt bekomme?

LCDGraphic = 128, 64, 8; {x-pix, y-pix, accesswidth} ist für 64 Pixel Höhe
LCDGraphic = 128, 32, 8; ändert aber leider nichts.

Vielleicht hat ja jemand schon mal so ein kleines Display in Gang gebracht.
Louis
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 17.01.2021 - 17:07  ·  #2
Oops, falscher Ordner, vielleicht findet es ja trotzdem jemand :-)
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 59
Posts: 2080
Registered: 03 / 2003
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 17.01.2021 - 21:00  ·  #3
Ich hab jetzt das Demo nicht da, aber welcher Controller ist da drin? SSD1306?

Was heißt, du kannst es nicht umstellen? Compilerfehler?

Schau mal hier: topic.php?t=3345
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 18.01.2021 - 10:06  ·  #4
Der SSD1306, ja. Ich kann den im Code umstellen:

LCDGraphic = 128, 64, 8; {x-pix, y-pix, accesswidth} ist für 64 Pixel Höhe
LCDGraphic = 128, 32, 8; ändert aber leider nichts.

Da tut sich also nichts. Ich kann dann nach wie vor 64 pixel hoch zeichnen, nur fehlt jede zweite Zeile.
Wenn ich also eine Linie auf Zeile 0 zeichne ist sie da, in Zeile 1 nicht, Zeile 2 geht wieder usw.
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 59
Posts: 2080
Registered: 03 / 2003
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 18.01.2021 - 12:04  ·  #5
Zeig mal den grafikrelevanten Teil deines Quellcodes: Initialisierung, Datenübertragung, GraphIOS

Man kann innerhalb X=Y=Integer immer zeichnen ;) ..... nur sehen evtl. nicht.
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 18.01.2021 - 16:50  ·  #6
Ich verwende die Demo "XGraph_OLED128x64" so wie sie von E-Lab zum Avrco dazu gegeben wurde.
Habe dann nur mal testweise ein paar Linien aufs Display gemalt, sonst alles gleich gelassen.

Code
{******************************************************************************}
{* Demo for SSD1306-OLED-Controller with LCDGraphic                           *}
{* Resolution: 128x64 Pixel  0.96" and 1.3" sizes                             *}
{* Interface: I²C on Port E                                                   *}
{* Terminal: Port D0                                                          *}
{* ELAB XMega Evaluation Board A3/A4                                          *}
{******************************************************************************}

{ $DEFINE OLED13}           // 1.3"OLED !!!!!!!!!!!!!!!!

program XGraph_OLED128x64;

{$NOSHADOW}
{ $WG}                     {global Warnings off}

Device = XMega256A3U, VCC = 3.3;
{ $BOOTRST $20000}         {Reset Jump to $20000}

import SysTick, TWI_E, LCDGraphic, BeepPort, SerPortC0, SysLEDblink;

from LCDGraphic import CharSet;     {block CharSet, pixels}

define
  // The XMegas don't provide any Oscillator fuses.
  // So the application must setup the desired values
  // possible OSC types: extXTAL, extClock, ext32kHz, int32Khz, int2MHz, int32MHz

  //>> CPU=32MHz, PeripherX4=32MHz, PeripherX2=32MHz
  OSCtype        = int32MHz,
                   PLLmul = 4,
                   prescB = 1,
                   prescC = 1;
  SysTick        = 10;             // msec
  StackSize      = $0064, iData;
  FrameSize      = $0100, iData;

  BeepPort       = PortR.0;
  SysLEDblink    = mSec300;        // 10..1000 msec
  SysLEDBlink0   = PortR.1, low;

  SerPortC0      = 19200, ParNone, Stop1, Databit8;
  TxBufferC0     = 16, iData;
  RxBufferC0     = 8, iData;

  TWIPrescE      = TWI_BR800;

  LCDGraphic     = 128, 64, 8;      {x-pix, y-pix, accesswidth}
  LCDgraphMode   = column, iData;
  DefCharSet     = 'Graphchars.pchr';  {FileName}
  GViewports     = 1, iData;        {logical ViewPorts, scalings}
  TGraphStr      = 16;              {Graphic Text String Length}

implementation

{$IDATA}

const
  // definitions for 2 bitmap types
  BmpSize8x8     : byte    = (8 * 8 div 8) + 2;
  BmpSize16x32   : byte    = (16 * 32 div 8) + 2;
  BmpSize32x32   : byte    = (32 * 32 div 8) + 2;

{--------------------------------------------------------------}
{ Type Declarations }
type
  // we need a few array types where we can insert the bitmaps
  tBMP8          = array[1..BmpSize8x8] of byte;
  tBMP32         = array[1..BmpSize32x32] of byte;
  tArrows        = array[0..3, 1..BmpSize8x8] of byte;
  tChips         = array[0..15, 1..BmpSize16x32] of byte;

{--------------------------------------------------------------}
const
  // constant which contain the bitmaps
  ELABbmp  : tBMP32    = 'E-LAB.pbmp';

  Arrows   : tArrows   = 'Arr_N.pbmp', 'Arr_W.pbmp', 'Arr_S.pbmp', 'Arr_E.pbmp';

  ChipsV   : tChips    = 'ChipV0.pbmp', 'ChipV1.pbmp', 'ChipV2.pbmp', 'ChipV3.pbmp',
                         'ChipV4.pbmp', 'ChipV5.pbmp', 'ChipV6.pbmp', 'ChipV7.pbmp',
                         'ChipV8.pbmp', 'ChipV9.pbmp', 'ChipV10.pbmp', 'ChipV11.pbmp',
                         'ChipV12.pbmp', 'ChipV13.pbmp', 'ChipV14.pbmp', 'ChipV15.pbmp';

  ChipsH   : tChips    = 'ChipH0.pbmp', 'ChipH1.pbmp', 'ChipH2.pbmp', 'ChipH3.pbmp',
                         'ChipH4.pbmp', 'ChipH5.pbmp', 'ChipH6.pbmp', 'ChipH7.pbmp',
                         'ChipH8.pbmp', 'ChipH9.pbmp', 'ChipH10.pbmp', 'ChipH11.pbmp',
                         'ChipH12.pbmp', 'ChipH13.pbmp', 'ChipH14.pbmp', 'ChipH15.pbmp';

{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var
  bb, idx,
  bright, co  : byte;
  i           : integer;
  ch          : char;

{--------------------------------------------------------------}
{ functions }
{$NOFRAME}

procedure WriteLCDCmd(Arg : byte);
begin
  TWIOutE($3C, $80, Arg);  // cmd
end;
{$NOFRAME}

procedure WriteLCD(Arg : byte);
begin
  TWIOutE($3C, $40, Arg);   // data
end WriteLCD;

procedure GraphInit;
begin
  WriteLCDCmd($AE);                           // display off

  WriteLCDCmd($D5);                           // set osc division
  WriteLCDCmd($80);                           //

  WriteLCDCmd($A8);                           // multiplex ratio
  WriteLCDCmd($3F);                           // duty=1/32

  WriteLCDCmd($D3);                           // set vertical shift by COM
  WriteLCDCmd($00);                           //

  WriteLCDCmd($8D);                           // set charge pump enable
  WriteLCDCmd($14);                           // $10=disable

  WriteLCDCmd($20);                           // set memory addressing mode
  WriteLCDCmd($02);                           // page addressing mode

  WriteLCDCmd($C8);                           // COM scan direction/vertical mirror

  WriteLCDCmd($DA);                           // set COM pins
  WriteLCDCmd($12);                           //

  WriteLCDCmd($81);                           // contrast control
  WriteLCDCmd($8F);                           // 0-255

  WriteLCDCmd($21);                           // set column address
  WriteLCDCmd($00);                           // start
  WriteLCDCmd($7F);                           // end

  WriteLCDCmd($40);                           // set display start line

  WriteLCDCmd($00);                           // set lower column address
  WriteLCDCmd($10);                           // set higher column address
  WriteLCDCmd($B0);                           // set page address

  WriteLCDCmd($A1);                           // set segment remap/horizontal mirror
  WriteLCDCmd($A6);                           // normal/$A7=inverse

  WriteLCDCmd($D9);                           // set pre-charge period
  WriteLCDCmd($1F);                           //

  WriteLCDCmd($DB);                           // set vcomh
  WriteLCDCmd($20);                           //

  WriteLCDCmd($AF);                           // display on

  MDelay(50);
end GraphInit;

{$D-}

userdevice GraphIOS(Cmd : byte; Arg : byte);
begin
  if Cmd = 0 then
{$IFDEF OLED13}           // 1.3"OLED
    WriteLCDCmd($02); // set lower 4 bit of the col adr to 2
{$ELSE}
    WriteLCDCmd($00); // set lower 4 bit of the col adr to 0
{$ENDIF}
    WriteLCDCmd($10);
    WriteLCDCmd($B0 + Arg);
  else
    WriteLCD(Arg);
  endif;
end GraphIOS;
{$D+}

procedure SetBrightness(br : byte);
begin
  WriteLCDCmd($81);                           // brightness control
  WriteLCDCmd(br);                            // 0-255
end SetBrightness;

procedure SetInverse(inv : boolean);
begin
  if inv = true then
    WriteLCDCmd($A7);                         // inverse
  else
    WriteLCDCmd($A6);                         // normal
  endif;
end SetInverse;

procedure MirrorH(mir : boolean);                 // mirror horizontal
begin
  if mir = true then
    WriteLCDCmd($A0);                         // mirrored
  else
    WriteLCDCmd($A1);                         // normal
  endif;
end MirrorH;

procedure MirrorV(mir : boolean);                 // mirror vertical
begin
  if mir = true then
    WriteLCDCmd($C0);                         // mirrored
  else
    WriteLCDCmd($C8);                         // normal
  endif;
end MirrorV;

procedure CheckSerPort;
begin
  if SerStatC0 then
    ch:= SerInpC0;
    case ch of
      '+' :
            IncToLim(bright);
            SetBrightness(bright);
            BeepClick;
          |
      '-' :
            DecToLim(bright);
            SetBrightness(bright);
            BeepClick;
          |
      'H' :
            MirrorH(true);
            BeepClick;
          |
      'h' :
            MirrorH(false);
            BeepClick;
          |
      'V' :
            MirrorV(true);
            BeepClick;
          |
      'v' :
            MirrorV(false);
            BeepClick;
          |
      'I' :
            SetInverse(true);
            BeepClick;
          |
      'i' :
            SetInverse(false);
            BeepClick;
          |
    else
      BeepOut(2000, 5);
    endcase;
    gSetTextMode(wmSetPix);
    gSetTextBkGnd(bkNormal);
    gDrawString(30, 40, 1, 1, TxtRot0, ByteToStr(bright : 3));
    gSetTextBkGnd(bkTransp);
    gSetTextMode(wmXorPix);
  endif;
end CheckSerPort;

procedure GraphTest;
begin
  bright:= 140;
  gClrScr($00);
  gDrawRect(1, 1, 127, 63, $FF);
  gSetTextJustify(alHorLeft, alVertTop);
  gDrawString(2, 2, 1, 2, TxtRot0,  'Test1');
  gDrawString(2, 20, 1, 2, TxtRot0, Test2');
  gDrawString(2, 40, 1, 2, TxtRot0, 'Test3');
  gDispRefresh;
  MDelay(100);


end GraphTest;


procedure GraphTest2;
begin
  bright:= 140;
  gDrawRect(0, 0, 127, 63, $AA);
  gDrawRect(49, 6, 125, 56, $FF);
  gDispRefresh;
  MDelay(100);

  gDrawBitMap(10, 10, @ELABbmp, wmSetPix);
  gDispRefresh;
  MDelay(100);
  gFillRect(10, 10, 42, 42, 0);
  gDispRefresh;

  gSetTextJustify(alHorCenter, alVertBottom);
  gSetTextBkGnd(bkTransp);
  gSetTextMode(wmSetPix);
  gDrawString(30, 40, 1, 1, TxtRot0, ByteToStr(bright : 3));
  gDrawString(62, 54, 1, 1, TxtRot0, 'Test');
  gSetTextMode(wmXorPix);
  gDrawString(90, 33, 2, 2, TxtRot0, 'E-LAB');
  gDrawString(90, 42, 1, 1, TxtRot0, 'Computers');
  gDrawString(62, 27, 1, 1, TxtRot90, 'AVRco');
  gDispRefresh;
  MDelay(5);
  loop
    for i:= 1 to 44 do
      gDrawString(61 + i, 54, 1, 1, TxtRot0, 'Test');
      gDrawString(62 + i, 54, 1, 1, TxtRot0, 'Test');
      gDispRefresh;
      CheckSerPort;
      MDelay(30);
    endfor;
    for i:= 44 downto 1 do
      gDrawString(62 + i, 54, 1, 1, TxtRot0, 'Test');
      gDrawString(61 + i, 54, 1, 1, TxtRot0, 'Test');
      gDispRefresh;
      CheckSerPort;
      MDelay(30);
    endfor;

    Inc(bb);
    if bb > 3 then
      bb:= 0;
    endif;
    gDrawBitMapN(29, 16, @Arrows[bb, 1], wmSetPix);

    for idx:= 0 to 15 do
      gDrawBitMapN(2, 3, @ChipsV[idx, 1], wmSetPix);
      gDrawBitMapN(15, 45, @ChipsH[idx, 1], wmSetPix);
      gDrawString(30, 58, 1, 1, TxtRot0, 'ABC');
      gDispRefresh;
      CheckSerPort;
      MDelay(30);
    endfor;
    MDelay(100);

    Inc(bb);
    if bb > 3 then
      bb:= 0;
    endif;
    gDrawBitMapN(29, 16, @Arrows[bb, 1], wmSetPix);

    for idx:= 15 downto 0 do
      gDrawBitMapN(2, 3, @ChipsV[idx, 1], wmSetPix);
      gDrawBitMapN(15, 45, @ChipsH[idx, 1], wmSetPix);
      gDrawString(30, 58, 1, 1, TxtRot0, 'ABC');
      gDispRefresh;
      CheckSerPort;
      MDelay(30);
    endfor;
    MDelay(100);
  endloop;

end GraphTest2;

{------------------------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
  EnableInts($87);
  //BeepChirpL(3);
  SysLEDflashAllOn;
  beepout(1200,10);
  Writeln(SerOutC0, 'AVRco LCD-Graphic Test');
  Writeln(SerOutC0, '+ & - contrast/Brightness');
  Writeln(SerOutC0, 'H & h horizontal mirror on/off');
  Writeln(SerOutC0, 'V & v vertical mirror on/off');
  Writeln(SerOutC0, 'I & i display inverse/normal');
  GraphInit;
  gClrScr(0);
  gSetTextJustify(alHorCenter, alVertTop);
  GraphTest;
  loop
  endloop;
end XGraph_OLED128x64.
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 59
Posts: 2080
Registered: 03 / 2003
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 19.01.2021 - 12:31  ·  #7
Was mir als erstes auffällt ist TWIPrescE = TWI_BR800; .... das funktioniert?
Ich hab leider kein solches Display je mit I²C getestet und komme frühestens am Wochenende dazu. Normalerweise nehme ich SPI.
Es könnte was mit der Initialisierung zu tun haben. Probiers doch mal mit dieser (Reset-Pin anpassen bzw. löschen wenn du keinen hast):
Code
Procedure GraphInit;
  Begin
    PortC:=%00000000;                             // /Reset
    MDelay(200);
    PortC:=%00001000;                             // Reset
    MDelay(200);

    WriteLCD($AE,false);                          // display off

    WriteLCD($20,false);                          // set memory addressing mode
    WriteLCD($02,false);                          // page addressing mode
    
    WriteLCD($22,false);                          // set page address
    WriteLCD($00,false);                          // start
    WriteLCD($7D,false);                          // end
    
    WriteLCD($00,false);                          // set lower column address
    WriteLCD($10,false);                          // set higher column address
    WriteLCD($B0,false);                          // set page address

    WriteLCD($81,false);                          // contrast control
    WriteLCD($80,false);                          // 0-255

    WriteLCD($A1,false);                          // set segment remap
    WriteLCD($A6,false);                          // normal/reverse
    WriteLCD($A8,false);                          // multiplex ratio
    WriteLCD($1F,false);                          // duty=1/32
    WriteLCD($C8,false);                          // com scan direction

    WriteLCD($D3,false);                          // display offset
    WriteLCD($00,false);                          //

    WriteLCD($D5,false);                          // set osc division
    WriteLCD($80,false);                          //

    WriteLCD($D9,false);                          // set pre-charge period
    WriteLCD($1F,false);                          //

    WriteLCD($DA,false);                          // set COM pins
    WriteLCD($00,false);                          //

    WriteLCD($DB,false);                          // set vcomh
    WriteLCD($40,false);                          //

    WriteLCD($8D,false);                          // set charge pump enable
    WriteLCD($14,false);                          // $10=disable

    WriteLCD($AF,false);                          // display on
    MDelay(500);
  End GraphInit;
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: XGraph_OLED128x64 für 128x32 pixel OLED

 · 
Posted: 19.01.2021 - 15:24  ·  #8
BR800 hat mich auch gewundert, aber das funktioniert einwandfrei.
Mit dem init läufts!
Vielen Dank dafür. Das Display ist winzig muss man schon sagen, aber perfekt für meinen Zweck.
You must be logged in or your permissions are to low to see this Attachment(s).
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 14 · Cache Hits: 14   138   152 · Page-Gen-Time: 0.087299s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI