コード例 #1
0
ファイル: example.py プロジェクト: DnPlas/Edison_Bluetooth
#-----------  BT Communication ------------ #


# BT dependent case function
def function(data):
    func = functionInUse.get(data, dummy)  # Selects the function to be used
    func()  # depending on BT commands


def dummy():  # If a character that's not defined in 'functionInUse'
    pass  # is sent to the system via BT, it won't do a thing


functionInUse = {
    'a': waterPlant,  # Sets which letter corresponds
    'b': requestData,
}  # to each BT controlled function


# ------------ Project Program ------------ #
# Run all non-BT controlled functions
def myProgram():
    displayLight()  # Run these functions until a BT event is triggered
    displayLightInfo()


# =========== * BT MAIN LOOP * ============ #
if __name__ == '__main__':
    s.bluetoothConnection()  # Enables BT connectivity
コード例 #2
0
ファイル: example.py プロジェクト: DnPlas/Edison_Bluetooth
        Request temperature via BT.
    """
    return str(getTemperature())


def dummy():
    """
        Dummy function as default for BT calling.
    """
    pass


# Sets which command corresponds to each BT controlled function.
functionInUse = {
    'get': getStatus,
}


# ------------ Project Program ----------- #
# Run all non-BT controlled functions
def myProgram():
    """
        Run these function until a BT event is triggered.
    """
    temperatureFunction()


# =========== * BT MAIN LOOP * =========== #
if __name__ == '__main__':
    spp.bluetoothConnection()
コード例 #3
0
    display.write('Light:%s' % str(light.value()))  # Display light sensor data
    sleep(1)

#-------------  BT Functions -------------  #
    
# Request light sensor data via BT
def requestData():
    return str(light.value())     # Returns light sensor data

#-----------  BT Communication ------------ #

# BT dependent case function
def function (data):
    func = functionInUse.get(data, dummy) # Selects the function to be used
    func()                                # depending on BT commands

def dummy(): # If a character that's not defined in 'functionInUse'
    pass     # is sent to the system via BT, it won't do a thing

functionInUse = {'a' : requestData,}    # Sets which letter corresponds
                                        # to each BT controlled function

# ------------ Project Program ------------ #
# Run all non-BT controlled functions
def myProgram():
      displayLightInfo()     # Run these functions until a BT event is triggered

# =========== * BT MAIN LOOP * ============ #
if __name__ == '__main__':
    s.bluetoothConnection() # Enables BT connectivity
コード例 #4
0
                  'c': resetPillCounter,
                  'd': resetAlarm,
                  'e': getPillCounter,
                  'f': getAlarmStatus,
                  'g': getPillIsDueState}
# -------------------------------------------------------------------------


# -------------------------------------------------------------------------
# Main Program Function
# -------------------------------------------------------------------------
# Finally, this is the main function that is executed continuously to
# check for input events, after triggering the timer and LCD
# initialization tasks.
# -------------------------------------------------------------------------
def myProgram():
    global initialized

    if not initialized:
        displayInit(LCD_BACKGROUND_COLOR)
        updateDisplay()
        setNextPillTimer()
        initialized = True

    checkButtonStatus()
# -------------------------------------------------------------------------


if __name__ == "__main__":
    spp.bluetoothConnection()