Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

variable declaration in a void function

Status
Not open for further replies.

winnie mong

Junior Member level 3
Junior Member level 3
Joined
Sep 8, 2013
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
366
helo there..
i have a function called choice below and i want to use it to produce a void function do_set_time.i am not sure how to name the parameters in my function call. please help...
scroll function is as follows:it scrolls message on the screen

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/************************************************************************************/
/* scroll()                                                                         */
/* This provides a scrolling message a number of times                              */
/************************************************************************************/
unsigned char   dpos;
unsigned char   pulses;
void scroll(const char *mess, unsigned char ntimes)
{
    unsigned char   stop;
 
    memset(sbuf,' ',SCROLL_BUF_LEN);
    strcpy(smess,mess);                     /* copy message into buffer */
    do {
        mess=sbuf;                          /* point to begin of message */
        do {
            display(mess++);                /* display part of the message */
            stop=pulses+Delay500ms;
            do {
                if(kbhit()) {               /* abort scrolling ? */
                    clrscr();               /* a clear display */
                    return;                 /* yes then bye */
                }         
            } while(stop!=pulses);
        } while(*mess);                     /* until all characters are displayed */
    } while(--ntimes);                      /* until message is displayed ntimes */
    clrscr();                               /* a clear display */
}



this is the choice function for one to be able to pick an item from a scrolling menu

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/************************************************************************************/
/* choice()                                                                         */
/* This a scrolling menu from which user functions can be selected for use          */
/************************************************************************************/
 
char choice(const   char *const *menu)
{
    const   char    *src;
    char    i,j,stop;
 
    for(i=0;i<3;i++) {
        for(j=0;src=menu[j];j++) {              /* get next string to be scrolled */ 
            scroll(src,1);                      /* scroll the menu item message */
            stop=pulses+Delay500ms;
            do {
                if(kbhit()) {                   /* check for keypad activities */
                    clrscr();                   /* clear display */
                    return j;                   /* if yes return with the key code */
                }
            } while(stop!=pulses);
        }
    }
    scroll("--TIMEOUT--",1);                    /* no input for 20 seconds stop processing */
    return(0xFF);                               /* dummy return will never be taken */
}





this is what i tried to come up with


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extern void scroll(const char *mess, unsigned char ntimes);
extern void clrscr(void);
extern char choice(const char *const *menu);
 
void do_set_time (int i, const char *const menu2[]){
    const char *const menu2[]={
       "CLK TIME",  /*parameter==0*/
       "ON TIME",    /*parameter==1*/
       "OFF TIME",    /*parameter==2*/
       0}; 
    
        if(i=0){printf("set system clock");
        }
        else if(i=1){printf("set geyser ON time");
        }
        else if(i=2){printf("set geyser OFF time");
        }
}//the three parameters will have same code, and what is being pointed to will 
//be executed in the main code.



dont hesitate to ask if you need more clarity..
 
Last edited:

From where does pulses get its value?

And what is this (const char *const *menu)?

Where is code for scroll()?
 

(const char *const *menu) is the parameter to point to the menu i would have created

- - - Updated - - -

i have edited my post.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top