Menu

Test byte in GCBglcd buffer

Help
2017-04-03
2017-04-03
  • stan cartwright

    stan cartwright - 2017-04-03

    Hi all.Sorry to be a nuisance. I want to test if a pixel is lit on a glcd. This code doesn't work. How do I define the start of SSD1306_BufferAlias?
    I don't want to copy and change the plot routine, well if I could still plot I would. I'm thinking of modifying the glcd for my own use and just use different inits for different displays but that's not encouraged it seems. Don't see why not. I got to include the glcd anyway so can't see the difference.

    #chip 18F25K22, 16
    #option explicit
    #include <glcd.h>
    ;
    ' Define I2C settings - CHANGE PORTS
    #define I2C_MODE Master
    #define I2C_DATA PORTC.4
    #define I2C_CLOCK PORTC.3
    #define I2C_DISABLE_INTERRUPTS ON
    'Optionally, you can reduce the I2C timings.
    #define I2C_BIT_DELAY 0 us
    #define I2C_CLOCK_DELAY 0 us
    #define I2C_END_DELAY 0 us
    ; ----- Define GLCD Hardware settings
    #define GLCD_TYPE GLCD_TYPE_SSD1306
    #define GLCD_I2C_Address 0x78
    ;
    dim pixel as byte
    dim pixel_set as byte
    dim pixel_x as byte
    dim pixel_y as byte
    dim ptr as word
    ;
    GLCDCLS
    do
    line (50,0,50,7,1)
    pixel_x=50:pixel_y=0
    pixel_lit
    ;glcdprint (0,30,SSD1306_BufferAlias) ;duplicate definition error
    glcdprint (8,0,pixel_set)
    glcdprint (60,50,ptr)
    if pixel_set=1 Then
      glcdprint (0,20,"pixel set")
    Else
      glcdprint (0,20,"pixel clear")
    end if
    
    loop
    '------
    sub pixel_lit
    pixel=pixel_y and 7
    ;
    ptr=pixel_y and 0xf8
    repeat 4
    set c off
    rotate ptr left ;x16
    end Repeat
    ptr=ptr Or pixel_x ;screen byte in buffer
    
    pixel_set=1
    repeat pixel
    set c off
    rotate pixel_set left ;screen byte value of pixel
    end repeat
    
    pixel_set=pixel_set And SSD1306_BufferAlias( ptr ) ;where is SSD1306_BufferAlias?
    end sub
    
     
  • Anobium

    Anobium - 2017-04-03

    This is a relatively simple method to implement.

    I already posted on this about a month ago. is this a different ask?

     
  • stan cartwright

    stan cartwright - 2017-04-03

    Hi Evan. You mentioned that the arduino c include idea is ad hoc and you want standardisation in GCB and that anyone can use the lib includes for their own ends. That's what I'll do a bit. Seeing it's only a black and white display I could change pset x,y,0 to 2-xor,3-pixel test set/clear. It would then be just SSD1306 glcd driver. I would be portable in that it would work on pic and uno but that's what uno and rpi is,open source on an attempt to standardise. I can see that keeping the x,y,colour format works for all displays the same idea. I'll see again if I can figure out how to use SSD1306_BufferAlias from outside include glcd.

     
  • stan cartwright

    stan cartwright - 2017-04-03

    Thanks. My problem is I'm unfamiliar with functions. I only started using sub on the weekend.I got side tracked half way through a robot project. I'll get back to it again. Thanks again.

     
  • Anobium

    Anobium - 2017-04-04

    For those following along...... I delete the posting with the code. As after speaking offline with Stan i thought has was not going to use the code.

    Summary: Turned out that reading of the help, specifically the FAQ helped, and printing numbers and strings needs to use STR(number_variable) and to add spaces to a string to use PAD() or LEFTPAD()

    :-)

     

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.