コード例 #1
0
    def __init__(self, vehicle_type, name, network_type, display, kill, location_data):

        #socket for broadcasting telemetry to gcs
        self.telem_broadcast_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        self.telem_broadcast_sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MULTICAST_TTL)
        self.telem_broadcast_sock.settimeout(0.4)
        self.telem_broadcast_sock.setsockopt(socket.SOL_SOCKET, 25, str(BIND_INTERFACE + '\0').encode('utf-8'))
        self.telem_broadcast_sock.bind((TELEM_IP, TELEM_PORT))

        #socket for listening to other vehicle telemetry
        self.vehicle_to_vehicle_telem_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.vehicle_to_vehicle_telem_sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MULTICAST_TTL)
        self.vehicle_to_vehicle_telem_sock.setsockopt(socket.SOL_SOCKET, 25, str(BIND_INTERFACE + '\0').encode('utf-8'))
        self.vehicle_to_vehicle_telem_sock.bind((TELEM_IP, V2V_TELEM_PORT))
        
        self.vehicle_type = vehicle_type
        self.name = name
        self.gufi = ""
        self.update_rate = 1

        self.network_type = network_type
        self.kill = kill
        self.agent_lock = threading.Lock()
        self.agents = {}
        self.identify_peripherals()
        
        self.display = display
        if display: self.lcd = lcd.lcd()
        
        self.location_data = location_data
        self.gps = None
コード例 #2
0
 def set(self, num):
     oldnum = self.read()
     if oldnum != num:
         lcd16 = lcd.lcd(0x3f)
         #lcd20 = lcd.lcd(0x27)
         lcd16.backlight(1)
         #lcd20.backlight(1)
         self.clear()
         name = ""
         if num == 1:
             name = "Salon"
             self.pcf.port[3] = False
         elif num == 2:
             name = "Kriss"
             self.pcf.port[4] = False
         elif num == 3:
             name = "FreeBox"
             self.pcf.port[5] = False
         elif num == 4:
             name = "TV"
             self.pcf.port[6] = False
         elif num == 5:
             name = "Cyke"
             self.pcf.port[7] = False
         self.write(num, name)
         lcd16.printlcd("Source : " + name, 1)
         #lcd20.printlcd("Source : " + name, 1)
     else:
         lcd16 = lcd.lcd(0x3f)
         #lcd20 = lcd.lcd(0x27)
         lcd16.backlight(1)
         #lcd20.backlight(1)
         name = ""
         if num == 1:
             name = "Salon"
         elif num == 2:
             name = "Kriss"
         elif num == 3:
             name = "FreeBox"
         elif num == 4:
             name = "TV"
         elif num == 5:
             name = "Cyke"
         lcd16.printlcd("Source : " + name, 1)
コード例 #3
0
ファイル: device.py プロジェクト: pphhss/IoT_Project_8team
    def __init(self):
        self.mqttAdater = ma.MQTTAdapter()
        self.sensormanager = sm.SensorManager()
        self.lcd = lcd.lcd()
        self.button_led = button_led.Button_LED()

        self.isStart = False
        print("DEVICE START")
        self.__processing()
        self.__receiving()
        self.__rfid_listening()
        print("DEVICE PROCESSING..")
        self.__listen()
コード例 #4
0
ファイル: goopy_display.py プロジェクト: alyf80/goopy
    def __init__(self, model, interval=1, delay=2):
        super().__init__(interval=interval, delay=delay)

        self._model = model

        self._lcd = lcd.lcd(cols=_COLS)
        self._lcd.clear()

        _sem.acquire()
        try:
            for i in range(0, len(_BANNER) - 1):
                self._lcd.print(_BANNER[i].center(_COLS), i)
            self._lcd.show()
        finally:
            _sem.release()
コード例 #5
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_zero():
    assert_equals(lcd(0), " _ \n| |\n|_|")
コード例 #6
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_all():
    assert_equals(lcd(123456789), """\
    _  _     _  _  _  _  _ 
  | _| _||_||_ |_   ||_||_|
  ||_  _|  | _||_|  ||_| _|""")
コード例 #7
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_nine():
    assert_equals(lcd(9), " _ \n|_|\n _|")     
コード例 #8
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_seven():
    assert_equals(lcd(7), " _ \n  |\n  |")
コード例 #9
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_five():
    assert_equals(lcd(5), " _ \n|_ \n _|")
コード例 #10
0
__author__ = 'beau'

import pyb
import micropython
from MAX6675 import MAX6675
from PDM import PDM
from rotary import rotary
import lcd as LCD
from PID import PID

micropython.alloc_emergency_exception_buf(100)

pdm = PDM()
tc = MAX6675()
knob = rotary()
lcd = LCD.lcd()

pdm.set_output(0.7)


def get_temp():
    global tc
    return tc.FIR.get_value() * 0.25


pid = PID(get_temp, pdm.set_output)

# sw = pyb.Switch()
# sw_state = 1
# def toggle():
#     global sw_state
コード例 #11
0
ファイル: logger.py プロジェクト: avallete/PokemonGo-Bot
from __future__ import unicode_literals
import time

try:
    import lcd
    lcd = lcd.lcd()
    # Change this to your i2c address
    lcd.set_addr(0x23)
except Exception:
    lcd = False


def log(string, color='white'):
    color_hex = {
        'red': '91m',
        'green': '92m',
        'yellow': '93m',
        'blue': '94m',
        'cyan': '96m'
    }
    if color not in color_hex:
        print('[{time}] {string}'.format(
            time=time.strftime("%H:%M:%S"),
            string=string.decode('utf-8')
        ))
    else:
        print(
            '[{time}] \033[{color} {string} \033[0m'.format(
                time=time.strftime("%H:%M:%S"),
                color=color_hex[color],
                string=string.decode('utf-8')
コード例 #12
0
ファイル: main.py プロジェクト: B3AU/micropython
__author__ = 'beau'

import pyb
import micropython
from MAX6675 import MAX6675
from PDM import PDM
from rotary import rotary
import lcd as LCD
from PID import PID

micropython.alloc_emergency_exception_buf(100)

pdm = PDM()
tc = MAX6675()
knob = rotary()
lcd = LCD.lcd()

pdm.set_output(0.7)

def get_temp():
    global tc
    return tc.FIR.get_value()*0.25

pid = PID(get_temp,pdm.set_output)


# sw = pyb.Switch()
# sw_state = 1
# def toggle():
#     global sw_state
#     if sw_state == 0:
コード例 #13
0
 def __init__(self):
     self.lcd = lcd.lcd()
     self.lcd.clear()
     self.where_to_write = 1
コード例 #14
0
ファイル: plug.py プロジェクト: Colorado4Wheeler/LCD-Creator
import datetime
from datetime import timedelta
import time
import indigo
import sys
import re  # regular expressions
import eps  # 1.13
import dtutil  # 1.13

from lcd import lcd

lcdlib = lcd()
parent = None

#
# Definitions
#
defThermostat = ["temperatureInput1", "humidity", "setpointHeat", "setpointCool"]
defSprinklers = ["activeZone", "activeZone.ui"]

defNOAA = ["currentCondition", "humidity", "windDegrees", "windDirection", "windMPH"]
defWeathersnoop = [
    "humidity",
    "weather",
    "windDirection",
    "windDirection.ui",
    "solarRadiation",
    "temperature_F.ui",
]  # any .ui here are just so we trigger a state change to calculate other things that don't exist in the weathersnoop device (like "feelslike")
defWUnderground = [
    "currentWeather",
コード例 #15
0
ファイル: constants.py プロジェクト: thorrak/fuscus
DOOR = door.door(door_pin, door_open_state)

if rotary is not None:
    encoder = rotaryEncoder.rotaryEncoder(rotary_A, rotary_B, rotary_PB)
else:
    encoder = rotaryEncoder.rotaryEncoder(0, 0, 0, dummy=True)

encoder.start()

heater = relay.relay(relay_HOT, invert=invert_hot)
cooler = relay.relay(relay_COLD, invert=invert_cold)


# Nokia LCD has 17 chars by 6 lines, but original display and web display
# show 20 chars by 4 lines, so make a buffer at least that big.
LCD = lcd.lcd(lines=6, chars=20, hardware=LCD_hardware)

tempControl = tempControl.tempController(ID_fridge, ID_beer, ID_ambient,
                                         cooler=cooler, heater=heater, door=DOOR)

# Set the temperature calibration offsets (if available)
# FIXME - This should be part of deviceManager & saved to/loaded from the eeprom
tempControl.fridgeSensor.calibrationOffset = fridgeCalibrationOffset
tempControl.beerSensor.calibrationOffset = beerCalibrationOffset
tempControl.ambientSensor.calibrationOffset = ambientCalibrationOffset

eepromManager = EepromManager.eepromManager(tempControl=tempControl)

piLink = piLink.piLink(tempControl=tempControl, path=config['port'].get('path'), eepromManager=eepromManager)

menu = Menu.Menu(encoder=encoder, tempControl=tempControl, piLink=piLink)
コード例 #16
0
ファイル: clock.py プロジェクト: jidey43/clock
def ring():
    print("ring")
    pass


def loop():
    while True:
        schedule.run_pending()
        lcd.update(tmp)
        if GPIO.input(12) == GPIO.LOW:
            print("next")
            music.next_song()
        time.sleep(1)

if __name__ == '__main__':
    lcd = lcd()
    tmp = temp()
    lamp = Lamp()
    lcd.update(tmp)
    sleep(5)
    music = Music()
    music.load_random()
    music.play_random()
    lamp.switch_on()
    lcd.wake_up(tmp)

    buttonPin = 12  # define the buttonPin
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    t = Thread(target=loop)
コード例 #17
0
ファイル: remoteRoom.py プロジェクト: Gui-B/Pi-sound-controle
#!/usr/bin/python
from pcf8574 import PCF8574
from time import sleep
import soundRelay as rl
import lcd

i2c_port_num = 1
btn_add = 0x38

btn = PCF8574(i2c_port_num, btn_add)
s = rl.soundrelay()

while True:
    if btn.port[0] is False:
        s.set(3)
    elif btn.port[1] is False:
        s.set(2)
    elif btn.port[2] is False:
        s.set(4)
    elif btn.port[3] is False:
        s.set(1)
    elif btn.port[4] is False:
        s.set(5)
    elif btn.port[5] is False:
        lcd16 = lcd.lcd(0x3f)
        #lcd20 = lcd.lcd(0x27)
        lcd16.backlight(0)
        #lcd20.backlight(0)
    sleep(0.1)

コード例 #18
0
#!/usr/bin/python

import sys
sys.path.append("/root/rpi-lcd")
import lcd
import time


lcd1 = lcd.lcd(0x27)
lcd2 = lcd.lcd(0x3f)
lcd1.backlight(1)
lcd2.backlight(1)
lcd1.printlcd( "blbl", 1)
time.sleep(1)
lcd1.printlcd( "blbl", 2)
time.sleep(1)
lcd1.printlcd("blbl", 3)
time.sleep(1)
lcd1.printlcd("blbl", 4)
time.sleep(2)
lcd2.printlcd("blbl", 1)
time.sleep(1)
lcd2.printlcd("blbl", 2)
time.sleep(2)
lcd1.backlight(0)
lcd2.backlight(0)
コード例 #19
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_one():
    assert_equals(lcd(1), "   \n  |\n  |")
コード例 #20
0
ファイル: ulsm (1).py プロジェクト: BrandonNgo721k/Smart-Home
    return GPIO.input(13)


mode = 0
switches = 0
#Catch when script is interupted, cleanup correctly
#light > 20000 equals dark
#distance < 20in then movement
try:
    # Main loop
    while True:
        runs = 0
        sent = 1
        #security mode
        while (mode == 1 & (runs < 10)):
            lcd.lcd_display_string(lcd(), 'Security Mode', 1)
            message = 'From Raspberry Pi: Security Compromised ' + str(sent)
            light = rc_time(pin_to_circuit)
            if light > 20000:
                lightprint = 'It is dark'
            else:
                lightprint = 'Light has been shown'
            #distance = distanceIN(PIN_TRIGGER, PIN_ECHO)
            #setup()
            distance = getDistanceIn()

            print "Light:", light, ' ', lightprint
            print "Distance:", distance, "in"
            #for movement or light send email
            if (light < 20000 or int(distance) < 20):
                if light < 20000:
コード例 #21
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_three():
    assert_equals(lcd(3), " _ \n _|\n _|")
コード例 #22
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_two():
    assert_equals(lcd(2), " _ \n _|\n|_ ")
コード例 #23
0
# pylint: disable=redefined-builtin
from __future__ import print_function
from builtins import str
import time

from colorama import Fore, Back, Style
from pokemongo_bot.event_manager import manager

# Uncomment for type annotations on Python 3
# from typing import Optional

try:
    # pylint: disable=import-error
    import lcd  # type: ignore

    LCD = lcd.lcd()
    # Change this to your i2c address
    LCD.set_addr(0x23)
except ImportError:
    LCD = None


def log(string, color="black", prefix=None, fire_event=True):
    # type: (str, Optional[str], Optional[str], Optional[bool]) -> None
    if fire_event:
        manager.fire("logging", text=string, color=color, prefix=prefix)
    else:
        _log(text=string, color=color, prefix=prefix)


@manager.on("logging")
コード例 #24
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_four():
    assert_equals(lcd(4), "   \n|_|\n  |")
コード例 #25
0
 def __init__(self):
     self.sc = lcd.lcd(address)
コード例 #26
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_six():
    assert_equals(lcd(6), " _ \n|_ \n|_|")
コード例 #27
0
ファイル: constants.py プロジェクト: V4lidus/fuscus
# Global objects for our hardware devices
DOOR = door.door(door_pin, door_open_state)

if rotary is not None:
    encoder = rotaryEncoder.rotaryEncoder(rotary_A, rotary_B, rotary_PB)
else:
    encoder = rotaryEncoder.rotaryEncoder(0, 0, 0, dummy=True)

encoder.start()

heater = relay.relay(relay_HOT, invert=invert_hot)
cooler = relay.relay(relay_COLD, invert=invert_cold)

# Nokia LCD has 17 chars by 6 lines, but original display and web display
# show 20 chars by 4 lines, so make a buffer at least that big.
LCD = lcd.lcd(lines=6, chars=20, hardware=LCD_hardware)

tempControl = tempControl.tempController(ID_fridge,
                                         ID_beer,
                                         ID_ambient,
                                         cooler=cooler,
                                         heater=heater,
                                         door=DOOR)

# Set the temperature calibration offsets (if available)
# FIXME - This should be part of deviceManager & saved to/loaded from the eeprom
tempControl.fridgeSensor.calibrationOffset = fridgeCalibrationOffset
tempControl.beerSensor.calibrationOffset = beerCalibrationOffset
tempControl.ambientSensor.calibrationOffset = ambientCalibrationOffset

eepromManager = EepromManager.eepromManager(tempControl=tempControl)
コード例 #28
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_eight():
    assert_equals(lcd(8), " _ \n|_|\n|_|") 
コード例 #29
0
ファイル: vibraTest.py プロジェクト: raditv/implantChecker
#!/usr/bin/python
import sys
sys.path.append("../lib")
import lcd
import accelerometer
import math
import time

accel = accelerometer.mpu6050()
screen = lcd.lcd()

accel.setup()
accel.setSampleRate(100)
accel.setGResolution(16)
screen.lcd_clear()

I = accel.readData()

Threshold = 0.2
ShakeFlag = False

while True:
    while (accel.readStatus() & 1) == 0:
        pass
        I = accel.readData()
        PeakForce = 0
        for loop in range(20):
            while (accel.readStatus() & 1) == 0:
                pass
        C = accel.readData()
        CurrentForce = math.sqrt((C.Gx - I.Gx) * (C.Gx - I.Gx) +
コード例 #30
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_onefourseven():
    assert_equals(lcd(147), """\
       _ 
  ||_|  |
  |  |  |""")
コード例 #31
0
#!/usr/bin/python
import pyowm
import lcd
lcd16 = lcd.lcd(0x3f)
lcd20 = lcd.lcd(0x27)
while True:
    owm = pyowm.OWM('d1063f632e75759f0dedbcae4ab9e830')
    observation = owm.weather_at_place('Toulouse,fr')
    w = observation.get_weather()
    temp = w.get_temperature('celsius')

コード例 #32
0
ファイル: test_lcd.py プロジェクト: SalzPUG/lcd
def test_lcd_string():
    assert_equals(lcd("0123456789"), """\
 _     _  _     _  _  _  _  _ 
| |  | _| _||_||_ |_   ||_||_|
|_|  ||_  _|  | _||_|  ||_| _|""")
コード例 #33
0
# Trainer INITIALIZATION
trainer = Trainer(conditions, task)

## TRACKING FILENAME
if filename is None:
    filename = '/home/pi/Videos/' + time.strftime("%Y%m%d_%H%M%S-") + 'tracker'
## RECORDING FILENAME
if recording:
    fourcc = cv2.VideoWriter_fourcc(*'MJPG')
    out = cv2.VideoWriter(
        os.path.join(videopath,
                     time.strftime("%Y%m%d_%H%M%S-") + filename + '.avi'),
        fourcc, framerate, resolution)

# LCD - open screen window
lcd = lcd(fullscr=True)

currentTime = time.time()
prevTime = time.time()
fps = None
counter = 0
TTLactive = True
cv2.namedWindow('Frame', cv2.WINDOW_FREERATIO)
# VIDEOTRACKING CALIBRATION
if posTracker:
    print('- Tracking Variables')
    print('     Finding arena: please wait...')
    clahe = cv2.createCLAHE(clipLimit=1.0, tileGridSize=(5, 5))
    x, y, w, h = 0, 0, 0, 0
    while (x, y, w, h) == (0, 0, 0, 0):
        frame = cap.read()
コード例 #34
0
ファイル: ds485.py プロジェクト: tanzilli/ds485
		s.connect(('8.8.8.8', 1))  # connect() for UDP doesn't send packets
		local_ip_address = s.getsockname()[0]
		return local_ip_address
	except:
		return "NO IP"	

def uptime():
	with open('/proc/uptime', 'r') as f:
		uptime_seconds = float(f.readline().split()[0])
		uptime_string = str(timedelta(seconds = uptime_seconds))

	return(uptime_string)

CONFIG_FILE="ds485.ini"

display=lcd.lcd()
display.backlight_on()
key=keys.KEYS()
relay=GPIO("J4.29","OUTPUT")
led=GPIO("PB8","OUTPUT")

STATE_INIT=0
STATE_WELCOME=1
STATE_MYADDR=2
STATE_TEMPERATURES=3
STATE_MYIP=4
STATE_UPTIME=5
STATE_MESSAGES=6
STATE_TEST_RELAY=7
STATE_BACKLIGHT=8
LAST_STATE=8
コード例 #35
0
from lcd import lcd
import time

display = lcd()

display.lcd_display_string("Hello", 1)

display.lcd_display_string("World!", 2)

time.sleep(3)

display.lcd_clear()
コード例 #36
0
ファイル: main.py プロジェクト: hemant-45/Rpi-codes
import lcd
import time
import RPi.GPIO as GPIO

D4 = 6
D5 = 13
D6 = 19
D7 = 26
RS = 20
EN = 21
mylcd = lcd.lcd()
mylcd.begin(D4, D5, D6, D7, RS, EN)
mylcd.Print("How are you")
time.sleep(2)
mylcd.clear()
mylcd.Print("I am RaspberryPi")
mylcd.setCursor(2, 1)
mylcd.Print("Electro-Passion")
time.sleep(2)
mylcd.clear()
mylcd.Print("Seconds=")
seconds = 0
mylcd.setCursor(1, 9)
mylcd.Print(seconds)
mylcd.shift(mylcd.right, 5)
mylcd.shift(mylcd.left, 5)
mylcd.blinkCursorOn()
time.sleep(2)
mylcd.blinkCursorOff()
コード例 #37
0
#!/usr/bin/python
import lcd
import os
from time import sleep
lcd20 = lcd.lcd(0x27)
line1 = ""
line2 = ""
line3 = ""
line4 = ""
light = None
while True:
    if True if os.system("ping -c 1 10.42.1.100 > /dev/null") is 0 else False:
        if not light or light is None:
            lcd20.backlight(1)
            light = True
        file = open("/gpio/nom", "r")
        name = file.read()
        file.close
        source = "Source : " + name
        if line1 != source:
            lcd20.printlcd(source + "          ", 1)
            line1 = source
    else:
        if light or light is None:
            lcd20.backlight(0)
            light = False
    sleep(0.1)