Displaying Power Expander Voltage on LCD

  1. 7 months ago

    We are trying to figure out how to display battery voltages on our LCD screen using EasyCv5. We have made it display primary and back_up voltages. We would like to program it as follows:
    Line 1 display primary voltage
    line 2 display power expander voltage
    line 2 display back_up battery voltage when button 1 is depressed.

    The power expander is connected to the cortex in analog port 1. Using the print screen function it displays a reading in the terminal window. We even know to divide that value by 70 to get a fairly accurate voltage. What do we need to do to get the secondary voltage displayed on the LCD line 2? And how do we get Button 1 to change the display to back_up battery voltage?

    Thank you in advance for our help!

  2. nenik

    14 Nov 2017 V5 Beta Tester

    I'm no EasyC expert, but in general, if you have a loop like this and want to switch the view using a button, you need to keep some kind of inner state - a variable. You'd then pick what to display based on that state:

      if (otherDisplay) {
        SetLCDText(1, 2, "9V=%d", NineV);
      } else {
        SetLCDText(1, 2, "Extra=%d", Back_up);

    You'd then also need to switch based on the button:

      if (Button1Pressed /* I don't know how to read LCD buttons in EasyC */ ) {
        otherDisplay = !otherDisplay;
        /* add some kind of debounce, otherwise the display will keep toggling
             between the two at the speed of your control loop while you're holding the button */ 

or Sign Up to reply!