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 writingpython3 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:
sudo cp comfyScript/bash/comfy /usr/bin/comfy
to assign custom command sudo chmod +x /usr/bin/comfy
to allow executableUsage:
comfy led [ledPin] [ledStatus]
where:
ledPin: LED power pin (BCM pinout)
ledStatus: 1/0 or GPIO.HIGH/GPIO.LOW
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
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
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
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
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
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)
Usage: for single motor control
comfy servo [pin] [angle]
where:
pin: control pin
angle: any numerical angle
Usage: to display, take picture & record video
To start streaming: comfy camera stream
Icons by Iconduck, Reshot
3D Raspberry icon by Icon8
LED Diode icon by Icon8
Icons by Iconduck
E-paper library by Waveshare
Comfy 2.0 development
Comfy 2.0 is a pretty interesting development experience.
- Shorterning
python3 comfyScript/LED/led.py
tocomfy LED
- Alias, bash.rc, bash_profile, & symlink do not work Solution: /usr/bin apps
- 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:
- Translation
comfy.py -> led.py
:- exec() creates 2* time to run (80.000 nano seconds -> 160.000 nano seconds)
- os.system & subsystem create 1000* to run
- Translation
bash script -> comfy.py
:- apparently bash is slower than python: https://blog.carlesmateo.com/2014/10/13/performance-of-several-languages/
Well don't know how but bash -> bash -> led.py works wonder! Anyway, good night!
ComfyScript 1.0
Usage:
python3 comfyScript/LED/led.py [ledPin] [ledStatus]
where:
ledPin: LED power pin (BCM pinout)
ledStatus: 1/0 or GPIO.HIGH/GPIO.LOW
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
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
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
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)
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
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)
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 displaySetup (once):
Enable I2C interface on your Raspberry Pi & reboot
sudo apt-get install python-smbus
sudo apt-get install i2c-tools
---Currently in Beta---
Setup (once):
Enable SPI interface on your Raspberry Pi & reboot
---Currently in Beta---