Menu

Write to ssd1306

Help
2017-08-07
2017-08-07
  • stan cartwright

    stan cartwright - 2017-08-07

    I dont understand how to access the variables in ssd1306 include.
    I am not sure if I need to use as alias, it's a major block for me and clarification would be a great help,an example fab. I want to write a byte to the display. When I sort that then other things.
    Here's my write byte to display. Please say what I doing wrong. I'm running out of logic/ideas. A few tips would be so helpful.
    edit I think maybe sending 64 meaning data to follow is wrong and perming 8 from 10 didn't work,ie try different code.

    #chip mega328p, 16
    #option explicit
    #include <glcd.h>
    ;
    #define HI2C_BAUD_RATE 400
    #define HI2C_DATA
    HI2CMode Master
    #define GLCD_TYPE GLCD_TYPE_SSD1306
    #define GLCD_I2C_Address 0x78
    
    ;
    
    dim tmp1,tmp2,row,py,px,SSD1306SendByte as byte
    dim shiftsright,sprite1,sprite_hibyte,sprite_lowbyte,spritebyte as byte
    
    GLCDCLS
    GLCDPrint (0,0,"test") ;THIS WORKS it prints test
    ;writing byte DOESN'T WORK
    px=50:py=20
    row=2
    ;ptr=py And 0xF8:ptr=(FnLSl (ptr,4) or px)+1 ;buffer position to start writing to
    spritebyte=255
    write_byte ;writes byte to display at row and px co-ord
    do forever
    ;
    sub write_byte ;writes byte to display at row and px co-ord
      writebyte SSD1306_PAGEADDR
      writebyte row
      writebyte 7
      writebyte SSD1306_COLUMNADDR
      writebyte px
      writebyte 127
      writebyte 64
      writebyte spritebyte
    end sub
    ;
    sub writebyte
      HI2CStart
      HI2CSend GLCD_I2C_Address
      HI2CSend 0x00
      HI2CSend SSD1306SendByte
      HI2CStop
    end sub
    
     

    Last edit: stan cartwright 2017-08-07
  • Chris Roper

    Chris Roper - 2017-08-07

    I don't have a GLCD Display to test with but have you tried:

      GLCDCLS
      GLCDPrint 0, 0, "Great Cow BASIC"
    

    Full help and example here:
    http://gcbasic.sourceforge.net/help/_ssd1306_controllers.html

     
  • stan cartwright

    stan cartwright - 2017-08-07

    The glcd works fine and in the program clears screen and prints test it not writing a byte though, well not on display.
    I changed the write sub but no joy. On a picaxe this was easy to make a lib but same code is not working with GCB. Trying to do a sprite routine but can't write 1 byte. doh! Ta anyway.
    this works in picaxe and want to convert to GCB
    ClearDisplay: ;clears oled screen
    hi2cout (0,SSD1306_PAGEADDR)
    hi2cout (0,0) ;set row=0
    hi2cout (0,7)
    ;
    hi2cout (0,SSD1306_COLUMNADDR)
    hi2cout (0,0) ;set column=0
    hi2cout (0,127)
    ;
    for ptr=0 to 1023
    hi2cout (64,0)
    next ptr
    ;
    return
    Now GCB,oh dear,dim workio

    sub write_byte ;writes byte to display at row and px co-ord
      writebyte SSD1306_PAGEADDR
      writebyte row
      writebyte 7
      writebyte SSD1306_COLUMNADDR
      writebyte px
      writebyte 127
    ;  writebyte 64
    ;  writebyte spritebyte
      HI2CStart
      HI2CSend GLCD_I2C_Address
    ;  HI2CSend 0x00
      HI2CSend 64
      HI2CStop
    ;
      HI2CStart
      HI2CSend GLCD_I2C_Address
    ;  HI2CSend 0x00
      HI2CSend spriteByte
      HI2CStop
    end sub
    
     

    Last edit: stan cartwright 2017-08-07
  • Anobium

    Anobium - 2017-08-07

    I can look at this when I get home from vacation.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.