Skip to content

A scripting language to control Raspberry Pi with comfyPi

Notifications You must be signed in to change notification settings

ThomasVuNguyen/comfyScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

comfyScript

A scripting language to control Raspberry Pi with comfyPi

A more elegant approach to Raspberry Pi

Comfy2.0 Update - Development experience improved! Imaging instead of writing
python3 comfyScript/LED/led.py [ledPin] [ledStatus]
Use can write
comfy led [ledPin] [ledStatus]
Well now you can! This will automatically be available if used with ComfySpace 3.0. If you want to do it manually or without ComfySpace:
  • Make sure comfyScript folder/repo is in your home directory
  • Run sudo cp comfyScript/bash/comfy /usr/bin/comfy to assign custom command
  • Run sudo chmod +x /usr/bin/comfy to allow executable
  • Start making!
  • Single-color LED

    Usage:
    comfy led [ledPin] [ledStatus]
      where:
        ledPin: LED power pin (BCM pinout)
        ledStatus: 1/0 or GPIO.HIGH/GPIO.LOW
    

    RGB LED

    Usage:
    comfy rgbled [redPin] [greenPin] [bluePin] [redStatus] [greenStatus] [blueStatus]
      where:
        redPin, greenPin & bluePin: pins for red, green & blue terminals (BCM pinout)
        redStatus, greenStatus, blueStatus: 1/0 or GPIO.HIGH/GPIO.LOW
    

    DHT (3 pins)

    Usage:
    comfy dht_temp [sensor type] [pinout]   -> temperature (C)
    comfy dht_humid [sensor type] [pinout]   -> relative humidity
      where:
        sensor type: 11,22, or 2302
        pinout: pinout to read sensor
    

    Stepper Motor

    Usage:
    comfy stepper [pin1] [pin2] [pin3] [pin4] [direction]
    
      where:
        pin1 to pin4: pins 1 -> 4 (ULN2003 driver board)
        direction: -1 for clockwise, 0 for stop & 1 for counter clockwise
    
    future plan: option for full, one-and-a-half, and one step control
    note: currently, there is a 0.1 second delay between direction changes - to be improved
    

    Distance Sensor (HC-SR04 and infared shock sensor)

    Usage:
    comfy distance [trig] [echo] [state]
    comfy avoidance [pin] [state]
    
      where:
        HC-SR04.py -> ultrasound sensor & avoidance_sensor.py for infared sensor
        pin: avoidance sensor pun
        trig & echo: trigger & echo pins
        state: 1 - running & 0 - disable (used to enable sensor from different SSH clients)
    
    future plan: option for distance in m, inches & ft (currently in cm)
    note: the reading rate is once every 0.1s, this can be changed manually if needed
    

    Buzzer (and passive buzzer)

    Usage:
    comfy buzzer [pin] [state]
    comfy passive_buzzer [pin] [state]
    
      where:
        passive_buzzer.py is used to passive buzzer
        pin: pinout to control buzzer
        state: 1 - running & 0 - disable 
    
    

    DC Motor & L298N motor controller

    Usage: for single motor control
    comfy dc [pin1] [pin2] [state1] [state2]
    
      where:
        
        pin1 -> pin4: L298 pinout connections
        state1 -> state 1: states of pin1 to pin4 (state = 1 means on and state = 0 means off)
    
    

    Servo Motor

    Usage: for single motor control
    comfy servo [pin] [angle]
    
      where:
        
        pin: control pin
        angle: any numerical angle
    
    

    Raspberry Pi camera

    Usage: to display, take picture & record video
    
    To start streaming: comfy camera stream
    
    

    Credits

    Icons by Iconduck, Reshot
    3D Raspberry icon by Icon8
    LED Diode icon by Icon8
    Icons by Iconduck
    E-paper library by Waveshare

    Dev blog

    Comfy 2.0 development

    Comfy 2.0 is a pretty interesting development experience.

    1. Shorterning python3 comfyScript/LED/led.py to comfy LED
    • Alias, bash.rc, bash_profile, & symlink do not work Solution: /usr/bin apps
    1. Performance
    • Running a bash script -> refer to central comfy.py -> led.py This caused a noticable latency issue.

    Let's take a look at how:

    Well don't know how but bash -> bash -> led.py works wonder! Anyway, good night!

    Optional

    ComfyScript 1.0

    Single-color LED

    Usage:
    python3 comfyScript/LED/led.py [ledPin] [ledStatus]
      where:
        ledPin: LED power pin (BCM pinout)
        ledStatus: 1/0 or GPIO.HIGH/GPIO.LOW
    

    RGB LED

    Usage:
    python3 comfyScript/LED/RGB_led.py [redPin] [greenPin] [bluePin] [redStatus][greenStatus] [blueStatus]
      where:
        redPin, greenPin & bluePin: pins for red, green & blue terminals (BCM pinout)
        redStatus, greenStatus, blueStatus: 1/0 or GPIO.HIGH/GPIO.LOW
    

    DHT (3 pins)

    Usage:
    python3 comfyScript/DHT/dht_temp.py [sensor type] [pinout]   -> temperature (C)
    python3 comfyScript/DHT/dht_humid.py [sensor type] [pinout]   -> relative humidity
      where:
        sensor type: 11,22, or 2302
        pinout: pinout to read sensor
    

    Stepper Motor

    Usage:
    python3 comfyScript/stepper/stepper.py [pin1] [pin2] [pin3] [pin4] [direction]
    
      where:
        pin1 to pin4: pins 1 -> 4 (ULN2003 driver board)
        direction: -1 for clockwise, 0 for stop & 1 for counter clockwise
    

    Distance Sensor (HC-SR04 and infared shock sensor)

    Usage:
    python3 comfyScript/distance_sensor/HC-SR04.py [trig] [echo] [state]
    python3 comfyScript/avoidance_sensor/avoidance_sensor.py [pin] [state]
    
      where:
        HC-SR04.py -> ultrasound sensor & avoidance_sensor.py for infared sensor
        pin: avoidance sensor pun
        trig & echo: trigger & echo pins
        state: 1 - running & 0 - disable (used to enable sensor from different SSH clients)
    

    Buzzer (and passive buzzer)

    Usage:
    python3 comfyScript/buzzer/buzzer.py [pin] [state]
    python3 comfyScript/buzzer/passive_buzzer.py [pin] [state]
    
      where:
        passive_buzzer.py is used to passive buzzer
        pin: pinout to control buzzer
        state: 1 - running & 0 - disable 
    
    

    DC Motor & L298N motor controller

    Usage:
    python3 comfyScript/motor/DCmotor.py pin1 pin2 pin3 pin4 state1 state2 state3 state4
    python3 comfyScript/motor/DCmotor_single.py pin1 pin2 state1 state2 (for single motor control)
    
      where:
        
        pin1 -> pin4: L298 pinout connections
        state1 -> state 1: states of pin1 to pin4 (state = 1 means on and state = 0 means off)
    
    

    Servo Motor

    Usage: for single motor control
    python3 comfyScript/servo/sg90.py [pin] [angle]
    
      where:
        
        pin: control pin
        angle: Any numerical angle
    
    
    Active development ## 0.96 inch I2C OLED display
    Setup (once):
    Enable I2C interface on your Raspberry Pi & reboot
    sudo apt-get install python-smbus
    sudo apt-get install i2c-tools
    
    ---Currently in Beta---
    
    

    2.7 in. e-Paper HAT

    Setup (once):
    Enable SPI interface on your Raspberry Pi & reboot
    
    ---Currently in Beta---
    
    

    About

    A scripting language to control Raspberry Pi with comfyPi

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published