Announcement

Collapse
No announcement yet.

Display text on a 128 g1h oled

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ADVANCETOM
    replied


    Sorry no can you help me with a example im still learning mate

    Leave a comment:


  • zorro
    replied


    ADVANCETOM

    I am not also a python person but i am able to display a temperature; What i have done is to get the int of the "temp" soustract the int of the temp to temp to get the rest. I ve got hte rest and multiply it by 100 and get an other int. With the two int got i transform then from int to ascii and concatane the two ascii with a"',".

    An example is better than a long speech : Let says the temp is 17,41°C

    temp = 17,41 A= int temp=17 B=(temp - int temp)x100=41

    convert A and B to ascii

    Concatane A , B

    You've got a nice string that could be send to the display with DrawText.

    Hope this help

    Leave a comment:


  • ESPsupport
    replied


    I can't imagine how
    ser.write("s%c%c%c%c%c%s%c" % (int(x),int(y),1,0xFF,0xFF,s,0x00))
    could work, but, as I said I know nothing about python. From my reading serial write will not format a string for you, it will write a string (which you have previously formatted) though.

    Leave a comment:


  • ADVANCETOM
    replied
    HTML Code:
    #!/usr/bin/python
    import serial
    import time
    import sys
    import getopt
    
    from Adafruit_BMP085 import BMP085
    
    # ===========================================================================
    # Example Code
    # ===========================================================================
    
    # Initialise the BMP085 and use STANDARD mode (default value)
    # bmp = BMP085(0x77, debug=True)
    bmp = BMP085(0x77)
    
    # To specify a different operating mode, uncomment one of the following:
    # bmp = BMP085(0x77, 0) # ULTRALOWPOWER Mode
    # bmp = BMP085(0x77, 1) # STANDARD Mode
    # bmp = BMP085(0x77, 2) # HIRES Mode
    # bmp = BMP085(0x77, 3) # ULTRAHIRES Mode
    
    temp = bmp.readTemperature()
    pressure = bmp.readPressure()
    altitude = bmp.readAltitude()
    
    print "Temperature: %.2f C" % temp
    print "Pressure: %.2f hPa" % (pressure / 100.0)
    print "Altitude: %.2f" % altitude
    
    try:
    opts, args = getopt.getopt(sys.argv[1:], "x:y:s:b")
    except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) # will print something like "option -a not recognized"
    sys.exit(2)
    
    x=0
    y=0
    s=""
    clear = False
    
    for o, a in opts:
    if o == "-x":
    x = a
    elif o == "-y":
    y = a
    elif o == "-s":
    s = a
    elif o == "-b":
    clear = True
    else:
    assert False, "Unhandled option"
    
    # Open the serial port on J16
    
    ser = serial.Serial(
    port='/dev/ttyUSB0',
    baudrate=115200,
    timeout=1,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS
    )
    
    ser.write("U") # Autobaud char
    rtc = ser.read(1) # Wait for a reply
    
    if clear==True:
    ser.write("E") # Clear screen
    rtc = ser.read(1) # Wait for a reply
    
    ser.write("s%c%c%c%c%c%s%c" % (int(x),int(y),1,0xFF,0xFF,s,0x00))
    rtc = ser.read(1) # Wait for a reply
    time.sleep(30)
    ser.close() # Close port
    Now i have this at working but only if i give a string s="Hello or else"but i need btw the TemperatureMaybe you could help now ?

    Leave a comment:


  • ESPsupport
    replied


    Sorry, I'm not really a Python person.

    You need to do your prints to a string and then send the resulting string to the display.

    There are a few bits of python code that you will find with a forum search, maybe one will give an example that you can use.

    Maybe the python forum might help if you asked about how to send something like that to the serial port

    Leave a comment:


  • ADVANCETOM
    replied


    Thats not really the Problem for me but thanks for fast response

    I wanna have the values on my Display but i dont know how?
    Thats my big Problem?


    HTML Code:
    print "Temperature: %.2f C" % temp
    print "Pressure:    %.2f hPa" % (pressure / 100.0)
    print "Altitude:    %.2f" % altitude
    
    
    This works in Python and show only in Python not with display
    Im already new in Programming Sorry
    Pls an example would be nice
    Thanks Tom    
    
    
    
    

    Leave a comment:


  • ESPsupport
    replied


    You need to wait/check the reponses to commands before you send the next one as the Display may be 'busy'.

    Also, if you are sending this immediately after powering up the display, be aware that it needs time to power up and initialize, so don't send anything for the first 2 or so seconds after power on.

    Leave a comment:


  • ADVANCETOM
    started a topic Display text on a 128 g1h oled

    Display text on a 128 g1h oled

    Hello my new project is an BMP085 Barometric pressure sensor ihave an working python script hereworking till erease screen but i wanna show this values on my Display.Need help!!Here is the script:
    HTML Code:
    #!/usr/bin/python
    import serial
    import time
    
    from Adafruit_BMP085 import BMP085
    
    # ===========================================================================
    # Example Code
    # ===========================================================================
    
    # Initialise the BMP085 and use STANDARD mode (default value)
    # bmp = BMP085(0x77, debug=True)
    bmp = BMP085(0x77)
    
    # To specify a different operating mode, uncomment one of the following:
    # bmp = BMP085(0x77, 0)  # ULTRALOWPOWER Mode
    # bmp = BMP085(0x77, 1)  # STANDARD Mode
    # bmp = BMP085(0x77, 2)  # HIRES Mode
    # bmp = BMP085(0x77, 3)  # ULTRAHIRES Mode
    
    temp = bmp.readTemperature()
    pressure = bmp.readPressure()
    altitude = bmp.readAltitude()
    
    print "Temperature: %.2f C" % temp
    print "Pressure:    %.2f hPa" % (pressure / 100.0)
    print "Altitude:    %.2f" % altitude
    
    ser = serial.Serial(
    
        port='/dev/ttyUSB0',
    
        baudrate=115200,
        timeout=1,
    
        parity=serial.PARITY_NONE,    
    
        stopbits=serial.STOPBITS_ONE,
    
        bytesize=serial.EIGHTBITS,
    
    )
    
    ser.write("U")    
    
    ser.write("E")          # Clear screen
    
    ser.close()                     # Close port
    Sorry for this maybe noob question, im still learningCheers Tom
Working...
X