Announcement

Collapse
No announcement yet.

Arduino + uOLED-160-G2 Screen Issues

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

  • Arduino + uOLED-160-G2 Screen Issues

    Hi there,

    I've connected a 160-g2 oled to a Teensy Arduino and have been trying to display different colored circles on it. My goal is to be able to set the color of a background circle based on a value passed through a function that creates this circle.

    I've noticed a few bizarre issues with the display:
    1. Background changes to a yellow/orange color.
    2. Display lags.
    3. Randomly drawn circles.

    Ideally the following pic would just be the blueish circle but the background isnt black and there seems to be this odd half circle.:



    Code:
    #include <RGBConverter.h>
    
    #include "Goldelox_Serial_4DLib.h"
    #include "GoldeloxBigDemo.h"
    #include "Goldelox_Const4D.h"
    
    //Goldelox_Serial_4DLib Display(&DisplaySerial); // Obviously unusable.
    HardwareSerial Uart = HardwareSerial(); // Suggested in the pjrc forum
    Goldelox_Serial_4DLib Display(&Uart);
    
    RGBConverter color;
    
    byte rgb[3];
    
    void setup()
    {
      
    delay(5000) ;
    Serial.begin(9600);
    Serial.println("Resetting Display...");
    //Reset the display
    pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
    // ############ Solution: ###########
    digitalWrite(2, LOW); // Reset the display
    delay(200);
    digitalWrite(2, HIGH); // Clear Reset
    // #######################
    delay(5000);
    Serial.println("Display Reset Done.");
    }
    
    void loop()
    {
    Serial.print("Loop\n") ;
    Uart.begin(9600);
    
    Serial.print("LOOP: set color\n") ;
    
    Serial.print("LOOP: Text Test\n") ;
    delay(2000);
    int randomNum = random(330);
    randomNum = randomNum + 70;
    word CircleColor = backgroundColor(int randomNum);
    Display.gfx_CircleFilled(80, 64, 64, CircleColor);
    
    //Display.gfx_CircleFilled(80, 64, 64, BLUE);
    }
    
    void backgroundColor(int temp){
      double tempHue = (200 + (temp - 70) * (-200) / (400-70))/360.0;
      Serial.print("Setting background to color:\n");
      double h1 = .8;
      double s1 = 1.0;
      double L1 = .7;
      color.hslToRgb(h1, s1, L1, rgb);
      long lrgb = ((long)rgb[0] << 16L) | ((long)rgb[1] << 8L) | (long)rgb[2];
      
    //  Serial.println(lrgb, HEX);
      uint16_t newRGB = (lrgb>>8&0xf800)|(lrgb>>5&0x07e0)|(lrgb>>3&0x001f);
      Serial.println(newRGB, HEX);
    //  Display.gfx_CircleFilled(80, 64, 64, 0xE33F);
      return BLUE
    //  delay(2000);
    }
    Thanks!

  • #2
    I think your Serial.prints are going to the same comms port as the display is connected to.

    Try removing them.

    Also, have you tried this? http://www.4dsystems.com.au/appnote/4D-AN-00123/
    Mark

    Comment


    • #3
      Hi Mark,

      I removed all of the Serial.prints but received mostly the same weird display. A yellow background and then the circle that I actually called for, but then it is sometimes covered up again by the yellow background, or in some cases red. Do similar things typically happen when running goldelox commands from inside a function other than loop?

      Comment


      • #4
        Hi Audrey,

        Converted your code to work on my arduino. It shows BLACK background and BLUE CircleFilled. After removing all of the Serial.print's, also Remove the "Uart.begin(9600);" in void loop(). Replace "Serial.begin(9600);" with "Uart.begin(9600);".

        To test if the display that you are using doesn't have any problems. Use 'Serial Commander'. In WS4 File->New->uOLED-160-G2->Serial. Then Tools->SPE Load. After loading Click Serial Commander. in Gfx tab click gfx_Cls and then send. Then click gfx_CirclFilled woth X= 80, Y= 64 , Raduis = 64 and Color Blue.

        I've attached the arduino code that worked for me. Note it uses reset pin 4, and Software serial.
        Attached Files
        Symon

        Comment

        Working...
        X