S7G2 Constructing a Password Protected LCD Page

s7g2
e2studio
guix

#1

Hi @craig @jcasman…here’s another fun LCD project.
I. Introduction
The purpose of this project was to construct an a simple Password protected LCD page. I also included a User ID login page along with a password. I decided to have a little bit of fun and modeled it after a bank’s online sign in page.
The user will be prompted to enter a User ID, if the User ID matches, then the user will be taken to a password page.
If either User ID or Password are incorrect, a message will appear.

II. GUIX Studio Construction
The first step is to design a keyboard on GUIX Studio for input. I made a simplistic keyboard with all capital letters and a few numbers for simplicity. I wanted to concentrate more on the coding. Below is a picture of the keyboard. Special attention must be placed on the naming convention of the keyboard. We will have to produce two instances of the keyboard, one for login page and the other for the password. We also have to add a prompt widget to obtain the user’s input.

Notice the naming convention of the prompt widget, this will have to match the e2 studio c code.

Below is an image of the password keyboard page and event handling naming convention on Guix Studio.

The pages will flow as follows:

  1. User starts at “Sign in Page”, asked for online ID.
  2. User clicks “Online ID” then transferred to User Name page prompt.
  3. If Username is incorrect, it will transfer the user to the “Incorrect Password/ID page”
  4. User hits the ok button and gets transferred back to User Name page.
  5. If Username is correct then, user will get transferred to the Password page.
  6. If password correct then it will go to the bank account page.
  7. If incorrect user will go back to password page or have the option to go to the main menu.
  8. A while loop could be implemented to give the user a maximum of “n” tries then get locked out, but I did not implement this.

Page Images


III. Code Construction
If you read the code, I have commented on almost every major function to provide an explanation of the functionality.
// keypad_event_handler.c
//Robinson Paniagua
// Modified March 28, 2017

#include “gx_api.h”
#include “my_guix_lab_resources.h”
#include “my_guix_lab_specifications.h”
#include “hal_data.h”
#include <string.h>
#define LOGIN_ID “ROB” // Sets the LOGIN ID, notice the Login ID is set to “Rob”, any other ID will give locked page

extern GX_WINDOW_ROOT * p_window_root; //Point to root window
static uint8_t login_code_str[11] = {0}; // Initiates the size of the login string, here it is a max of 12 characters 0-11
// {0} initializes the login string to 0, null.
static GX_PROMPT * keypad_output_display = &keypad.keypad_prompt1; ( Assigns the output from WindowNamed “Keypad” from prompt named “Prompt1” named in guix studio)

static void append_key_code(char * key_str); // Append Function, for declaring functionality to keyboard

/* Keypad Event Handler */
UINT KeypadEventHandler (GX_WINDOW * widget, GX_EVENT * event_ptr) (KeypadEvent Handler Function, this name must match the named given in GUIX Studio in the event handling box in the properties menu for the window. )

{
//Declares what each Key will produce using the function “append”, using a switch - case
UINT status;

switch (event_ptr->gx_event_type)
{
    case GX_SIGNAL(KEY_0, GX_EVENT_CLICKED): //"Key_0 is the given in GUIX Studio "Widget Name"
    {
        append_key_code("0");               //Append Key Code - defines the operation of Key_0, we do this for every character in the keyboard
    }
    break;
    case GX_SIGNAL(KEY_1, GX_EVENT_CLICKED):
    {
        append_key_code("1");
    }
    break;
    case GX_SIGNAL(KEY_2, GX_EVENT_CLICKED):
    {
        append_key_code("2");
    }
    break;
    case GX_SIGNAL(KEY_3, GX_EVENT_CLICKED):
    {
        append_key_code("3");
    }
    break;
    case GX_SIGNAL(KEY_4, GX_EVENT_CLICKED):
    {
        append_key_code("4");
    }
    break;
    case GX_SIGNAL(KEY_5, GX_EVENT_CLICKED):
    {
        append_key_code("5");
    }
    break;
    case GX_SIGNAL(KEY_6, GX_EVENT_CLICKED):
    {
        append_key_code("6");
    }
    break;
    case GX_SIGNAL(KEY_7, GX_EVENT_CLICKED):
    {
        append_key_code("7");
    }
    break;
    case GX_SIGNAL(KEY_8, GX_EVENT_CLICKED):
    {
        append_key_code("8");
    }
    break;
    case GX_SIGNAL(KEY_9, GX_EVENT_CLICKED):
    {
        append_key_code("9");
    }
    break;
    case GX_SIGNAL(KEY_A, GX_EVENT_CLICKED):
          {
              append_key_code("A");
          }
          break;
          case GX_SIGNAL(KEY_B, GX_EVENT_CLICKED):
          {
              append_key_code("B");
          }
          break;
          case GX_SIGNAL(KEY_C, GX_EVENT_CLICKED):
          {
              append_key_code("C");
          }
          break;
          case GX_SIGNAL(KEY_D, GX_EVENT_CLICKED):
          {
              append_key_code("D");
          }
          break;
          case GX_SIGNAL(KEY_E, GX_EVENT_CLICKED):
          {
              append_key_code("E");
          }
          break;
          case GX_SIGNAL(KEY_F, GX_EVENT_CLICKED):
          {
              append_key_code("F");
          }
          break;
          case GX_SIGNAL(KEY_G, GX_EVENT_CLICKED):
          {
              append_key_code("G");
          }
          break;
          case GX_SIGNAL(KEY_H, GX_EVENT_CLICKED):
          {
              append_key_code("H");
          }
          break;
          case GX_SIGNAL(KEY_I, GX_EVENT_CLICKED):
          {
              append_key_code("I");
          }
          break;
          case GX_SIGNAL(KEY_J, GX_EVENT_CLICKED):
          {
              append_key_code("J");
          }
          break;
          case GX_SIGNAL(KEY_K, GX_EVENT_CLICKED):
                {
                    append_key_code("K");
                }
                break;
                case GX_SIGNAL(KEY_L, GX_EVENT_CLICKED):
                {
                    append_key_code("L");
                }
                break;
                case GX_SIGNAL(KEY_M, GX_EVENT_CLICKED):
                {
                    append_key_code("M");
                }
                break;
                case GX_SIGNAL(KEY_N, GX_EVENT_CLICKED):
                {
                    append_key_code("N");
                }
                break;
                case GX_SIGNAL(KEY_P, GX_EVENT_CLICKED):
                {
                    append_key_code("P");
                }
                break;
                case GX_SIGNAL(KEY_Q, GX_EVENT_CLICKED):
                {
                    append_key_code("Q");
                }
                break;
                case GX_SIGNAL(KEY_R, GX_EVENT_CLICKED):
                {
                    append_key_code("R");
                }
                break;
                case GX_SIGNAL(KEY_S, GX_EVENT_CLICKED):
                {
                    append_key_code("S");
                }
                break;
                case GX_SIGNAL(KEY_T, GX_EVENT_CLICKED):
                {
                    append_key_code("T");
                }
                break;
                case GX_SIGNAL(KEY_U, GX_EVENT_CLICKED):
                {
                    append_key_code("U");
                }
                break;
                case GX_SIGNAL(KEY_O, GX_EVENT_CLICKED):
                {
                    append_key_code("O");
                }
                break;
                case GX_SIGNAL(KEY_V, GX_EVENT_CLICKED):
                {
                    append_key_code("V");
                }
                break;
                case GX_SIGNAL(KEY_W, GX_EVENT_CLICKED):
                {
                    append_key_code("W");
                }
                break;
                case GX_SIGNAL(KEY_Y, GX_EVENT_CLICKED):
                {
                    append_key_code("Y");
                }
                break;
                case GX_SIGNAL(KEY_Z, GX_EVENT_CLICKED):
                {
                    append_key_code("Z");
                }
                break;
                case GX_SIGNAL(KEY_X, GX_EVENT_CLICKED):
                {
                    append_key_code("X");
                }
                break;
                case GX_SIGNAL(KEY_Exc, GX_EVENT_CLICKED):
                {
                    append_key_code("!");
                }
                break;
                case GX_SIGNAL(KEY_Under, GX_EVENT_CLICKED):
                {
                    append_key_code("_");
                }
                break;
                case GX_SIGNAL(KEY_Period, GX_EVENT_CLICKED):
                {
                    append_key_code(".");
                }
                break;




    case GX_SIGNAL(KEY_Clear, GX_EVENT_CLICKED): // * key
    {
        login_code_str[0] = 0; // Clear user ID Login array string and prompt display
        status = gx_prompt_text_set(keypad_output_display, (GX_CHAR *)login_code_str);

    }
    break;
    case GX_SIGNAL(KEY_Enter, GX_EVENT_CLICKED): //Key_enter is the name we gave in GUIX Studio Widget Name
    {


               // Compares the string of the user verses the string of the Login ID.
                   if (0 == strcmp((char*)login_code_str, (char*)LOGIN_ID))
                   {
                       gx_studio_named_widget_create("keypad2", GX_NULL, GX_NULL); // If user input "login" == Login ID then go to PassWord Page
                       gx_widget_attach(p_window_root, &keypad2); // Get pointer to the unlocked image. Password page located in page keypad2

                   }
                   else  // if Login ID not correct go to the locked page and try again.
                   {
                       gx_studio_named_widget_create("code_result_locked", GX_NULL, GX_NULL); //Points to Window Code Result Locked
                                                                                  //Code result locked was the name I gave the Window in Guix Studio
                       gx_widget_attach(p_window_root, &code_result_locked); // Get pointer to the locked image.

                   }
                   //Once we move on to password page, we want to clear the user ID for security reasons
                   login_code_str[0] = 0; // Clear code and prompt display when exiting the window
                   status = gx_prompt_text_set(keypad_output_display, (GX_CHAR *)login_code_str);

               }
               break;
    case GX_SIGNAL(KEY_Main, GX_EVENT_CLICKED): // Key Main , the key I created in Guix Studio, takes user to main menu -> SignIn Page
     {
         // Go back to keypad window when Main button is touched ..Main = Sign in page
         gx_studio_named_widget_create("SignInPage", GX_NULL, GX_NULL);

         gx_widget_delete(widget);
         if (p_window_root->gx_widget_first_child == GX_NULL)
         {
             gx_widget_attach(p_window_root, &SignInPage); //Point the user to sign in page
         }

     }
     break;

    case GX_SIGNAL(BACK_BTN, GX_EVENT_CLICKED):
    {
        /** Go back to keypad window when BACK_BTN is touched */
        gx_studio_named_widget_create("keypad", GX_NULL, GX_NULL); //point the user to the keypad page

        gx_widget_delete(widget);
        if (p_window_root->gx_widget_first_child == GX_NULL)
        {
            gx_widget_attach(p_window_root, &keypad); //Points the user to the keypad page
        }

        login_code_str[0] = 0; //Clears out the prompt when exiting the Login page
    }
    break;

    default:
    return gx_window_event_process(widget, event_ptr); //intiates the widget event process
}
return 0;

}

//Function that defines the individual key output
void append_key_code(char * key_str)
{
UINT status;

if(strlen((char*)login_code_str)< (sizeof(login_code_str)-1)) //Compares the string length to the User input, double layer security
{
    strcat((char*)login_code_str, key_str); //Compares the String Characters, 
}
status = gx_prompt_text_set(keypad_output_display, (GX_CHAR *)login_code_str);

if (GX_SUCCESS != status)
{
    while(1);
}

}

This code has to be replicated for each keypad. Since we have a password and login keypad, we must use two keypad event handling pages with different variables and arrays.One keypad handling page is for the password, and the other is for the login is. I have named one variable PassWord and the other LOGIN_ID.
Instead of using #define LOGIN_ID “ROB”, in the Password event handling page, we would use #define PASSWORD “12345”

Final Product

Conclusion
This project was lots of fun. It enabled password protecting pages. We could use this ability in any number of applications that can be applied to the board. We could design a login page in order to access any other functionality of the board. So, lets says if the board was controlling other peripherals, such as movement of a motor. We could set a password before the user can actually start to operate the motor, or any other peripheral device.

Robinson Paniagua


[SOLVED] S7G2 GUIX Touch Drivers error with SSP1.2.0
#2

Holy smokes! Awesomeness! Way to go my man. I’m going to promote this now on social media.


#3

@craig
Thanks!!..Looking forward to my next project. Don’t have any ideas yet.

Robinson Paniagua


#4

This is seriously great, Rob! Thanks for uploading it.


#5

Might be interesting to dive into the Renesas IoT Sandbox. Here’s the beginner tutorial.

The tutorial uses a pre-built binary. It’ll look like this:

The code is available
https://synergygallery.renesas.com/addon/detail/63

The file has the ConnectedWeatherPanel code

You can then build that demo and customize the GUI.

It’s possible to go from that tutorial to the

Connected Weather Demo