Skip to content

Commit 5b2730c

Browse files
committed
fix touch vibration panics on V1 and V3
1 parent f0f2044 commit 5b2730c

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

main.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ def handle_exception(loop, context):
1010
loop = asyncio.get_event_loop()
1111
loop.set_exception_handler(handle_exception)
1212

13-
import machine, time
14-
15-
vibe = machine.Pin(4, machine.Pin.OUT)
16-
vibe.on()
17-
time.sleep_ms(50)
18-
vibe.off()
19-
vibe = None
2013

2114
set_global_exception() # Debug aid
2215
Single.Kernel = Kernel() # Constructor might create tasks

system/Hardware.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def __init__(self):
226226
#acc_config = 0x17
227227
#self.imu.write_byte(bma423.BMA4_ACCEL_CONFIG_ADDR, acc_config)
228228
#print("int1 imu:", self.imu.read_byte(bma423.BMA4_INT1_IO_CTRL_ADDR))
229-
self.imu.map_int(0, bma423.BMA423_WAKEUP_INT | bma423.BMA423_ANY_NO_MOTION_INT)
229+
self.imu.map_int(0, bma423.BMA423_WAKEUP_INT)
230230
self.imu.map_int(1, 0)
231231
feat_data = self.imu.read_data(bma423.BMA4_FEATURE_CONFIG_ADDR, bma423.BMA423_FEATURE_SIZE)
232232
feat_data[bma423.BMA423_WAKEUP_OFFSET] = 0x03 # enable and sensitivity 2/7
@@ -254,6 +254,7 @@ def __init__(self):
254254

255255
if self.WatchVersion == WATCHV1 or self.WatchVersion == WATCHV3:
256256
self.vibrator = machine.Pin(4, machine.Pin.OUT)
257+
self.vibration_controller = None
257258
else:
258259
self.vibration_controller = adafruit_drv2605.DRV2605(sensor_i2c)
259260
self.vibration_controller._write_u8(0x01, 0b10000000) # reset
@@ -349,23 +350,23 @@ def blit_buffer_rgb565(self, array):
349350
def feedback1(self, _ = None):
350351
if self.vibrator:
351352
self.vibrator.on()
352-
machine.Timer(-1, mode=machine.Timer.ONE_SHOT, period=20, callback=self.feedback_frame)
353+
_thread.stack_size(64) # just a small thread bro i swear it's my last one bro
354+
_thread.start_new_thread(self.feedback_frame, (20,))
353355
elif self.vibration_controller:
354356
self.vibration_controller.sequence[0] = adafruit_drv2605.Effect(2)
355357
self.vibration_controller.play()
356358

357-
358-
359-
360359
def feedback2(self, _ = None):
361360
if self.vibrator:
362361
self.vibrator.on()
363-
machine.Timer(-1, mode=machine.Timer.ONE_SHOT, period=50, callback=self.feedback_frame)
362+
_thread.stack_size(64)
363+
_thread.start_new_thread(self.feedback_frame, (50,))
364364
elif self.vibration_controller:
365365
self.vibration_controller.sequence[0] = adafruit_drv2605.Effect(1)
366366
self.vibration_controller.play()
367367

368-
def feedback_frame(self, _):
368+
def feedback_frame(self, tm):
369+
time.sleep_ms(tm)
369370
if self.vibrator:
370371
self.vibrator.off()
371372

@@ -475,7 +476,6 @@ def irq_touch_process(self, pin):
475476
Single.Kernel.event(Events.GestureEvent(3))
476477

477478
Single.Kernel.event(Events.ReleaseEvent(float(x) / float(Hardware.DISPLAY_WIDTH), float(y) / float(Hardware.DISPLAY_HEIGHT)))
478-
#micropython.schedule(self.feedback1(), "bruh") # why? idk. It's giving recursion errors where it shouldnt
479479
self.feedback1()
480480

481481
def fucky_wucky(self, e): # try to print exception to display

system/Kernel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def kernel_main_thread(self): # thread 0
178178
Logger.log("Thread stack size is: " + str(_thread.stack_size())) # because this sets it back to 4K
179179
Logger.process()
180180
Logger.log("Thread " + str(_thread.get_ident()) + " is Kernel Thread")
181-
Logger.log("with stack size: " + str(_thread.stack_size()))
181+
_thread.stack_size(Single.MP_THREAD_STACK_SIZE)
182+
Logger.log("with stack size: " + str(_thread.stack_size())) # same deal
182183
self.kernel_thread = _thread.get_ident()
183184
Logger.log("Hardware thread: " + str(checkHardwareThread()))
184185
if not self._lock.acquire():

0 commit comments

Comments
 (0)