Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1ef9f9

Browse files
fri3d-2024: fix joystick left/right direction
1 parent176b59e commitf1ef9f9

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

‎internal_filesystem/boot_fri3d-2024.py‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
importi2c
88
importmath
99

10+
importmicropython
11+
importgc
12+
1013
importlvglaslv
1114
importtask_handler
1215

@@ -143,7 +146,7 @@ def read_joystick_angle(threshold=0.1):
143146
returnNone# Neutral position
144147

145148
# Calculate angle in degrees with UP = 0°, clockwise
146-
angle_rad=math.atan2(-x,y)
149+
angle_rad=math.atan2(x,y)
147150
angle_deg=math.degrees(angle_rad)
148151
angle_deg= (angle_deg+360)%360# Normalize to [0, 360)
149152
returnangle_deg
@@ -185,10 +188,21 @@ def keypad_read_cb(indev, data):
185188
current_key=lv.KEY.END
186189
else:
187190
# Check joystick
188-
angle=read_joystick_angle(0.25)
191+
angle=read_joystick_angle(0.30)# 0.25-0.27 is right on the edge so 0.30 seems good
189192
ifangleandtime.time()<60:
190-
print(f"joystick angle:{angle}")
191-
mpos.ui.focus_direction.move_focus_direction(angle)
193+
print(f"got joystick angle:{angle}")
194+
#gc.collect()
195+
print("Memory after joystick:",end=" ")
196+
micropython.mem_info()
197+
try:
198+
mpos.ui.focus_direction.move_focus_direction(angle)
199+
exceptExceptionase:
200+
print(f"Error in move_focus_direction:{e}")
201+
print(f"after joystick angle:{angle}")
202+
#gc.collect()
203+
print("Memory after joystick:",end=" ")
204+
micropython.mem_info()
205+
else:# old behavior
192206
joystick=read_joystick()
193207
ifjoystick=="LEFT":
194208
current_key=lv.KEY.LEFT
@@ -234,7 +248,6 @@ def keypad_read_cb(indev, data):
234248

235249
# Handle ESC for back navigation (only on initial PRESSED)
236250
ifcurrent_key==lv.KEY.ESCandlast_state==lv.INDEV_STATE.PRESSEDandsince_last_repeat==0:
237-
importmpos
238251
mpos.ui.back_screen()
239252

240253
group=lv.group_create()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp