Menu

Rotary Encoder Button Real Time Beeper Suggested Change

Mike W
2017-11-11
2017-11-21
  • Mike W

    Mike W - 2017-11-11

    The rotary encoder option has a great feature that lets you use it’s push button to change the number of steps moved per encoder detent or, if pushed long enough, re-zero the focuser.

    A 1 second push sets 1 step per detent, 2 seconds 10 steps, 3 seconds 100 steps and a 4 second push re-zeros the focuser.

    You get feedback beeps 1, 2, 3 or 4 beeps, but only after you release the push button.

    Because of this, you kind of have to guess how long you’ve pressed the button.

    But; press a little too long and you might unintentionally re-zero your focuser!

    These two changes will give you real-time feedback beeps while you press the button.

    Starting with firmware version “Focuserv258_DRV8825_HW203_OLED _RE_F” I’ve replaced lines 1398 through 1441 with this:

        RESWdb.update();                // check rotary encoder push switch
          if ( RESWdb.fell())             // if pushed then halt focuser or perform, additional action
        {
          long encswstart = millis();    // start time of encoder sw press
    
          int PressTime = 1;  
          beep(PressTime);
    
          // wait for PB to be released
          while ( !digitalRead(encoderSWPin)){
    
            if (millis() - encswstart > 1000 * PressTime){
              PressTime++;
              beep(PressTime);
            }
            if ( PressTime == 4){
              break;
            }
          };
    
          switch(PressTime){
            case 1:
              motorSpeed = 0;
              encswval = 1;
              break;
    
            case 2:
              motorSpeed = 1;
              encswval = 10;
              break;
    
            case 3:
              motorSpeed = 2;
              encswval = 100;
              break;
    
            case 4:
              motorSpeed = 1;
              encswval = 1;
              currentPosition = 0;
              targetPosition = 0;
              isMoving = false;
              break;
    
            default:
              break;
          }
        }
    

    I’ve also changed the timing of beep() function to fit the available time slice, lines 1695 through 1706:

    void beep(int beeps)
    {
      int lp1;
      for (  lp1 = 0; lp1 < beeps; lp1++ )
      {
        analogWrite(Buzzer, 1023);    // turn on buzzer
        delay( 100 );                 // beep for 100ms
        analogWrite(Buzzer, 0);     // turn off buzzer
        delay( 50 );                // delay between beeps for 50ms
      }
    }
    

    Hope this is helpfull.

    Mike W

     

    Last edit: Mike W 2017-11-11
  • Rev.Antun

    Rev.Antun - 2017-11-17

    Hi Mike!

    Thx for share with us, nice helpful gadget :D

    Cheers Toni

     
  • brownrb

    brownrb - 2017-11-17

    Hi Mike
    My apologies, have been busy working on another project. If ok with you will add your proposed changes into next firmware release for RE. Am always looking to make things better and appreciate the suggestions and changes.

    Regards
    Robert

     
  • Mike W

    Mike W - 2017-11-20

    Robert,

    Yes, I'd be happy to have the changes included in the next release!

    Regards,

    Mike W

     
  • brownrb

    brownrb - 2017-11-21

    So this is coming soon in firmware 259 which in a few days will be released

     

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.