예제 #1
0
 def __init__(self, pub):
     global self_motor
     self_motor = self
     self.psm = PiStorms()
     self.speed = 0
     self.pub = pub
     self.pendulum_state = None
     self.time = 0.0
     self.led_flag = True
예제 #2
0
    def __init__(self):
        global self_motor
        self_motor = self

        self.psm = PiStorms()
        self.angle = 0
        self.isReady = False

        self.pub = mqtt.Client(client_id="motor_pub", transport="TCP")
        self.pub.connect(MQTT_SERVER, 1883, 60)

        self.sub = mqtt.Client(client_id="motor_sub", transport="TCP")
        self.sub.on_connect = self.on_connect
        self.sub.on_message = self.on_message
        self.sub.connect(MQTT_SERVER, 1883, 60)

        thread = threading.Thread(target=self.__sub, args=(self.sub, ))
        thread.daemon = True
        thread.start()
예제 #3
0
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 04/18/17  Seth Tenembaum  Initial development.
#

# This program demonstrates how to create and display a basic, static graph
# on the PiStorms screen.
# It is heavily based on https://matplotlib.org/examples/pylab_examples/simple_plot.html

from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np

# setup figure
plt.figure(figsize=(4, 3), dpi=80)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
예제 #4
0
        mindsensors_i2c.__init__(self, color_address >> 1)

    def get_colornum(self):
        try:
            return (self.readIntegerBE(self.Color_COMMAND))
        except:
            print("Error: Could not read color")
            return ""

HC = HiTechnicColorV2()

# END CLASSES #

# CONSTANTS #

PSM = PiStorms()

SCREEN = PSM.screen

M1   = PSM.BAM1
M2   = PSM.BAM2
AM   = (M1, M2)

M3   = PSM.BBM1
M4   = PSM.BBM2
BM   = (M3, M4)

ML   = AM + BM

S1   = PSM.BAS1
S2   = PSM.BAS2
예제 #5
0
def init():
	global psm
	writeDebug("===Starting on " + datetime.datetime.now().strftime("%D %I:%M %p"))
	psm = PiStorms()
예제 #6
0
# September 20, 2015  Nitin Patil     Initial Authoring

from PiStorms import PiStorms

#Demo Code for the PiStorms and Raspberry Pi

#initial setup code
import os, sys, inspect, time, thread, random
currentdir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
#sys.path.insert(0,parentdir)
from PiStorms import PiStorms

#starts an instance of PiStorms
psm = PiStorms(rotation=1)

#exit variable will be used later to exit the program and return to PiStorms
exit = False

#clears the screen of any unwanted text by displaying a white rectangle
psm.screen.fillRect(0, 0, 320, 240)

#displays PiDoG's greeting of "Hello, I PiDoG"
psm.screen.drawAutoText("Hello", 80, 30, fill=(255, 0, 0), size=70)
psm.screen.drawAutoText("I am PyDog", 50, 140, fill=(255, 0, 0), size=45)
count = 0

#main loop
while (not exit):
예제 #7
0
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author      Comments
# Oct 2015  Michael     Initial Authoring
# Jun 2017  Seth        Simplification

import sys

from mindsensors_i2c import mindsensors_i2c

from PiStorms import PiStorms
psm = PiStorms("Explorer")

psm.BAS1.activateCustomSensorI2C()
psm.BAS2.activateCustomSensorI2C()

i2c_all = []
for addr in range(0x00, 0x34, 2) + range(0x38, 0xEF, 2):
    i2c_all.append(mindsensors_i2c(addr >> 1))


def ping(i2c):
    return i2c.readByte(0x00) != None


while not psm.isKeyPressed():
    found = filter(ping, i2c_all)
예제 #8
0
파일: stop.py 프로젝트: dengzac/cty-AROB
from PiStorms import PiStorms
pms = PiStorms()
pms.BAM1.setSpeed(0)
pms.BAM2.setSpeed(0)
예제 #9
0
# 10/18/15   Deepak     UI improvements and messenger integration

from PiStorms import PiStorms
from mindsensors_i2c import mindsensors_i2c
import sys, os, time, json
PROGRAM_DIRECTORY = "/home/pi/PiStormsprograms"
json_file = '/var/tmp/ps_data.json'
rotation = 3
if (os.getenv("PSREVERSE", "0") == "1"):
    rotation = 3
#print os.getcwd()

try:
    bootmode = mindsensors_i2c(0xEA >> 1)
    bootmode.readbyte()
    psm = PiStorms("PiStorms", rotation)
    psm.screen.termPrintAt(4, "PiStorms in fw upgrade mode")

except:
    psm = PiStorms("PiStorms", rotation)


def listPrograms(directory):
    files = os.listdir(directory)
    #files = os.listdir("./" + directory)
    x = 0
    while (x < len(files)):

        if (not files[x].endswith(".py")) or (not files[x][0].isdigit()):
            del files[x]
        else: