📄 bbu_keypad.s
字号:
51 cmp r1, #0x51 ; Move up the command list? <DOWN> pushed?
bne %F52 ; No - skip the following
ldr r3, =BBU_KPCP ; Address of Keypad Command Pointer
ldr r2, [r3] ; Fetch the pointer
bl BBU_KPIN_NC ; Get pointer to next command down the list...
str r2, [r3] ; ...and save the pointer
;
; Did the user push <OK>?
;
52 cmp r1, #0x54 ; Move up the command list? <DOWN> pushed?
bne %F53 ; No - skip the following
ldr r1, =bbu_cmd_status ; Address of command status word
ldr r2, [r1] ; Fetch the status word
orr r2, r2, #BBU_CMD_KEYPAD_OK ; Set the KEYAPD <OK> bit
str r2, [r1] ; Write the status back
b %F99 ; ... and take the exit path
;
; First blank out the lines to be rewritten (a total of 7 lines)
;
53 mov r0, #6 ; Row 6
mov r1, #0 ; Column 0
ldr r2, =BBU_KPIN_BL20 ; Empty line
bl BBU_LCD_put16x20str ; Blank the line
add r0, r0, #1 ; Point to 2nd line
bl BBU_LCD_put16x20str ; Blank the line
add r0, r0, #1 ; Point to 3rd line
bl BBU_LCD_put16x20str ; Blank the line
;
; Line where active command is to be displayd is a highlighted color
;
ldr r4, =BBU_BG_COLOR ; This is where the background color is stored
ldr r3, =0xFFE0 ; Change background color to YELLOW
strh r3, [r4] ; Update background color
add r0, r0, #1 ; Active command line = YELLOW
bl BBU_LCD_put16x20str ; Blank the 4th line
ldr r3, =0x07FF ; Change background color to CYAN
strh r3, [r4] ; Update background color
;
; Rest of scroll region is back to the original background color
;
add r0, r0, #1 ; Point to next line
bl BBU_LCD_put16x20str ; Blank the 5th line
add r0, r0, #1 ; Point to next line
bl BBU_LCD_put16x20str ; Blank the 6th line
add r0, r0, #1 ; Point to next line
bl BBU_LCD_put16x20str ; Blank the 7th line
;
; Now fill in the commands to be displayed
;
ldr r0, =BBU_TX_COLOR ; This is where the background color is stored
ldr r1, =0x0000 ; Change text color to BLACK
strh r1, [r0] ; Update background color
mov r0, #6 ; Row 6
mov r1, #1 ; Column 1
ldr r3, =BBU_KPCP ; Address of Keypad Command Pointer
ldr r2, [r3] ; Fetch the pointer
bl BBU_LCD_put16x20str ; Print this line
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
;
; Highlight the active command
;
ldr r3, =0xFFE0 ; Change background color to YELLOW
strh r3, [r4] ; Update background color
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
;
ldr r5, =BBU_ibuf ; Address of BBU input buffer
mov r3, r2 ; Copy address of this command
90 ldrb r6, [r3], #1 ; Get command byte
strb r6, [r5], #1 ; Copy to BBU input buffer
cmp r6, #0 ; End of command reached?
bne %B90 ; No - Keep looping until command is moved
;
ldr r3, =0x07FF ; Change background color to CYAN
strh r3, [r4] ; Update background color
;
; Return to displaying neighboring commands in the list
;
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
bl BBU_KPIN_NC ; Point to the next command
add r0, r0, #1 ; Point to the next line
bl BBU_LCD_put16x20str ; Print this line
99 ldmfd sp!, {r0-r6, pc} ; Restore used registers & return to caller
;
; KEYPAD INPUT STATUS WORD
;
BBU_KPCP DCD 0 ; Keypad Command Pointer
BBU_KISW DCB 0 ; Status word
BBU_KISPB DCB 0 ; Scratch Pad Byte
;
; List of commands available to BBU through keypad use are listed below.
; Commands must be seperated by a NULL byte.
;
BBU_KP_CMDS
DCB "IRDA 1",0
DCB "IRDA 0",0
DCB "VIBRATE 25",0
DCB "VIBRATE 40",0
DCB "VIBRATE 63",0
DCB "VIBRATE 0",0
DCB "FUEL",0
DCB "ICAM",0
DCB "ICAM 1",0
DCB "CAMV 1",0
DCB "CAMV 0",0
DCB "I_CODEC",0
DCB "I_CODEC /P",0
DCB "SPKR 0",0
DCB "SPKR 20",0
DCB "SPKR 40",0
DCB "SPKR 50",0
DCB "SPKR 63",0
DCB "EAR 0",0
DCB "EAR 20",0
DCB "EAR 40",0
DCB "EAR 50",0
DCB "EAR 63",0
DCB "TONE /L=1/R=1",0
DCB "TONE /L=1/R=2",0
DCB "TONE /L=2/R=2",0
DCB "TONE /L=2/R=4",0
DCB "TONE /L=4/R=4",0
DCB "TONE /P=1",0
DCB "TONE /P=2",0
DCB "TONE /P=4",0
DCB "TONE 0",0
DCB "MIC 1",0
DCB "MIC 0",0
DCB "RECORD 10",0
DCB "RECORD 20",0
DCB "RECORD 40",0
DCB "RECORD 80",0
DCB "RECORD 120",0
DCB "PLAY",0
DCB "KPBL 10",0
DCB "KPBL 20",0
DCB "KPBL 40",0
DCB "KPBL 63",0
DCB "KPBL 127",0
DCB "KPBL 0",0
DCB "LCDBL 10",0
DCB "LCDBL 20",0
DCB "LCDBL 40",0
DCB "LCDBL 63",0
DCB "LCDBL 127",0
DCB "LED 1",0
DCB "LED 0",0
DCB "BAUD 38400",0
DCB "BAUD 115200",0
DCB 0xFF ; Marks the end of the Keypad commands
;
; Misc Text for LCD
;
BBU_KPIN_BL20 DCB " ",0
BBU_KPIN_HDR0 DCB " BBU KEYPAD CONTROL ",0
BBU_KPIN_BL16 DCB " ",0
BBU_KPIN_HDR1 DCB " Use the <UP>/<DOWN> keys to select a ",0
BBU_KPIN_HDR2 DCB " BBU command then press <OK> to run. ",0
ALIGN 4
ENDFUNC
;
;*********************************************************************************
;
; ***************
; * *
; * BBU_KPIN_NC * Subroutine
; * *
; ***************
;
; This fuction points to the next keypad command in the command list
;
; INPUT:
;
; r2 = pointer to the cmmand just displayed
;
; OUTPUT:
;
; r2 = pointer to the next command to be displayed
;
BBU_KPIN_NC FUNCTION
;
stmfd sp!, {r1, lr} ; Save used registers
100 ldrb r1, [r2], #1 ; Fetch next byte
cmp r1, #0 ; Was this the end of the command string?
bne %B100 ; No - loop until the end is found
ldrb r1, [r2] ; Get the next byte
cmp r1, #0xFF ; Is this the end of the command list?
bne %F102 ; Nope - Return to caller
ldr r2, =BBU_KP_CMDS ; Reset to the top of the list
102 ldmfd sp!, {r1, pc} ; Restore used registers & return to caller
ENDFUNC
;
;*********************************************************************************
;
; ****************
; * *
; * BBU_KPIN_NCR * Subroutine
; * *
; ****************
;
; This fuction points to the next keypad command in the command list (Reverse direction)
;
; INPUT:
;
; r2 = pointer to the cmmand just displayed
;
; OUTPUT:
;
; r2 = pointer to the next command to be displayed (in reverse direction)
;
BBU_KPIN_NCR FUNCTION
;
stmfd sp!, {r0-r1, lr} ; Save used registers
ldr r0, =BBU_KP_CMDS ; Address of top of list
cmp r2, r0 ; Currently at the top of the list?
subne r2, r2, #1 ; Skip back over the NULL byte in previous command
bne %F106 ; No - skip over the following
;
; Currently pointing to the top of the list....
; Locate the last command on the list and point to it
;
104 ldrb r1, [r2], #1 ; Fetch a byte
cmp r1, #0xFF ; End of list marker?
bne %B104 ; No - keep looping until we find it
sub r2, r2, #2 ; Back up 2 bytes
;
; Back up one command on the list
;
106 sub r2, r2, #1 ; back up 1 byte
cmp r2, r0 ; Back to the 1st command?
beq %F108 ; YES - just exit
ldrb r1, [r2], ; Fetch this byte
cmp r1, #0 ; Was this the end of the previous command string?
bne %B106 ; No - loop until the end is found
add r2, r2, #1 ; Yes - Point to 1st byte of command
108 ldmfd sp!, {r0-r1, pc} ; Restore used registers & return to caller
ENDFUNC
;
;*********************************************************************************
;
; *********************
; * *
; * BBU_KEYPAD_putstr * Subroutine
; * *
; *********************
;
; This subroutine is designed for use with the keypad input command mode of BBU
; and is used to send BBU strings out to the LCD for the user.
;
;
; INPUT:
;
; r0 = pointer to NULL terminated string to be displayed.
;
; OUTPUT:
;
; none
;
BBU_KEYPAD_putstr FUNCTION
;
stmfd sp!, {r0-r3, lr} ; Save used registers
mov r3, r0 ; Copy pointer to r3
;
; Set background and text colors
;
ldr r0, =BBU_BG_COLOR ; This is where the background color is stored
ldr r1, =0x07E0 ; Change background color to GREEN
strh r1, [r0] ; Update background color
ldr r0, =BBU_TX_COLOR ; This is where the background color is stored
ldr r1, =0x0000 ; Change background color to BLACK
strh r1, [r0] ; Update background color
mov r0, #264 ; Top of scroll region
mov r1, #516 ; Bottom of scroll region
mov r2, #12 ; Lines are 12 pixels high
bl BBU_LCD_scroll_up ; Scroll up one line
mov r0, #42 ; 43rd line (count starts at 0)
mov r1, #0 ; Column 0
ldr r2, =BBU_60CH_BL ; 60 Character blank line
bl BBU_LCD_put7x11str ; Clear the line
mov r2, r3 ; Pointer to string
bl BBU_LCD_put7x11str ; Output the text
108 ldmfd sp!, {r0-r3, pc} ; Restore used registers & return to caller
;
; Blank Line
;
BBU_60CH_BL DCB " ",0
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -