Skip to content

Commit fae1387

Browse files
committed
Navigate remote menu with thumbstick and save/load units
1 parent 06c975c commit fae1387

4 files changed

Lines changed: 72 additions & 34 deletions

File tree

display/main_voyager.lisp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
; includes
22
(define lisp_V 1.50)
33
(define THR_TIMEOUT 2.5) ; 5 for 160Mhz
4-
(def UNITS 0); 0--> imperial 1--> metric
54

65
(def mac_0 0)
76
(def mac_1 0)
@@ -80,6 +79,7 @@
8079
(def time_since_screen_update 0)
8180
(def SCREEN_REFRESH_INTERVAL 100) ; 100ms = 10Hz
8281

82+
(def units 0)
8383
(def direction 1)
8484
(def menu_index 0)
8585
(def main_prescaler 0)
@@ -119,6 +119,7 @@
119119
(setq pulley_config (to-float (eeprom-read-f pulley_add))) ; load default pulley value
120120
(setq batt_type_config (to-i (eeprom-read-i batt_type_add))) ; load default batt_type
121121
(setq safety_status (to-i (eeprom-read-i safety_status_add))) ; load the safety status for throttle
122+
(setq units (to-i (eeprom-read-i units_add))) ; load the units
122123

123124
(esp_now_init)
124125

display/res/eeprom_init.lisp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
(define pulley_add 18)
2020
(define batt_type_add 19)
2121
(define safety_status_add 20)
22+
(define units_add 21)
2223

2324
; Default values
2425
(define default_min_cal 100) ; Default based on typical production remotes
@@ -37,6 +38,7 @@
3738
(define default_s_count 18)
3839
(define default_safety_switch 0)
3940
(define init_flag 0xFFFE) ; Switched to 0xFFFE for v1.50 release to load new defaults
41+
(define default_units 0) ; Default to Imperial (0 = Imperial, 1 = Metric)
4042

4143
(defun eeprom_check(){
4244
(setq test_value (to-i (eeprom-read-i 1))) ; Calibration (Min)
@@ -134,12 +136,17 @@
134136
(print "eeprom 20 error (safety status), writing default: 0")
135137
(eeprom-store-i 20 default_safety_switch)
136138
})
139+
(setq test_value (to-i (eeprom-read-i 21))) ; Units
140+
(if(or (< test_value 0)(> test_value 1)){
141+
(print "eeprom 21 error, writing default")
142+
(eeprom-store-i 21 default_units)
143+
})
137144
})
138145

139146
(defun eeprom_init(){
140147

141148
(setq test_value (to-i (eeprom-read-i 32)))
142-
149+
143150
; MEMORY NOT INITIALIZED
144151
(if(< test_value init_flag){
145152
(print "Memory not initialized, writing default values")
@@ -163,7 +170,7 @@
163170
(eeprom-store-f 18 default_gear_ratio) ; Gear Ratio
164171
(eeprom-store-i 19 default_s_count) ; S-Count
165172
(eeprom-store-i 20 default_safety_switch) ; Safety Switch
166-
(eeprom-store-i 21 0)
173+
(eeprom-store-i 21 default_units) ; Units
167174
(eeprom-store-i 22 0)
168175
(eeprom-store-i 23 0)
169176
(eeprom-store-i 24 0)
@@ -192,7 +199,7 @@
192199
(eeprom-store-f 18 default_gear_ratio) ; Gear Ratio
193200
(eeprom-store-i 19 default_s_count) ; S-Count
194201
(eeprom-store-i 20 default_safety_switch) ; Safety Switch
195-
(eeprom-store-i 21 0)
202+
(eeprom-store-i 21 default_units) ; Units
196203
(eeprom-store-i 22 0)
197204
(eeprom-store-i 23 0)
198205
(eeprom-store-i 24 0)

display/screens/main_screen.lisp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,28 @@
9999
;; ;;;;;;;;;; ;;
100100

101101
;; SPEED ;;
102-
(def current_speed (if (= UNITS 1) (speed_cal) (* (speed_cal) 0.621)))
102+
(def current_speed (if (= units 1) (speed_cal) (* (speed_cal) 0.621)))
103103

104104
(def current_display_speed (to-i (* current_speed 10))) ; For comparing displayed values
105105
(if (or (!= current_display_speed last_displayed_speed)
106106
(!= speed_color last_speed_color)
107107
(= first_draw 1))
108108
(progn
109-
(write-speed current_speed UNITS (+ x_offset (if (= UNITS 1) 33 28)) (+ y_offset 19) speed_color)
109+
(write-speed current_speed units (+ x_offset (if (= units 1) 33 28)) (+ y_offset 19) speed_color)
110110
(setq last_displayed_speed current_display_speed)
111111
(setq last_speed_color speed_color)
112112
)
113113
)
114114
;; ;;;;; ;;
115115

116116
;; TRIP ;;
117-
(def current_trip (if (= UNITS 1) distance (* distance 0.621)))
117+
(def current_trip (if (= units 1) distance (* distance 0.621)))
118118

119119
(def current_display_trip (to-i (* current_trip 10))) ; For comparing displayed values
120120
(if (or (!= current_display_trip last_displayed_trip)
121121
(= first_draw 1))
122122
(progn
123-
(write_trip current_trip UNITS (+ x_offset 63) (+ y_offset 50))
123+
(write_trip current_trip units (+ x_offset 63) (+ y_offset 50))
124124
(setq last_displayed_trip current_display_trip)
125125
)
126126
)

display/screens/remote_screen.lisp

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
(def firts_iteration_remote 0)
22
(def remote_screen_num 0)
3+
(def remote_screen_count 3)
4+
(def thum_stick_prescaler 0)
35
(def distance_total 0.0)
6+
47
@const-start
58
(defun remote_screen(){
69
(if (= firts_iteration_remote 0){
710
(disp-clear)
811
(def text_box (img-buffer 'indexed2 128 14))
9-
(txt-block-l text_box 1 0 0 font_9x14 "EXIT NEXT")
10-
(disp-render text_box (+ x_offset 0) (+ y_offset 53) '(0 0xFFFFFF))
11-
(img-clear text_box)
1212
(def text_box_2 (img-buffer 'indexed2 40 14))
1313
(def numb_box (img-buffer 'indexed2 120 30))
1414
(setq firts_iteration_remote 1)
15-
1615
})
17-
16+
17+
(if (= remote_screen_num 2)
18+
(txt-block-l text_box 1 0 0 font_9x14 "EXIT EDIT")
19+
(txt-block-l text_box 1 0 0 font_9x14 "EXIT ")
20+
)
21+
(disp-render text_box (+ x_offset 0) (+ y_offset 53) '(0 0xFFFFFF))
22+
(img-clear text_box)
23+
1824
(cond
1925
((eq remote_screen_num 0) (progn
2026
(txt-block-l text_box 1 0 0 font_9x14 "MAC address")
@@ -63,12 +69,12 @@
6369
(txt-block-l text_box 1 0 0 font_9x14 "Units")
6470
(disp-render text_box (+ x_offset 1) (+ y_offset -1) '(0 0xFFFFFF))
6571
(img-clear text_box)
66-
67-
(if (= UNITS 1)
72+
73+
(if (= units 1)
6874
(txt-block-c numb_box 1 60 0 font_20x30 "METRIC");
6975
(txt-block-c numb_box 1 60 0 font_20x30 "IMPERIAL");
7076
)
71-
77+
7278
(disp-render numb_box (+ x_offset 4) (+ y_offset 17) '(0 0xFFFFFF))
7379
(img-clear numb_box)
7480

@@ -82,45 +88,69 @@
8288
(img-clear text_box)
8389
(setq distance_total (to-float (eeprom-read-f total_trip_add)))
8490
(setq distance_total (+ distance_total (if (= distance 0) 0 (/ distance 1000))))
85-
(if (= UNITS 1)
86-
{
91+
(if (= units 1)
92+
{
8793
(txt-block-c numb_box 1 60 0 font_20x30 (str-from-n distance_total "%0.1f"));
8894
(txt-block-c text_box_2 1 20 0 font_9x14 "Km")
89-
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 44) '(0 0xFFFFFF))
95+
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 42) '(0 0xFFFFFF))
9096
(img-clear text_box_2)
9197
}
9298
{
9399
(setq distance_total (* distance_total 0.6213))
94100
(txt-block-c numb_box 1 60 0 font_20x30 (str-from-n distance_total "%0.1f"));
95101
(txt-block-c text_box_2 1 20 0 font_9x14 "Mil")
96-
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 44) '(0 0xFFFFFF))
102+
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 42) '(0 0xFFFFFF))
97103
(img-clear text_box_2)
98104
})
99105

100-
(disp-render numb_box (+ x_offset 4) (+ y_offset 17) '(0 0xFFFFFF))
101-
(img-clear numb_box)
102-
106+
(disp-render numb_box (+ x_offset 4) (+ y_offset 14) '(0 0xFFFFFF))
107+
(img-clear numb_box)
108+
103109
))
104110
)
105-
111+
112+
; cycle through screens
113+
(setq thum_stick_prescaler (+ thum_stick_prescaler 1))
114+
(if (and (> thum_stick_prescaler 10)){
115+
(if (< (get-adc 0) 0.8){
116+
(setq remote_screen_num (+ remote_screen_num 1))
117+
(if (> remote_screen_num remote_screen_count) {
118+
(setq remote_screen_num 0)
119+
})
120+
(disp-render numb_box (+ x_offset 4) (+ y_offset 17) '(0 0xFFFFFF)); needed to clear the pixels
121+
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 44) '(0 0xFFFFFF)); needed to clear the pixels
122+
})
123+
124+
(if (> (get-adc 0) 2){
125+
(setq remote_screen_num (- remote_screen_num 1))
126+
(if (< remote_screen_num 0) {
127+
(setq remote_screen_num remote_screen_count)
128+
})
129+
(disp-render numb_box (+ x_offset 4) (+ y_offset 17) '(0 0xFFFFFF)); needed to clear the pixels
130+
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 44) '(0 0xFFFFFF)); needed to clear the pixels
131+
})
132+
(setq thum_stick_prescaler 0)
133+
})
134+
135+
; update
106136
(if (= cfg_pressed_short 1){
107137
(setq cfg_pressed_short 0)
108-
(setq remote_screen_num (+ remote_screen_num 1))
109-
(disp-render numb_box (+ x_offset 4) (+ y_offset 17) '(0 0xFFFFFF)); needed to clear the pixels
110-
(disp-render text_box_2 (+ x_offset 47) (+ y_offset 44) '(0 0xFFFFFF)); needed to clear the pixels
111-
(if (> remote_screen_num 3)
112-
(setq remote_screen_num 0)
138+
; update units
139+
(if (= remote_screen_num 2)
140+
(if (= units 0) (setq units 1) (setq units 0))
113141
)
114-
})
115-
142+
(eeprom-store-i units_add units)
143+
})
144+
145+
; exit
116146
(if (= on_pressed_short 1){
117-
(setq on_pressed_short 0)
147+
(setq on_pressed_short 0)
118148
(disp-clear)
119149
(setq firts_iteration 0)
120150
(setq menu_sub_index 0)
121151
(setq enter_menu 0)
122152
(setq firts_iteration_remote 0)
123-
(setq remote_screen_num 0)
124-
})
153+
(setq remote_screen_num 0)
154+
})
125155
})
126156
@const-start

0 commit comments

Comments
 (0)