Silícios LabPCBWay
Published © GPL3+

Creating a Menu of HMI with Arduino and LCD 16 x 2

You will learn how to create a Human Machine Interface with Arduino and LCD 16 x 2.

BeginnerFull instructions provided1 hour8,052
Creating a Menu of HMI with Arduino and LCD 16 x 2

Things used in this project

Hardware components

PCBWay Custom PCB
PCBWay Custom PCB
×1
Resistor 1K 1/4W - UTSOURCE
×1
Resistor 330R 1/4W - UTSOURCE
×1
LCD 16 x 2 - Green Backlight - UTSOURCE
×1
Arduino UNO R3 - UTSOURCE
×1
Pushbutton Switch 6 x 6 x 5 - UTSOURCE
×2

Software apps and online services

Flowcode 7
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Flowchart for creating or modeling your LCD MENU with Arduino

Code

Code for create a Menu With LCD 16 x 2

C/C++
This code is the result of flowchart converted for C Language.
//************************************************************************************
//**  
//**  Source name:   Diego mOREIRA
//**  Instagram: @fcodiegomoreira and too @silicios.lab
//**  Title:         
//**  Description:   
//**  Device:        AVR.ATMEGA.ATMEGA328P
//**  
//**  Generated by:  Flowcode v7.2.1.4
//**  
//**  
//**  http://www.matrixtsl.com
//**  
//************************************************************************************


#define MX_AVR

#define MX_CAL_AVR

#define MX_CLK_SPEED 16000000

#define FCP_NULL Unconnected_Port

#define MX_UART_ID
#define MX_UART_UCSRC

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <avr\io.h>
#include <avr\interrupt.h>
#include <avr\eeprom.h>
#include <avr\wdt.h>


/*========================================================================*\
   Use :Include the type definitions
\*========================================================================*/
#include "C:\Program Files (x86)\Flowcode 7\CAL\internals.c"





/*========================================================================*\
   Use :panel
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/
#define FCV_FALSE (0)
#define FCV_TRUE (1)
MX_GLOBAL MX_SINT16 FCV_CONT = (1);
MX_GLOBAL MX_BOOL FCV_BOTAODOWN = (0);
MX_GLOBAL MX_BOOL FCV_IMPRIME = (1);
MX_GLOBAL MX_UINT8 FCV_ESTADODOWN = (0x0);
MX_GLOBAL MX_BOOL FCV_ESTADOUP = (0);
MX_GLOBAL MX_BOOL FCV_BOTAOUP = (0); // Armazena o estado do botao


/*========================================================================*\
   Use :ButtonCtrl
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/

/*========================================================================*\
   Use :switch_base
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/
MX_UINT8 FCD_05262_switch_base__ReadState();
void FCD_05262_switch_base__WaitUntilHigh();
void FCD_05262_switch_base__WaitUntilLow();

/*========================================================================*\
   Use :ButtonCtrl
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/

/*========================================================================*\
   Use :switch_base
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/
MX_UINT8 FCD_05261_switch_base__ReadState();
void FCD_05261_switch_base__WaitUntilHigh();
void FCD_05261_switch_base__WaitUntilLow();

/*========================================================================*\
   Use :ctrl_lcd
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/

/*========================================================================*\
   Use :LCD
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/
void FCD_04071_LCD__Clear();
void FCD_04071_LCD__PrintString(MX_CHAR *FCL_TEXT, MX_UINT16 FCLsz_TEXT);
void FCD_04071_LCD__PrintAscii(MX_UINT8 FCL_CHARACTER);
void FCD_04071_LCD__PrintNumber(MX_SINT16 FCL_NUMBER);
void FCD_04071_LCD__RAMWrite(MX_UINT8 FCL_INDEX, MX_UINT8 FCL_D0, MX_UINT8 FCL_D1, MX_UINT8 FCL_D2, MX_UINT8 FCL_D3, MX_UINT8 FCL_D4, MX_UINT8 FCL_D5, MX_UINT8 FCL_D6, MX_UINT8 FCL_D7);
void FCD_04071_LCD__ClearLine(MX_UINT8 FCL_LINE);
void FCD_04071_LCD__Cursor(MX_UINT8 FCL_X, MX_UINT8 FCL_Y);
void FCD_04071_LCD__Command(MX_UINT8 FCL_INSTRUCTION);
void FCD_04071_LCD__PrintFormattedNumber(MX_UINT32 FCL_NUMBER, MX_BOOL FCL_FORMAT);
void FCD_04071_LCD__ScrollDisplay(MX_UINT8 FCL_POSITION, MX_UINT8 FCL_DIRECTION);
void FCD_04071_LCD__RawSend(MX_UINT8 FCL_DATA, MX_BOOL FCL_TYPE);
void FCD_04071_LCD__RemapCharacter(MX_UINT8 FCL_REMAPIDX, MX_UINT8 FCL_SEARCHCHARACTER, MX_UINT8 FCL_REPLACEMENTCHARACTER);
void FCD_04071_LCD__Start();

/*========================================================================*\
   Use :lcd_eb005
       :Declarações de variaveis
       :Declarações de funções macro
\*========================================================================*/
#define FCD_0ad31_lcd_eb005__Clear FCD_04071_LCD__Clear
#define FCD_0ad31_lcd_eb005__PrintString FCD_04071_LCD__PrintString
#define FCD_0ad31_lcd_eb005__PrintAscii FCD_04071_LCD__PrintAscii
#define FCD_0ad31_lcd_eb005__PrintNumber FCD_04071_LCD__PrintNumber
#define FCD_0ad31_lcd_eb005__RAMWrite FCD_04071_LCD__RAMWrite
#define FCD_0ad31_lcd_eb005__ClearLine FCD_04071_LCD__ClearLine
#define FCD_0ad31_lcd_eb005__Cursor FCD_04071_LCD__Cursor
#define FCD_0ad31_lcd_eb005__Command FCD_04071_LCD__Command
#define FCD_0ad31_lcd_eb005__PrintFormattedNumber FCD_04071_LCD__PrintFormattedNumber
#define FCD_0ad31_lcd_eb005__ScrollDisplay FCD_04071_LCD__ScrollDisplay
#define FCD_0ad31_lcd_eb005__RawSend FCD_04071_LCD__RawSend
#define FCD_0ad31_lcd_eb005__RemapCharacter FCD_04071_LCD__RemapCharacter
#define FCD_0ad31_lcd_eb005__Start FCD_04071_LCD__Start

/*========================================================================*\
   Use :Include the chip adaption layer
\*========================================================================*/
#include "C:\Program Files (x86)\Flowcode 7\CAL\includes.c"


/*========================================================================*\
   Use :ButtonCtrl
       :Implementações de macro
\*========================================================================*/

/*========================================================================*\
   Use :switch_base
       :Implementações de macro
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :Reads the button state as 0 for released or 1 for pressed
       :Performs debounce if required
       :
       :Retorna : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCD_05262_switch_base__ReadState()
{
    //Definições de variável local
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;
    MX_UINT8 FCR_RETVAL;


    #if (1)

        if (0 != FCP_GET(B, D, 0x8, 0x3))
        {

            FCR_RETVAL = 1;

        } else {

            FCR_RETVAL = 0;

        }

        FCL_DEL_COUNT = 0;
        FCL_OLD_SWITCHVAL = FCR_RETVAL;

        #if (1) // 10 > 0

            while (FCL_DEL_COUNT < 10)
            {

                FCI_DELAYBYTE_MS(1);

                if (0 != FCP_GET(B, D, 0x8, 0x3))
                {

                    FCR_RETVAL = 1;

                } else {

                    FCR_RETVAL = 0;

                }

                if (FCR_RETVAL == FCL_OLD_SWITCHVAL)
                {

                    FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                } else {

                    FCL_DEL_COUNT = 0;

                }

                FCL_OLD_SWITCHVAL = FCR_RETVAL;


            }

        // #else

        //Código foi otimizado pelo pré-processador
        #endif

    #else

    //Código foi otimizado pelo pré-processador
    #endif

    return (FCR_RETVAL);

}

/*=----------------------------------------------------------------------=*\
   Use :Waits until the switch is in state 'high'
       :The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05262_switch_base__WaitUntilHigh()
{
    //Definições de variável local
    MX_UINT8 FCL_SWITCHVAL = (0xff); // The state of the pin
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;


    #if (1)

        while (1)
        {

            FCL_SWITCHVAL = FCP_GET(B, D, 0x8, 0x3);

            #if (0) // 0 == 1

            //Código foi otimizado pelo pré-processador
            // #else

            #endif

            FCL_DEL_COUNT = 0;
            FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;

            #if (1) // 10 > 0

                while (FCL_DEL_COUNT < 10)
                {

                    FCI_DELAYBYTE_MS(1);

                    FCL_SWITCHVAL = FCP_GET(B, D, 0x8, 0x3);

                    #if (0) // 0 == 1

                    //Código foi otimizado pelo pré-processador
                    // #else

                    #endif

                    if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)
                    {

                        FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                    } else {

                        FCL_DEL_COUNT = 0;

                    }

                    FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;


                }

            // #else

            //Código foi otimizado pelo pré-processador
            #endif


            if ((FCL_SWITCHVAL == 0) == 0) break;
        }

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

}

/*=----------------------------------------------------------------------=*\
   Use :Waits until the switch is in state 'low'
       :The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05262_switch_base__WaitUntilLow()
{
    //Definições de variável local
    MX_UINT8 FCL_SWITCHVAL; // The state of the pin
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;


    #if (1)

        while (1)
        {

            FCL_SWITCHVAL = FCP_GET(B, D, 0x8, 0x3);

            #if (0) // 0 == 1

            //Código foi otimizado pelo pré-processador
            // #else

            #endif

            FCL_DEL_COUNT = 0;
            FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;

            #if (1) // 10 > 0

                while (FCL_DEL_COUNT < 10)
                {

                    FCI_DELAYBYTE_MS(1);

                    FCL_SWITCHVAL = FCP_GET(B, D, 0x8, 0x3);

                    #if (0) // 0 == 1

                    //Código foi otimizado pelo pré-processador
                    // #else

                    #endif

                    if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)
                    {

                        FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                    } else {

                        FCL_DEL_COUNT = 0;

                    }

                    FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;


                }

            // #else

            //Código foi otimizado pelo pré-processador
            #endif


            if ((FCL_SWITCHVAL != 0) == 0) break;
        }

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

}


/*========================================================================*\
   Use :ButtonCtrl
       :Implementações de macro
\*========================================================================*/

/*========================================================================*\
   Use :switch_base
       :Implementações de macro
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :Reads the button state as 0 for released or 1 for pressed
       :Performs debounce if required
       :
       :Retorna : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCD_05261_switch_base__ReadState()
{
    //Definições de variável local
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;
    MX_UINT8 FCR_RETVAL;


    #if (1)

        if (0 != FCP_GET(B, D, 0x4, 0x2))
        {

            FCR_RETVAL = 1;

        } else {

            FCR_RETVAL = 0;

        }

        FCL_DEL_COUNT = 0;
        FCL_OLD_SWITCHVAL = FCR_RETVAL;

        #if (1) // 10 > 0

            while (FCL_DEL_COUNT < 10)
            {

                FCI_DELAYBYTE_MS(1);

                if (0 != FCP_GET(B, D, 0x4, 0x2))
                {

                    FCR_RETVAL = 1;

                } else {

                    FCR_RETVAL = 0;

                }

                if (FCR_RETVAL == FCL_OLD_SWITCHVAL)
                {

                    FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                } else {

                    FCL_DEL_COUNT = 0;

                }

                FCL_OLD_SWITCHVAL = FCR_RETVAL;


            }

        // #else

        //Código foi otimizado pelo pré-processador
        #endif

    #else

    //Código foi otimizado pelo pré-processador
    #endif

    return (FCR_RETVAL);

}

/*=----------------------------------------------------------------------=*\
   Use :Waits until the switch is in state 'high'
       :The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05261_switch_base__WaitUntilHigh()
{
    //Definições de variável local
    MX_UINT8 FCL_SWITCHVAL = (0xff); // The state of the pin
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;


    #if (1)

        while (1)
        {

            FCL_SWITCHVAL = FCP_GET(B, D, 0x4, 0x2);

            #if (0) // 0 == 1

            //Código foi otimizado pelo pré-processador
            // #else

            #endif

            FCL_DEL_COUNT = 0;
            FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;

            #if (1) // 10 > 0

                while (FCL_DEL_COUNT < 10)
                {

                    FCI_DELAYBYTE_MS(1);

                    FCL_SWITCHVAL = FCP_GET(B, D, 0x4, 0x2);

                    #if (0) // 0 == 1

                    //Código foi otimizado pelo pré-processador
                    // #else

                    #endif

                    if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)
                    {

                        FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                    } else {

                        FCL_DEL_COUNT = 0;

                    }

                    FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;


                }

            // #else

            //Código foi otimizado pelo pré-processador
            #endif


            if ((FCL_SWITCHVAL == 0) == 0) break;
        }

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

}

/*=----------------------------------------------------------------------=*\
   Use :Waits until the switch is in state 'low'
       :The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05261_switch_base__WaitUntilLow()
{
    //Definições de variável local
    MX_UINT8 FCL_SWITCHVAL; // The state of the pin
    MX_UINT16 FCL_DEL_COUNT;
    MX_UINT8 FCL_OLD_SWITCHVAL;


    #if (1)

        while (1)
        {

            FCL_SWITCHVAL = FCP_GET(B, D, 0x4, 0x2);

            #if (0) // 0 == 1

            //Código foi otimizado pelo pré-processador
            // #else

            #endif

            FCL_DEL_COUNT = 0;
            FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;

            #if (1) // 10 > 0

                while (FCL_DEL_COUNT < 10)
                {

                    FCI_DELAYBYTE_MS(1);

                    FCL_SWITCHVAL = FCP_GET(B, D, 0x4, 0x2);

                    #if (0) // 0 == 1

                    //Código foi otimizado pelo pré-processador
                    // #else

                    #endif

                    if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)
                    {

                        FCL_DEL_COUNT = FCL_DEL_COUNT + 1;

                    } else {

                        FCL_DEL_COUNT = 0;

                    }

                    FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;


                }

            // #else

            //Código foi otimizado pelo pré-processador
            #endif


            if ((FCL_SWITCHVAL != 0) == 0) break;
        }

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

}


/*========================================================================*\
   Use :ctrl_lcd
       :Implementações de macro
\*========================================================================*/

/*========================================================================*\
   Use :LCD
       :Implementações de macro
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :Clears the entire contents of the display.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Clear()
{




    FCD_04071_LCD__RawSend(0x01, 0);

    FCI_DELAYBYTE_MS(2);

    FCD_04071_LCD__RawSend(0x02, 0);

    FCI_DELAYBYTE_MS(2);

}

/*=----------------------------------------------------------------------=*\
   Use :Breaks down a string of text and sends it to the LCD via the private RawSend(byte, mask) macro
       :
       :Par??metros para a macro PrintString:
       :  Text[20] : Enter the text or variable to print to the LCD
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintString(MX_CHAR *FCL_TEXT, MX_UINT16 FCLsz_TEXT)
{
    //Definições de variável local
    MX_UINT8 FCL_IDX = (0x0);
    MX_UINT8 FCL_COUNT;


    FCL_COUNT = FCI_GETLENGTH(FCL_TEXT, FCLsz_TEXT);

    while (FCL_IDX < FCL_COUNT)
    {

        #if (0) // 0 > 0

        //Código foi otimizado pelo pré-processador
        #else


            FCD_04071_LCD__RawSend(FCL_TEXT[FCL_IDX], 0x10);

        #endif

        FCL_IDX = FCL_IDX + 1;


    }


}

/*=----------------------------------------------------------------------=*\
   Use :Takes the ascii value for a character and prints the character
       :
       :Par??metros para a macro PrintAscii:
       :  character : Holds an ascii value.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintAscii(MX_UINT8 FCL_CHARACTER)
{

    FCD_04071_LCD__RawSend(FCL_CHARACTER, 0x10);



}

/*=----------------------------------------------------------------------=*\
   Use :Based on v5 macro, will allow you to print a number. This is limited to a signed-INT, -32768 to 32767
       :
       :Par??metros para a macro PrintNumber:
       :  Number : Enter the number or variable to print to the LCD
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintNumber(MX_SINT16 FCL_NUMBER)
{
    //Definições de variável local
    #define FCLsz_S 10
    MX_CHAR FCL_S[FCLsz_S];


    FCI_TOSTRING(FCL_NUMBER, FCL_S,10);

    FCD_04071_LCD__PrintString(FCL_S, FCLsz_S);

    //Definições de variável local
    #undef FCLsz_S
}

/*=----------------------------------------------------------------------=*\
   Use :Modifies the internal memory of the LCD to allow for up to 8 customised characters to be created and stored in the device memory
       :
       :Par??metros para a macro RAMWrite:
       :  Index : Values 0 to 7
       :  d0 : MX_UINT8
       :  d1 : MX_UINT8
       :  d2 : MX_UINT8
       :  d3 : MX_UINT8
       :  d4 : MX_UINT8
       :  d5 : MX_UINT8
       :  d6 : MX_UINT8
       :  d7 : MX_UINT8
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__RAMWrite(MX_UINT8 FCL_INDEX, MX_UINT8 FCL_D0, MX_UINT8 FCL_D1, MX_UINT8 FCL_D2, MX_UINT8 FCL_D3, MX_UINT8 FCL_D4, MX_UINT8 FCL_D5, MX_UINT8 FCL_D6, MX_UINT8 FCL_D7)
{

    FCD_04071_LCD__RawSend(64 + (FCL_INDEX << 3), 0);

    FCI_DELAYBYTE_MS(2);

    FCD_04071_LCD__RawSend(FCL_D0, 0x10);

    FCD_04071_LCD__RawSend(FCL_D1, 0x10);

    FCD_04071_LCD__RawSend(FCL_D2, 0x10);

    FCD_04071_LCD__RawSend(FCL_D3, 0x10);

    FCD_04071_LCD__RawSend(FCL_D4, 0x10);

    FCD_04071_LCD__RawSend(FCL_D5, 0x10);

    FCD_04071_LCD__RawSend(FCL_D6, 0x10);

    FCD_04071_LCD__RawSend(FCL_D7, 0x10);

    FCD_04071_LCD__Clear();

}

/*=----------------------------------------------------------------------=*\
   Use :Clears a single line on the display and then moves the cursor to the start of the line to allow you to start populating the line with data.
       :
       :Par??metros para a macro ClearLine:
       :  Line : The line to clear, zero being the first (top) line of the display
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__ClearLine(MX_UINT8 FCL_LINE)
{
    //Definições de variável local
    MX_UINT8 FCL_X;


    if (FCL_LINE < 2)
    {

        FCD_04071_LCD__Cursor(0, FCL_LINE);

        FCL_X = 0;

        while (FCL_X < 16)
        {


            FCD_04071_LCD__RawSend(' ', 0x10);

            FCL_X = FCL_X + 1;


        }

        FCD_04071_LCD__Cursor(0, FCL_LINE);

    // } else {

    }

}

/*=----------------------------------------------------------------------=*\
   Use :Moves the cursor on the LCD Display
       :
       :Par??metros para a macro Cursor:
       :  x : Set the cursor position in the X plane, 0 is the left most cell
       :  y : Set the cursor position in the Y plane, 0 is the top most cell
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Cursor(MX_UINT8 FCL_X, MX_UINT8 FCL_Y)
{



    #if (0) // 2 == 1

    //Código foi otimizado pelo pré-processador
    // #else

    #endif

    #if (1) // 2 == 2

        if (FCL_Y == 0)
        {

            FCL_Y = 0x80;

        } else {

            FCL_Y = 0xC0;

        }

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

    #if (0) // 2 == 4

    //Código foi otimizado pelo pré-processador
    // #else

    #endif

    FCD_04071_LCD__RawSend(FCL_Y + FCL_X, 0);

    FCI_DELAYBYTE_MS(2);

}

/*=----------------------------------------------------------------------=*\
   Use :Use this method/macro to send a specific command to the LCD. Refer to the Matrix Multimedia EB006 datasheet for a list of supported instructions. For Non-Matrix LCD's refer to the manufacturers datasheet.
       :
       :Par??metros para a macro Command:
       :  instruction : Send a defined command to the LCD Screen. See datasheet for supported commands.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Command(MX_UINT8 FCL_INSTRUCTION)
{

    FCD_04071_LCD__RawSend(FCL_INSTRUCTION, 0);

    FCI_DELAYBYTE_MS(2);

}

/*=----------------------------------------------------------------------=*\
   Use :Will allow you to print a number up to 32-bits with signed or unsigned formatting.
       :Signed = -2147483648 to 2147483647
       :Unsigned = 0 to 4294967295
       :
       :Par??metros para a macro PrintFormattedNumber:
       :  Number : Enter the number or variable to print to the LCD
       :  Format : 0=Signed, 1=Unsigned
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintFormattedNumber(MX_UINT32 FCL_NUMBER, MX_BOOL FCL_FORMAT)
{
    //Definições de variável local
    #define FCLsz_S 15
    MX_CHAR FCL_S[FCLsz_S];


    if (FCL_FORMAT == 1)
    {

        FCI_UTOS32(FCL_NUMBER, FCL_S,15);

    } else {

        FCI_ITOS32((MX_SINT32)(FCL_NUMBER), FCL_S,15);

    }

    FCD_04071_LCD__PrintString(FCL_S, FCLsz_S);

    //Definições de variável local
    #undef FCLsz_S
}

/*=----------------------------------------------------------------------=*\
   Use :Scrolls the display left or right by a number of given positions.
       :
       :Par??metros para a macro ScrollDisplay:
       :  Position : Holds the number of positions to shift the display
       :  Direction : 0 = left, 1 = right
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__ScrollDisplay(MX_UINT8 FCL_POSITION, MX_UINT8 FCL_DIRECTION)
{
    //Definições de variável local
    MX_UINT8 FCL_CMD = (0x0);


    FCL_CMD = 0;

    if (FCL_DIRECTION == 0)
    {

        FCL_CMD = 0x18;


    } else {

        FCL_CMD = 0x1C;


    }

    if (FCL_CMD != 0 && FCL_POSITION != 0)
    {

        while (FCL_POSITION != 0)
        {

            FCD_04071_LCD__RawSend(FCL_CMD, 0);

            FCL_POSITION = FCL_POSITION - 1;


        }

    // } else {

    }

}

/*=----------------------------------------------------------------------=*\
   Use :Sends data to the LCD display
       :
       :Par??metros para a macro RawSend:
       :  data : The data byte to send to the LCD
       :  type : A boolean to indicate command type: true to write data, false to write a command
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__RawSend(MX_UINT8 FCL_DATA, MX_BOOL FCL_TYPE)
{
    //Definições de variável local
    MX_UINT8 FCL_NIBBLE;


    //Comentário:
    //Output upper nibble of the byte

    #if (1) // 0 == 0

        FCP_SET(B, B, 0x1, 0x0, 0);
        FCP_SET(B, B, 0x2, 0x1, 0);
        FCP_SET(B, B, 0x4, 0x2, 0);
        FCP_SET(B, B, 0x8, 0x3, 0);
        FCP_SET(B, B, 0x10, 0x4, 0);
        FCP_SET(B, B, 0x20, 0x5, 0);

        #if (0)

        //Código foi otimizado pelo pré-processador
        // #else

        #endif

        FCL_NIBBLE = (FCL_DATA >> 4);
        FCP_SET(B, B, 0x1, 0x0, (FCL_NIBBLE & 0x01));
        FCL_NIBBLE = FCL_NIBBLE >> 1;
        FCP_SET(B, B, 0x2, 0x1, (FCL_NIBBLE & 0x01));
        FCL_NIBBLE = FCL_NIBBLE >> 1;
        FCP_SET(B, B, 0x4, 0x2, (FCL_NIBBLE & 0x01));
        FCL_NIBBLE = FCL_NIBBLE >> 1;
        FCP_SET(B, B, 0x8, 0x3, (FCL_NIBBLE & 0x01));

    // #else

    //Código foi otimizado pelo pré-processador
    #endif

    //Comentário:
    //Output byte to pins

    #if (0) // 0 == 1

    //Código foi otimizado pelo pré-processador
...

This file has been truncated, please download it to see its full contents.

Credits

Silícios Lab

Silícios Lab

73 projects • 176 followers
Hello, I love program microcontrollers and works with electronic projects.
PCBWay

PCBWay

94 projects • 149 followers
We are a PCB and assembly manufacturer, As low as $5/10pcs and 24 hours delivery time. We are committed to helping creators build project.

Comments