cleanup
This commit is contained in:
parent
ce6c408a9f
commit
a8831884e4
@ -8,13 +8,16 @@ class Button():
|
|||||||
self.debounceTimeMs = int(debounceTimeMs)
|
self.debounceTimeMs = int(debounceTimeMs)
|
||||||
self.clickTime = clickTime
|
self.clickTime = clickTime
|
||||||
self.pushDownTimeStamp = -clickTime
|
self.pushDownTimeStamp = -clickTime
|
||||||
|
self.setCallbacks(onPushDown,onPushUp,onClick,onHold)
|
||||||
|
self.pin.irq(trigger=machine.Pin.IRQ_RISING|machine.Pin.IRQ_FALLING , handler=self._IRQ)
|
||||||
|
self.value = self.pin.value()
|
||||||
|
self.inverted = inverted
|
||||||
|
|
||||||
|
def setCallbacks(self,onPushDown = None, onPushUp = None,onClick = None,onHold = None):
|
||||||
self.onPushDown = onPushDown
|
self.onPushDown = onPushDown
|
||||||
self.onPushUp = onPushUp
|
self.onPushUp = onPushUp
|
||||||
self.onClick = onClick
|
self.onClick = onClick
|
||||||
self.onHold = onHold
|
self.onHold = onHold
|
||||||
self.pin.irq(trigger=machine.Pin.IRQ_RISING|machine.Pin.IRQ_FALLING , handler=self._IRQ)
|
|
||||||
self.value = self.pin.value()
|
|
||||||
self.inverted = inverted
|
|
||||||
|
|
||||||
def _IRQ(self,p):
|
def _IRQ(self,p):
|
||||||
new_value = self.pin.value()
|
new_value = self.pin.value()
|
||||||
|
2
boot.py
2
boot.py
@ -3,7 +3,7 @@ import webrepl
|
|||||||
|
|
||||||
webrepl.start()
|
webrepl.start()
|
||||||
|
|
||||||
sta_if = network.WLAN(network.STA_IF);
|
sta_if = network.WLAN(network.STA_IF)
|
||||||
sta_if.active(True)
|
sta_if.active(True)
|
||||||
|
|
||||||
#load wifi credentials from file
|
#load wifi credentials from file
|
||||||
|
9
main.py
9
main.py
@ -28,13 +28,16 @@ Buzzer = machine.PWM(machine.Pin(2), freq=10000, duty=0)
|
|||||||
stepDurationMs = 8
|
stepDurationMs = 8
|
||||||
stepperminu = StepperL298M.Stepper([19,21,22,23],inverted=False,stepDurationMs=stepDurationMs)
|
stepperminu = StepperL298M.Stepper([19,21,22,23],inverted=False,stepDurationMs=stepDurationMs)
|
||||||
stepperhour = StepperL298M.Stepper([12,27,26,25],inverted=True, stepDurationMs=stepDurationMs)
|
stepperhour = StepperL298M.Stepper([12,27,26,25],inverted=True, stepDurationMs=stepDurationMs)
|
||||||
clock = StepperClock.StepperClock(stepperhour,stepperminu)
|
|
||||||
|
|
||||||
|
|
||||||
leftButtonLED = machine.Pin(32,machine.Pin.OUT)
|
leftButtonLED = machine.Pin(32,machine.Pin.OUT)
|
||||||
middleButtonLED = machine.Pin(33,machine.Pin.OUT)
|
middleButtonLED = machine.Pin(33,machine.Pin.OUT)
|
||||||
rightButtonLED = machine.Pin(13,machine.Pin.OUT)
|
rightButtonLED = machine.Pin(13,machine.Pin.OUT)
|
||||||
|
|
||||||
|
|
||||||
|
clock = StepperClock.StepperClock(stepperhour,stepperminu)
|
||||||
|
|
||||||
|
|
||||||
def leftButtonClickDown():
|
def leftButtonClickDown():
|
||||||
leftButtonLED.on()
|
leftButtonLED.on()
|
||||||
def leftButtonClickUp():
|
def leftButtonClickUp():
|
||||||
@ -56,10 +59,6 @@ def rightButtonClick():
|
|||||||
else:
|
else:
|
||||||
stepperminu.rotateTo(stepperminu.getOrientation()-0.25)
|
stepperminu.rotateTo(stepperminu.getOrientation()-0.25)
|
||||||
|
|
||||||
#if(clock.isRunning()):
|
|
||||||
# stepperhour.stepnum = (stepperhour.stepnum+8)%stepperhour.stepsPerRev
|
|
||||||
#else:
|
|
||||||
# stepperhour.rotateTo(stepperhour.getOrientation()+0.25)
|
|
||||||
rightButton = Button.Button(pin=34,onPushDown=rightButtonClickDown,onPushUp=rightButtonClickUp,onClick=rightButtonClick,inverted=True)
|
rightButton = Button.Button(pin=34,onPushDown=rightButtonClickDown,onPushUp=rightButtonClickUp,onClick=rightButtonClick,inverted=True)
|
||||||
|
|
||||||
def middleButtonClickDown():
|
def middleButtonClickDown():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user