Choose and write from value.

Discussion in 'Programmer's Corner' started by FroceMaster, Jan 13, 2018 at 6:19 AM.

  1. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    450
    4
    Hi.
    Difficult to explain but here we go.

    Have Microchip and LCD and need to do following.

    20 variables in "raindays"
    have special charters in LCD that need to be show depend on value in variables.
    Like a collumdiagram.
    The special charter i have is just the botton line in LCD and number 2 is 2 line, and 3 lines ect until last special char that is "full" ( 8 line)
    simpel, if raindays[0] is ex 10 then i need to lid up 10 "lines" in first cullom, line 4 in LCD "full" and 2 lines i line 3 of LCD,
    So that i will have a "PINDIAGRAM" if you got my meaning,

    feel free to ask more,
     
  2. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    5,049
    1,186
    Programming in assembler or C?
     
  3. ericgibbs

    Moderator

    Jan 29, 2010
    3,429
    636
    hi FM,
    What you are describing is using the 4 Line LCD as a Bar Graph, showing the different rainfall values.
    What help are you are asking for.??
    E
     
  4. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    450
    4
    C code .

    Yes bar graph.
    First line is text.
    Should i use some case statement or how ?
    If raindays = 1 then write 1 bar or ??
     
  5. ericgibbs

    Moderator

    Jan 29, 2010
    3,429
    636
    hi,
    I would ask the same question as Albert post #2, programming language.??
    E
     
  6. LesJones

    Active Member

    Jan 8, 2017
    900
    193
    I thought that and then noticed he had answered in the first line of post #4
    The fact that it is "C" rules me out as being able to help.

    Les.
     
  7. ericgibbs

    Moderator

    Jan 29, 2010
    3,429
    636
    hi Les,
    I scanned past the first line of his post.!:rolleyes:
    I also do not program in 'C'.
    E
     
  8. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    450
    4
    Code (Text):
    1.  lcd1_goto(0x00);
    2.  
    3.   lcd1_puts("  Daily rain 1-20");
    4.  
    5.     // all data is loaded to variables. raindays[]
    6.  
    7.   char d;
    8.  
    9.   int x;
    10.  
    11.    for (d=19;d>=0;d--);  //loop to load days,
    12.  
    13.   {
    14.  
    15.   x=raindays[d];
    16.  
    17.   if (x>15 && x<23)
    18.  
    19. {lcd1_goto(0x40+d); // line 2
    20.  
    21. Lcd1_print_char(x-15); // should give me ex 22-15 = char 7
    22.  
    23. lcd1_goto(0x14+d);  // line 3
    24.  
    25. lcd1_print_char(7); // full house
    26.  
    27. lcd1_goto(0x54+d); // line 4
    28.  
    29. lcd1_print_char(7); // full house
    30.  
    31. }
    32.  
    33. if (x<17 && x>8)
    34.  
    35. {lcd1_goto(0x14+d);//line 3 // between 8 and 16
    36.  
    37. lcd1_print_char(x-7) ;
    38.  
    39. lcd1_goto(0x54); // line 4
    40.  
    41. lcd1_print_char(7); // full house
    42.  
    43.  
    44.  
    45.  
    46. }
    think i got i now ;)
     
  9. ericgibbs

    Moderator

    Jan 29, 2010
    3,429
    636
  10. Raymond Genovese

    Member

    Mar 5, 2016
    433
    283
    It is difficult for me to understand what you are saying. You may want to look into the ability to program custom characters. This will depend on the LCD/controller, but many common ones support this feature.

    Basically, you would program 8 custom characters, with ascending numbers of horizontal dots forming "bars of different heights". Then, you can display what you appear to want to display fairly easy (assuming I am understanding you).

    You can see an example of programming custom characters using 'C' here - although not with a PIC.

    [​IMG]

    You can also search on the subject - there are many examples to be found.
     
  11. WBahn

    Moderator

    Mar 31, 2012
    21,107
    6,069
    @FroceMaster: Is this any kind of school assignment? If so, I can move it to Homework Help where you will tend to get assistance aimed at helping you learn what you need to succeed in doing these tasks on your own.
     
  12. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    450
    4
    Have considered to use craphic but seems to difficult,

    No not a school project,
    It's for my self , and learning by doing,
    All programming is started from zero, for many years ago i started in TurboPascal, moved up to VB6
    and later VB.net, and C code for PIC. just by reading internet and help in here.
     
Loading...