Help With OLED Display / 128X64 SSD1306 - Page 3


+ Reply to Thread
Page 3 of 5 FirstFirst 12345 LastLast
Results 31 to 45 of 70

Thread: Help With OLED Display / 128X64 SSD13062559 days old

  1. #31
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    571
    Thumbs Up
    Received: 36
    Given: 27
    Total Downloaded
    4.63 GB

    0 Not allowed!

    Default Re: sample code from my tests

    Hi George,

    This code is very "rough and ready", but it does compile and run. Hope it's of some use.


    Bob
    Attached Files Attached Files

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #32
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    571
    Thumbs Up
    Received: 36
    Given: 27
    Total Downloaded
    4.63 GB

    0 Not allowed!

    Default Re: sample code from my tests

    George,

    A neuron must have fired somewhere in my old brain because I remembered the route cause of the problem you describe. If you rename the include file to anything you like you'll find that it compiles. Why you have to do this is a mystery to me, but then again, so much of life is....

    Bob

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #33
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,352
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: sample code from my tests

    Cheers Bob

    but then again, so much of life is....
    You've got that right.

    George
    George.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #34
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: Help With OLED Display / 128X64 SSD1306

    Appreciate the help here George. I will try this code out on a PIC18F24J50 and get back to you in a week or so :-)

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #35
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: Help With OLED Display / 128X64 SSD1306

    I modified the 1306 include file. It now refreshes RAM to display around 10 fold faster and is getting usable. Still slow on the print commands, maybe some of you guys can take a look and we can polish this code so it works like other displays? :-)

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #36
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: Help With OLED Display / 128X64 SSD1306

    I modified the 1306 include file. It now refreshes RAM to display around 10 fold faster and is getting usable. Still slow on the print commands, maybe some of you guys can take a look and we can polish this code so it works like other displays? :-)

    Code:
    All_Digital=On
    
    
         TRISA=111110
         TRISB=111111
         TRISC=000111
    
    
    All_Digital = true
    Dim dta As Byte
    Dim XXX As Byte
    Dim YYY As Byte 
    Dim III As Byte
    Dim loop As Word
    
    
    Declare LCD_Type = Graphic              ; use this declaration as code make use of compiler's hijacked PRINT command
    ;
    ;=====================   O P T I O N S   =============================== 
    $define use_drawLine                        ; user code make use of drawLine graphic function. Comment If Not needed
    $define use_drawRectangle                   ; user code make use of drawRectangle graphic function. Comment If Not needed
    $define use_drawCircle                      ; user code make use of drawCircle graphic function. Comment If Not needed
    $define use_fillRectangle                   ; user code make use of fillRectangle graphic function. Comment If Not needed
    $define use_fillCircle                      ; user code make use of fillCircle graphic function. Comment if not needed 
    $define use_AutoLineFeed                    ; enable this function if AutoLineFeed needed in user code 
    ;============================
    ;    Fonts to be used
    ;============================
    $define use_Font_f8x8                       ; will use the font stored in file "f8x8.inc"
    ;$define use_Font_clock24x49                 ; will use the Font stored in file "Clock24x49.inc"
    $define use_Font_f13x16                     ; will use the Font stored in file "f13x16.inc" 
    $define use_Font_f8x11                      ; will use the Font stored in file "f8x11.inc"
    $define use_Font_f12x12                     ; will use the Font stored in file "f12x12.inc"  
    ;$define use_Font_f9x14                      ; will use the Font stored in file "f9x14.inc"
    $define use_Font_decode6x5                  ; will use the Font stored in file "decode6x5.inc"
    $define use_Font_arrows15x18                ; will use the Font stored in file "arrows15x18.inc"  
    ; 
    ;==============================================================================
    Symbol DisplayWidth     128
    Symbol DisplayHeight    64
    
    
    Symbol SSD1306 = $78
    
    
    
    
    ;==============================================================================
    ;         NOKIA DRIVER DECLARES  
    ;==============================================================================
    Dim COMMAND_BYTE As Byte System                 ' USED TO SEND A COMMAND TO NOKIA 3310 LCD
    Dim glcd_Cursor_Y As Byte System                ' HOLDS THE VALUE FOR Y ROWS
    Dim glcd_Cursor_X As Byte System                ' HOLDS THE VALUE FOR X COLS
    Dim WORD_TEMP As Word                           ' DUMMY VAR
    'Dim SPP_Resp_Nokia As Byte
    Dim _charToPrint As Byte
    Dim CONTRAST As Byte
    ;----------------
    Dim GEN As Byte System                          ; used with #disable PRINT
    Dim _GLCD_FONT As Byte System 
    Dim PRINTING_FONT As Word System
    Dim _GLCD_FLAG As Byte System
    Dim PP0 As Byte System
    Dim PP0_temp As Byte
    Dim PP0h As Byte System
    Dim PP0h_temp As Byte
    Dim PP0hh As Byte System
    Dim PP0hh_temp As Byte
    Dim PP0hhh As Byte System
    Dim PP0hhh_temp As Byte
    Dim PP2 As Byte System
    Dim PP2_temp As Byte
    Dim PP2h As Byte System
    Dim PP2h_temp As Byte
    Dim PP2hh As Byte System
    Dim PP2hh_temp As Byte
    Dim PP2hhh As Byte System
    Dim PP2hhh_temp As Byte
    Dim PP7 As Byte System
    Dim PP7_temp As Byte
    Dim PP7h As Byte System
    Dim PP7h_temp As Byte
    Dim PP7hh As Byte System
    Dim PP7hh_temp As Byte
    Dim PP7hhh As Byte System
    Dim PP7hhh_temp As Byte
    ;------------------------------------------------------------------------------
    Dim memByte[1024] As Byte At $AAC 'Moved close to end of ram      
    Dim memByteRow As Byte
    Dim memByteBit As Byte
    Dim memByteNr As Word
    Dim memByteTemp As Byte System
    Dim Element#No As Word
    Dim PValue As Byte
    Dim FSR0 As FSR0L.Word
    ;
    Dim charwidth   As Byte 
    Dim width       As Byte
    Dim _i          As Byte
    Dim bitspixel   As Byte
    Dim bitsmask    As Byte
    Dim bits        As Word;
    Dim bits_tWord  As Byte
    Dim bitscount   As Byte;
    Dim table[4]    As Byte;
    Dim padding     As Byte;
    Dim index       As Dword
    Dim index_byte  As Byte
    Dim pixelcount  As Byte;
    Dim clipinvalid As Byte;
    Dim xx           As Byte            ;     glcdCoord_t xx;
    Dim yy           As Byte            ;     glcdCoord_t yy;
    Dim ppx As Byte
    Dim ppy As Byte
    Dim pixelcolor  As Byte             ; color    
    Dim clipY       As Byte             ; glcdCoord_t type 
    Dim stopY       As Byte;
    Dim stopX       As Byte;
    Dim Color As Byte
    ;
    Dim glcd_FontFirstChar  As Byte     ; first defined character in selected font
    Dim glcd_FontLastChar   As Byte     ; last defined character in selected font
    Dim glcd_FontWidth      As Byte     ; character width for fixed pitch of selected font
    Dim glcd_FontHeight     As Byte     ; character height of selected font
    Dim glcd_FontBitsPixel  As Byte     ; color depth of selected font, if MSB is set the font is compressed
    Dim glcd_FontSize       As Word     ; Font size
    Dim glcd_Clip_x1 As Byte
    Dim glcd_Clip_x2 As Byte
    Dim glcd_Clip_y1 As Byte
    Dim glcd_Clip_y2 As Byte
    Dim glcd_FontData   As  Word            ; STORES OUT THE START OF THE LOOKUP TABLE FOR THIS FONT 
    Dim FONT_NAME       As  glcd_FontData   ; Font Table Address
    ; structure  glcd_Flagsbits
    Dim glcd_Flagsbits As Byte    ; with the following structure bits
    $define AutoLineFeed 0        ; Font routines should use implicit linefeed And wrap around glcd_Window
    $define FixedFont    1        ; == 0 fonts painted proportional, == 1 fonts painted in fixed pitch
    $define Clipping     2        ; activate clipping
    ;
    Dim intermed_index As Word
    $define FONT_HEADER_SIZE 7
    ;
    Dim _t As Byte
    Dim glcd_Window_x1      As Byte
    Dim glcd_Window_x2      As Byte  ;
    Dim glcd_Window_y1      As Byte
    Dim glcd_Window_y2      As Byte
    Dim glcd_Cursor_X_temp As Byte
    Dim glcd_Cursor_Y_temp As Byte
    ;
    ; graphical functions variables
    Dim x0                As Byte    ; used in drawLine , drawCircle
    Dim y0                As Byte    ; used in drawLine , drawCircle
    Dim x1                As Byte    ; used in drawLine , drawCircle
    Dim y1                As Byte    ; used in drawLine , drawCircle
    ;
    Dim dx                As Dword   ; drawLine
    Dim dy                As Dword   ; drawLine
    Dim stepx             As Dword   ; drawLine
    Dim stepy             As Dword   ; drawline
    Dim dx2               As Dword   ; drawline
    Dim dy2               As Dword   ; drawLine
    Dim pen               As Byte    ; drawLine
    Dim y0t               As Byte    ; drawline 
    
    
    ' Changed from DWORD to SDWORD so  drawLine & drawCircle
    ' works with standard PROTON.
    
    
    Dim err               As SDword   ; drawline, drawCircle
    ;
    Dim _X                As Byte    ; drawCircle
    Dim _Y                As Byte    ; drawCircle
    Dim radius            As Byte    ; drawCircle, fillCircle
    Dim parL              As Byte    ; drawCircle
    Dim parR              As Byte    ; drawCircle
    
    
    Dim xfr0              As Byte    ; drawCMD rectangle
    Dim xfr1              As Byte    ; drawCMD rectangle
    Dim yfr0              As Byte    ; drawCMD rectangle
    Dim yfr1              As Byte    ; drawCMD rectangle
    ;
    Dim xr0               As Byte    ; fillRectangle
    Dim xr1               As Byte    ; fillRectangle
    Dim yr0               As Byte    ; fillRectangle
    Dim yr1               As Byte    ; fillRectangle
    ;
    
    
    Dim x0Fill            As Byte    ; fillCircle
    Dim y0Fill            As Byte    ; fillCircle
    Dim glcd_cursor_xm    As Byte    ; fillCircle
    Dim glcd_cursor_ym    As Byte    ; fillCircle
    Dim _P1               As Byte    ; fillCircle
    Dim _P2               As Byte    ; fillCircle
    Dim _P3               As Byte    ; fillCircle
    Dim _P4               As Byte    ; fillCircle
    
    
    ' Changed from DWORD to SDWORD so fillCircle works
    ' with standard PROTON
    Dim errFill           As SDword   ; fillCircle
    ;
    Dim glcdOffset        As Byte    ; refreshMEM offset
    Dim rLoopA            As Byte    ; refreshMEM offset
    Dim rLoopB            As Byte    ; refreshMem offset
    Dim c As Byte
    Dim x_low As Byte
    Dim x_high As Byte
    Dim testloop As Byte
    Dim x_temp As Byte
    Dim y_temp As Byte
    ;==============================================================================
    
    
    
    
    GoTo OVER_MACROS
    ;==============================================================================  
    #Disable GLCD_CLS
    #Disable GLCD_CURSOR
    #Disable GLCD_WRITE
    #Disable GLCD_READ
    #Disable Print                          ; hijacking the compiler's PRINT command
    Asm
    [email protected]
           GoTo NOKIA_CLS_SUB
    [email protected]
           Movwf glcd_Cursor_Y
           Movff GEN,glcd_Cursor_X 
           GoTo SSD1306_CURSOR_SUB
    Print   
        GoTo SSD1306_PRINT_SUB
    EndAsm       
    ;**************** M A C R O S *************************************************
    writeSPI Macro P1                      ' writeSPI Shift-out Shift-in using hardware MSSP
        #if (Prm_1 == Byte)
            Byte_Byte P1, SSPBUF
        #endif
        #if (Prm_1 == Word)
            Word_Byte P1, SSPBUF
        #endif
        #if (Prm_1 == Num8) | (Prm_1 == Num16)
            Num_Byte P1, SSPBUF
        #endif
    Endm
    
    
    '=============================================================================
    SSD1306_command:
    Pop c
    HBusOut SSD1306,[0,c]
    Return
    
    
    '------------------------------------------------------------ 
    SSD1306_data:
        Pop c
        'HBusOut $40
        'HBusOut c 
        HBusOut SSD1306,[$40,c]
    Return
    '------------------------------------------------------------ 
    GetElement    Macro  P1, P2             ; Thanks Tim !!!
        #if (Prm_Count > 2)
            #error "GetElement - Too many parameters"
        #else
            #if (Prm_Count < 2)
                #error "GetElement - Too few parameters"
            #else
                #if(Prm_1 != Byte_Array_Ptr)
                    #error "GetElement - Array(Param1) Should be a BYTE array pointer"
                #endif
                #if(Prm_2 != Word) && (Prm_2 != Num16)
                    #error "GetElement - Element(Param2) Should be a Word variable or number"
                #endif
                #if (Prm_1 == Byte_Array_Ptr)
                    Num_FSR0 P1
                #endif
                #if (Prm_2 == Word)
                    Word_Word P2, Element#No
                #endif
                #if (Prm_2 == Num16)
                    Num_Word P2, Element#No
                #endif
                GoSub GetArray_Sub
            #endif
        #endif
        #if (GetElement_RETURN != 1)
            #error "GetElement - Mandatory return parameter misssing"
        #else
            #if(Return_Type != Byte)
                #error "GetElement - Return variable should be a Byte variable only"
            #else
                #if (Return_Type == Byte)
                    Byte_Byte INDF0, Return_Var
                #endif
            #endif
        #endif
        Endm
    ;========================================================================
    PutElement  Macro  P1, P2, P3
        #if (Prm_Count > 3)
            #error "PutElement - Too many parameters"
        #else
            #if (Prm_Count < 3)
                #error "PutElement - Too few parameters"
            #else
                #if(Prm_1 != Byte_Array_Ptr)
                    #error "PutElement - Array(Param1) Should be a BYTE array only"
                #endif
                #if(Prm_2 != Word) && (Prm_2 != Num16)
                    #error "PutElement - Element(Param2) Should be a Word variable or number"
                #endif
                #if(Prm_3 != Byte) && (Prm_3 != Num8)
                    #error "PutElement - Value(Param3) Should be a Byte variable or number"
                #endif
                #if (Prm_1 == Byte_Array_Ptr)
                    Num_FSR0 P1
                #endif
                #if (Prm_2 == Word)
                    Word_Word P2, Element#No
                #endif
                #if (Prm_2 == Num16)
                    Num_Word P2, Element#No
                #endif
                #if (Prm_3 == Byte)
                    Byte_Byte P3, PValue
                #endif
                #if (Prm_3 == Num8)
                    Num_Byte P3, PValue
                #endif
                GoSub PutArray_Sub
            #endif
        #endif
        Endm    
    GetArray_Sub:
       FSR0 = FSR0 + Element#No 
       Return   
    PutArray_Sub:
       FSR0 = FSR0 + Element#No
       INDF0 = PValue
       Return
    ;==============================================================================
    putPixel    Macro        P1                                   ; pixelcolor ... 1 or 0           
                #if (Prm_1 == Byte)
                   Byte_Byte P1, Color                             
                 #endif
                 #if (Prm_1 == Num8)
                   Num_Byte P1, Color
                 #endif
                 GoSub putPixel_SUB
                 Endm             
    putPixel_SUB:
                 If xx > (DisplayWidth - 1) Then Return
                 If yy > (DisplayHeight - 1) Then Return  
                 memByteRow = yy / 8
                 memByteBit = yy // 8
                 memByteNr  = memByteRow * 128 + xx 
    putPixel_SUBa:
                 memByteTemp = GetElement memByte, memByteNr
                 If Color = 1 Then
                    If _GLCD_FLAG.0 = 1 Then                        ; if INVERTED 
                        LoadBit  memByteTemp, memByteBit, 0
                    Else
                        LoadBit  memByteTemp, memByteBit, 1
                    EndIf        
                 Else                                               ; if color = 0
                    If _GLCD_FLAG.1 = 1 Then 
                        Return                                      ; if XOR  and color 0 then do not draw the blanc pixels
                    Else
                        If _GLCD_FLAG.0 = 1 Then                    ; if INVERTED 
                            LoadBit  memByteTemp, memByteBit, 1
                        Else
                            LoadBit  memByteTemp, memByteBit, 0
                        EndIf
                    EndIf     
                 EndIf             
                 PutElement memByte, memByteNr, memByteTemp
                 Return
    ;==============================================================================
    drawPixel    Macro        P1, P2, P3     ; x,y, pixelcolor ... 1 or 0
                #if (Prm_1 == Byte)
                  Byte_Byte P1, ppx
                #endif
                #if (Prm_1 == Num8)
                  Num_Byte P1, ppx
                #endif
                #if (Prm_2 == Byte)
                  Byte_Byte P2, ppy
                #endif
                #if (Prm_2 == Num8) 
                  Num_Byte P2, ppy
                #endif            
                #if (Prm_3 == Byte)
                   Byte_Byte P3, Color        ; pixelcolor
                 #endif
                 #if (Prm_3 == Num8) 
                   Num_Byte P3, Color
                 #endif
                 GoSub drawPixel_SUB
                 Endm  
    drawPixel_SUB:
                 If ppx > (DisplayWidth - 1) Then Return
                 If ppy > (DisplayHeight - 1) Then Return 
                 memByteRow = ppy / 8
                 memByteBit = ppy // 8
                 memByteNr  = memByteRow * 128 + ppx
                 GoSub putPixel_SUBa
                 Return
    ;==================================================================================
    NOKIA_CURSOR Macro P1, P2                           ; P2 = X ( 0 to 83)  and  P1 = Y ( 0 to 47 )
                 #if (Prm_1 == Byte)
                   Byte_Byte P1, glcd_Cursor_X
                 #endif
                 #if (Prm_1 == Num8) 
                   Num_Byte P1, glcd_Cursor_X
                 #endif
                 #if (Prm_2 == Byte)
                   Byte_Byte P2, glcd_Cursor_Y
                  #endif
                 #if (Prm_2 == Num8) 
                   Num_Byte P2, glcd_Cursor_Y
                 #endif
                 GoSub SSD1306_CURSOR_SUB       
                 Endm
    
    
    SSD1306_CURSOR_SUB:                                 
    
    
    GoSub SSD1306_command [$21]
    GoSub SSD1306_command [glcd_Cursor_X]
    GoSub SSD1306_command [127]
    GoSub SSD1306_command[$22]
    GoSub SSD1306_command[glcd_Cursor_Y]
    GoSub SSD1306_command [7]
    Return  
               
    ;==============================================================================
    NOKIA_INIT Macro
               GoSub NOKIA_INI       ; LCD INITIALISATION SEQUENCE
               Endm
    NOKIA_INI:   ;
    
    
    DelayMS 500
    
    
    HBStart 'Send a Start condition to the I2C bus
    HBusOut SSD1306 'Slave Adress 
    
    
    HBusOut 0x80 ;
    HBusOut 0xae ;//--turn off oled panel
     
    HBusOut 0x80 ;
    HBusOut 0xd5 ;//--set display clock divide ratio/oscillator frequency
    HBusOut 0x80 ;
    'HBusOut 0x80 ;//--set divide ratio
    HBusOut 0xF0 ;//--set divide ratio
    
    
    HBusOut 0x80 ;
    HBusOut 0xa8 ;//--set multiplex ratio 1 to 64 
    HBusOut 0x80 ;
    HBusOut 0x3f ;//--1/64 duty
    HBusOut 0x80 ;
    HBusOut 0xd3 ;//-set display offset
    HBusOut 0x80 ;
    HBusOut 0x00 ;//-not offset
    HBusOut 0x80 ;
    HBusOut 0x8d ;//--set Charge Pump enable/disable
    HBusOut 0x80 ;
    HBusOut 0x14 ;//--set 0x10 disable
    HBusOut 0x80 ;
    HBusOut 0x40 ;//--set start line address
    HBusOut 0x80 ;
    HBusOut 0xa6 ;//--set normal display
    HBusOut 0x80 ;
    HBusOut 0xa4 ;//Disable Entire Display On
    HBusOut 0x80 ;
    HBusOut 0xa1 ;//--set segment re-map 128 to 0
    HBusOut 0x80 ;
    HBusOut 0xC8 ;//--Set COM Output Scan Direction 64 to 0
    HBusOut 0x80 ;
    HBusOut 0xda ;//--set com pins hardware configuration
    HBusOut 0x80 ;
    HBusOut 0x12 ;
    HBusOut 0x80 ;
    HBusOut 0x81 ;//--set contrast control register
    HBusOut 0x80 ;
    '--------------------------------------
    HBusOut 0xFF ;  'THIS IS CONTRAST VALUE  ****was 8F
    '--------------------------------------
    HBusOut 0x80 ;
    HBusOut 0xd9 ;//--set pre-charge period
    HBusOut 0x80 ;
    HBusOut 0xf1 ;
    HBusOut 0x80 ;
    HBusOut 0xdb ;//--set vcomh
    HBusOut 0x80 ;
    HBusOut 0x40 ;
    HBusOut 0x80 ;
    HBusOut 0xaf ;//--turn on oled panel
    HBStop
               Return
    ;==============================================================================
    setContrast Macro P1            ; P1 as contrast VAL or byte
                #if (Prm_1 == Byte)
                    Byte_Byte P1, CONTRAST
                #endif
                #if (Prm_1 == Num8) 
                    Num_Byte P1, CONTRAST
                #endif
                GoSub setcontrast_SUB
                Endm    
    setcontrast_SUB:            
    '            Low Nokia_DC
    '            writeSPI $21 :  writeSPI $00
    '            CONTRAST = $80 | CONTRAST  
    '            writeSPI CONTRAST :  writeSPI $00        ; <<----------- CONTRAST
    '            writeSPI $20 :  writeSPI $00
    '            High Nokia_DC
                Return     
    ;==============================================================================
    NOKIA_CLS  Macro
               GoSub NOKIA_CLS_SUB          ; CLEAR SCREEN MACRO
               Endm
    NOKIA_CLS_SUB:                          ' CLEAR SCREEN 
    
    
               Return
    ;==============================================================================
    refreshMem  Macro  P1                   ; x offset in pixels to scroll horizontally. equals zero to print standard full screen
                #if (Prm_1 == Byte)
                   Byte_Byte P1, glcdOffset
                #endif
                #if (Prm_1 == Num8) 
                   Num_Byte P1, glcdOffset
                #endif
                GoSub refreshMEM_SUB
                Endm           
    refreshMEM_SUB:
    y = 0
    x = 0
    
    
    GoSub GOTOXY
    
    
    'I tried to use single hbus out commands in order to send out 
    'the display address just one time instead of everytime as 
    'is at the moment. The display is being written to BUT is 
    'scrambled, need to investigte further as this will save
    '1 byte of unneccassary data transfer on each loop itteration
    'and speed things up even more.
    
    
    'HBStart                               'Start of single bus commands
    'HBusOut SSD1306                       'Send out address
    
    
    'Peplaced the old for next loop
    'with a while wend as it's faster
    Repeat  
        Repeat
            WORD_TEMP=y*128 + x
            memByteTemp = GetElement memByte, WORD_TEMP  
    
    
            'GoSub GOTOXY 
            GoSub SSD1306_data [memByteTemp]
            
            Inc x
        Until x > 127
        x = 0
        Inc y
    Until y > 7
    
    
    'HBStop                                 'End of single bus commands
    
    
    Return
    
    
    '--------------------------------------------------- 
    'This only needs to be done before the memory transfer
    'is carried out. Befor this was done on each 1024 itterations
    'of thew above loop costing around and extra 19,000 hbusout 
    'commands and speeded thing up by around 10+ fold.           
    GOTOXY:
    GoSub SSD1306_command [$20]         'Horizontal address increment command
    GoSub SSD1306_command [$0]          'and set the mode
    
    
    GoSub SSD1306_command [$21]         'Column adrees command
    GoSub SSD1306_command  [x]          'Set to min colums          
    GoSub SSD1306_command  [127]        'set to max columns
    
    
    GoSub SSD1306_command  [$22]        'Row address command
    GoSub SSD1306_command  [y]          'Set to min rows
    GoSub SSD1306_command  [7]          'Set to max rows      
    Return
    ;==============================================================================
    Clear_Mem  Macro
                GoSub CLS_MEM_SUB
                Endm
    CLS_MEM_SUB:
                WORD_TEMP = 0
                Repeat
                    PutElement memByte, WORD_TEMP, 0
                    Inc WORD_TEMP
                Until WORD_TEMP = 1024
    
    
                Return            
    ;==============================================================================
    SelectFont      Macro   P1                                         ;   P1 as selected font label name
                        #if (Prm_1 == Label)
                          label_word P1, FONT_NAME
                        #endif
                        GoSub glcdSelectFont_SUB
                        Endm
    glcdSelectFont_SUB:
                        glcd_FontSize       = CRead  glcd_FontData + 0 ; font_Size_in_Bytes_over_all_included_Size_it_self;
                        glcd_FontWidth      = CRead  glcd_FontData + 2 ; font_Width_in_Pixel_for_fixed_drawing
                        glcd_FontHeight     = CRead  glcd_FontData + 3 ; font_Height_in_Pixel_for_all_Characters
                        glcd_FontBitsPixel  = CRead  glcd_FontData + 4 ; font_Bits_per_Pixels // if MSB are set then font is a compressed font
                        glcd_FontFirstChar  = CRead  glcd_FontData + 5 ; font_First_Char
                        glcd_FontLastChar   = CRead  glcd_FontData + 6 ; font_Last_Char
                        Return                    
    ;==============================================================================
    $ifdef use_AutoLineFeed
    glcdNewLine         Macro                                           ; <CR><LF> in glcd_Window of glcd_Cursor
                        GoSub glcdNewLine_SUB
                        Endm
    glcdNewLine_SUB:
                        glcd_Cursor_X = glcd_Window_x1;
                        glcd_Cursor_Y = glcd_Cursor_Y  + glcd_FontHeight;
                        If glcd_Cursor_Y + glcd_FontHeight > glcd_Window_y2 Then
                            glcd_Cursor_Y = glcd_Window_y1;
                        EndIf
                        Return
    $endif                    
    ;==============================================================================
    SSD1306_PRINT_SUB:                            ;- 
        If WREG = 0 Then                        ; 
           _charToPrint = _charToPrint
        Else
           _charToPrint = WREG
        EndIf
        ;   
        PP0_temp = PP0
        PP0h_temp = PP0h
        PP0hh_temp = PP0hh
        PP0hhh_temp = PP0hhh
        PP2_temp = PP2
        PP2h_temp = PP2h
        PP2hh_temp = PP2hh
        PP2hhh_temp = PP2hhh
        PP7_temp = PP7
        PP7h_temp = PP7h
        PP7hh_temp = PP7hh
        PP7hhh_temp = PP7hhh
      ; is the character defined in the font and a font selected?
        If _charToPrint < glcd_FontFirstChar Or _charToPrint > glcd_FontLastChar Or glcd_FontSize = 0 Then
            Return;
        EndIf
      ; is the character in the font declared but not defined?
        charwidth = CRead glcd_FontData + FONT_HEADER_SIZE + _charToPrint - glcd_FontFirstChar;
        If charwidth = 0 Then 
            Return;
        EndIf
      ; all characters have at right, a small implicit empty column
        width = charwidth;
        If _charToPrint < 128 Then 
           Inc width ; 
        EndIf
      ; if we are to draw the font with fixed width then set the width accordingly
        If glcd_Flagsbits.FixedFont = 1 And width <= glcd_FontWidth Then 
            width = glcd_FontWidth;
        EndIf
      ; adjusts the drawn characters in the character window adding a linefeed
        If glcd_Flagsbits.AutoLineFeed = 1 And (glcd_Cursor_X + width) >= glcd_Window_x2 Then
            glcdNewLine
        EndIf
      ; is the character positioned inside the visible area ?
        If glcd_Cursor_X > glcd_Clip_x2 Or glcd_Cursor_Y > glcd_Clip_y2 Then 
            Return
        EndIf
        ; ABSOLUTE CURSOR POSITION
        xx = glcd_Cursor_X;  make a copy of actual cursor position
        yy = glcd_Cursor_Y;
        glcd_Cursor_X = glcd_Cursor_X + width;    Prepare next x coord for the next char on line
        ; make copies for the cursor coordinates
        glcd_Cursor_X_temp = glcd_Cursor_X
        glcd_Cursor_Y_temp = glcd_Cursor_Y
      ; is the character positioned inside the visible area ?
        If xx > glcd_Clip_x2 Or (yy + glcd_FontHeight) < glcd_Clip_y1 Then
            Return;
        EndIf
        _i = 0   ;
      ; If FixedFont must be centered within the characters glcd_FontWidth, but only
      ; if the sign is smaller than glcd_FontWidth. We will also fill the same right
      ; and left edges of the character, again only if the background color is not transparent.
        If glcd_Flagsbits.FixedFont = 1 And width > charwidth Then 
            _i = (width - charwidth) / 2;        
            xx = xx + _i;
        EndIf
        _i = width - charwidth - _i;
      ;  the actual character can be drawn?
        If xx > glcd_Clip_x2 Or (xx + charwidth) < glcd_Clip_x1 Then
            Return 
        EndIf
      ;    
        bitspixel = glcd_FontBitsPixel & $7F;             ; Bits per Pixel   asta ar trebui sa fie 1
        bitsmask = $FF >> (8 - bitspixel);                ; Bitmask for color
                                                          ; Bitmask = 1 daca avem 1 bit per pixel
       ; ALL reads in the font memory are structured so that they all blocks
       ; Bytes carried out sequentially. This is important and very well optimized for example. I2C EEPROM.
        If glcd_FontBitsPixel.7 = 1 Then 
            ; COMPRESSED FONTS
            ; Get the length of the RLE BytePadding table and calculate the Byteindex to the data.
            ; This reading has an additional overhead of 4 bytes for compressed fonts.
            ; For compressed fonts no left clipping can be done: (
            intermed_index = glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index + glcd_FontLastChar - glcd_FontFirstChar
            intermed_index = intermed_index + 1
            padding  = CRead intermed_index  
            Inc intermed_index    
            table[0] = 1 
            table[1] = CRead intermed_index  
            Inc intermed_index
            table[2] = CRead intermed_index  
            Inc intermed_index
            table[3] = CRead intermed_index  
            Inc intermed_index
            index = 0 
            _i = glcd_FontFirstChar
            While _i < _charToPrint
                index_byte = CRead intermed_index 
                index = index + index_byte
                Inc intermed_index
                Inc _i
            Wend
            index = index * padding;
            intermed_index = glcd_FontLastChar - glcd_FontFirstChar + 3
            intermed_index = intermed_index  * 2
            intermed_index = intermed_index  +  glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index  + index
            bits = CRead intermed_index  
            bitscount = 8 
        Else 
        ; UNCOMPRESSED FONTS
        ; now calculate the bit index to the bit data in the font
            intermed_index = glcd_FontData + FONT_HEADER_SIZE 
            index = 0 
            _i = glcd_FontFirstChar
            While _i < _charToPrint
                 index_byte = CRead intermed_index        ; here we read the char width ????
                 index = index + index_byte
                 Inc intermed_index
                 Inc _i
            Wend
            ; Left clipping into account, only possible with uncompressed fonts
            If xx < glcd_Clip_x1 Then 
                _t = glcd_Clip_x1 - xx   
                index = index + _t 
                charwidth = charwidth - _t;
                xx = glcd_Clip_x1 
            EndIf
            index = index * glcd_FontHeight *  bitspixel 
        ; would position the data's first byte font files with a sign and get the first bits
            bitscount = index // 8  
            index = index / 8
            intermed_index = glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index + glcd_FontLastChar - glcd_FontFirstChar
            intermed_index = intermed_index  + 1 + index  
            bits = CRead intermed_index                     ; here we read the first bits of font data to display ;  
            bits = bits >> bitscount 
            bitscount = 8 - bitscount 
        EndIf
      ; we send the bit data of each pixel in the yy direction of each Column
        pixelcount = 0                                  ; Number of pixels to be set    
        pixelcolor = 0                                  ; to be set pixel color 
        clipinvalid = 1                                 ; Validity of the address pointers on the GLCD
        clipY = 0                                   
        stopY = glcd_Cursor_Y + glcd_FontHeight -1      ; lowest pixel line of the character
        stopX = xx + charwidth -1 
      ; right clipping account
        If stopX > glcd_Clip_x2 Then 
            stopX = glcd_Clip_x2 
        EndIf
        xx = xx
        Repeat
            If clipY = clipY | glcd_Cursor_Y Then 
                clipinvalid = 1;
            EndIf
            yy = glcd_Cursor_Y
            Repeat
                    If pixelcount = 0 Then 
                        If bitscount <= 8 Then 
                            Inc intermed_index
                            bits_tWord = CRead intermed_index       ; read a byte
                            bits = bits | (bits_tWord << bitscount)
                            bitscount = bitscount + 8 
                        EndIf
                        If glcd_FontBitsPixel.7 = 1 Then            ; if the character font is compressed 
                            pixelcount = table[bits & 3] 
                            bits = bits >> 2 
                            bitscount = bitscount -2 
                        Else 
                            Inc pixelcount 
                        EndIf
                        If bitspixel <= 3 Then 
                            pixelcolor = bits & bitsmask;  
                            If pixelcolor > 1 Then   ; color correction if more bits per pixel than necessary
                                pixelcolor = 1
                            EndIf
                        EndIf
                        bits = bits >> bitspixel;
                        bitscount = bitscount - bitspixel;
                    EndIf
                    Dec pixelcount  
                    If  yy >= glcd_Clip_y1 And yy <= glcd_Clip_y2 And xx >= glcd_Clip_x1 Then  
                        If clipinvalid = 1 Then 
                            clipY = yy 
                            clipinvalid = 0 
                        EndIf
                        putPixel pixelcolor  
                    Else 
                        clipinvalid = 1 
                    EndIf
            Inc yy
            Until yy = stopY + 1
        
        Inc xx
        Until xx = stopX + 1
        ;
        PP0 = PP0_temp
        PP0h = PP0h_temp
        PP0hh = PP0hh_temp
        PP0hhh = PP0hhh_temp
        PP2 = PP2_temp
        PP2h = PP2h_temp
        PP2hh = PP2hh_temp
        PP2hhh = PP2hhh_temp
        PP7 = PP7_temp
        PP7h = PP7h_temp
        PP7hh = PP7hh_temp
        PP7hhh = PP7hhh_temp
        NOKIA_CURSOR glcd_Cursor_X_temp , glcd_Cursor_Y_temp   ; reposition the cursor for the next char
        Return 
    ;==============================================================================
    $ifdef use_drawLine
    drawLine    Macro P1, P2, P3, P4, P5 ;  x0, y0, x1, y1, color
                #if (Prm_1 == Byte)
                  Byte_Byte P1, x0
                #endif
                #if (Prm_1 == Num8)  
                  Num_Byte P1, x0
                #endif
                #if (Prm_2 == Byte)
                  Byte_Byte P2, y0
                #endif
                #if (Prm_2 == Num8)  
                  Num_Byte P2, y0
                #endif
                #if (Prm_3 == Byte)
                  Byte_Byte P3, x1
                #endif
                #if (Prm_3 == Num8) 
                  Num_Byte P3, x1
                #endif
                #if (Prm_4 == Byte)
                  Byte_Byte P4, y1
                #endif
                #if (Prm_4 == Num8) 
                  Num_Byte P4, y1
                #endif
                #if (Prm_5 == Byte)
                  Byte_Byte P5, pen
                #endif
                #if (Prm_5 == Num8)  
                  Num_Byte P5, pen
                #endif
                GoSub drawLine_SUB
                Endm            
    drawLine_SUB:
                ;left to right only
                If x0 > x1 Then
                    Swap x1, x0
                EndIf
                If y0 > y1 Then
                    Swap y1, y0
                EndIf
                ;
                If x0 = x1 And y0 = y1 Then
                    drawPixel x0, y0, pen
                    Return
                EndIf
                ; if vertical line
                If x0 = x1 Then
                    y0t = y0
                    Repeat
                        drawPixel x0, y0t, pen
                        Inc y0t
                    Until y0t =  y1 + 1
                    ;
                EndIf    
                ; calculate direction
                dx = x1 - x0
                dy = y1 - y0
                If dx < 0 Then
                  dx = Abs dx
                  stepx = -1
                Else 
                  stepx = 1 
                EndIf
                If dy < 0  Then
                  dy = Abs dy 
                  stepy = -1   
                Else   
                  stepy = 1 
                EndIf
                dx2 = dx << 1
                dy2 = dy << 1
                drawPixel x0, y0, pen
                If dx > dy Then
                      err = dy2 - dx
                      While x0 <> x1 
                             If err >= 0 Then
                              y0  = y0 + stepy
                              err = err - dx2
                             EndIf
                             x0  = x0 + stepx
                             err = err + dy2
                             drawPixel x0, y0, pen
                      Wend
                Else
                      err = dx2 - dy
                      While yy <> y1 
                             If err >= 0 Then
                              x0  = x0 + stepx
                              err = err - dy2
                             EndIf
                             yy = yy + stepy
                             err = err + dx2
                             drawPixel x0, y0, pen
                      Wend
                EndIf
                Return
    $endif
    ;==============================================================================
    $ifdef use_fillRectangle
    fillRectangle    Macro   P1, P2, P3, P4, P5
                #if (Prm_1 == Byte)
                  Byte_Byte P1, xr0
                #endif
                #if (Prm_1 == Num8)  
                  Num_Byte P1, xr0
                #endif
                #if (Prm_2 == Byte)
                  Byte_Byte P2, yr0
                #endif
                #if (Prm_2 == Num8)  
                  Num_Byte P2, yr0
                #endif
                #if (Prm_3 == Byte)
                  Byte_Byte P3, xr1
                #endif
                #if (Prm_3 == Num8)  
                  Num_Byte P3, xr1
                #endif
                #if (Prm_4 == Byte)
                  Byte_Byte P4, yr1
                #endif
                #if (Prm_4 == Num8)   
                  Num_Byte P4, yr1
                #endif
                #if (Prm_5 == Byte)
                  Byte_Byte P5, Color
                #endif
                #if (Prm_5 == Num8)   
                  Num_Byte P5, Color
                #endif
                GoSub fillRectangle_SUB
                Endm
    fillRectangle_SUB:
                ;left to right only
                If xr0 > xr1 Then
                    Swap xr1, xr0
                EndIf
                If yr0 > yr1 Then
                    Swap yr1, yr0
                EndIf
                yr0 = yr0
                Repeat
                    drawLine xr0, yr0, xr1, yr0, Color
                Inc yr0
                Until yr0 = yr1
                Return 
    $endif
    ';==============================================================================
    $ifdef use_drawRectangle
     drawRectangle   Macro   P1, P2, P3, P4, P5
                #if (Prm_1 == Byte)
                  Byte_Byte P1, xfr0
                #endif
                #if (Prm_1 == Num8) 
                  Num_Byte P1, xfr0
                #endif
                #if (Prm_2 == Byte)
                  Byte_Byte P2, yfr0
                #endif
                #if (Prm_2 == Num8)  
                  Num_Byte P2, yfr0
                #endif
                #if (Prm_3 == Byte)
                  Byte_Byte P3, xfr1
                #endif
                #if (Prm_3 == Num8)  
                  Num_Byte P3, xfr1
                #endif
                #if (Prm_4 == Byte)
                  Byte_Byte P4, yfr1
                #endif
                #if (Prm_4 == Num8)  
                  Num_Byte P4, yfr1
                #endif
                #if (Prm_5 == Byte)
                  Byte_Byte P5, Color
                #endif
                #if (Prm_5 == Num8)  
                  Num_Byte P5, Color
                #endif
                GoSub drawRectangle_SUB
                Endm
    drawRectangle_SUB:            
                drawLine xfr0, yfr0 , xfr1, yfr0 , Color
                drawLine xfr0, yfr1 , xfr1, yfr1 , Color
                drawLine xfr0, yfr0 , xfr0, yfr1 , Color
                drawLine xfr1, yfr0 , xfr1, yfr1 , Color
                Return;
    $endif
    ';==============================================================================       
    $ifdef use_drawCircle
    drawCircle  Macro   p1, p2, p3, p4          ; X0, Y0, RADIUS, color
                        #if (Prm_1 == Byte)
                          Byte_Byte P1, x0
                        #endif
                        #if (Prm_1 == Num8) 
                          Num_Byte P1, x0
                        #endif
                        #if (Prm_2 == Byte)
                          Byte_Byte P2, y0
                        #endif
                        #if (Prm_2 == Num8)  
                          Num_Byte P2, y0
                        #endif
                        #if (Prm_3 == Byte)
                          Byte_Byte P3, radius
                        #endif
                        #if (Prm_3 == Num8)  
                          Num_Byte P3, radius
                        #endif
                        #if (Prm_4 == Byte)
                          Byte_Byte P4, Color
                        #endif
                        #if (Prm_4 == Num8)  
                          Num_Byte P4, Color
                        #endif
                        GoSub drawCircle_SUB
                        Endm
     drawCircle_SUB:
                        err = - radius
                        _X   = radius
                        _Y   = 0
                        While _X >= _Y 
                            parL = x0 + _X
                            parR = y0 + _Y
                            drawPixel parL , parR, Color 
                            parL = x0 - _X
                            parR = y0 + _Y
                            drawPixel parL , parR, Color 
                            parL = x0 + _X
                            parR = y0 - _Y
                            drawPixel parL , parR, Color 
                            parL = x0 - _X
                            parR = y0 - _Y
                            drawPixel parL , parR, Color 
                            parL = x0 + _Y
                            parR = y0 + _X
                            drawPixel parL , parR, Color 
                            parL = x0 - _Y
                            parR = y0 + _X
                            drawPixel parL , parR, Color 
                            parL = x0 + _Y
                            parR = y0 - _X
                            drawPixel parL , parR, Color 
                            parL = x0 - _Y
                            parR = y0 - _X
                            drawPixel parL , parR, Color 
                            err = err + _Y
                            _Y = _Y + 1
                            err = err + _Y;
                            If err >= 0 Then
                              _X = _X - 1
                              err = err - _X
                              err = err - _X
                            EndIf
                        Wend
                        Return;
    $endif                    
    ';==============================================================================
    $ifdef use_fillCircle
    fillCircle  Macro   P1, P2, P3, P4 ;  x0, y0, radius, color
                        #if (Prm_1 == Byte)
                          Byte_Byte P1, x0Fill
                        #endif
                        #if (Prm_1 == Num8)  
                          Num_Byte P1, x0Fill
                        #endif
                        #if (Prm_2 == Byte)
                          Byte_Byte P2, y0Fill
                        #endif
                        #if (Prm_2 == Num8)  
                          Num_Byte P2, y0Fill
                        #endif
                        #if (Prm_3 == Byte)
                          Byte_Byte P3, radius
                        #endif
                        #if (Prm_3 == Num8)  
                          Num_Byte P3, radius
                        #endif
                        #if (Prm_4 == Byte)
                          Byte_Byte P4, Color
                        #endif
                        #if (Prm_4 == Num8)   
                          Num_Byte P4, Color
                        #endif
                        GoSub fillCircle_SUB
                        Endm
    fillCircle_SUB:                     
                        errFill  = - radius;
                        glcd_cursor_xm   = radius;
                        glcd_cursor_ym   = 0;         
                        While glcd_cursor_xm >= glcd_cursor_ym 
                            _P1 = x0Fill - glcd_cursor_xm
                            _P2 = y0Fill + glcd_cursor_ym
                            _P3 = x0Fill + glcd_cursor_xm
                            _P4 = y0Fill + glcd_cursor_ym
                            drawLine _P1, _P2, _P3, _P4, Color;
                            _P1 = x0Fill - glcd_cursor_xm
                            _P2 = y0Fill - glcd_cursor_ym
                            _P3 = x0Fill + glcd_cursor_xm
                            _P4 = y0Fill - glcd_cursor_ym
                            drawLine _P1, _P2, _P3, _P4, Color
                            _P1 = x0Fill - glcd_cursor_ym
                            _P2 = y0Fill + glcd_cursor_xm
                            _P3 = x0Fill + glcd_cursor_ym
                            _P4 = y0Fill + glcd_cursor_xm
                            drawLine _P1, _P2, _P3, _P4, Color
                            _P1 = x0Fill - glcd_cursor_ym
                            _P2 = y0Fill - glcd_cursor_xm
                            _P3 = x0Fill + glcd_cursor_ym
                            _P4 = y0Fill - glcd_cursor_xm
                            drawLine _P1, _P2, _P3, _P4, Color
                            ;
                            errFill = errFill + glcd_cursor_ym;
                            glcd_cursor_ym = glcd_cursor_ym + 1;
                            errFill = errFill + glcd_cursor_ym;
                            If errFill >= 0 Then
                              glcd_cursor_xm =  glcd_cursor_xm - 1
                              errFill = errFill - glcd_cursor_xm;
                              errFill = errFill - glcd_cursor_xm;
                            EndIf
                        Wend
                        Return;
    $endif
    
    
    Display_INIT Macro
        GoSub DISPLAY_INIT_SUB
        Endm
    
    
    DISPLAY_INIT_SUB:               
        Clear
    
    
        NOKIA_INIT                          ; INIT NOKIA LCD
        ;
        DelayMS 200
        ;                                   ; initial clip & window set
        glcd_Flagsbits.AutoLineFeed = 0     ; auto-feedline enabled or not
        glcd_Flagsbits.FixedFont = 0
        glcd_Flagsbits.Clipping = 0
        ;
        glcd_Clip_x1 = 0                    ; 
        glcd_Clip_x2 = DisplayWidth - 1 
        glcd_Clip_y1 = 0
        glcd_Clip_y2 = DisplayHeight - 1 
        ;
        glcd_Window_x1 = 0
        glcd_Window_x2 = DisplayWidth - 1
        glcd_Window_y1 = 0
        glcd_Window_y2 = DisplayHeight - 1
        ;
        Return
    ;******************************************************************************
    
    
    
    
    OVER_MACROS:

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #37
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: Help With OLED Display / 128X64 SSD1306

    note in the variable decs......

    'I needed to moved close to end of ram as
    'im using a PIC18F24J50 and the compiler only
    'see's the first 1K RAM because of USB buffer.
    Dim memByte[1024] As Byte At $AAC

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #38
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    Got more speed out of the RAM transfer to the display by issuing the display address only once, saves another 1024 bytes from being sent over I2C.

    Code:
    All_Digital=On
    
    
         TRISA=%11111110
         TRISB=%11111111
         TRISC=%11000111
    
    
    All_Digital = true
    Dim dta As Byte
    Dim XXX As Byte
    Dim YYY As Byte 
    Dim III As Byte
    Dim loop As Word
    
    
    Declare LCD_Type = Graphic                  ; use this declaration as code make use of compiler's hijacked PRINT command
    ;
    ;=====================   O P T I O N S   =============================== 
    $define use_drawLine                        ; user code make use of drawLine graphic function. Comment If Not needed
    $define use_drawRectangle                   ; user code make use of drawRectangle graphic function. Comment If Not needed
    $define use_drawCircle                      ; user code make use of drawCircle graphic function. Comment If Not needed
    $define use_fillRectangle                   ; user code make use of fillRectangle graphic function. Comment If Not needed
    $define use_fillCircle                      ; user code make use of fillCircle graphic function. Comment if not needed 
    $define use_AutoLineFeed                    ; enable this function if AutoLineFeed needed in user code 
    ;============================
    ;    Fonts to be used
    ;============================
    $define use_Font_f8x8                       ; will use the font stored in file "f8x8.inc"
    ;$define use_Font_clock24x49                 ; will use the Font stored in file "Clock24x49.inc"
    $define use_Font_f13x16                     ; will use the Font stored in file "f13x16.inc" 
    $define use_Font_f8x11                      ; will use the Font stored in file "f8x11.inc"
    $define use_Font_f12x12                     ; will use the Font stored in file "f12x12.inc"  
    ;$define use_Font_f9x14                      ; will use the Font stored in file "f9x14.inc"
    $define use_Font_decode6x5                  ; will use the Font stored in file "decode6x5.inc"
    $define use_Font_arrows15x18                ; will use the Font stored in file "arrows15x18.inc"  
    ; 
    ;==============================================================================
    Symbol DisplayWidth     128
    Symbol DisplayHeight    64
    
    
    Symbol SSD1306 = $78
    
    
    
    
    ;==============================================================================
    ;         NOKIA DRIVER DECLARES  
    ;==============================================================================
    Dim COMMAND_BYTE As Byte System                 ' USED TO SEND A COMMAND TO NOKIA 3310 LCD
    Dim glcd_Cursor_Y As Byte System                ' HOLDS THE VALUE FOR Y ROWS
    Dim glcd_Cursor_X As Byte System                ' HOLDS THE VALUE FOR X COLS
    Dim WORD_TEMP As Word                           ' DUMMY VAR
    'Dim SPP_Resp_Nokia As Byte
    Dim _charToPrint As Byte
    Dim CONTRAST As Byte
    ;----------------
    Dim GEN As Byte System                          ; used with #disable PRINT
    Dim _GLCD_FONT As Byte System 
    Dim PRINTING_FONT As Word System
    Dim _GLCD_FLAG As Byte System
    Dim PP0 As Byte System
    Dim PP0_temp As Byte
    Dim PP0h As Byte System
    Dim PP0h_temp As Byte
    Dim PP0hh As Byte System
    Dim PP0hh_temp As Byte
    Dim PP0hhh As Byte System
    Dim PP0hhh_temp As Byte
    Dim PP2 As Byte System
    Dim PP2_temp As Byte
    Dim PP2h As Byte System
    Dim PP2h_temp As Byte
    Dim PP2hh As Byte System
    Dim PP2hh_temp As Byte
    Dim PP2hhh As Byte System
    Dim PP2hhh_temp As Byte
    Dim PP7 As Byte System
    Dim PP7_temp As Byte
    Dim PP7h As Byte System
    Dim PP7h_temp As Byte
    Dim PP7hh As Byte System
    Dim PP7hh_temp As Byte
    Dim PP7hhh As Byte System
    Dim PP7hhh_temp As Byte
    ;------------------------------------------------------------------------------
    'I needed to move this array close to end of ram as
    'im using a PIC18F24J50 and the compiler only
    'see's the first 1K RAM because of USB buffer. 
    Dim memByte[1024] As Byte At $AAC  
        
    Dim memByteRow As Byte
    Dim memByteBit As Byte
    Dim memByteNr As Word
    Dim memByteTemp As Byte System
    Dim Element#No As Word
    Dim PValue As Byte
    Dim FSR0 As FSR0L.Word
    ;
    Dim charwidth   As Byte 
    Dim width       As Byte
    Dim _i          As Byte
    Dim bitspixel   As Byte
    Dim bitsmask    As Byte
    Dim bits        As Word;
    Dim bits_tWord  As Byte
    Dim bitscount   As Byte;
    Dim table[4]    As Byte;
    Dim padding     As Byte;
    Dim index       As Dword
    Dim index_byte  As Byte
    Dim pixelcount  As Byte;
    Dim clipinvalid As Byte;
    Dim xx           As Byte            ;     glcdCoord_t xx;
    Dim yy           As Byte            ;     glcdCoord_t yy;
    Dim ppx As Byte
    Dim ppy As Byte
    Dim pixelcolor  As Byte             ; color    
    Dim clipY       As Byte             ; glcdCoord_t type 
    Dim stopY       As Byte;
    Dim stopX       As Byte;
    Dim Color As Byte
    ;
    Dim glcd_FontFirstChar  As Byte     ; first defined character in selected font
    Dim glcd_FontLastChar   As Byte     ; last defined character in selected font
    Dim glcd_FontWidth      As Byte     ; character width for fixed pitch of selected font
    Dim glcd_FontHeight     As Byte     ; character height of selected font
    Dim glcd_FontBitsPixel  As Byte     ; color depth of selected font, if MSB is set the font is compressed
    Dim glcd_FontSize       As Word     ; Font size
    Dim glcd_Clip_x1 As Byte
    Dim glcd_Clip_x2 As Byte
    Dim glcd_Clip_y1 As Byte
    Dim glcd_Clip_y2 As Byte
    Dim glcd_FontData   As  Word            ; STORES OUT THE START OF THE LOOKUP TABLE FOR THIS FONT 
    Dim FONT_NAME       As  glcd_FontData   ; Font Table Address
    ; structure  glcd_Flagsbits
    Dim glcd_Flagsbits As Byte    ; with the following structure bits
    $define AutoLineFeed 0        ; Font routines should use implicit linefeed And wrap around glcd_Window
    $define FixedFont    1        ; == 0 fonts painted proportional, == 1 fonts painted in fixed pitch
    $define Clipping     2        ; activate clipping
    ;
    Dim intermed_index As Word
    $define FONT_HEADER_SIZE 7
    ;
    Dim _t As Byte
    Dim glcd_Window_x1      As Byte
    Dim glcd_Window_x2      As Byte  ;
    Dim glcd_Window_y1      As Byte
    Dim glcd_Window_y2      As Byte
    Dim glcd_Cursor_X_temp As Byte
    Dim glcd_Cursor_Y_temp As Byte
    ;
    ; graphical functions variables
    Dim x0                As Byte    ; used in drawLine , drawCircle
    Dim y0                As Byte    ; used in drawLine , drawCircle
    Dim x1                As Byte    ; used in drawLine , drawCircle
    Dim y1                As Byte    ; used in drawLine , drawCircle
    ;
    Dim dx                As Dword   ; drawLine
    Dim dy                As Dword   ; drawLine
    Dim stepx             As Dword   ; drawLine
    Dim stepy             As Dword   ; drawline
    Dim dx2               As Dword   ; drawline
    Dim dy2               As Dword   ; drawLine
    Dim pen               As Byte    ; drawLine
    Dim y0t               As Byte    ; drawline 
    
    
    ' Changed from DWORD to SDWORD so  drawLine & drawCircle
    ' works with standard PROTON.
    
    
    Dim err               As SDword   ; drawline, drawCircle
    ;
    Dim _X                As Byte    ; drawCircle
    Dim _Y                As Byte    ; drawCircle
    Dim ramIndex          As Word
    Dim radius            As Byte    ; drawCircle, fillCircle
    Dim parL              As Byte    ; drawCircle
    Dim parR              As Byte    ; drawCircle
    
    
    Dim xfr0              As Byte    ; drawCMD rectangle
    Dim xfr1              As Byte    ; drawCMD rectangle
    Dim yfr0              As Byte    ; drawCMD rectangle
    Dim yfr1              As Byte    ; drawCMD rectangle
    ;
    Dim xr0               As Byte    ; fillRectangle
    Dim xr1               As Byte    ; fillRectangle
    Dim yr0               As Byte    ; fillRectangle
    Dim yr1               As Byte    ; fillRectangle
    ;
    
    
    Dim x0Fill            As Byte    ; fillCircle
    Dim y0Fill            As Byte    ; fillCircle
    Dim glcd_cursor_xm    As Byte    ; fillCircle
    Dim glcd_cursor_ym    As Byte    ; fillCircle
    Dim _P1               As Byte    ; fillCircle
    Dim _P2               As Byte    ; fillCircle
    Dim _P3               As Byte    ; fillCircle
    Dim _P4               As Byte    ; fillCircle
    
    
    ' Changed from DWORD to SDWORD so fillCircle works
    ' with standard PROTON
    Dim errFill           As SDword   ; fillCircle
    ;
    Dim glcdOffset        As Byte    ; refreshMEM offset
    Dim rLoopA            As Byte    ; refreshMEM offset
    Dim rLoopB            As Byte    ; refreshMem offset
    Dim c As Byte
    Dim x_low As Byte
    Dim x_high As Byte
    Dim testloop As Byte
    Dim x_temp As Byte
    Dim y_temp As Byte
    
    
    ;==============================================================================
    
    
    
    
    GoTo OVER_MACROS
    ;==============================================================================  
    #Disable GLCD_CLS
    #Disable GLCD_CURSOR
    #Disable GLCD_WRITE
    #Disable GLCD_READ
    #Disable Print                          ; hijacking the compiler's PRINT command
    Asm
    [email protected]
           GoTo NOKIA_CLS_SUB
    [email protected]
           Movwf glcd_Cursor_Y
           Movff GEN,glcd_Cursor_X 
           GoTo SSD1306_CURSOR_SUB
    Print   
        GoTo SSD1306_PRINT_SUB
    EndAsm       
    ;**************** M A C R O S *************************************************
    writeSPI Macro P1                      ' writeSPI Shift-out Shift-in using hardware MSSP
        #if (Prm_1 == Byte)
    		Byte_Byte P1, SSPBUF
    	#endif
    	#if (Prm_1 == Word)
    	    Word_Byte P1, SSPBUF
        #endif
    	#if (Prm_1 == Num8) | (Prm_1 == Num16)
    		Num_Byte P1, SSPBUF
    	#endif
    Endm
    
    
    '=============================================================================
    SSD1306_command:
    Pop c
    HBusOut SSD1306,[0,c]
    Return
    
    
    '------------------------------------------------------------ 
    SSD1306_data:
        Pop c
        HBusOut c 
    Return
    '------------------------------------------------------------ 
    GetElement    Macro  P1, P2             ; Thanks Tim !!!
        #if (Prm_Count > 2)
        	#error "GetElement - Too many parameters"
        #else
        	#if (Prm_Count < 2)
        		#error "GetElement - Too few parameters"
        	#else
        		#if(Prm_1 != Byte_Array_Ptr)
        			#error "GetElement - Array(Param1) Should be a BYTE array pointer"
        		#endif
        		#if(Prm_2 != Word) && (Prm_2 != Num16)
        			#error "GetElement - Element(Param2) Should be a Word variable or number"
        		#endif
        		#if (Prm_1 == Byte_Array_Ptr)
        			Num_FSR0 P1
        		#endif
        		#if (Prm_2 == Word)
        			Word_Word P2, Element#No
        		#endif
        		#if (Prm_2 == Num16)
        			Num_Word P2, Element#No
        		#endif
        		GoSub GetArray_Sub
        	#endif
        #endif
        #if (GetElement_RETURN != 1)
        	#error "GetElement - Mandatory return parameter misssing"
        #else
        	#if(Return_Type != Byte)
        		#error "GetElement - Return variable should be a Byte variable only"
        	#else
        		#if (Return_Type == Byte)
        			Byte_Byte INDF0, Return_Var
        		#endif
        	#endif
        #endif
        Endm
    ;========================================================================
    PutElement  Macro  P1, P2, P3
        #if (Prm_Count > 3)
        	#error "PutElement - Too many parameters"
        #else
        	#if (Prm_Count < 3)
        		#error "PutElement - Too few parameters"
        	#else
        		#if(Prm_1 != Byte_Array_Ptr)
        			#error "PutElement - Array(Param1) Should be a BYTE array only"
        		#endif
        		#if(Prm_2 != Word) && (Prm_2 != Num16)
        			#error "PutElement - Element(Param2) Should be a Word variable or number"
        		#endif
        		#if(Prm_3 != Byte) && (Prm_3 != Num8)
        			#error "PutElement - Value(Param3) Should be a Byte variable or number"
        		#endif
        		#if (Prm_1 == Byte_Array_Ptr)
        			Num_FSR0 P1
        		#endif
        		#if (Prm_2 == Word)
        			Word_Word P2, Element#No
        		#endif
        		#if (Prm_2 == Num16)
        			Num_Word P2, Element#No
        		#endif
        		#if (Prm_3 == Byte)
        			Byte_Byte P3, PValue
        		#endif
        		#if (Prm_3 == Num8)
        			Num_Byte P3, PValue
        		#endif
        		GoSub PutArray_Sub
        	#endif
        #endif
        Endm    
    GetArray_Sub:
       FSR0 = FSR0 + Element#No 
       Return   
    PutArray_Sub:
       FSR0 = FSR0 + Element#No
       INDF0 = PValue
       Return
    ;==============================================================================
    putPixel    Macro        P1                                   ; pixelcolor ... 1 or 0           
                #if (Prm_1 == Byte)
        		   Byte_Byte P1, Color                             
        	     #endif
        	     #if (Prm_1 == Num8)
        		   Num_Byte P1, Color
        	     #endif
                 GoSub putPixel_SUB
                 Endm             
    putPixel_SUB:
                 If xx > (DisplayWidth - 1) Then Return
                 If yy > (DisplayHeight - 1) Then Return  
                 memByteRow = yy / 8
                 memByteBit = yy // 8
                 memByteNr  = memByteRow * 128 + xx 
    putPixel_SUBa:
                 memByteTemp = GetElement memByte, memByteNr
                 If Color = 1 Then
                    If _GLCD_FLAG.0 = 1 Then                        ; if INVERTED 
                        LoadBit  memByteTemp, memByteBit, 0
                    Else
                        LoadBit  memByteTemp, memByteBit, 1
                    EndIf        
                 Else                                               ; if color = 0
                    If _GLCD_FLAG.1 = 1 Then 
                        Return                                      ; if XOR  and color 0 then do not draw the blanc pixels
                    Else
                        If _GLCD_FLAG.0 = 1 Then                    ; if INVERTED 
                            LoadBit  memByteTemp, memByteBit, 1
                        Else
                            LoadBit  memByteTemp, memByteBit, 0
                        EndIf
                    EndIf     
                 EndIf             
                 PutElement memByte, memByteNr, memByteTemp
                 Return
    ;==============================================================================
    drawPixel    Macro        P1, P2, P3     ; x,y, pixelcolor ... 1 or 0
                #if (Prm_1 == Byte)
    		      Byte_Byte P1, ppx
    	        #endif
                #if (Prm_1 == Num8)
    		      Num_Byte P1, ppx
    	        #endif
    	        #if (Prm_2 == Byte)
    		      Byte_Byte P2, ppy
    	        #endif
                #if (Prm_2 == Num8) 
    		      Num_Byte P2, ppy
    	        #endif            
                #if (Prm_3 == Byte)
        		   Byte_Byte P3, Color        ; pixelcolor
        	     #endif
        	     #if (Prm_3 == Num8) 
        		   Num_Byte P3, Color
        	     #endif
                 GoSub drawPixel_SUB
                 Endm  
    drawPixel_SUB:
                 If ppx > (DisplayWidth - 1) Then Return
                 If ppy > (DisplayHeight - 1) Then Return 
                 memByteRow = ppy / 8
                 memByteBit = ppy // 8
                 memByteNr  = memByteRow * 128 + ppx
                 GoSub putPixel_SUBa
                 Return
    ;==================================================================================
    NOKIA_CURSOR Macro P1, P2                           ; P2 = X ( 0 to 83)  and  P1 = Y ( 0 to 47 )
                 #if (Prm_1 == Byte)
        		   Byte_Byte P1, glcd_Cursor_X
        	     #endif
        	     #if (Prm_1 == Num8) 
        		   Num_Byte P1, glcd_Cursor_X
        	     #endif
                 #if (Prm_2 == Byte)
        		   Byte_Byte P2, glcd_Cursor_Y
         	     #endif
        	     #if (Prm_2 == Num8) 
        		   Num_Byte P2, glcd_Cursor_Y
        	     #endif
                 GoSub SSD1306_CURSOR_SUB       
                 Endm
    
    
    SSD1306_CURSOR_SUB:                                 
    
    
    GoSub SSD1306_command [$21]
    GoSub SSD1306_command [glcd_Cursor_X]
    GoSub SSD1306_command [127]
    GoSub SSD1306_command[$22]
    GoSub SSD1306_command[glcd_Cursor_Y]
    GoSub SSD1306_command [7]
    Return  
               
    ;==============================================================================
    NOKIA_INIT Macro
               GoSub NOKIA_INI       ; LCD INITIALISATION SEQUENCE
               Endm
    NOKIA_INI:   ;
    
    
    DelayMS 500
    
    
    HBStart 'Send a Start condition to the I2C bus
    HBusOut SSD1306 'Slave Adress 
    
    
    HBusOut 0x80 ;
    HBusOut 0xae ;//--turn off oled panel
     
    HBusOut 0x80 ;
    HBusOut 0xd5 ;//--set display clock divide ratio/oscillator frequency
    HBusOut 0x80 ;
    'HBusOut 0x80 ;//--set divide ratio
    HBusOut 0xF0 ;//--set divide ratio
    
    
    HBusOut 0x80 ;
    HBusOut 0xa8 ;//--set multiplex ratio 1 to 64 
    HBusOut 0x80 ;
    HBusOut 0x3f ;//--1/64 duty
    HBusOut 0x80 ;
    HBusOut 0xd3 ;//-set display offset
    HBusOut 0x80 ;
    HBusOut 0x00 ;//-not offset
    HBusOut 0x80 ;
    HBusOut 0x8d ;//--set Charge Pump enable/disable
    HBusOut 0x80 ;
    HBusOut 0x14 ;//--set 0x10 disable
    HBusOut 0x80 ;
    HBusOut 0x40 ;//--set start line address
    HBusOut 0x80 ;
    HBusOut 0xa6 ;//--set normal display
    HBusOut 0x80 ;
    HBusOut 0xa4 ;//Disable Entire Display On
    HBusOut 0x80 ;
    HBusOut 0xa1 ;//--set segment re-map 128 to 0
    HBusOut 0x80 ;
    HBusOut 0xC8 ;//--Set COM Output Scan Direction 64 to 0
    HBusOut 0x80 ;
    HBusOut 0xda ;//--set com pins hardware configuration
    HBusOut 0x80 ;
    HBusOut 0x12 ;
    HBusOut 0x80 ;
    HBusOut 0x81 ;//--set contrast control register
    HBusOut 0x80 ;
    '--------------------------------------
    HBusOut 0xFF ;  'THIS IS CONTRAST VALUE  ****was 8F
    '--------------------------------------
    HBusOut 0x80 ;
    HBusOut 0xd9 ;//--set pre-charge period
    HBusOut 0x80 ;
    HBusOut 0xf1 ;
    HBusOut 0x80 ;
    HBusOut 0xdb ;//--set vcomh
    HBusOut 0x80 ;
    HBusOut 0x40 ;
    HBusOut 0x80 ;
    HBusOut 0xaf ;//--turn on oled panel
    HBStop
               Return
    ;==============================================================================
    setContrast Macro P1            ; P1 as contrast VAL or byte
                #if (Prm_1 == Byte)
            		Byte_Byte P1, CONTRAST
            	#endif
            	#if (Prm_1 == Num8) 
            		Num_Byte P1, CONTRAST
            	#endif
            	GoSub setcontrast_SUB
            	Endm	
    setcontrast_SUB:        	
    '        	Low Nokia_DC
    '            writeSPI $21 :  writeSPI $00
    '            CONTRAST = $80 | CONTRAST  
    '            writeSPI CONTRAST :  writeSPI $00        ; <<----------- CONTRAST
    '            writeSPI $20 :  writeSPI $00
    '            High Nokia_DC
            	Return     
    ;==============================================================================
    NOKIA_CLS  Macro
               GoSub NOKIA_CLS_SUB          ; CLEAR SCREEN MACRO
               Endm
    NOKIA_CLS_SUB:                          ' CLEAR SCREEN 
    
    
               Return
    ;==============================================================================
    refreshMem  Macro  P1                   ; x offset in pixels to scroll horizontally. equals zero to print standard full screen
                #if (Prm_1 == Byte)
        		   Byte_Byte P1, glcdOffset
        	    #endif
        	    #if (Prm_1 == Num8) 
        		   Num_Byte P1, glcdOffset
        	    #endif
                GoSub refreshMEM_SUB
                Endm           
    refreshMEM_SUB:
    y = 0
    x = 0
    
    
    'Set up the SSD1306 to recieve
    'the contents of the PIC RAM.
    GoSub GOTOXY
    
    
    'Set SPI for continous display recieve until
    'a stop bus is sent to the display
    HBStart                               'Send BUS start condition
    HBusOut SSD1306                       'Send out address
    HBusOut $40                           'Continous data mode
    
    
    'Transfer the RAM data in PIC
    'to the SSD1306 display, 1024 bytes.
    Repeat  
        Repeat
            WORD_TEMP=y*128 + x
            memByteTemp = GetElement memByte, WORD_TEMP  
    
    
            GoSub SSD1306_data [memByteTemp]  
            
            Inc x
        Until x > 127
        x = 0
        Inc y
    Until y > 7
    
    
    HBStop                                 'End of single bus commands
    
    
    Return
    
    
    '---------------------------------------------------           
    GOTOXY:
    'This only needs to be run before the memory transfer
    'is carried out. Befor this was done on each 1024 itterations
    'of the above loop's costing around and extra 19,000 hbusout 
    'commands and speeded thing up by around 10+ fold. 
    GoSub SSD1306_command [$20]         'Horizontal address increment command
    GoSub SSD1306_command [$0]          'and set the mode
    
    
    GoSub SSD1306_command [$21]         'Column address command
    GoSub SSD1306_command  [x]          'Set to min columns          
    GoSub SSD1306_command  [127]        'set to max columns
    
    
    GoSub SSD1306_command  [$22]        'Row address command
    GoSub SSD1306_command  [y]          'Set to min rows
    GoSub SSD1306_command  [7]          'Set to max rows      
    Return
    ;==============================================================================
    Clear_Mem  Macro
                GoSub CLS_MEM_SUB
                Endm
    CLS_MEM_SUB:
                WORD_TEMP = 0
                Repeat
                    PutElement memByte, WORD_TEMP, 0
                    Inc WORD_TEMP
                Until WORD_TEMP = 1024
    
    
                Return            
    ;==============================================================================
    SelectFont      Macro   P1                                         ;   P1 as selected font label name
                        #if (Prm_1 == Label)
    		              label_word P1, FONT_NAME
    	                #endif
                        GoSub glcdSelectFont_SUB
                        Endm
    glcdSelectFont_SUB:
                        glcd_FontSize       = CRead  glcd_FontData + 0 ; font_Size_in_Bytes_over_all_included_Size_it_self;
                        glcd_FontWidth      = CRead  glcd_FontData + 2 ; font_Width_in_Pixel_for_fixed_drawing
                        glcd_FontHeight     = CRead  glcd_FontData + 3 ; font_Height_in_Pixel_for_all_Characters
                        glcd_FontBitsPixel  = CRead  glcd_FontData + 4 ; font_Bits_per_Pixels // if MSB are set then font is a compressed font
                        glcd_FontFirstChar  = CRead  glcd_FontData + 5 ; font_First_Char
                        glcd_FontLastChar   = CRead  glcd_FontData + 6 ; font_Last_Char
                        Return                    
    ;==============================================================================
    $ifdef use_AutoLineFeed
    glcdNewLine         Macro                                           ; <CR><LF> in glcd_Window of glcd_Cursor
                        GoSub glcdNewLine_SUB
                        Endm
    glcdNewLine_SUB:
                        glcd_Cursor_X = glcd_Window_x1;
                        glcd_Cursor_Y = glcd_Cursor_Y  + glcd_FontHeight;
                        If glcd_Cursor_Y + glcd_FontHeight > glcd_Window_y2 Then
                            glcd_Cursor_Y = glcd_Window_y1;
                        EndIf
                        Return
    $endif                    
    ;==============================================================================
    SSD1306_PRINT_SUB:                            ;- 
        If WREG = 0 Then                        ; 
           _charToPrint = _charToPrint
        Else
           _charToPrint = WREG
        EndIf
        ;   
        PP0_temp = PP0
        PP0h_temp = PP0h
        PP0hh_temp = PP0hh
        PP0hhh_temp = PP0hhh
        PP2_temp = PP2
        PP2h_temp = PP2h
        PP2hh_temp = PP2hh
        PP2hhh_temp = PP2hhh
        PP7_temp = PP7
        PP7h_temp = PP7h
        PP7hh_temp = PP7hh
        PP7hhh_temp = PP7hhh
      ; is the character defined in the font and a font selected?
        If _charToPrint < glcd_FontFirstChar Or _charToPrint > glcd_FontLastChar Or glcd_FontSize = 0 Then
            Return;
        EndIf
      ; is the character in the font declared but not defined?
        charwidth = CRead glcd_FontData + FONT_HEADER_SIZE + _charToPrint - glcd_FontFirstChar;
        If charwidth = 0 Then 
            Return;
        EndIf
      ; all characters have at right, a small implicit empty column
        width = charwidth;
        If _charToPrint < 128 Then 
           Inc width ; 
        EndIf
      ; if we are to draw the font with fixed width then set the width accordingly
        If glcd_Flagsbits.FixedFont = 1 And width <= glcd_FontWidth Then 
            width = glcd_FontWidth;
        EndIf
      ; adjusts the drawn characters in the character window adding a linefeed
        If glcd_Flagsbits.AutoLineFeed = 1 And (glcd_Cursor_X + width) >= glcd_Window_x2 Then
            glcdNewLine
        EndIf
      ; is the character positioned inside the visible area ?
        If glcd_Cursor_X > glcd_Clip_x2 Or glcd_Cursor_Y > glcd_Clip_y2 Then 
            Return
        EndIf
        ; ABSOLUTE CURSOR POSITION
        xx = glcd_Cursor_X;  make a copy of actual cursor position
        yy = glcd_Cursor_Y;
        glcd_Cursor_X = glcd_Cursor_X + width;    Prepare next x coord for the next char on line
        ; make copies for the cursor coordinates
        glcd_Cursor_X_temp = glcd_Cursor_X
        glcd_Cursor_Y_temp = glcd_Cursor_Y
      ; is the character positioned inside the visible area ?
        If xx > glcd_Clip_x2 Or (yy + glcd_FontHeight) < glcd_Clip_y1 Then
            Return;
        EndIf
        _i = 0   ;
      ; If FixedFont must be centered within the characters glcd_FontWidth, but only
      ; if the sign is smaller than glcd_FontWidth. We will also fill the same right
      ; and left edges of the character, again only if the background color is not transparent.
        If glcd_Flagsbits.FixedFont = 1 And width > charwidth Then 
            _i = (width - charwidth) / 2;        
            xx = xx + _i;
        EndIf
        _i = width - charwidth - _i;
      ;  the actual character can be drawn?
        If xx > glcd_Clip_x2 Or (xx + charwidth) < glcd_Clip_x1 Then
            Return 
        EndIf
      ;    
        bitspixel = glcd_FontBitsPixel & $7F;             ; Bits per Pixel   asta ar trebui sa fie 1
        bitsmask = $FF >> (8 - bitspixel);                ; Bitmask for color
                                                          ; Bitmask = 1 daca avem 1 bit per pixel
       ; ALL reads in the font memory are structured so that they all blocks
       ; Bytes carried out sequentially. This is important and very well optimized for example. I2C EEPROM.
        If glcd_FontBitsPixel.7 = 1 Then 
            ; COMPRESSED FONTS
            ; Get the length of the RLE BytePadding table and calculate the Byteindex to the data.
            ; This reading has an additional overhead of 4 bytes for compressed fonts.
            ; For compressed fonts no left clipping can be done: (
            intermed_index = glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index + glcd_FontLastChar - glcd_FontFirstChar
            intermed_index = intermed_index + 1
            padding  = CRead intermed_index  
            Inc intermed_index    
            table[0] = 1 
            table[1] = CRead intermed_index  
            Inc intermed_index
            table[2] = CRead intermed_index  
            Inc intermed_index
            table[3] = CRead intermed_index  
            Inc intermed_index
            index = 0 
            _i = glcd_FontFirstChar
            While _i < _charToPrint
                index_byte = CRead intermed_index 
                index = index + index_byte
                Inc intermed_index
                Inc _i
            Wend
            index = index * padding;
            intermed_index = glcd_FontLastChar - glcd_FontFirstChar + 3
            intermed_index = intermed_index  * 2
            intermed_index = intermed_index  +  glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index  + index
            bits = CRead intermed_index  
            bitscount = 8 
        Else 
        ; UNCOMPRESSED FONTS
        ; now calculate the bit index to the bit data in the font
            intermed_index = glcd_FontData + FONT_HEADER_SIZE 
            index = 0 
            _i = glcd_FontFirstChar
            While _i < _charToPrint
                 index_byte = CRead intermed_index        ; here we read the char width ????
                 index = index + index_byte
                 Inc intermed_index
                 Inc _i
            Wend
            ; Left clipping into account, only possible with uncompressed fonts
            If xx < glcd_Clip_x1 Then 
                _t = glcd_Clip_x1 - xx   
                index = index + _t 
                charwidth = charwidth - _t;
                xx = glcd_Clip_x1 
            EndIf
            index = index * glcd_FontHeight *  bitspixel 
        ; would position the data's first byte font files with a sign and get the first bits
            bitscount = index // 8  
            index = index / 8
            intermed_index = glcd_FontData + FONT_HEADER_SIZE
            intermed_index = intermed_index + glcd_FontLastChar - glcd_FontFirstChar
            intermed_index = intermed_index  + 1 + index  
            bits = CRead intermed_index                     ; here we read the first bits of font data to display ;  
            bits = bits >> bitscount 
            bitscount = 8 - bitscount 
        EndIf
      ; we send the bit data of each pixel in the yy direction of each Column
        pixelcount = 0                                  ; Number of pixels to be set    
        pixelcolor = 0                                  ; to be set pixel color 
        clipinvalid = 1                                 ; Validity of the address pointers on the GLCD
        clipY = 0                                   
        stopY = glcd_Cursor_Y + glcd_FontHeight -1      ; lowest pixel line of the character
        stopX = xx + charwidth -1 
      ; right clipping account
        If stopX > glcd_Clip_x2 Then 
            stopX = glcd_Clip_x2 
        EndIf
    	xx = xx
    	Repeat
            If clipY = clipY | glcd_Cursor_Y Then 
                clipinvalid = 1;
            EndIf
    		yy = glcd_Cursor_Y
    		Repeat
                    If pixelcount = 0 Then 
                        If bitscount <= 8 Then 
                            Inc intermed_index
                            bits_tWord = CRead intermed_index       ; read a byte
                            bits = bits | (bits_tWord << bitscount)
                            bitscount = bitscount + 8 
                        EndIf
                        If glcd_FontBitsPixel.7 = 1 Then            ; if the character font is compressed 
                            pixelcount = table[bits & 3] 
                            bits = bits >> 2 
                            bitscount = bitscount -2 
                        Else 
                            Inc pixelcount 
                        EndIf
                        If bitspixel <= 3 Then 
                            pixelcolor = bits & bitsmask;  
                            If pixelcolor > 1 Then   ; color correction if more bits per pixel than necessary
                                pixelcolor = 1
                            EndIf
                        EndIf
                        bits = bits >> bitspixel;
                        bitscount = bitscount - bitspixel;
                    EndIf
                    Dec pixelcount  
                    If  yy >= glcd_Clip_y1 And yy <= glcd_Clip_y2 And xx >= glcd_Clip_x1 Then  
                        If clipinvalid = 1 Then 
                            clipY = yy 
                            clipinvalid = 0 
                        EndIf
                        putPixel pixelcolor  
                    Else 
                        clipinvalid = 1 
                    EndIf
            Inc yy
    		Until yy = stopY + 1
        
    	Inc xx
    	Until xx = stopX + 1
    	;
        PP0 = PP0_temp
        PP0h = PP0h_temp
        PP0hh = PP0hh_temp
        PP0hhh = PP0hhh_temp
        PP2 = PP2_temp
        PP2h = PP2h_temp
        PP2hh = PP2hh_temp
        PP2hhh = PP2hhh_temp
        PP7 = PP7_temp
        PP7h = PP7h_temp
        PP7hh = PP7hh_temp
        PP7hhh = PP7hhh_temp
        NOKIA_CURSOR glcd_Cursor_X_temp , glcd_Cursor_Y_temp   ; reposition the cursor for the next char
        Return 
    ;==============================================================================
    $ifdef use_drawLine
    drawLine    Macro P1, P2, P3, P4, P5 ;  x0, y0, x1, y1, color
                #if (Prm_1 == Byte)
    		      Byte_Byte P1, x0
    	        #endif
                #if (Prm_1 == Num8)  
    		      Num_Byte P1, x0
    	        #endif
    	        #if (Prm_2 == Byte)
    		      Byte_Byte P2, y0
    	        #endif
                #if (Prm_2 == Num8)  
    		      Num_Byte P2, y0
    	        #endif
    	        #if (Prm_3 == Byte)
    		      Byte_Byte P3, x1
    	        #endif
                #if (Prm_3 == Num8) 
    		      Num_Byte P3, x1
    	        #endif
    	        #if (Prm_4 == Byte)
    		      Byte_Byte P4, y1
    	        #endif
                #if (Prm_4 == Num8) 
    		      Num_Byte P4, y1
    	        #endif
    	        #if (Prm_5 == Byte)
    		      Byte_Byte P5, pen
    	        #endif
                #if (Prm_5 == Num8)  
    		      Num_Byte P5, pen
    	        #endif
                GoSub drawLine_SUB
                Endm            
    drawLine_SUB:
                ;left to right only
                If x0 > x1 Then
                    Swap x1, x0
                EndIf
                If y0 > y1 Then
                    Swap y1, y0
                EndIf
                ;
                If x0 = x1 And y0 = y1 Then
                    drawPixel x0, y0, pen
                    Return
                EndIf
                ; if vertical line
                If x0 = x1 Then
                    y0t = y0
                    Repeat
                        drawPixel x0, y0t, pen
                        Inc y0t
                    Until y0t =  y1 + 1
                    ;
                EndIf    
                ; calculate direction
                dx = x1 - x0
                dy = y1 - y0
                If dx < 0 Then
                  dx = Abs dx
                  stepx = -1
                Else 
                  stepx = 1 
                EndIf
                If dy < 0  Then
                  dy = Abs dy 
                  stepy = -1   
                Else   
                  stepy = 1 
                EndIf
                dx2 = dx << 1
                dy2 = dy << 1
                drawPixel x0, y0, pen
                If dx > dy Then
                      err = dy2 - dx
                      While x0 <> x1 
                             If err >= 0 Then
                              y0  = y0 + stepy
                              err = err - dx2
                             EndIf
                             x0  = x0 + stepx
                             err = err + dy2
                             drawPixel x0, y0, pen
                      Wend
                Else
                      err = dx2 - dy
                      While yy <> y1 
                             If err >= 0 Then
                              x0  = x0 + stepx
                              err = err - dy2
                             EndIf
                             yy = yy + stepy
                             err = err + dx2
                             drawPixel x0, y0, pen
                      Wend
                EndIf
                Return
    $endif
    ;==============================================================================
    $ifdef use_fillRectangle
    fillRectangle    Macro   P1, P2, P3, P4, P5
                #if (Prm_1 == Byte)
    		      Byte_Byte P1, xr0
    	        #endif
                #if (Prm_1 == Num8)  
    		      Num_Byte P1, xr0
    	        #endif
    	        #if (Prm_2 == Byte)
    		      Byte_Byte P2, yr0
    	        #endif
                #if (Prm_2 == Num8)  
    		      Num_Byte P2, yr0
    	        #endif
    	        #if (Prm_3 == Byte)
    		      Byte_Byte P3, xr1
    	        #endif
                #if (Prm_3 == Num8)  
    		      Num_Byte P3, xr1
    	        #endif
    	        #if (Prm_4 == Byte)
    		      Byte_Byte P4, yr1
    	        #endif
                #if (Prm_4 == Num8)   
    		      Num_Byte P4, yr1
    	        #endif
    	        #if (Prm_5 == Byte)
    		      Byte_Byte P5, Color
    	        #endif
                #if (Prm_5 == Num8)   
    		      Num_Byte P5, Color
    	        #endif
    	        GoSub fillRectangle_SUB
    	        Endm
    fillRectangle_SUB:
                ;left to right only
                If xr0 > xr1 Then
                    Swap xr1, xr0
                EndIf
                If yr0 > yr1 Then
                    Swap yr1, yr0
                EndIf
                yr0 = yr0
                Repeat
                    drawLine xr0, yr0, xr1, yr0, Color
                Inc yr0
                Until yr0 = yr1
                Return 
    $endif
    ';==============================================================================
    $ifdef use_drawRectangle
     drawRectangle   Macro   P1, P2, P3, P4, P5
                #if (Prm_1 == Byte)
    		      Byte_Byte P1, xfr0
    	        #endif
                #if (Prm_1 == Num8) 
    		      Num_Byte P1, xfr0
    	        #endif
    	        #if (Prm_2 == Byte)
    		      Byte_Byte P2, yfr0
    	        #endif
                #if (Prm_2 == Num8)  
    		      Num_Byte P2, yfr0
    	        #endif
    	        #if (Prm_3 == Byte)
    		      Byte_Byte P3, xfr1
    	        #endif
                #if (Prm_3 == Num8)  
    		      Num_Byte P3, xfr1
    	        #endif
    	        #if (Prm_4 == Byte)
    		      Byte_Byte P4, yfr1
    	        #endif
                #if (Prm_4 == Num8)  
    		      Num_Byte P4, yfr1
    	        #endif
    	        #if (Prm_5 == Byte)
    		      Byte_Byte P5, Color
    	        #endif
                #if (Prm_5 == Num8)  
    		      Num_Byte P5, Color
    	        #endif
    	        GoSub drawRectangle_SUB
    	        Endm
    drawRectangle_SUB:	        
                drawLine xfr0, yfr0 , xfr1, yfr0 , Color
                drawLine xfr0, yfr1 , xfr1, yfr1 , Color
                drawLine xfr0, yfr0 , xfr0, yfr1 , Color
                drawLine xfr1, yfr0 , xfr1, yfr1 , Color
                Return;
    $endif
    ';==============================================================================       
    $ifdef use_drawCircle
    drawCircle  Macro   p1, p2, p3, p4          ; X0, Y0, RADIUS, color
                        #if (Prm_1 == Byte)
            		      Byte_Byte P1, x0
            	        #endif
                        #if (Prm_1 == Num8) 
            		      Num_Byte P1, x0
            	        #endif
            	        #if (Prm_2 == Byte)
            		      Byte_Byte P2, y0
            	        #endif
                        #if (Prm_2 == Num8)  
            		      Num_Byte P2, y0
            	        #endif
                        #if (Prm_3 == Byte)
            		      Byte_Byte P3, radius
            	        #endif
                        #if (Prm_3 == Num8)  
            		      Num_Byte P3, radius
            	        #endif
            	        #if (Prm_4 == Byte)
            		      Byte_Byte P4, Color
            	        #endif
                        #if (Prm_4 == Num8)  
            		      Num_Byte P4, Color
            	        #endif
                        GoSub drawCircle_SUB
                        Endm
     drawCircle_SUB:
                        err = - radius
                        _X   = radius
                        _Y   = 0
                        While _X >= _Y 
                            parL = x0 + _X
                            parR = y0 + _Y
                            drawPixel parL , parR, Color 
                            parL = x0 - _X
                            parR = y0 + _Y
                            drawPixel parL , parR, Color 
                            parL = x0 + _X
                            parR = y0 - _Y
                            drawPixel parL , parR, Color 
                            parL = x0 - _X
                            parR = y0 - _Y
                            drawPixel parL , parR, Color 
                            parL = x0 + _Y
                            parR = y0 + _X
                            drawPixel parL , parR, Color 
                            parL = x0 - _Y
                            parR = y0 + _X
                            drawPixel parL , parR, Color 
                            parL = x0 + _Y
                            parR = y0 - _X
                            drawPixel parL , parR, Color 
                            parL = x0 - _Y
                            parR = y0 - _X
                            drawPixel parL , parR, Color 
                            err = err + _Y
                            _Y = _Y + 1
                            err = err + _Y;
                            If err >= 0 Then
                              _X = _X - 1
                              err = err - _X
                              err = err - _X
                            EndIf
                        Wend
                        Return;
    $endif                    
    ';==============================================================================
    $ifdef use_fillCircle
    fillCircle  Macro   P1, P2, P3, P4 ;  x0, y0, radius, color
                        #if (Prm_1 == Byte)
            		      Byte_Byte P1, x0Fill
            	        #endif
                        #if (Prm_1 == Num8)  
            		      Num_Byte P1, x0Fill
            	        #endif
            	        #if (Prm_2 == Byte)
            		      Byte_Byte P2, y0Fill
            	        #endif
                        #if (Prm_2 == Num8)  
            		      Num_Byte P2, y0Fill
            	        #endif
                        #if (Prm_3 == Byte)
            		      Byte_Byte P3, radius
            	        #endif
                        #if (Prm_3 == Num8)  
            		      Num_Byte P3, radius
            	        #endif
            	        #if (Prm_4 == Byte)
            		      Byte_Byte P4, Color
            	        #endif
                        #if (Prm_4 == Num8)   
            		      Num_Byte P4, Color
            	        #endif
                        GoSub fillCircle_SUB
                        Endm
    fillCircle_SUB:                     
                        errFill  = - radius;
                        glcd_cursor_xm   = radius;
                        glcd_cursor_ym   = 0;         
                        While glcd_cursor_xm >= glcd_cursor_ym 
                            _P1 = x0Fill - glcd_cursor_xm
                            _P2 = y0Fill + glcd_cursor_ym
                            _P3 = x0Fill + glcd_cursor_xm
                            _P4 = y0Fill + glcd_cursor_ym
                            drawLine _P1, _P2, _P3, _P4, Color;
                            _P1 = x0Fill - glcd_cursor_xm
                            _P2 = y0Fill - glcd_cursor_ym
                            _P3 = x0Fill + glcd_cursor_xm
                            _P4 = y0Fill - glcd_cursor_ym
                            drawLine _P1, _P2, _P3, _P4, Color
                            _P1 = x0Fill - glcd_cursor_ym
                            _P2 = y0Fill + glcd_cursor_xm
                            _P3 = x0Fill + glcd_cursor_ym
                            _P4 = y0Fill + glcd_cursor_xm
                            drawLine _P1, _P2, _P3, _P4, Color
                            _P1 = x0Fill - glcd_cursor_ym
                            _P2 = y0Fill - glcd_cursor_xm
                            _P3 = x0Fill + glcd_cursor_ym
                            _P4 = y0Fill - glcd_cursor_xm
                            drawLine _P1, _P2, _P3, _P4, Color
                            ;
                            errFill = errFill + glcd_cursor_ym;
                            glcd_cursor_ym = glcd_cursor_ym + 1;
                            errFill = errFill + glcd_cursor_ym;
                            If errFill >= 0 Then
                              glcd_cursor_xm =  glcd_cursor_xm - 1
                              errFill = errFill - glcd_cursor_xm;
                              errFill = errFill - glcd_cursor_xm;
                            EndIf
                        Wend
                        Return;
    $endif
    
    
    Display_INIT Macro
        GoSub DISPLAY_INIT_SUB
        Endm
    
    
    DISPLAY_INIT_SUB:               
        Clear
    
    
        NOKIA_INIT                          ; INIT NOKIA LCD
        ;
        DelayMS 200
        ;                                   ; initial clip & window set
        glcd_Flagsbits.AutoLineFeed = 0     ; auto-feedline enabled or not
        glcd_Flagsbits.FixedFont = 0
        glcd_Flagsbits.Clipping = 0
        ;
        glcd_Clip_x1 = 0                    ; 
        glcd_Clip_x2 = DisplayWidth - 1 
        glcd_Clip_y1 = 0
        glcd_Clip_y2 = DisplayHeight - 1 
        ;
        glcd_Window_x1 = 0
        glcd_Window_x2 = DisplayWidth - 1
        glcd_Window_y1 = 0
        glcd_Window_y2 = DisplayHeight - 1
        ;
        Return
    ;******************************************************************************
    
    
    
    
    OVER_MACROS:

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #39
    VaGyver
    Guest VaGyver's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    Ray, very good improvement!

    With a 18f26k22 running at 16 MHZ (internal osc) i have 8-9 full display refreshments (i think it is called fps).

    You made me rethink about I2C instead of SPI that i am currently using in my running project (since i need two more free pins).

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #40
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    Hi Vangelis,
    I have been running my display 24-7 for around 3 weeks with the i2c bus running at 1mhz without any problems. Obviously this also increases the refresh rate quite a bit. The data sheet for the SID1306 states a bus speed of 400khz soim in over clocker land I guess :-)

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #41
    VaGyver
    Guest VaGyver's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    I am also using 1 MHZ.

    Until now, no problem!

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #42
    RayEllam
    Guest RayEllam's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    Hi Vangellis,

    Just wondering how easy/difficult this will be to port to 16bit PICS? my project is currently using a PIC 18F24J50 for the initial prototype. Im finding 10 bit ADC is not really up to what i need (speed and resolution are on the edge). I could use an 8 bit device with a higher resolution but im thinking it's maybe time to bin the 8 bit devices altogether and stick with 16 bit, a lot of these actually look a little cheaper and with MUCH higher specs................have you taken the plunge with 16 bit? how do you find the new compiler?

    Regards
    Ray

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #43
    VaGyver
    Guest VaGyver's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    Hi Ray!
    Well, there is a relative thread for this, here
    http://www.protonbasic.co.uk/showthr...ighlight=pic32 (and other too).


    So, instead of answering here (and make an out of topic conversation), i will tell you my opinion in the above thread, in order to leave this (oled 128x64) thread dedicated .

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #44
    Junior Member Maxi's Avatar
    Join Date
    Mar 2010
    Posts
    93
    Thumbs Up
    Received: 1
    Given: 26
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: sample code from my tests

    Quote Originally Posted by Mellbreak View Post
    Hi George,

    This code is very "rough and ready", but it does compile and run. Hope it's of some use.
    Bob
    Hi Bob
    I need a little help
    I cant run this code where is my fault?
    Could you tell me I2C pic pin outs?

    I can compile it verywell but no any screen
    use 18F26K22, IDE 3.5.7.3, +5v, mclr goto 5v
    10k pullups at I2C pins


  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  29. #45
    VaGyver
    Guest VaGyver's Avatar

    0 Not allowed!

    Default Re: sample code from my tests

    RC3 (pin 14) for clock
    RC4 (pin 15) for data

  30. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Help With OLED Display / 128X64 SSD1306
    By basparky in forum Proton 24
    Replies: 27
    Last Post: 16th March 2019, 17:36
  2. Graphic-SH1106 OLED and SSD1306 OLED
    By Dompie in forum LCD module
    Replies: 0
    Last Post: 18th October 2017, 15:30
  3. OLED Display 128x64 0.96 I2C version
    By starwars in forum LCD module
    Replies: 6
    Last Post: 16th January 2017, 20:53
  4. SSD1306 OLED driver some extensions
    By Dompie in forum WIKI Discussion
    Replies: 8
    Last Post: 12th January 2017, 21:45

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts