예제 #1
0
def dataRotary(mqttclient):

    knob = grove.GroveRotary(3)
    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
    twythonid = twitterHandler()

    while True:
        abs = knob.abs_value()
        myLcd.setCursor(0, 0)
        myLcd.write('Health System')
        myLcd.setColor(0, 128, 0)
        myLcd.setCursor(1, 0)
        myLcd.write('Heart Rate %s' % abs)
        while (abs > 950):
            myLcd.setColor(255, 0, 0)
            id = str(randint(0, 1000))
            status = "0x" + id + " #IoTLab Health System Heart Rate Warning " + str(
                abs)
            mqttclient.publish("IoTPy/Buzzer", "None")
            twythonid.update_status(status=status)
            data = {}
            data['alive'] = "1"
            data['warning'] = "1"
            data['message'] = status
            dweepy.dweet_for('IoTHealthSystem', data)
            time.sleep(1.5)
            data['warning'] = "0"
            data['message'] = ""
            dweepy.dweet_for('IoTHealthSystem', data)
            break
        time.sleep(0.25)
예제 #2
0
def rotary():

    "This function reads the rotary potentiometer to set thermostat temperature."

    temp_set = 0
    abs = 0
    # New knob on AIO pin 1
    knob = grove.GroveRotary(1)

    # Read values
    abs = knob.abs_value()

    # Scaling 0 => 10 degrees C
    # Scaling 1023 => 50 degrees C   
    temp_set = (1023 -  abs) / 1023 * 40 + 10
    temp_set = int(temp_set)
#    print 'int(abs)= ', int(abs)
#    print 'temp_set= ', temp_set

    myLcd.setCursor(0,0)
    myLcd.write('Set temp: ' + str(temp_set) + ' C  ' )

    # Sleep for 1 sec
    time.sleep(1)
    return temp_set; 
예제 #3
0
파일: groverotary.py 프로젝트: oronum/upm
def main():
    # New knob on AIO pin 0
    knob = grove.GroveRotary(0)

    # Loop indefinitely
    while True:
        # Read values
        abs = knob.abs_value()
        absdeg = knob.abs_deg()
        absrad = knob.abs_rad()

        rel = knob.rel_value()
        reldeg = knob.rel_deg()
        relrad = knob.rel_rad()

        print "Abs values: %4d" % int(abs) , " raw %4d" % int(absdeg), "deg = %5.2f" % absrad , " rad ",
        print "Rel values: %4d" % int(rel) , " raw %4d" % int(reldeg), "deg = %5.2f" % relrad , " rad"

        # Sleep for 2.5 s
        sleep(2.5)
예제 #4
0
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from time import sleep
import pyupm_grove as grove

# New knob on AIO pin 0
knob = grove.GroveRotary(0)

# Loop indefinitely
while True:

    # Read values
    abs = knob.abs_value()
    absdeg = knob.abs_deg()
    absrad = knob.abs_rad()

    rel = knob.rel_value()
    reldeg = knob.rel_deg()
    relrad = knob.rel_rad()

    print "Abs values: %4d" % int(abs), " raw %4d" % int(
        absdeg), "deg = %5.2f" % absrad, " rad ",
 def get_actuator(self):
     return pyupm_grove.GroveRotary(self.pin)
예제 #6
0
파일: pot_rotary.py 프로젝트: rbanffy/pingo
import pyupm_grove
import time

pot = pyupm_grove.GroveRotary(0)

while 1:
  print(pot.abs_deg())
  time.sleep(0.5)