Controller print display flickers

  1. 5 days ago

    I'm experimenting with the screen.print functions for the brain and the controller and having some issues with the controller. Code is below. The brain screen prints the RPM of the motor without issue. However, the very next line, seemingly with identical syntax, prints to the controller, but the display will flash the "RPM=##" for an instant and then it goes away. It flashes consistently every second and would be impossible to read during a match unless you were staring right at it. Any thoughts on why the controller display is doing this?

    int main(){
    Brain.Screen.print("Flywheel RPM Counter");
    double wheelRPM = 0;
    while(1){
    if(Controller1.ButtonX.pressing())
    {
    Flymotor1.spin(directionType::fwd, 30, velocityUnits::rpm);

    }
    else
    {
    Flymotor1.stop(brakeType::coast);
    }
    wheelRPM = Flymotor1.velocity(velocityUnits::rpm);

    int wheelRPMvalue = wheelRPM;
    Brain.Screen.drawRectangle(1,50,100,50);
    Brain.Screen.printAt(3,80, "RPMs = %d", wheelRPMvalue);
    Controller1.Screen.print("RPM = %d", wheelRPMvalue);

    task::sleep(20);
    }
    }

  2. Figured it out myself. Needed to

    Controller1.screen.clearScreen()
    Mostly works, but still get residual values after the motors have stopped and the value on the Brain is different from the value on the controller even though they're printing the same variable.

  3. jpearman

    Oct 10 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    you need to set cursor position before using Screen.print on the controller. We will see if we can improve that API for the next VCS release.

    int main(){
      Brain.Screen.print("Flywheel RPM Counter");
      double wheelRPM = 0;
      Controller1.Screen.clearScreen();
    
      while(1) {
        if(Controller1.ButtonX.pressing())
          {
          Flymotor1.spin(directionType::fwd, 30, velocityUnits::rpm);
          }
        else
          {
          Flymotor1.stop(brakeType::coast);
          }
         wheelRPM = Flymotor1.velocity(velocityUnits::rpm);
    
        int wheelRPMvalue = wheelRPM;
        Brain.Screen.drawRectangle(1,50,100,50);
        Brain.Screen.printAt(3,80, "RPMs = %d", wheelRPMvalue);
        Controller1.Screen.setCursor( 1, 1 );
        Controller1.Screen.print( "RPM = %d", wheelRPMvalue);
    
        task::sleep(20);
      }
    }
  4. jpearman

    Oct 10 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 5 days ago by jpearman

    ok, what I said above is not completely accurate.
    The controller has three lines available for text display. The VCS class defaults to using line 1, that's at the top of the controller screen. When you write to line 1 it's not visible as the controller is showing match timer etc. The controller used to automatically clear the screen in this case, but it doesn't do that anymore.
    If you want to display on the bottom line then you need to set the cursor position to line 3, this can be done once at program start. clearScreen will show all three lines of text, but you need to avoid calling clearScreen in a loop with print, we can only send commands to the controller at a fairly low rate, and if clearScreen and print are used consecutively you can sometimes have issues. Here's another revised version.

    int main(){
      Brain.Screen.print("Flywheel RPM Counter");
      double wheelRPM = 0;
      //Controller1.Screen.clearScreen();
      Controller1.Screen.setCursor( 3, 1 );
    
      while(1) {
        if(Controller1.ButtonX.pressing())
          {
          Flymotor1.spin(directionType::fwd, 30, velocityUnits::rpm);
          }
        else
          {
          Flymotor1.stop(brakeType::coast);
          }
         wheelRPM = Flymotor1.velocity(velocityUnits::rpm);
    
        int wheelRPMvalue = wheelRPM;
        Brain.Screen.drawRectangle(1,50,100,50);
        Brain.Screen.printAt(3,80, "RPMs = %d", wheelRPMvalue);
        Controller1.Screen.print( "RPM = %d", wheelRPMvalue);
    
        task::sleep(20);
      }
    }
  5. 3 days ago

    Hmm... is there any way to hide the competition data/etc. on the controller, then? I have more data than one line can fit that I'd like visible at a time on the controller, such as both the RPM and temperature of a particular motor.

 

or Sign Up to reply!