Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : HD44780 commands
Author | Message | ||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 712 |
Hello, has anyone working sets of commands (LCD CMD /LCD DATA) with examples to use the complete command set of the HD44780, like Scrolling, blinking, shifting etc? Would be very helpfull for the community. Preferrable in 8 AND 4 bit Mode. Thank you. |
||||
cosmic frog Senior Member Joined: 09/02/2012 Location: United KingdomPosts: 278 |
Yes I am also interested in this subject. I would like some info on how to make user defined characters. I've looked at the data sheets for lcds but Don't know who to use the DATA to get it to work. Dave. |
||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 712 |
"Preferrable in 8 AND 4 bit Mode." but i think this will be done by the LCD commands, so this is "transparent" for the micromite, so it will do it in the right way |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1328 |
This link HD44780 is a pretty good condensed reference. The way that Geoff has implemented the LCD CMD command is very easy to use; it's just e.g. LCD CMD 15, which will turn the cursor on. However it's not quite as simple as that because if you look at the 'Description' part of the 4th row of the above link, the '15' means DB0-DB3 are all 1's and that command also does these things: Sets On/Off of all display (D), cursor On/Off (C) and blink of cursor position character (B).
You'll need to make sure that the command numbers you use are going to do what you really want; the easy way is just to try them! The following program, (mostly in the 'display_menu' and 'set_time' sections, also shows another couple of examples i.e. for LCD CMD 12 & 20. You can see how they work if you compare them to the table in the above link. The program is reasonably self-documenting but essentially the LCD is used to enter and edit exposure times and uses cursor blinking and positioning to make the data entry easier. Greg 'UVTimer - Author: Greg Yaxley with contributions
'from David Mortimer. 2nd May 2014 'Program to enter, display & control exposure time for 'a UV lamp box using a 4x4 keypad & 4x20 LCD display. 'MicroMite Basic V4.5_28 pin. '---------------------------------------------- OPTION AUTORUN ON 'run on power-up dutycycle = 80 'default dutycycle for PWM (brightness) pwm 2,50,dutycycle 'LCD backlight PWM control: Ch 2A, 50Hz 80% LCD INIT 2,3,4,5, 23,24 'backlight on Ch. 2A (pin 26) LCD clear Keypad KeyCode, Key_Int, 15,16,17,18,6,7,9,10 led = 14 'pin no. for lamps-ON led buzz = 21 'pin no. for buzzer timeset = 0 'flag: exposure time is not set pin(led)=0: pin(buzz)=0 'ensure led, lamps and buzzer start OFF setpin led,DOUT setpin buzz,DOUT display_menu: keycode = 99 'reset keypad settick 0,0 'turn OFF timer interrupt lcd cmd 12 'make cursor invisible (turn off) if timeset = 0 then Mins$ = "00": secs$ = "00" 'default time lcd 1,1, " Time set = "+ mins$ +":"+ secs$ lcd 2,1, " Brightness * or # " 'lcd 2,c20, "" 'clear LCD line 2 LCD 3,1, "Reset time - Press A" LCD 4,1, "Lamps ON - Press B" do if keycode = 20 goto set_time 'key A if keycode = 21 goto lamps_ON 'key B if keycode = 23 goto display_menu 'key D if keycode = 10 or keycode = 11 then brightness 'keys * and # loop set_time: settick 0,0 mins$= "": secs$= "" 'null default time strings timeset = 0 're-zero time-set flag lcd 2,c20,"" 'clear LCD line 2 (after a countdown) lcd 3,1, " Enter set time " lcd 4,1, " MENU - Press D " lcd 1,13, "" 'set cursor at 'mins' position lcd cmd 15 'turn cursor on for count = 1 to 2 'get the two minutes digits get_keycode if keycode = 23 then goto display_menu if keycode > 9 then goto set_time mins$ = mins$ + keycode$ 'build mins$ lcd 1,13, mins$ 'display current mins$ string next lcd cmd 20 'move cursor past ":" for count = 1 to 2 'get the two seconds digits get_keycode if keycode = 23 then goto display_menu if keycode > 9 then goto set_time if keycode > 5 and count = 1 then beep (2,100,100) 'out-of-bounds secs entry goto set_time endif secs$ = secs$ + keycode$ 'build secs$ lcd 1,16, secs$ 'display current secs$ string next timeset = 1 'flag: time correctly set lcd cmd 12 'make cursor invisible (turn off) '----------end of set_time:------------------ lamps_ON: 'If time is set, turns lamps ON, counts down if timeset = 0 then beep (2,50,50) '& then turns OFF. if timeset = 1 then 'Exits if requested. LCD 3,1, "Reset time - Press A" 'keycode 20 LCD 4,1, "Lamps ON - Press B" 'keycode 21 if keycode = 20 then goto set_time if keycode = 21 then 'legitimite request for "lamps ON" setpin led,DOUT 'make lamp/relay pin digital out setpin buzz,DOUT 'make buzzer pin digital out lcd 2,1, "Countdown = " +mins$ +":" +secs$ +" " lcd 3,1, " - LAMPS ON - " lcd 4,1, "Lamps OFF - Press C " beep (3,200,200) 'buzz "lamps-ON" - 3 short beeps mins = val(mins$): secs = val(secs$) totsecsrem = (mins*60)+secs 'total secs for countdown pin(led) = 1 'turn ON lamp LED & relay settick 1000,countdown 'interrupt each second for countdown do while totsecsrem > 0 if keycode > 21 then exit do 'exit if C or D pressed loop '-------lamps_OFF------ settick 0,0 'stop countdown interrupt beep (1,800,0) 'one long beep = "lamps OFF" pin(led) = 0 'turn OFF lamp LED & relay endif endif goto display_menu Key_Int: 'key press detected keycode$ = str$(keycode) ireturn sub get_keycode keycode$ = "99" do loop until keycode$ <> "99" end sub sub countdown totsecsrem = totsecsrem - 1 'decrement 1 sec each interrupt remmins = totsecsrem/60 'convert to mins & mins fraction dispmins = fix(remmins) 'extract the mins dispsecs = cint((remmins-dispmins)*60) 'convert fraction to secs lcd 2,13, str$(dispmins,2,0,"0") +":"+ str$(dispsecs,2,0,"0") end sub 'display 2 digits for mins & secs, & any leading zeros sub beep (beeps,ontime,offtime) for i=1 to beeps pin(buzz)=1: pause ontime pin(buzz)=0 if i < beeps then pause offtime next End sub sub brightness lcd 2,c20,"" if keycode = 11 then dutycycle = dutycycle + 10 if keycode = 10 then dutycycle = dutycycle - 10 if dutycycle < 0 then dutycycle = 0 if dutycycle > 100 then dutycycle = 100 lcd 2,1, " MAXIMUM BRIGHTNESS " endif pwm 2,50,dutycycle keycode = 99 end sub |
||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 712 |
Hello Paceman, thank you very much for your help. The code may also help me in my "menue Project". But i will use a Rotary Encoder. If there is someone out there who has the base of a runnning menue structure controlled by a Rotary Encoder, this will make me happy ? ;-). I'am playing around with the lcd command, but i have to investigate this deeper. For example i do not understand how you could know, that lcd 2,c20,"" clears lcd line 2 ??? Can you explain how you find out that this works in this way? I cannot find any example in the docu about this. Best would be to provide a table with all the possible commands... Thank you again ;-) |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Take a look at top of Page 41 in User Manual (v4.5D available as the 'current' version on Geoff's website - GeoffG.net) WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1328 |
Dietmar, The lcd 2,c20,"" command is one of Geoff Graham's special MMBasic commands for the LCD - see page 40 of the MicroMite User Manual. The 2 refers to the line, the c20 refers to the length of the line and the "" means to fill it with nulls, i.e. blank it. I haven't tried using a rotary encoder yet, but when you get yours going for input to the LCD, post it for us all. Greg |
||||
Print this page |