Exemplo n.º 1
0
def getPotLum():
    voltg = get_value('04')

    if(voltg[0:2] == '99'):
        voltg = voltg[2:]
    else:
        return 'error: message has no ACK'
    if(voltg[0:2] == '04'):
        voltg = voltg[2:]
    else:
        return 'error: response to unrequired command'
    if(voltg[len(voltg)-2:] == 'ff'):
        voltg = voltg[:len(voltg)-2]
    else:
        return 'error: message has no FIN'

    voltg = int(voltg, 16)
    if(voltg <= 450):
        print('0')
        return 0
    else:
        pot_lum = 1.794477785e-23*pow(voltg, 8) - 2.710712994e-19*pow(voltg, 7) + \
            1.702597885e-15*pow(voltg, 6) - 5.762038572e-12*pow(voltg, 5) + \
            1.14039482e-8*pow(voltg, 4) - 1.34384905e-5*pow(voltg, 3) + \
            9.132915482e-3*pow(voltg, 2) - 2.824372903*voltg + 422.2915764
        return pot_lum
Exemplo n.º 2
0
def getPotLum():
    adc_value = get_value('04')

    if(adc_value[0:2] == '99'):
        adc_value = adc_value[2:]
    else:
        return 'error: message has no ACK'
    if(adc_value[0:2] == '04'):
        adc_value = adc_value[2:]
    else:
        return 'error: response to unrequired command'
    if(adc_value[len(adc_value)-2:] == 'ff'):
        adc_value = adc_value[:len(adc_value)-2]
    else:
        return 'error: message has no FIN'

    adc_value = int(adc_value, 16)
    if(adc_value <= 450):
        return 0
    else:
        # pot_lum = 1.794477785e-23*pow(adc_value, 8) - 2.710712994e-19*pow(adc_value, 7) + \
        #     1.702597885e-15*pow(adc_value, 6) - 5.762038572e-12*pow(adc_value, 5) + \
        #     1.14039482e-8*pow(adc_value, 4) - 1.34384905e-5*pow(adc_value, 3) + \
        #     9.132915482e-3*pow(adc_value, 2) - 2.824372903*adc_value + 422.2915764
        return adc_value
Exemplo n.º 3
0
def getBuzzer():
    buz = get_value('03')
    # print("GetBuzzer - Received Word: ", buz)
    if (buz[0:2] == '99'):
        buz = buz[2:]
    else:
        return 'error: message has no ACK'
    if (buz[0:2] == '03'):
        buz = buz[2:]
        print('responding to command 0x03')
    else:
        return 'error: response to unrequired command'
    if (buz[len(buz) - 2:] == 'ff'):
        buz = buz[:len(buz) - 2]
    else:
        return 'error: message has no FIN'

    buz_info = []
    '''

            Retorna um conjunto de tuplas para cada perfil de cura.
            Perfil de cura 10s -> retorna uma tupla
            Perifil de cura 20s -> Retorna duas tuplas
             
            E assim por diante

            As tuplas são da forma (a ,b), onde a e b significam:
            a -> Tempo de duração do bipe
            b - > Tempo em que o bipe tocou (se 10, 20, 40 ou 60s após o início
                                             do perfil de cura)


    '''
    while (len(buz) != 0):

        #  print("Buz inside ", buz)
        #  print("Buzinfo inside ", buz_info)

        buz_info = buz_info + [(int(buz[:2], 16), int(buz[2:10], 16))]
        buz = buz[10:]
        #Sugestão de correção se necessário
        # if (x < 3):
        #     buz_infoA = buz_info + (int(buz[x], 16), int(buz[x+1], 16))
        # else:
        #     buz_infoB = buz_info + (int(buz[x], 16), int(buz[x+1], 16))

    # print("Buz outside ", buz)
    # print("Buzinfo outside ", buz_info)

    return buz_info
Exemplo n.º 4
0
def getPanel():

    panel_value = get_value('02')

    if (panel_value[0:2] == '99'):
        panel_value = panel_value[2:]
    else:
        return 'error: message has no ACK'
    if (panel_value[0:2] == '02'):
        panel_value = panel_value[2:]
        # print('responding to command 0x02')
    else:
        return 'error: response to unrequired command'
    if (panel_value[len(panel_value) - 2:] == 'ff'):
        panel_value = panel_value[:len(panel_value) - 2]
    else:
        return 'error: message has no FIN'
#
# panel_value = panel_value[6:]

    return switchCase(panel_value)
Exemplo n.º 5
0
def getBatLvl():
    batlvl = get_value('05')

    if (batlvl[0:2] == '99'):
        batlvl = batlvl[2:]
    else:
        return 'error: message has no ACK'
    if (batlvl[0:2] == '05'):
        batlvl = batlvl[2:]
        print('responding to command 0x04')
    else:
        return 'error: response to unrequired command'

    if (batlvl[len(batlvl) - 2:] == 'ff'):
        batlvl = batlvl[:len(batlvl) - 2]
        # print("ENTROU PORRA")
    else:
        print("Bat level is: ", batlvl)
        return 'error: message has no FIN'

    batlvl = int(batlvl, 16)

    # print("Volts: ", ((3.3 * batlvl)/4095)*2)
    return batlvl