(FIXED) PROS littlevGL help

I was using this code to display autonomous selection buttons however, it stopped working. I am not sure what I did to the code because it displays nothing on the screen when I run the program. I also tried to use an exact copy of the littlevGL “hello world” tutorial program but nothing appears on the screen.


#include "main.h"
#include "Robot/Global.hpp"
#include "Robot/functions.hpp"

/**
 * Runs initialization code. This occurs as soon as the program is started.
 *
 * All other competition modes are blocked by initialize; it is recommended
 * to keep execution time for this mode under a few seconds.
 */

int middle = 0;
string auton = 0;

  static lv_res_t blueFront(lv_obj_t * btn)
  {
    static bool pressed = true;
    delay(100);
    if (pressed)
    {
      middle = 1;
      pressed = false;
      count = 1;
      auton = "BLUE FRONT";
    }
    return LV_RES_OK;
  }

  static lv_res_t redFront(lv_obj_t * btn)
  {
    static bool pressed = true;
    delay(100);
    if (pressed)
    {
      middle = 1;
      pressed = false;
      count = 0;
      auton = "RED FRONT";
    }
    return LV_RES_OK;
  }

  static lv_res_t blueBack(lv_obj_t * btn)
  {
    static bool pressed = true;
    delay(100);
    if (pressed)
    {
      middle = 1;
      pressed = false;
      count = 3;
      auton = "BLUE BACK";
    }
    return LV_RES_OK;
  }

  static lv_res_t redBack(lv_obj_t * btn)
  {
    static bool pressed = true;
    delay(100);
    if (pressed)
    {
      middle = 1;
      pressed = false;
      count = 2;
      auton = "RED BACK";
    }
    return LV_RES_OK;
  }

  void lv_objects(void)
{



    /********************
     * CREATE A SCREEN  *
     ********************/
    lv_obj_t * scr = lv_page_create(NULL, NULL);
    lv_scr_load(scr);

    // Creates a screen object that has nothing displayed on it //
    lv_obj_t * none = lv_page_create(NULL,NULL);
    /****************
     *     TITLE    *
     ****************/
    while(middle == 0)
    {
    lv_obj_t * label = lv_label_create(scr, NULL);
    lv_label_set_text(label, "Autonomous Selection");
    lv_obj_set_x(label, 145);
    lv_obj_set_y(label,15);

    /***********************
     * CREATE FOUR BUTTONS
     ***********************/

    // Create a button for the blue front auton //
    lv_obj_t * blueF = lv_btn_create(lv_scr_act(), NULL);
    lv_btn_set_action(blueF, LV_BTN_ACTION_CLICK, blueFront);
    lv_obj_align(blueF, blueF,LV_ALIGN_CENTER, 100, 35);

    label = lv_label_create(blueF, NULL);
    lv_label_set_text(label, "BLUE FRONT");

    // Creates a button for the red front auton //
    lv_obj_t * redF = lv_btn_create(lv_scr_act(), NULL);
    lv_btn_set_action(blueF, LV_BTN_ACTION_CLICK, redFront);
    lv_obj_align(redF, blueF, LV_ALIGN_CENTER, 150, 0);

    label = lv_label_create(redF, NULL);
    lv_label_set_text(label, "RED FRONT");

    // Create a button for the red back auton //
    lv_obj_t *redB = lv_btn_create(lv_scr_act(),NULL);
    lv_btn_set_action(blueF, LV_BTN_ACTION_CLICK, redBack);
    lv_obj_align(redB,blueF,LV_ALIGN_OUT_BOTTOM_MID,0,10);

    label = lv_label_create(redB,NULL);
    lv_label_set_text(label,"RED BACK");

    // Create a button for the blue back auton //
    lv_obj_t *blueB = lv_btn_create(lv_scr_act(),NULL);
    lv_btn_set_action(blueF, LV_BTN_ACTION_CLICK, blueBack);
    lv_obj_align(blueB,redF,LV_ALIGN_OUT_BOTTOM_MID,0,10);

    label = lv_label_create(blueB,NULL);
    lv_label_set_text(label,"BLUE BACK");
    delay(20);
  }
    lv_scr_load(none);
  
}

void initialize()
{
  lv_objects();

}

/**
 * Runs while the robot is in the disabled state of Field Management System or
 * the VEX Competition Switch, following either autonomous or opcontrol. When
 * the robot is enabled, this task will exit.
 */
void disabled()
{
}

/**
 * Runs after initialize(), and before autonomous when connected to the Field
 * Management System or the VEX Competition Switch. This is intended for
 * competition-specific initialization routines, such as an autonomous selector
 * on the LCD.
 *
 * This task will exit when the robot is enabled and autonomous or opcontrol
 * starts.
 */
void competition_initialize()
{
}

First you don’t need the “while (middle==0)” loop. The screen and input is persistent. Starting Auton (comp switch or match controller) starts autonomous.

Second you don’t need lv_scr_load(none), but if you want to clear the screen put that at the beginning of autonomous or create another button for it and put it in the call back.

you should probably be able to figure out the reset from that.

I made those changes and the Brain screen is blank when the program is executed. I also tried to run the littlevGL “hello world” tutorial program in a different project and it gives me a memory permission error.
WIN_20190124_18_05_17_Pro.jpg

Ok, I only have the PC simulator for testing. My team won’t give up the brain. attached is what i see from the pc simulator.

The other things I did was to remove the “delay()” statements and change string auton=0 to char *auton (no initial assignment); “count” must be declared elsewhere b/c i need to define it as an int.
c1.PNG

Thank you so much, I changed the string to char * auton and it is working. If you dont mind could you explain why that fixed my problem?

auton needs to be a pointer so you can reassign its address to each of the string constants’ address.

Makes sense, thanks again!

you’re welcome.

do you mind sharing your code for the button menu. I try to learn for this too. thanks