mirror of
https://github.com/dbisu/pico-ducky.git
synced 2025-12-06 02:41:45 +00:00
making light pwm (#68)
Co-authored-by: unknown <ask.wietting@gmail.com>
This commit is contained in:
@@ -19,8 +19,25 @@ import supervisor
|
|||||||
import time
|
import time
|
||||||
import digitalio
|
import digitalio
|
||||||
from board import *
|
from board import *
|
||||||
led = digitalio.DigitalInOut(LED)
|
import pwmio
|
||||||
led.direction = digitalio.Direction.OUTPUT
|
|
||||||
|
led = pwmio.PWMOut(LED, frequency=5000, duty_cycle=0)
|
||||||
|
|
||||||
|
def led_pwm_up(led):
|
||||||
|
for i in range(100):
|
||||||
|
# PWM LED up and down
|
||||||
|
if i < 50:
|
||||||
|
led.duty_cycle = int(i * 2 * 65535 / 100) # Up
|
||||||
|
time.sleep(0.01)
|
||||||
|
def led_pwm_down(led):
|
||||||
|
for i in range(100):
|
||||||
|
# PWM LED up and down
|
||||||
|
if i >= 50:
|
||||||
|
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
# led = digitalio.DigitalInOut(LED)
|
||||||
|
# led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
duckyCommands = {
|
duckyCommands = {
|
||||||
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
|
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
|
||||||
@@ -109,8 +126,7 @@ supervisor.disable_autoreload()
|
|||||||
# sleep at the start to allow the device to be recognized by the host computer
|
# sleep at the start to allow the device to be recognized by the host computer
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
|
|
||||||
led.value = True
|
led_pwm_up(led)
|
||||||
|
|
||||||
|
|
||||||
def getProgrammingStatus():
|
def getProgrammingStatus():
|
||||||
# check GP0 for setup mode
|
# check GP0 for setup mode
|
||||||
@@ -198,8 +214,12 @@ if(progStatus == False):
|
|||||||
else:
|
else:
|
||||||
print("Update your payload")
|
print("Update your payload")
|
||||||
|
|
||||||
|
led_state = False
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1.0)
|
if led_state:
|
||||||
led.value = False
|
led_pwm_up(led)
|
||||||
time.sleep(1.0)
|
led_state = False
|
||||||
led.value = True
|
else:
|
||||||
|
led_pwm_down(led)
|
||||||
|
led_state = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user