Menu

OLED Screen Updates Change Request

Mike W
2017-10-24
2017-10-25
  • Mike W

    Mike W - 2017-10-24

    Hello All,

    I've added a 2.42" I2C OLED display to my Focuser Pro2 (search E-Bay for "2.42 oled i2c", make sure to get the I2C interface not the SPI). I am using the "Focuserv256_DRV8825_HW203_OLED_RE_F" firmware.

    I made a couple of changes to fix a problem and improve display quality.

    If "lcdupdateonmove" is enabled, when the number of displayed digits decrease with either of the variables "currentPosition" or "targetPosition" (i.e. 4 digits to 3 digits, 1000 to 999) the least significant digit from the larger number is left as an artifact on the display (going from 1000 to 999 will display 9990). When “displaylcd()” runs it does clear the issue, but the displayed number is incorrect for a short time.

    Starting at line 1514 I’ve changed my firmware to this:

        myoled.print("Current Pos =");
        myoled.print(currentPosition);
        myoled.clearToEOL();
        myoled.println();
    
        myoled.print("Target Pos  =");
        myoled.print(targetPosition);
        myoled.clearToEOL();
        myoled.println();
    

    Using “clearToEOL” removes the artifact.

    I’ve used a similar strategy to eliminate screen flicker, caused by clearing the screen and then re-writing it, when running “displaylcd()”.

    I made the following changes started at line 1065:

    void displaylcd()
    {
      char tempString[20];
    
      // display values
    
      //Current Pos
      //myoled.clear();
      myoled.home();
      myoled.print("Current Pos =");
      myoled.print(currentPosition);
      myoled.clearToEOL();
      myoled.println();
    
      //Target Pos
      myoled.print("Target Pos  =");
      myoled.print(targetPosition);
      myoled.clearToEOL();
      myoled.println();
    
      //coilPwr
      if ( myfocuser.coilPwr )
        myoled.print(coilpwrontxt);
      else
        myoled.print(coilpwrofftxt);
    
      myoled.clearToEOL();
      myoled.println();
    
      //ReverseDirection
      if ( myfocuser.ReverseDirection )
        myoled.print(revdirontxt);
      else
        myoled.print(revdirofftxt);
    
      myoled.clearToEOL();
      myoled.println();
    
      // stepmode setting
      if ( myfocuser.stepmode == 1 )
        myoled.print("Step Mode   =Full");
      else if ( myfocuser.stepmode == 2 )
        myoled.print("Step Mode   =Half");
      else if ( myfocuser.stepmode == 4 )
        myoled.print("Step Mode   =1/4");
      else if ( myfocuser.stepmode == 8 )
        myoled.print("Step Mode   =1/8");
      else if ( myfocuser.stepmode == 16 )
        myoled.print("Stemo Mode  =1/16");
      else if ( myfocuser.stepmode == 32 )
        myoled.print("Step Mode   =1/32");
    
      myoled.clearToEOL();
      myoled.println();
    
      //Temperature
      char tempstr[8];
      if ( myfocuser.tempmode == true )
      {
        // no need to convert, already in C
        dtostrf(ch1tempval, 4, 3, tempstr);
        myoled.print  ("Temperature =");
        myoled.print(tempstr);
        myoled.print(" c");
        myoled.clearToEOL();
        myoled.println();
      }
      else
      {
        // convert to F for display
        float tempvalf;
        tempvalf = (ch1tempval * 1.8) + 32;
        dtostrf(tempvalf, 4, 3, tempstr);
        myoled.print("Temperature =");
        myoled.print(tempstr);
        myoled.print(" f");
        myoled.clearToEOL();
        myoled.println();
      }
    
    
      //Motor Speed
      if ( motorSpeed == 0 )
        myoled.print("Motor Speed =Slow");
      else if (motorSpeed == 1 )
        myoled.print("Motor Speed =Med");
      else if ( motorSpeed == 2 )
        myoled.print("Motor Speed =Fast");
        myoled.clearToEOL();
        myoled.println();
    
      //MaxSteps
      myoled.print("MaxSteps    =");
      ltoa(myfocuser.maxstep, tempString, 10);
      myoled.print(tempString);
      myoled.clearToEOL();
      myoled.println();
    }
    

    I hope this has some value and thanks for all the hard work!

     
  • Miloš Stojadinović

    Hi Mike,

    Can these changes related to the screen flicker be used with the small OLED screen?

    Miloš

     
  • Mike W

    Mike W - 2017-10-24

    Miloš,

    This works with any display that uses the SSD1306 (or SSD1309) driver chip when in ASCII mode, which would be any OLED display that works with the various Focuser Pro2 OLED firmwares.

    So yes, it will work!

    Mike W

     
  • brownrb

    brownrb - 2017-10-25

    Hi Mike
    Are you happy for me to weave your code changes into the next release?

    Regards
    Robert

     
  • Mike W

    Mike W - 2017-10-25

    Robert,

    Yes, please do!

    I appreciate all your hard work on this project, it's been fun to build and use!

    Regards,

    Mike W

     
  • Miloš Stojadinović

    That's great, looking forward to the new version Robert! Thank you so much Mike.

     

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.