Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How can i reduce my program size

waqasbjwaqasbj Member Posts: 4
Hello every body ,
Can any one help me sorting out my prob,the problem is regarding my prgram of making a coffe machine .i am currently working on Pic micros`s .i have made all the program but the main problem is the microprocessor memory size. the memory size i got is 1K but my program is bigger then this .i have tried a lot but couldnt do any thing about it .if any body can help me sorting out my problem. thank you.

Comments

  • IDKIDK Member Posts: 1,784
    : Hello every body ,
    : Can any one help me sorting out my prob,the problem is regarding my prgram of making a coffe machine .i am currently working on Pic micros`s .i have made all the program but the main problem is the microprocessor memory size. the memory size i got is 1K but my program is bigger then this .i have tried a lot but couldnt do any thing about it .if any body can help me sorting out my problem. thank you.
    :
    Make the program in assembly!
    This will make the program the fastest and smallest possible.
    This is what assembly was made for.

    Another way would be to look at the funcs that are big, and rewrite them.
  • waqasbjwaqasbj Member Posts: 4
    Probelm with my program is that i cant make it in assembly .i have to make it in c language and secondly i dont know assembly language it is ll be difficult to learn assembly language in few day.about function i ll have a good look on it again .thankx
  • LundinLundin Member Posts: 3,711
    : Hello every body ,
    : Can any one help me sorting out my prob,the problem is regarding my prgram of making a coffe machine .i am currently working on Pic micros`s .i have made all the program but the main problem is the microprocessor memory size. the memory size i got is 1K but my program is bigger then this .i have tried a lot but couldnt do any thing about it .if any body can help me sorting out my problem. thank you.
    :


    1K what? RAM or flash? Assuming flash.

    You aren't calling C library functions, I hope?
    If you do, start with replacing them with your own functions.

    Apart from that, there is really nothing we can do to help you without looking at the code.
  • IDKIDK Member Posts: 1,784
    : Probelm with my program is that i cant make it in assembly .i have to make it in c language and secondly i dont know assembly language it is ll be difficult to learn assembly language in few day.about function i ll have a good look on it again .thankx
    :
    Sorry for my little rude answear but this is where asm is at its expertese.
    (I'm making a game now, and it's like 300 byte!)

    Please post your code, or parts of it, and I could maybe find something to improve...

    Happy coding wishes
    the one and only
    [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

  • waqasbjwaqasbj Member Posts: 4
    Hi again , this is my program , processor i am using is pic16f84 which 1024 K flash .half of the prgrma is working but if i include next half compiler keeps on giving me memory sortage error.

    #include
    #include"LCDdrive.h"
    #include"func.h"
    #include
    void KeyScan(void);
    void menu (void);
    unsigned char Key = 0, Menu = 0, LastMenu = 0, MenuTimer = 0, Percent1 = 50;
    unsigned char Percent2 = 50, Percent3 = 50, CycleTimer = 1, Starttimer = 1;

    /****************************************************************/
    /*void KeyScan(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Scans the inputs to see if a button has been pressed. */
    /* If a button is being pressed "Key" is set to the value */
    /* of that button. */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void KeyScan(void)
    {
    Key = 0;
    if (RA0==1) // UP
    Key = 1;
    if (RA1==1) // DOWN
    Key = 2;
    if (RA2==1) // SET
    Key = 3;
    } // KeyScan Subroutine

    /****************************************************************/
    /*void MenuShow(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Changes the displayed screen depending on which */
    /* key is pressed */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void MenuShow(void)
    {
    switch (Menu)
    {
    case 0:
    {
    if (Key == 0)
    {

    }

    case 2: // Displays ALARMS / FANS
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">ALARM SETUP ");
    LCD_cursor(0,1);
    LCD_puts(" FAN SETUP ");
    } // if
    if (Key == 1) // UP
    Menu = 3;
    if (Key == 2) // DOWN
    Menu = 3;
    if (Key == 3) // SET
    Menu = 4;
    break;
    }

    case 3:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(" ");
    LCD_cursor(0,1);
    LCD_puts(">");
    } // if
    if (Key == 1) // UP
    Menu = 2;
    if (Key == 2) // DOWN
    Menu = 2;
    if (Key == 3) // SET
    Menu = 7;
    break;
    }

    case 4:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(" Alarm2 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 6;
    if (Key == 2) // DOWN
    Menu = 5;
    if (Key == 3) // SET
    {
    LastMenu = 4;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 5:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 4;
    if (Key == 2) // DOWN
    Menu = 6;
    if (Key == 3) // SET
    {
    LastMenu = 5;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 6:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 5;
    if (Key == 2) // DOWN
    Menu = 4;
    if (Key == 3) // SET
    {
    LastMenu = 6;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 7:
    {
    if (Key == 0)
    {

    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 9;
    if (Key == 2) // DOWN
    Menu = 8;
    if (Key == 3) // SET
    {
    LastMenu = 7;
    Menu = 10; // Changes the settings - modify
    } // if
    break;
    }

    case 8:
    {
    if (Key == 0)
    {
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 7;
    if (Key == 2) // DOWN
    Menu = 9;
    if (Key == 3) // SET
    {
    LastMenu = 8;
    Menu = 10; // Changes the settings - modify
    } // if
    break;
    }

    case 9:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");

    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 8;
    if (Key == 2) // DOWN
    Menu = 7;
    if (Key == 3) // SET
    {
    LastMenu=9;
    Menu = 9; // Changes the settings - modify
    } // if
    break;
    }

    }
    } // Switch Menu
    } // MenuShow Subroutine


    /****************************************************************/
    /*void main(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Initializes all variables; */
    /* Displays first few menu items on lcd; */
    /* And controls which menu is being displayed. */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void main(void)
    {

    sys_init();
    LCD_initialise();
    while (1)
    {
    KeyScan(); // Check is a Key is being pressed

    if (Key != 0) // Reset the menutimer every time a key is pressed
    MenuTimer = 0;

    if (Starttimer == 0)
    MenuShow(); // Display the selected Menu



    while (Key != 0) // Debounce keys - wait until keys are released
    KeyScan();

    del(); // Timer to escape back out of menu after specified time
    MenuTimer += 1;
    if (MenuTimer == 50)
    {
    MenuTimer = 0; // Resets MenuTimer
    if (Starttimer == 1)
    Starttimer = 0;

    CycleTimer += 1; // Adjust timer to Cycle main screen
    if (CycleTimer == 4)
    CycleTimer = 1;

    // Decide which menu to go to after 5 sec. delay
    switch (Menu)
    {
    case 2:
    {
    Menu = 0;
    break;
    }
    case 3:
    {
    Menu = 0;
    break;
    }
    case 4:
    {
    Menu = 2;
    break;
    }
    case 5:
    {
    Menu = 2;
    break;
    }
    case 6:
    {
    Menu = 2;
    break;
    }
    case 7:
    {
    Menu = 2;
    break;
    }
    case 8:
    {
    Menu = 2;
    break;
    }
    case 9:
    {
    Menu = 2;
    break;
    }

    } // Switch Menu
    } // If Menutimer = 100
    } // Main While Loop
    } // Main Program


    Another c Prgram associated with it
    #include
    #include"func.h"
    void sys_init(void)
    {
    RP0=1; /*select Bank 1 */
    OPTION = 0x07;
    TRISB=0x00; /*make PORTB output and input */
    TRISA=0xFF; /*make PORTA input */
    OPTION=0x07; /*Configure Timer 0*/
    RP0=0; /* Select Bank 0*/
    INTCON=0xa0; /*Configure Interrupts*/
    TMR0=0x00; /*select bank 0*/
    PORTB=0x00; /* clear all leds on PORTB*/
    }

    void RB6_flash (char i)

    {
    char a;
    for(a=0;a

    // LCD Driver module
    // LCD module is connected as follows:
    // RB0 - RB3 -> DB4 - DB7
    // RB4 -> RS
    // RB5 -> E

    // define constants
    #define RS RB4 // RS control line is bit 4 of port B
    #define E RB5 // E control line is bit 5 of port B
    #define LCD_INIT 0x33 // command to initialise LCD display
    #define FOUR_BIT_MODE 0x32 // command to make the LCD transfer instructions and data in 4 bit chunks rather than 8
    #define TWO_LINE_MODE 0x2c // command to put the LCD in two-line mode
    #define MOVE_AFTER_WRITE 0x06 // command to increment cursor position automatically
    #define DISPLAY_INIT 0x0c // command to turn display on, switch off the cursor and stop it blinking

    #define WRITE_DELAY 200 // constant used to set write delay time (50 us required)
    #define BIT_DELAY 2 // constant used to set pulse duration (a few us required)
    #define INST_DELAY 1000 // constant used to det instruction delay (1.53 ms required)

    // FUNCTION EXTERNAL FUNCTION REFERENCES


    // FUNCTION ADVANCE DECLARATIONS
    void LCD_write(unsigned char c, unsigned char rs); // basic write function (instruction or data depending on rs)
    void LCD_initialise(void); // send initialisation commands to LCD
    void LCD_clear(void); // function to clear LCD display and home the cursor
    void LCD_delay(unsigned int D); // function to generate a delay
    void pulse_E(void); // function to pulse E pin high then low
    void LCD_putch(unsigned char c); // character output routine
    void LCD_puts(unsigned char *s); // Writes string s to LCD
    void LCD_cursor (unsigned char x, unsigned char y ); // Moves cursor to x,y
    //void LCD_cursor_on (void); // Turn cursor on
    //void LCD_cursor_off (void); // Turn cursor off
    // Display a numeric value (0-999)

    // Initialise LCD module
    void LCD_initialise(void)
    {

    // INITIALISE LCD
    LCD_write(LCD_INIT, 0); // command to initialise LCD display, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Set LCD for 4-bit mode
    LCD_write(FOUR_BIT_MODE, 0); // command to set LCD in 4-bit mode, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // set LCD in up for two lines
    LCD_write(TWO_LINE_MODE, 0); // command to set LCD for two lines, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Select move after write
    LCD_write(MOVE_AFTER_WRITE, 0); // command to set LCD to increment cursor pos. automatically (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Configure display & cursor
    LCD_write(DISPLAY_INIT, 0); // command to configure display, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    LCD_clear();
    }



    // LCD_write() function is a basic write subroutine that could be an instruction or data
    void LCD_write(unsigned char c, unsigned char rs)
    {
    unsigned char temp; // temporary variable to hold ms 4 bits of c
    unsigned char RSmask = 0; // used to set or reset bit 4 of PORTB
    unsigned char TRISB_BAK; // Current status of port B data direction register

    // INITIALISATION
    RP0 = 1; // get ready to write to data direction registers
    TRISB_BAK = TRISB; // Get current state of TRISB register
    TRISB = 0x00; // Set PORTB bits 0 - 7 as outputs
    RP0 = 0; // get ready to use ports

    if (rs == 1) RSmask = 0x10; // set up bit mask for RS line

    // set MS 4 bits of c up on RB0 - RB3
    temp = c;
    PORTB = (temp >> 4) | RSmask; // shift MS 4 bits into LS 4 bits, set/rst RS and present on PORTB

    // pulse E high then low
    pulse_E(); // call function to strobe data to LCD module

    // set LS 4 bits up on RB0 - RB3
    PORTB = (c & 0x0F) | RSmask; // present LS 4 bits on RB0 - RB3 and set/rst RS line

    // pulse E high then low
    pulse_E(); // Call function to strobe data to LCD module

    PORTB = 0x10; // set E high again to avoid annoying LED flicker

    RP0 = 1; // get ready to write to data direction registers
    TRISB = TRISB_BAK; // Restore state of TRISB register
    RP0 = 0; // get ready to use ports
    }


    //putch(c) function is character output routine
    void LCD_putch(unsigned char c)
    {
    LCD_write(c, 1); // call basic LCD write routine with RS high (send data)
    LCD_delay(WRITE_DELAY); // call function to wait until LCD has completed write operation
    }

    //LCD_clear() function is an instruction to clear all data from LCD display and return cursor to beginning of display
    void LCD_clear(void)
    {
    LCD_write(1, 0); // call basic write function with instruction 1, (clear display) and RS 0, (write instruction)
    LCD_delay(INST_DELAY); // Call function to wait until LCD has completed instruction
    LCD_write(2, 0); // call basic write function with instruction 2, (cursor home) and RS = 0, (write instruction)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    }

    // function to pulse E pin high then low with a duration of a few usecs
    void pulse_E(void)
    {
    // set E high and wait a bit
    E = 1; // set E line high
    LCD_delay(BIT_DELAY); // pulse delay for E

    // set E low and wait a bit
    E = 0; // set E line low
    LCD_delay(BIT_DELAY); // pulse delay for E

    }

    // Function to generate a delay
    void LCD_delay(unsigned int D)
    {
    unsigned int counter; // variable used as delay loop counter
    for (counter = 0; counter < D; counter++);
    }

    // Function to write null terminated string to LCD display
    void LCD_puts(unsigned char *s)
    {
    unsigned char c = 255;
    unsigned char i = 0;
    while ((c > 0) && (i < 16)) //16 is the maximum length of the string
    {
    c = s[i];
    if (c != 0) LCD_putch(c);
    i++;
    }
    }

    void LCD_cursor (unsigned char x, unsigned char y )
    {
    if ( y==0 )
    {
    //position for line 0
    y=0x80 ;
    }
    else
    {
    //position for line 1
    y=0xc0 ;
    }

    LCD_write( y+x, 0) ;
    }

    /*
    void LCD_cursor_on ( void ) // Turn cursor on
    {
    LCD_write(0x0f, 0);
    }

    void LCD_cursor_off ( void ) // Turn cursor off
    {
    LCD_write (0x0c, 0);
    }

    void LCD_display_value ( unsigned int value )
    {
    unsigned char hunds, tens, units ;

    first get the digits

    units = value % 10 ;
    value = value / 10 ;
    tens = value % 10 ;
    value = value / 10 ;
    hunds = value % 10 ;

    now display them

    LCD_putch('0' + hunds ) ;
    LCD_putch('0' + tens);
    LCD_putch('0' + units);
    }*/
    void LCD_DisplayRow (char row, char *string)
    {
    char i;
    LCD_cursor(0, row);
    for (i=0; i<16; i++)
    {
    LCD_putch (*string++);
    }

    }
    void LCD_DisplayScreen (char *ptr)
    {
    LCD_DisplayRow(0,ptr+ 0);
    LCD_DisplayRow(1,ptr+16);
    }



  • waqasbjwaqasbj Member Posts: 4
    Hi again , this is my program , processor i am using is pic16f84 which 1024 K flash .half of the prgrma is working but if i include next half compiler keeps on giving me memory sortage error.

    #include
    #include"LCDdrive.h"
    #include"func.h"
    #include
    void KeyScan(void);
    void menu (void);
    unsigned char Key = 0, Menu = 0, LastMenu = 0, MenuTimer = 0, Percent1 = 50;
    unsigned char Percent2 = 50, Percent3 = 50, CycleTimer = 1, Starttimer = 1;

    /****************************************************************/
    /*void KeyScan(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Scans the inputs to see if a button has been pressed. */
    /* If a button is being pressed "Key" is set to the value */
    /* of that button. */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void KeyScan(void)
    {
    Key = 0;
    if (RA0==1) // UP
    Key = 1;
    if (RA1==1) // DOWN
    Key = 2;
    if (RA2==1) // SET
    Key = 3;
    } // KeyScan Subroutine

    /****************************************************************/
    /*void MenuShow(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Changes the displayed screen depending on which */
    /* key is pressed */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void MenuShow(void)
    {
    switch (Menu)
    {
    case 0:
    {
    if (Key == 0)
    {

    }

    case 2: // Displays ALARMS / FANS
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">ALARM SETUP ");
    LCD_cursor(0,1);
    LCD_puts(" FAN SETUP ");
    } // if
    if (Key == 1) // UP
    Menu = 3;
    if (Key == 2) // DOWN
    Menu = 3;
    if (Key == 3) // SET
    Menu = 4;
    break;
    }

    case 3:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(" ");
    LCD_cursor(0,1);
    LCD_puts(">");
    } // if
    if (Key == 1) // UP
    Menu = 2;
    if (Key == 2) // DOWN
    Menu = 2;
    if (Key == 3) // SET
    Menu = 7;
    break;
    }

    case 4:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(" Alarm2 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 6;
    if (Key == 2) // DOWN
    Menu = 5;
    if (Key == 3) // SET
    {
    LastMenu = 4;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 5:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 4;
    if (Key == 2) // DOWN
    Menu = 6;
    if (Key == 3) // SET
    {
    LastMenu = 5;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 6:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 5;
    if (Key == 2) // DOWN
    Menu = 4;
    if (Key == 3) // SET
    {
    LastMenu = 6;
    Menu = 11; // Changes the settings - modify
    } // if
    break;
    }

    case 7:
    {
    if (Key == 0)
    {

    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 9;
    if (Key == 2) // DOWN
    Menu = 8;
    if (Key == 3) // SET
    {
    LastMenu = 7;
    Menu = 10; // Changes the settings - modify
    } // if
    break;
    }

    case 8:
    {
    if (Key == 0)
    {
    LCD_puts(">Alarm1 = %-i.%-u C ");
    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 7;
    if (Key == 2) // DOWN
    Menu = 9;
    if (Key == 3) // SET
    {
    LastMenu = 8;
    Menu = 10; // Changes the settings - modify
    } // if
    break;
    }

    case 9:
    {
    if (Key == 0)
    {
    LCD_cursor(0,0);
    LCD_puts(">Alarm1 = %-i.%-u C ");

    LCD_cursor(0,1);
    LCD_puts(">Alarm1 = %-i.%-u C ");
    } // if
    if (Key == 1) // UP
    Menu = 8;
    if (Key == 2) // DOWN
    Menu = 7;
    if (Key == 3) // SET
    {
    LastMenu=9;
    Menu = 9; // Changes the settings - modify
    } // if
    break;
    }

    }
    } // Switch Menu
    } // MenuShow Subroutine


    /****************************************************************/
    /*void main(void) */
    /* */
    /*Inputs: */
    /* none */
    /* */
    /*Outputs: */
    /* none */
    /* */
    /*Operation: */
    /* Initializes all variables; */
    /* Displays first few menu items on lcd; */
    /* And controls which menu is being displayed. */
    /* */
    /*By: Bernhard Spalteholz */
    /*Date: */
    /****************************************************************/

    void main(void)
    {

    sys_init();
    LCD_initialise();
    while (1)
    {
    KeyScan(); // Check is a Key is being pressed

    if (Key != 0) // Reset the menutimer every time a key is pressed
    MenuTimer = 0;

    if (Starttimer == 0)
    MenuShow(); // Display the selected Menu



    while (Key != 0) // Debounce keys - wait until keys are released
    KeyScan();

    del(); // Timer to escape back out of menu after specified time
    MenuTimer += 1;
    if (MenuTimer == 50)
    {
    MenuTimer = 0; // Resets MenuTimer
    if (Starttimer == 1)
    Starttimer = 0;

    CycleTimer += 1; // Adjust timer to Cycle main screen
    if (CycleTimer == 4)
    CycleTimer = 1;

    // Decide which menu to go to after 5 sec. delay
    switch (Menu)
    {
    case 2:
    {
    Menu = 0;
    break;
    }
    case 3:
    {
    Menu = 0;
    break;
    }
    case 4:
    {
    Menu = 2;
    break;
    }
    case 5:
    {
    Menu = 2;
    break;
    }
    case 6:
    {
    Menu = 2;
    break;
    }
    case 7:
    {
    Menu = 2;
    break;
    }
    case 8:
    {
    Menu = 2;
    break;
    }
    case 9:
    {
    Menu = 2;
    break;
    }

    } // Switch Menu
    } // If Menutimer = 100
    } // Main While Loop
    } // Main Program


    Another c Prgram associated with it
    #include
    #include"func.h"
    void sys_init(void)
    {
    RP0=1; /*select Bank 1 */
    OPTION = 0x07;
    TRISB=0x00; /*make PORTB output and input */
    TRISA=0xFF; /*make PORTA input */
    OPTION=0x07; /*Configure Timer 0*/
    RP0=0; /* Select Bank 0*/
    INTCON=0xa0; /*Configure Interrupts*/
    TMR0=0x00; /*select bank 0*/
    PORTB=0x00; /* clear all leds on PORTB*/
    }

    void RB6_flash (char i)

    {
    char a;
    for(a=0;a

    // LCD Driver module
    // LCD module is connected as follows:
    // RB0 - RB3 -> DB4 - DB7
    // RB4 -> RS
    // RB5 -> E

    // define constants
    #define RS RB4 // RS control line is bit 4 of port B
    #define E RB5 // E control line is bit 5 of port B
    #define LCD_INIT 0x33 // command to initialise LCD display
    #define FOUR_BIT_MODE 0x32 // command to make the LCD transfer instructions and data in 4 bit chunks rather than 8
    #define TWO_LINE_MODE 0x2c // command to put the LCD in two-line mode
    #define MOVE_AFTER_WRITE 0x06 // command to increment cursor position automatically
    #define DISPLAY_INIT 0x0c // command to turn display on, switch off the cursor and stop it blinking

    #define WRITE_DELAY 200 // constant used to set write delay time (50 us required)
    #define BIT_DELAY 2 // constant used to set pulse duration (a few us required)
    #define INST_DELAY 1000 // constant used to det instruction delay (1.53 ms required)

    // FUNCTION EXTERNAL FUNCTION REFERENCES


    // FUNCTION ADVANCE DECLARATIONS
    void LCD_write(unsigned char c, unsigned char rs); // basic write function (instruction or data depending on rs)
    void LCD_initialise(void); // send initialisation commands to LCD
    void LCD_clear(void); // function to clear LCD display and home the cursor
    void LCD_delay(unsigned int D); // function to generate a delay
    void pulse_E(void); // function to pulse E pin high then low
    void LCD_putch(unsigned char c); // character output routine
    void LCD_puts(unsigned char *s); // Writes string s to LCD
    void LCD_cursor (unsigned char x, unsigned char y ); // Moves cursor to x,y
    //void LCD_cursor_on (void); // Turn cursor on
    //void LCD_cursor_off (void); // Turn cursor off
    // Display a numeric value (0-999)

    // Initialise LCD module
    void LCD_initialise(void)
    {

    // INITIALISE LCD
    LCD_write(LCD_INIT, 0); // command to initialise LCD display, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Set LCD for 4-bit mode
    LCD_write(FOUR_BIT_MODE, 0); // command to set LCD in 4-bit mode, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // set LCD in up for two lines
    LCD_write(TWO_LINE_MODE, 0); // command to set LCD for two lines, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Select move after write
    LCD_write(MOVE_AFTER_WRITE, 0); // command to set LCD to increment cursor pos. automatically (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    // Configure display & cursor
    LCD_write(DISPLAY_INIT, 0); // command to configure display, (RS = 0)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction

    LCD_clear();
    }



    // LCD_write() function is a basic write subroutine that could be an instruction or data
    void LCD_write(unsigned char c, unsigned char rs)
    {
    unsigned char temp; // temporary variable to hold ms 4 bits of c
    unsigned char RSmask = 0; // used to set or reset bit 4 of PORTB
    unsigned char TRISB_BAK; // Current status of port B data direction register

    // INITIALISATION
    RP0 = 1; // get ready to write to data direction registers
    TRISB_BAK = TRISB; // Get current state of TRISB register
    TRISB = 0x00; // Set PORTB bits 0 - 7 as outputs
    RP0 = 0; // get ready to use ports

    if (rs == 1) RSmask = 0x10; // set up bit mask for RS line

    // set MS 4 bits of c up on RB0 - RB3
    temp = c;
    PORTB = (temp >> 4) | RSmask; // shift MS 4 bits into LS 4 bits, set/rst RS and present on PORTB

    // pulse E high then low
    pulse_E(); // call function to strobe data to LCD module

    // set LS 4 bits up on RB0 - RB3
    PORTB = (c & 0x0F) | RSmask; // present LS 4 bits on RB0 - RB3 and set/rst RS line

    // pulse E high then low
    pulse_E(); // Call function to strobe data to LCD module

    PORTB = 0x10; // set E high again to avoid annoying LED flicker

    RP0 = 1; // get ready to write to data direction registers
    TRISB = TRISB_BAK; // Restore state of TRISB register
    RP0 = 0; // get ready to use ports
    }


    //putch(c) function is character output routine
    void LCD_putch(unsigned char c)
    {
    LCD_write(c, 1); // call basic LCD write routine with RS high (send data)
    LCD_delay(WRITE_DELAY); // call function to wait until LCD has completed write operation
    }

    //LCD_clear() function is an instruction to clear all data from LCD display and return cursor to beginning of display
    void LCD_clear(void)
    {
    LCD_write(1, 0); // call basic write function with instruction 1, (clear display) and RS 0, (write instruction)
    LCD_delay(INST_DELAY); // Call function to wait until LCD has completed instruction
    LCD_write(2, 0); // call basic write function with instruction 2, (cursor home) and RS = 0, (write instruction)
    LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    }

    // function to pulse E pin high then low with a duration of a few usecs
    void pulse_E(void)
    {
    // set E high and wait a bit
    E = 1; // set E line high
    LCD_delay(BIT_DELAY); // pulse delay for E

    // set E low and wait a bit
    E = 0; // set E line low
    LCD_delay(BIT_DELAY); // pulse delay for E

    }

    // Function to generate a delay
    void LCD_delay(unsigned int D)
    {
    unsigned int counter; // variable used as delay loop counter
    for (counter = 0; counter < D; counter++);
    }

    // Function to write null terminated string to LCD display
    void LCD_puts(unsigned char *s)
    {
    unsigned char c = 255;
    unsigned char i = 0;
    while ((c > 0) && (i < 16)) //16 is the maximum length of the string
    {
    c = s[i];
    if (c != 0) LCD_putch(c);
    i++;
    }
    }

    void LCD_cursor (unsigned char x, unsigned char y )
    {
    if ( y==0 )
    {
    //position for line 0
    y=0x80 ;
    }
    else
    {
    //position for line 1
    y=0xc0 ;
    }

    LCD_write( y+x, 0) ;
    }

    /*
    void LCD_cursor_on ( void ) // Turn cursor on
    {
    LCD_write(0x0f, 0);
    }

    void LCD_cursor_off ( void ) // Turn cursor off
    {
    LCD_write (0x0c, 0);
    }

    void LCD_display_value ( unsigned int value )
    {
    unsigned char hunds, tens, units ;

    first get the digits

    units = value % 10 ;
    value = value / 10 ;
    tens = value % 10 ;
    value = value / 10 ;
    hunds = value % 10 ;

    now display them

    LCD_putch('0' + hunds ) ;
    LCD_putch('0' + tens);
    LCD_putch('0' + units);
    }*/
    void LCD_DisplayRow (char row, char *string)
    {
    char i;
    LCD_cursor(0, row);
    for (i=0; i<16; i++)
    {
    LCD_putch (*string++);
    }

    }
    void LCD_DisplayScreen (char *ptr)
    {
    LCD_DisplayRow(0,ptr+ 0);
    LCD_DisplayRow(1,ptr+16);
    }

  • LundinLundin Member Posts: 3,711
    Start with removing as much code as possible from the switch in MenuShow. You should only need to set variables inside it - call every function from outside it sence you are doing more or less the same things inside every case. The code will be smaller and easier to read.
  • IDKIDK Member Posts: 1,784
    [b][red]This message was edited by IDK at 2006-3-17 7:26:41[/red][/b][hr]
    I don't know how much you need optimising, but I should suggest rewriting the menu swich. I would have done it the OO way, creating some objects. Maybe like this:

    Two pointers to strings pointing to the texts that should be printed.
    Four bytes defining the menu opertations that should take place.
    (I don't acctually know C/C++ but I know the rest ;-))

    Then do a func that uses the data to do what you want. It could look like this: (instead of the menu swich loop...
    [code]
    for(int i = 1; i < 10; ++i)
    {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(strings[i]);
    : LCD_cursor(0,1);
    : LCD_puts(strings[i]);
    : } // if
    : if (Key == 1) // UP
    : Menu = Menus[i]/16;
    : if (Key == 2) // DOWN
    : Menu = Menus[i]%16;
    : if (Key == 3) // SET
    {
    : LastMenu = Menus2[i]/16;
    : Menu = Menus2[i]%16;
    }
    : break;
    }
    [/code]

    Look at the [blue]blue[/blue] things I've written.
    [code]
    : #include
    : #include"LCDdrive.h"
    : #include"func.h"
    : #include
    : void KeyScan(void);
    : void menu (void);
    : unsigned char Key = 0, Menu = 0, LastMenu = 0, MenuTimer = 0, Percent1 = 50;
    : unsigned char Percent2 = 50, Percent3 = 50, CycleTimer = 1, Starttimer = 1;
    :
    : void KeyScan(void)
    : {
    : Key = 0;
    : if (RA0==1) // UP
    : Key = 1;
    : if (RA1==1) // DOWN
    : Key = 2;
    : if (RA2==1) // SET
    : Key = 3;
    : } // KeyScan Subroutine
    :
    : void MenuShow(void)
    : {
    : switch (Menu)
    : {
    : case 0:
    : {
    : if (Key == 0)
    : {
    :
    : }
    :
    : case 2: // Displays ALARMS / FANS
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(">ALARM SETUP ");
    : LCD_cursor(0,1);
    : LCD_puts(" FAN SETUP ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 3;
    : if (Key == 2) // DOWN
    : Menu = 3;
    : if (Key == 3) // SET
    : Menu = 4;
    : break;
    : }
    :
    : case 3:
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(" ");
    : LCD_cursor(0,1);
    : LCD_puts(">");
    : } // if
    : if (Key == 1) // UP
    : Menu = 2;
    : if (Key == 2) // DOWN
    : Menu = 2;
    : if (Key == 3) // SET
    : Menu = 7;
    : break;
    : }
    :
    : case 4:
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : LCD_cursor(0,1);
    : LCD_puts(" Alarm2 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 6;
    : if (Key == 2) // DOWN
    : Menu = 5;
    : if (Key == 3) // SET
    : {
    : LastMenu = 4;
    : Menu = 11; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : case 5:
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : LCD_cursor(0,1);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 4;
    : if (Key == 2) // DOWN
    : Menu = 6;
    : if (Key == 3) // SET
    : {
    : LastMenu = 5;
    : Menu = 11; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : case 6:
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : LCD_cursor(0,1);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 5;
    : if (Key == 2) // DOWN
    : Menu = 4;
    : if (Key == 3) // SET
    : {
    : LastMenu = 6;
    : Menu = 11; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : case 7:
    : {
    : if (Key == 0)
    : {
    :
    : LCD_cursor(0,0);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : LCD_cursor(0,1);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 9;
    : if (Key == 2) // DOWN
    : Menu = 8;
    : if (Key == 3) // SET
    : {
    : LastMenu = 7;
    : Menu = 10; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : case 8:
    : {
    : if (Key == 0)
    : {
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : LCD_cursor(0,1);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 7;
    : if (Key == 2) // DOWN
    : Menu = 9;
    : if (Key == 3) // SET
    : {
    : LastMenu = 8;
    : Menu = 10; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : case 9:
    : {
    : if (Key == 0)
    : {
    : LCD_cursor(0,0);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    :
    : LCD_cursor(0,1);
    : LCD_puts(">Alarm1 = %-i.%-u C ");
    : } // if
    : if (Key == 1) // UP
    : Menu = 8;
    : if (Key == 2) // DOWN
    : Menu = 7;
    : if (Key == 3) // SET
    : {
    : LastMenu=9;
    : Menu = 9; // Changes the settings - modify
    : } // if
    : break;
    : }
    :
    : }
    : } // Switch Menu
    : } // MenuShow Subroutine
    :
    :
    : /****************************************************************/
    : /*void main(void) */
    : /* */
    : /*Inputs: */
    : /* none */
    : /* */
    : /*Outputs: */
    : /* none */
    : /* */
    : /*Operation: */
    : /* Initializes all variables; */
    : /* Displays first few menu items on lcd; */
    : /* And controls which menu is being displayed. */
    : /* */
    : /*By: Bernhard Spalteholz */
    : /*Date: */
    : /****************************************************************/
    :
    : void main(void)
    : {
    :
    : sys_init();
    : LCD_initialise();
    : while (1)
    : {
    : KeyScan(); // Check is a Key is being pressed
    :
    : if (Key != 0) // Reset the menutimer every time a key is pressed
    : MenuTimer = 0;
    :
    : if (Starttimer == 0)
    : MenuShow(); // Display the selected Menu
    :
    :
    :
    : while (Key != 0) // Debounce keys - wait until keys are released
    : KeyScan();
    :
    : del(); // Timer to escape back out of menu after specified time
    : MenuTimer += 1;
    : if (MenuTimer == 50)
    : {
    : MenuTimer = 0; // Resets MenuTimer
    : if (Starttimer == 1)
    : Starttimer = 0;
    :
    : CycleTimer += 1; // Adjust timer to Cycle main screen
    : if (CycleTimer == 4)
    : CycleTimer = 1;
    :
    : // Decide which menu to go to after 5 sec. delay
    : switch (Menu)
    : {
    : case 2:
    : {
    : Menu = 0;
    : break;
    : }
    : case 3:
    : {
    : Menu = 0;
    : break;
    : }
    [blue] default:[/blue]
    : {
    : Menu = 2;
    : break;
    : }
    :
    : } // Switch Menu
    : } // If Menutimer = 100
    : } // Main While Loop
    : } // Main Program
    :
    :
    : Another c Prgram associated with it
    : #include
    : #include"func.h"
    : void sys_init(void)
    : {
    : RP0=1; /*select Bank 1 */
    : OPTION = 0x07;
    : TRISB=0x00; /*make PORTB output and input */
    : TRISA=0xFF; /*make PORTA input */
    : OPTION=0x07; /*Configure Timer 0*/ [blue]why this line again?[/blue]
    : RP0=0; /* Select Bank 0*/
    : INTCON=0xa0; /*Configure Interrupts*/
    : TMR0=0x00; /*select bank 0*/
    : PORTB=0x00; /* clear all leds on PORTB*/
    : }
    :
    : void RB6_flash (char i)
    :
    : {
    : char a;
    : for(a=0;a
    :
    : // LCD Driver module
    : // LCD module is connected as follows:
    : // RB0 - RB3 -> DB4 - DB7
    : // RB4 -> RS
    : // RB5 -> E
    :
    : // define constants
    : #define RS RB4 // RS control line is bit 4 of port B
    : #define E RB5 // E control line is bit 5 of port B
    : #define LCD_INIT 0x33 // command to initialise LCD display
    : #define FOUR_BIT_MODE 0x32 // command to make the LCD transfer instructions and data in 4 bit chunks rather than 8
    : #define TWO_LINE_MODE 0x2c // command to put the LCD in two-line mode
    : #define MOVE_AFTER_WRITE 0x06 // command to increment cursor position automatically
    : #define DISPLAY_INIT 0x0c // command to turn display on, switch off the cursor and stop it blinking
    :
    : #define WRITE_DELAY 200 // constant used to set write delay time (50 us required)
    : #define BIT_DELAY 2 // constant used to set pulse duration (a few us required)
    : #define INST_DELAY 1000 // constant used to det instruction delay (1.53 ms required)
    :
    : // FUNCTION EXTERNAL FUNCTION REFERENCES
    :
    :
    : // FUNCTION ADVANCE DECLARATIONS
    : void LCD_write(unsigned char c, unsigned char rs); // basic write function (instruction or data depending on rs)
    : void LCD_initialise(void); // send initialisation commands to LCD
    : void LCD_clear(void); // function to clear LCD display and home the cursor
    : void LCD_delay(unsigned int D); // function to generate a delay
    : void pulse_E(void); // function to pulse E pin high then low
    : void LCD_putch(unsigned char c); // character output routine
    : void LCD_puts(unsigned char *s); // Writes string s to LCD
    : void LCD_cursor (unsigned char x, unsigned char y ); // Moves cursor to x,y
    : //void LCD_cursor_on (void); // Turn cursor on
    : //void LCD_cursor_off (void); // Turn cursor off
    : // Display a numeric value (0-999)
    :
    : // Initialise LCD module
    : void LCD_initialise(void)
    : {
    :
    : // INITIALISE LCD
    : LCD_write(LCD_INIT, 0); // command to initialise LCD display, (RS = 0)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    :
    : // Set LCD for 4-bit mode
    : LCD_write(FOUR_BIT_MODE, 0); // command to set LCD in 4-bit mode, (RS = 0)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    :
    : // set LCD in up for two lines
    : LCD_write(TWO_LINE_MODE, 0); // command to set LCD for two lines, (RS = 0)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    :
    : // Select move after write
    : LCD_write(MOVE_AFTER_WRITE, 0); // command to set LCD to increment cursor pos. automatically (RS = 0)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    :
    : // Configure display & cursor
    : LCD_write(DISPLAY_INIT, 0); // command to configure display, (RS = 0)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    :
    : LCD_clear();
    : }
    :
    :
    :
    : // LCD_write() function is a basic write subroutine that could be an instruction or data
    : void LCD_write(unsigned char c, unsigned char rs)
    : {
    : unsigned char temp; // temporary variable to hold ms 4 bits of c
    : unsigned char RSmask = 0; // used to set or reset bit 4 of PORTB
    : unsigned char TRISB_BAK; // Current status of port B data direction register
    :
    : // INITIALISATION
    : RP0 = 1; // get ready to write to data direction registers
    : TRISB_BAK = TRISB; // Get current state of TRISB register
    : TRISB = 0x00; // Set PORTB bits 0 - 7 as outputs
    : RP0 = 0; // get ready to use ports
    :
    : if (rs == 1) RSmask = 0x10; // set up bit mask for RS line
    :
    : // set MS 4 bits of c up on RB0 - RB3
    : temp = c;
    : PORTB = (temp >> 4) | RSmask; // shift MS 4 bits into LS 4 bits, set/rst RS and present on PORTB
    :
    : // pulse E high then low
    : pulse_E(); // call function to strobe data to LCD module
    :
    : // set LS 4 bits up on RB0 - RB3
    : PORTB = (c & 0x0F) | RSmask; // present LS 4 bits on RB0 - RB3 and set/rst RS line
    :
    : // pulse E high then low
    : pulse_E(); // Call function to strobe data to LCD module
    :
    : PORTB = 0x10; // set E high again to avoid annoying LED flicker
    :
    : RP0 = 1; // get ready to write to data direction registers
    : TRISB = TRISB_BAK; // Restore state of TRISB register
    : RP0 = 0; // get ready to use ports
    : }
    :
    :
    : //putch(c) function is character output routine
    : void LCD_putch(unsigned char c)
    : {
    : LCD_write(c, 1); // call basic LCD write routine with RS high (send data)
    : LCD_delay(WRITE_DELAY); // call function to wait until LCD has completed write operation
    : }
    :
    : //LCD_clear() function is an instruction to clear all data from LCD display and return cursor to beginning of display
    : void LCD_clear(void)
    : {
    : LCD_write(1, 0); // call basic write function with instruction 1, (clear display) and RS 0, (write instruction)
    : LCD_delay(INST_DELAY); // Call function to wait until LCD has completed instruction
    : LCD_write(2, 0); // call basic write function with instruction 2, (cursor home) and RS = 0, (write instruction)
    : LCD_delay(INST_DELAY); // call function to wait until LCD has completed instruction
    : }
    :
    : // function to pulse E pin high then low with a duration of a few usecs
    : void pulse_E(void)
    : {
    : // set E high and wait a bit
    : E = 1; // set E line high
    : LCD_delay(BIT_DELAY); // pulse delay for E
    :
    : // set E low and wait a bit
    : E = 0; // set E line low
    : LCD_delay(BIT_DELAY); // pulse delay for E
    :
    : }
    :
    : // Function to generate a delay
    : void LCD_delay(unsigned int D)
    : {
    : unsigned int counter; // variable used as delay loop counter
    : for (counter = 0; counter < D; counter++);
    : }
    :
    : // Function to write null terminated string to LCD display
    : void LCD_puts(unsigned char *s)
    : {
    : unsigned char c = 255;
    : unsigned char i = 0;
    : while ((c > 0) && (i < 16)) //16 is the maximum length of the string
    : {
    : c = s[i];
    : if (c != 0) LCD_putch(c);
    : i++;
    : }
    : }
    :
    : void LCD_cursor (unsigned char x, unsigned char y )
    : {
    : if ( y==0 )
    : {
    : //position for line 0
    : y=0x80 ;
    : }
    : else
    : {
    : //position for line 1
    : y=0xc0 ;
    : }
    :
    : LCD_write( y+x, 0) ;
    : }
    :
    : /*
    : void LCD_cursor_on ( void ) // Turn cursor on
    : {
    : LCD_write(0x0f, 0);
    : }
    :
    : void LCD_cursor_off ( void ) // Turn cursor off
    : {
    : LCD_write (0x0c, 0);
    : }
    :
    : void LCD_display_value ( unsigned int value )
    : {
    : unsigned char hunds, tens, units ;
    :
    : first get the digits
    :
    : units = value % 10 ;
    : value = value / 10 ;
    : tens = value % 10 ;
    : value = value / 10 ;
    : hunds = value % 10 ;
    :
    : now display them
    :
    : LCD_putch('0' + hunds ) ;
    : LCD_putch('0' + tens);
    : LCD_putch('0' + units);
    : }*/
    : void LCD_DisplayRow (char row, char *string)
    : {
    : char i;
    : LCD_cursor(0, row);
    : for (i=0; i<16; i++)
    : {
    : LCD_putch (*string++);
    : }
    :
    : }
    : void LCD_DisplayScreen (char *ptr)
    : {
    : LCD_DisplayRow(0,ptr+ 0);
    : LCD_DisplayRow(1,ptr+16);
    : }
    :
    :
    :
    :
    [/code]

    EDIT: I removed some comments becouse the message was to long...
Sign In or Register to comment.