Skip to content

Commit

Permalink
fix touch vibration panics on V1 and V3
Browse files Browse the repository at this point in the history
  • Loading branch information
VynDragon committed Jul 1, 2023
1 parent f0f2044 commit 5b2730c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
7 changes: 0 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ def handle_exception(loop, context):
loop = asyncio.get_event_loop()
loop.set_exception_handler(handle_exception)

import machine, time

vibe = machine.Pin(4, machine.Pin.OUT)
vibe.on()
time.sleep_ms(50)
vibe.off()
vibe = None

set_global_exception() # Debug aid
Single.Kernel = Kernel() # Constructor might create tasks
Expand Down
16 changes: 8 additions & 8 deletions system/Hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def __init__(self):
#acc_config = 0x17
#self.imu.write_byte(bma423.BMA4_ACCEL_CONFIG_ADDR, acc_config)
#print("int1 imu:", self.imu.read_byte(bma423.BMA4_INT1_IO_CTRL_ADDR))
self.imu.map_int(0, bma423.BMA423_WAKEUP_INT | bma423.BMA423_ANY_NO_MOTION_INT)
self.imu.map_int(0, bma423.BMA423_WAKEUP_INT)
self.imu.map_int(1, 0)
feat_data = self.imu.read_data(bma423.BMA4_FEATURE_CONFIG_ADDR, bma423.BMA423_FEATURE_SIZE)
feat_data[bma423.BMA423_WAKEUP_OFFSET] = 0x03 # enable and sensitivity 2/7
Expand Down Expand Up @@ -254,6 +254,7 @@ def __init__(self):

if self.WatchVersion == WATCHV1 or self.WatchVersion == WATCHV3:
self.vibrator = machine.Pin(4, machine.Pin.OUT)
self.vibration_controller = None
else:
self.vibration_controller = adafruit_drv2605.DRV2605(sensor_i2c)
self.vibration_controller._write_u8(0x01, 0b10000000) # reset
Expand Down Expand Up @@ -349,23 +350,23 @@ def blit_buffer_rgb565(self, array):
def feedback1(self, _ = None):
if self.vibrator:
self.vibrator.on()
machine.Timer(-1, mode=machine.Timer.ONE_SHOT, period=20, callback=self.feedback_frame)
_thread.stack_size(64) # just a small thread bro i swear it's my last one bro
_thread.start_new_thread(self.feedback_frame, (20,))
elif self.vibration_controller:
self.vibration_controller.sequence[0] = adafruit_drv2605.Effect(2)
self.vibration_controller.play()




def feedback2(self, _ = None):
if self.vibrator:
self.vibrator.on()
machine.Timer(-1, mode=machine.Timer.ONE_SHOT, period=50, callback=self.feedback_frame)
_thread.stack_size(64)
_thread.start_new_thread(self.feedback_frame, (50,))
elif self.vibration_controller:
self.vibration_controller.sequence[0] = adafruit_drv2605.Effect(1)
self.vibration_controller.play()

def feedback_frame(self, _):
def feedback_frame(self, tm):
time.sleep_ms(tm)
if self.vibrator:
self.vibrator.off()

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

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

def fucky_wucky(self, e): # try to print exception to display
Expand Down
3 changes: 2 additions & 1 deletion system/Kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def kernel_main_thread(self): # thread 0
Logger.log("Thread stack size is: " + str(_thread.stack_size())) # because this sets it back to 4K
Logger.process()
Logger.log("Thread " + str(_thread.get_ident()) + " is Kernel Thread")
Logger.log("with stack size: " + str(_thread.stack_size()))
_thread.stack_size(Single.MP_THREAD_STACK_SIZE)
Logger.log("with stack size: " + str(_thread.stack_size())) # same deal
self.kernel_thread = _thread.get_ident()
Logger.log("Hardware thread: " + str(checkHardwareThread()))
if not self._lock.acquire():
Expand Down

0 comments on commit 5b2730c

Please sign in to comment.