Example #1
0
def screen_set_clear():
    for pin in screen_data[1:]:
        gpio.digitalWrite(pin, gpio.LOW)
    gpio.digitalWrite(screen_data[0], gpio.HIGH)
    gpio.digitalWrite(screen_rs, gpio.LOW)
    gpio.digitalWrite(screen_cs, gpio.LOW)
    time.sleep(0.005)
    gpio.digitalWrite(screen_cs, gpio.HIGH)
Example #2
0
def main ():
    gpio.setup ()
    gpio.pinMode (LED, gpio.OUTPUT)

    while True:
        print("HIGH");
        gpio.digitalWrite (LED, gpio.HIGH)
        time.sleep(0.5)
        print("LOW");
        gpio.digitalWrite (LED, gpio.LOW)
        time.sleep(0.5)

    return 0
Example #3
0
def screen_write_data(words):
    gpio.digitalWrite(screen_rs, gpio.HIGH)
    for c in words:
        for i in range(0, 8):
            gpio.digitalWrite(screen_data[i], c % 2)
            c //= 2
        gpio.digitalWrite(screen_cs, gpio.LOW)
        gpio.digitalWrite(screen_cs, gpio.HIGH)
        time.sleep(0.00005)
Example #4
0
def freq_out (delay):
    gpio.digitalWrite (out_pin, 1)
    time.sleep (delay)
    gpio.digitalWrite (out_pin, 0)
    time.sleep (delay)
    gpio.digitalWrite (out_pin, 1)
    time.sleep (delay)
    gpio.digitalWrite (out_pin, 0)
    time.sleep (delay)
Example #5
0
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys
from time import sleep
from wiringX import gpio

gpio.setup()

gpio.pinMode(gpio.PIN0, gpio.OUTPUT)

print gpio.platform()
print gpio.I2CRead(0x10)
try:
    while True:
        gpio.digitalWrite(gpio.PIN0, gpio.LOW)
        sleep(1)
        gpio.digitalWrite(gpio.PIN0, gpio.HIGH)
        sleep(1)
except KeyboardInterrupt:
    pass
Example #6
0
def screen_light(on):
    if on: gpio.digitalWrite(screen_led, gpio.LOW)
    else: gpio.digitalWrite(screen_led, gpio.HIGH)
Example #7
0
def screen_input_mode(cursor_right, word_move):
    for pin in screen_data[3:]:
        gpio.digitalWrite(pin, gpio.LOW)
    gpio.digitalWrite(screen_data[2], gpio.HIGH)
    if cursor_right: gpio.digitalWrite(screen_data[1], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[1], gpio.LOW)
    if word_move: gpio.digitalWrite(screen_data[0], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[0], gpio.LOW)
    gpio.digitalWrite(screen_rs, gpio.LOW)
    gpio.digitalWrite(screen_cs, gpio.LOW)
    time.sleep(0.005)
    gpio.digitalWrite(screen_cs, gpio.HIGH)
Example #8
0
def screen_set_function(bitwide, dual, bits):
    gpio.digitalWrite(screen_data[0], gpio.LOW)
    gpio.digitalWrite(screen_data[1], gpio.LOW)
    gpio.digitalWrite(screen_data[5], gpio.HIGH)
    gpio.digitalWrite(screen_data[6], gpio.LOW)
    gpio.digitalWrite(screen_data[7], gpio.LOW)
    if bitwide: gpio.digitalWrite(screen_data[4], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[4], gpio.LOW)
    if dual: gpio.digitalWrite(screen_data[3], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[3], gpio.LOW)
    if bits: gpio.digitalWrite(screen_data[2], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[2], gpio.LOW)
    gpio.digitalWrite(screen_rs, gpio.LOW)
    gpio.digitalWrite(screen_cs, gpio.LOW)
    time.sleep(0.005)
    gpio.digitalWrite(screen_cs, gpio.HIGH)
Example #9
0
def screen_set_display(show, cursor, flash):
    for pin in screen_data[4:]:
        gpio.digitalWrite(pin, gpio.LOW)
    gpio.digitalWrite(screen_data[3], gpio.HIGH)
    if show: gpio.digitalWrite(screen_data[2], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[2], gpio.LOW)
    if cursor: gpio.digitalWrite(screen_data[1], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[1], gpio.LOW)
    if flash: gpio.digitalWrite(screen_data[0], gpio.HIGH)
    else: gpio.digitalWrite(screen_data[0], gpio.LOW)
    gpio.digitalWrite(screen_rs, gpio.LOW)
    gpio.digitalWrite(screen_cs, gpio.LOW)
    time.sleep(0.005)
    gpio.digitalWrite(screen_cs, gpio.HIGH)
Example #10
0
def screen_set_cursor():
    for pin in screen_data[0:-2]:
        gpio.digitalWrite(pin, gpio.LOW)
    gpio.digitalWrite(screen_data[6], gpio.HIGH)
    #gpio.digitalWrite(screen_data[4], gpio.HIGH)
    gpio.digitalWrite(screen_data[7], gpio.HIGH)
    gpio.digitalWrite(screen_rs, gpio.LOW)
    gpio.digitalWrite(screen_cs, gpio.LOW)
    time.sleep(0.005)
    gpio.digitalWrite(screen_cs, gpio.HIGH)
Example #11
0
# PIN21-PIN28 -> D0-D7
screen_data = [29, 28, 27, 26, 25, 24, 23, 22]
# 29 in pin map
screen_led = 21
screen_cs = gpio.PIN2
screen_rs = gpio.PIN3

# set GPIOs
gpio.pinMode(FAN_GPIO, gpio.PINMODE_OUTPUT)
gpio.pinMode(INFRARED_GPIO, gpio.PINMODE_INPUT)
gpio.pinMode(screen_led, gpio.PINMODE_OUTPUT)
gpio.pinMode(screen_cs, gpio.PINMODE_OUTPUT)
gpio.pinMode(screen_rs, gpio.PINMODE_OUTPUT)

# init GPIOs
gpio.digitalWrite(FAN_GPIO, gpio.LOW)
for pin in screen_data:
    gpio.pinMode(pin, gpio.PINMODE_OUTPUT)
    gpio.digitalWrite(pin, gpio.LOW)
gpio.digitalWrite(screen_led, gpio.LOW)
gpio.digitalWrite(screen_cs, gpio.HIGH)
gpio.digitalWrite(screen_rs, gpio.LOW)

# sensor data keys
keylist = [
    'c-pm1.0', 'c-pm2.5', 'c-pm10', 'a-pm1.0', 'a-pm2.5', 'a-pm10', '>0.3um',
    '>0.5um', '>1.0um', '>2.5um', '>5.0um', '>10um', 'voc', 'T', 'RH'
]


# screen control functions
Example #12
0
#
#	Copyright (c) 2016 CurlyMo <*****@*****.**>
#
#  This Source Code Form is subject to the terms of the Mozilla Public
#  License, v. 2.0. If a copy of the MPL was not distributed with this
#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import os
import sys
from time import sleep
from wiringX import gpio

gpio.setup(gpio.RASPBERRYPI1B2);

gpio.pinMode(gpio.PIN0, gpio.PINMODE_OUTPUT);
gpio.pinMode(gpio.PIN1, gpio.PINMODE_INPUT);

try:
	while True:
		print "Writing to pin 0: High";
		gpio.digitalWrite(gpio.PIN0, gpio.HIGH);
		print "Reading from pin 1: "+str(gpio.digitalRead(gpio.PIN1));
		sleep(1);
		print "Writing to pin 0: Low";
		gpio.digitalWrite(gpio.PIN0, gpio.LOW);
		print "Reading from pin 1: "+str(gpio.digitalRead(gpio.PIN1));
		sleep(1);
except KeyboardInterrupt:
	pass
Example #13
0
def setStep (w1, w2, w3, w4):
    gpio.digitalWrite (coil_A_1_pin, w1)
    gpio.digitalWrite (coil_A_2_pin, w2)
    gpio.digitalWrite (coil_B_1_pin, w3)
    gpio.digitalWrite (coil_B_2_pin, w4)
Example #14
0
if os.system('w -V'): exit(1)
if os.system('vmstat -V'): exit(1)
if os.system('cat /proc/cpuinfo| grep "processor"| wc -l'): exit(1)
cores = int(subprocess.getoutput('cat /proc/cpuinfo| grep "processor"| wc -l'))

# raspberrypi3
gpio.setup(gpio.RASPBERRYPI3)
# GPIO.1 PIN12
# wiringX 编码同 wiringPi
FAN_GPIO = gpio.PIN1
fan_status = 1
# set FAN_GPIO output
gpio.pinMode(FAN_GPIO, gpio.PINMODE_OUTPUT)
# init
gpio.digitalWrite(FAN_GPIO, gpio.LOW)

# 状态上报
URL = '127.0.0.1'
PORT = 8080
NAME = 'raspi'

# files
tempFile = '/sys/class/thermal/thermal_zone0/temp'
netFile = '/proc/net/dev'
statusCom = 'w'
ditlCom = 'vmstat'

# 同样的错误半小时上报一次
#gpio_error_time = 0
#temp_exceed_time = 0