With assembly language programs I find that storing string tables in-line with your code provides a more intuitive structure, much like a high-level language;4) How best to store the menu descriptions (e.g. individual characters in a 'computed goto' look-up table?)
;
; main menu
;
menu.a
PutStr "\x1b[2J" ; home cursor, clear screen
PutStr " Menu\r\n\n"
PutStr " 1 - set azimuth\r\n"
PutStr " 2 - set elevation\r\n"
call Get232 ; get rs-232 input
xorlw '2' ; a '2'?
beq menu.2 ; yes, branch, else
xorlw '1'^'2' ; a '1'?
bnz menu.a ; no, branch, else
menu.1
Hi Richard,Your idea of initially entering a number seems a little bit of a retrograde step, certainly not a method new users would find easy without a printed list of codes.
With assembly language programs I find that storing string tables in-line with your code provides a more intuitive structure, much like a high-level language;
Menu
clrf Item ; Item = 0 |B0
goto PutItem ; put item string on LCD |B0
Menu.a
swtest (uparrow) ; if <up> arrow key |B0
goto DecItem ; branch, else |B0
swtest (dnarrow) ; if <dn> arrow key |B0
goto IncItem ; branch, else |B0
swtest (rtarrow) ; if <rt> arrow key |B0
goto SelItem ; branch, select item, else |B0
swtest (setsw) ; if <set> switch pressed |B0
goto SetMode ; branch, else |B0
goto Menu.a ; start over |B0
DecItem
movf Item,W ; Item > 0? |B0
bz Menu.a ; no, branch, else |B0
decf Item,F ; dec menu item number |B0
goto PutItem ; put item string on LCD |B0
IncItem
movf Item,W ; Item 0..2 |B0
xorlw 2 ; last item? |B0
bz Menu.a ; yes, branch, else |B0
incf Item,F ; inc menu item number |B0
goto PutItem ; put item string on LCD |B0
SelItem
movf Item,W ; Item 0..2 |B0
addwf PCL,F ; |B0
goto Item0 ; branch to item 0 code |B0
goto Item1 ; branch to item 1 code |B0
goto Item2 ; branch to item 2 code |B0
PutItem
PutLCD cmd,line2+4 ; line 2, htab 4 |B0
movf Item,W ; Item 0..2 |B0
addwf PCL,F ; |B0
goto Istr0 ; print item string 0 |B0
goto Istr1 ; print item string 1 |B0
goto Istr2 ; print item string 2 |B0
;
Istr0 PutStr " menu item 0 "
goto Menu.a ; |B0
Istr1 PutStr " menu item 1 "
goto Menu.a ; |B0
Istr2 PutStr " menu item 2 "
goto Menu.a ; |B0
;
; Item code modules
;
Item0 nop ; |B0
........
Item1 nop ; |B0
........
Item2 nop ; |B0
........
My existing pic assembler / 2x16 lcd menu system is done by pressing a switch to invoke the main menu and pressing the key again to advance to the next menu function, - very simple but effective although a little cumbersome.
...
Your idea of initially entering a number seems a little bit of a retrograde step, certainly not a method new users would find easy without a printed list of codes.
There must be many possible ways of creating menus, but the limitation will always be the lcd, typically a 2x16 unit. A 4x16 will give more freedom but basically the same constraints.
Probably something you may have looked at but discounted, is the use of glcd units.
They can be used a simple text screen, giving an equivalent display of 8 rows of 16 + characters, or with large character images as shown in the attached picture.
They are cost effective and practicable with simple assembler code, as can be seen in my recent post ( sorry the opening message photos deleted by mistake, but they are in the attached pdf)
https://www.electro-tech-online.com/threads/glcds-with-pic-18f-assembler.40676/
...
This also introduces the option of a touch screen as a practical reality for diyers - attached are pics of my current, very early, touch screen work.
The touch screen overlay and fdc connector costs under GB £10
( this 5x3 switch touch panel is the simple 'digital switch' type that is connected directly to the pic without a special controller chip)
...
Menu systems aren't that difficult. Here's a simple 3 item LCD menu example (for 16F' devices) that uses <up>, <dn>, and <rt> arrow push buttons (yes, it uses macros). I've omitted the PCLATH code in the jump tables for clarity (caveat);
Mike
Richard,
Your comments are perplexing. When you're dedicating six or more pins to drive a character LCD you only need a single additional pin to read 1 to 5 push button switches by multiplexing some of the LCD lines.
Mike
;******************************************************************
;
; example macro usage
;
PutStr "Bill's Particle Accelerator Demo\r\n\n"
PutStr "Main Menu\r\n"
;
;******************************************************************
;******************************************************************
;
; PutStr macro - print a string to the RS-232 port
;
PutStr macro str ;
local String, Print
movlw low String ;
movwf PTRL ;
movlw high String ;
movwf PTRH ;
goto Print ;
String dt str,0
Print call PutString ; print string
endm
;******************************************************************
;******************************************************************
;
; PutString Subroutine
;
; - setup PTRL and PTRH to string address before entry
; - string must be terminated with a 0 byte
;
PutString
call GetTable ; get a table character |B0
andlw b'11111111' ; |B0
btfsc STATUS,Z ; a 00 byte, last character? |B0
return ; yes, return, else |B0
[COLOR=Red]call Put232[/COLOR] ; output character |B0
incfsz PTRL,F ; increment pointer |B0
goto PutString ; |B0
incf PTRH,F ; |B0
goto PutString ; |B0
;
GetTable
movf PTRH,W ; |B0
movwf PCLATH ; |B0
movf PTRL,W ; |B0
movwf PCL ; |B0
;******************************************************************
example only, in Basic expanded format.
main:
do while menukey = 1
..... normal operating code here
wend
do while menukey =0 ' finger off pb, test
wend
do while menukey =1
wend
'
do while menukey =0
menu1:
lcdout "[B]Set Date[/B]"
if acceptkey = 1 then
goto set_date
endif
do while menukey =1 ' finger off pb test
wend
'
do while menukey =0
menu2:
lcdout "[B]Set Time[/B]"
if acceptkey = 1 then
goto set_time
endif
set_date:
lcdout "[B]dd mm yy[/B]" ' actual date, [dd is underlined by LCD cursor]
'
set_day:
if Inckey= 1 then
..... inc the days
endif
if deckey= 1 then
..... dec the days
endif
if acceptkey= 1 then
goto set_month
endif
if escapekey= 1 then
goto quit
endif
goto set_day
'
set_month:
lcdout "[B]dd mm yy[/B]" ' actual date, [mm is underlined by LCD cursor]
......................................................
As promised, here's the PutStr sub-system for 16F' devices in a nut-shell.
I worked a few Ham radio operators several years ago through the LEO (low earth orbit) Russian RS-12/RS-13 satellite. I kept a program on my PC up to date with Keplerian data and the program provided accurate AOS and LOS and it also controlled both of the VFO's on my cross-band transceiver (transmitter uplink and receiver downlink) to automatically correct for Doppler shift once I acquired the satellites beacon. It was a wonderful and exciting experience.Nothing to do with astronomy, really. The azimuth, elevation reference did not go unnoticed.
Astronomer',
As promised, here's the PutStr sub-system for 16F' devices in a nut-shell.
Astronomer',
As promised, here's the PutStr sub-system for 16F' devices in a nut-shell. It's very similar in function the the PH Anderson examples you cited.
A similar sub-system for 18F' devices is much smaller, tighter, cleaner.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?