annotate src/menu_processor.inc @ 31:53a09c1b7410

BUGFIX: alternating brightness at very low ambient light
author heinrichsweikamp
date Sun, 21 Jul 2013 18:04:29 +0200
parents 11d4fc797f74
children dcf3e08f31ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File menu_processor.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Routines to handle all OSTC3 graphic/text menus.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-30 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 ; Restart menu-system from first icon/line:
heinrichsweikamp
parents:
diff changeset
13 extern menu_processor_reset
heinrichsweikamp
parents:
diff changeset
14
heinrichsweikamp
parents:
diff changeset
15 ; Recal last (automatically) saved icon/line when returning from submenu.
heinrichsweikamp
parents:
diff changeset
16 extern menu_processor_pop
heinrichsweikamp
parents:
diff changeset
17
heinrichsweikamp
parents:
diff changeset
18 ; Rexecute the menu block
heinrichsweikamp
parents:
diff changeset
19 extern menu_processor
heinrichsweikamp
parents:
diff changeset
20
heinrichsweikamp
parents:
diff changeset
21 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
22 ; Menus parameters
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 ;NOTE: should be idenric in .inc and .asm !
heinrichsweikamp
parents:
diff changeset
25 #define MENU_LINES_MAX .7 ; Number of lines per screen?
heinrichsweikamp
parents:
diff changeset
26 #define MENU_HEIGHT .27 ; Spacing on screen.
heinrichsweikamp
parents:
diff changeset
27 #define MENU_VCENTER .125 ; Position on screen.
heinrichsweikamp
parents:
diff changeset
28
heinrichsweikamp
parents:
diff changeset
29 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
30
heinrichsweikamp
parents:
diff changeset
31 COMMON_BEGIN_MENU MACRO dynamic, txt, nb_items
heinrichsweikamp
parents:
diff changeset
32 local center
heinrichsweikamp
parents:
diff changeset
33 If nb_items > MENU_LINES_MAX
heinrichsweikamp
parents:
diff changeset
34 center set MENU_VCENTER - (MENU_HEIGHT/2) * MENU_LINES_MAX
heinrichsweikamp
parents:
diff changeset
35 Else
heinrichsweikamp
parents:
diff changeset
36 center set MENU_VCENTER - (MENU_HEIGHT/2) * nb_items
heinrichsweikamp
parents:
diff changeset
37 Endif
heinrichsweikamp
parents:
diff changeset
38 If nb_items <= 0
heinrichsweikamp
parents:
diff changeset
39 Error "Zero items in menu ", x
heinrichsweikamp
parents:
diff changeset
40 Endif
heinrichsweikamp
parents:
diff changeset
41
heinrichsweikamp
parents:
diff changeset
42 extern txt
heinrichsweikamp
parents:
diff changeset
43 call menu_processor
heinrichsweikamp
parents:
diff changeset
44 ; Push 6 bytes of menu header data.
heinrichsweikamp
parents:
diff changeset
45 db nb_items, dynamic
heinrichsweikamp
parents:
diff changeset
46 db LOW(txt), HIGH(txt)
heinrichsweikamp
parents:
diff changeset
47 db UPPER(txt), center
heinrichsweikamp
parents:
diff changeset
48 ENDM
heinrichsweikamp
parents:
diff changeset
49
heinrichsweikamp
parents:
diff changeset
50 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
51 ; Macro to generat (and check) menu vertical menu blocks with data.
heinrichsweikamp
parents:
diff changeset
52 ;
heinrichsweikamp
parents:
diff changeset
53 MENU_BEGIN MACRO menu_title, nb_items
heinrichsweikamp
parents:
diff changeset
54 COMMON_BEGIN_MENU 0, menu_title, nb_items
heinrichsweikamp
parents:
diff changeset
55 ENDM
heinrichsweikamp
parents:
diff changeset
56
heinrichsweikamp
parents:
diff changeset
57 MENU_BEGIN_DYNAMIC macro title_proc, nb_items
heinrichsweikamp
parents:
diff changeset
58 COMMON_BEGIN_MENU 1, title_proc, nb_items
heinrichsweikamp
parents:
diff changeset
59 ENDM
heinrichsweikamp
parents:
diff changeset
60
heinrichsweikamp
parents:
diff changeset
61 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
62
heinrichsweikamp
parents:
diff changeset
63 ; Submenu
heinrichsweikamp
parents:
diff changeset
64 MENU_CALL MACRO txt, proc
heinrichsweikamp
parents:
diff changeset
65 extern txt
heinrichsweikamp
parents:
diff changeset
66 db 0, 0, 0, 0
heinrichsweikamp
parents:
diff changeset
67 db LOW(proc), HIGH(proc), UPPER(proc), 0
heinrichsweikamp
parents:
diff changeset
68 db LOW(txt), HIGH(txt)
heinrichsweikamp
parents:
diff changeset
69 ENDM
heinrichsweikamp
parents:
diff changeset
70
heinrichsweikamp
parents:
diff changeset
71 ; Generic option menu
heinrichsweikamp
parents:
diff changeset
72 MENU_OPTION MACRO txt, option, callback
heinrichsweikamp
parents:
diff changeset
73 extern txt
heinrichsweikamp
parents:
diff changeset
74 extern option
heinrichsweikamp
parents:
diff changeset
75 db 2, LOW(callback), HIGH(callback), UPPER(callback)
heinrichsweikamp
parents:
diff changeset
76 db LOW(option),HIGH(option),UPPER(option), 0
heinrichsweikamp
parents:
diff changeset
77 db LOW(txt), HIGH(txt)
heinrichsweikamp
parents:
diff changeset
78 ENDM
heinrichsweikamp
parents:
diff changeset
79
heinrichsweikamp
parents:
diff changeset
80 MENU_DYNAMIC MACRO callback, proc
heinrichsweikamp
parents:
diff changeset
81 extern callback
heinrichsweikamp
parents:
diff changeset
82 db 3, LOW(callback), HIGH(callback), UPPER(callback)
heinrichsweikamp
parents:
diff changeset
83 db LOW(proc), HIGH(proc), UPPER(proc), 0
heinrichsweikamp
parents:
diff changeset
84 db 0, 0
heinrichsweikamp
parents:
diff changeset
85 ENDM
heinrichsweikamp
parents:
diff changeset
86
heinrichsweikamp
parents:
diff changeset
87 MENU_END MACRO
heinrichsweikamp
parents:
diff changeset
88 ENDM