diff --git a/main.py b/main.py index 20a6fc1..e3ddb78 100644 --- a/main.py +++ b/main.py @@ -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 diff --git a/system/Hardware.py b/system/Hardware.py index 1934cf7..02ac2f6 100644 --- a/system/Hardware.py +++ b/system/Hardware.py @@ -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 @@ -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 @@ -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() @@ -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 diff --git a/system/Kernel.py b/system/Kernel.py index 445daa8..14410ad 100644 --- a/system/Kernel.py +++ b/system/Kernel.py @@ -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():