Ejemplo n.º 1
0
    def getPressKey(self):
        a = [0, 1, 2, 3, 11, 18, 8, 9]
        r = [0, 1, 2, 3]
        c = [18, 11, 8, 9]

        key = [
            ["1", "2", "3", "A"],
            ["4", "5", "6", "B"],
            ["7", "8", "9", "C"],
            ["*", "0", "#", "D"],
        ]

        values = [
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
        ]

        lastvalues = copy.deepcopy(values)

        # close before open if used
        for pin in a:
            try:
                omega_gpio.closepin(pin)
            except:
                e = 1  # dummy command :-)

        # pin init
        for pin in r:
            omega_gpio.initpin(pin, 'out')

        for pin in c:
            omega_gpio.initpin(pin, 'in')

        while True:
            rpos = 0
            for rpin in r:
                omega_gpio.setoutput(r[0], 0)
                omega_gpio.setoutput(r[1], 0)
                omega_gpio.setoutput(r[2], 0)
                omega_gpio.setoutput(r[3], 0)
                omega_gpio.setoutput(rpin, 1)
                time.sleep(0.05)
                cpos = 0
                for cpin in c:
                    input = omega_gpio.readinput(cpin)
                    values[rpos][cpos] = input
                    cpos = cpos + 1
                rpos = rpos + 1

            for x in range(0, 4):
                for y in range(0, 4):
                    if values[x][y] != lastvalues[x][y]:
                        self.keycode = key[x][y]
                        if values[x][y] == 1:
                            return self.keycode

            lastvalues = copy.deepcopy(values)
Ejemplo n.º 2
0
    def keypad_init(self):
        self.a = [0, 1, 2, 3, 11, 18, 8, 9]
        self.r = [0, 1, 2, 3]
        self.c = [18, 11, 8, 9]

        self.key = [
            ["1", "2", "3", "A"],
            ["4", "5", "6", "B"],
            ["7", "8", "9", "C"],
            ["*", "0", "#", "D"],
        ]

        self.values = [
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
        ]

        self.lastvalues = copy.deepcopy(self.values)

        # close before open if used
        for pin in self.a:
            try:
                omega_gpio.closepin(pin)
            except:
                e = 1  # dummy command :-)

        # pin init
        for pin in self.r:
            omega_gpio.initpin(pin, 'out')

        for pin in self.c:
            omega_gpio.initpin(pin, 'in')
Ejemplo n.º 3
0
  def closeIOPins(self):
  #------------------------
    # Release all I/O pins 
    for pin in self.muxSigSelectPins:
      omega_gpio.closepin(pin)

    for pin in self.muxEnablePins:
      omega_gpio.closepin(pin)

    for pin in self.onionSegStatePins:
      omega_gpio.closepin(pin)
Ejemplo n.º 4
0
    def checkKey(self):
        a = [0, 1, 2, 3, 11, 18, 8, 9]
        r = [0, 1, 2, 3]
        c = [18, 11, 8, 9]

        key = [
            ["1", "2", "3", "A"],
            ["4", "5", "6", "B"],
            ["7", "8", "9", "C"],
            ["*", "0", "#", "D"],
        ]

        values = [
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
            ["0", "0", "0", "0"],
        ]

        lastvalues = copy.deepcopy(values)

        # close before open if used
        for pin in a:
            try:
                omega_gpio.closepin(pin)
            except:
                e = 1  # dummy command :-)

        # pin init
        for pin in r:
            omega_gpio.initpin(pin, 'out')

        for pin in c:
            omega_gpio.initpin(pin, 'in')

        if True:
            rpos = 0
            for rpin in r:
                omega_gpio.setoutput(r[0], 0)
                omega_gpio.setoutput(r[1], 0)
                omega_gpio.setoutput(r[2], 0)
                omega_gpio.setoutput(r[3], 0)
                omega_gpio.setoutput(rpin, 1)
                time.sleep(0.05)
                cpos = 0
                for cpin in c:
                    input = omega_gpio.readinput(cpin)
                    values[rpos][cpos] = input
                    cpos = cpos + 1
                rpos = rpos + 1

            for x in range(0, 4):
                for y in range(0, 4):
                    if values[x][y] != lastvalues[x][y]:
                        keycode = key[x][y]
                        if values[x][y] == 1:
                            if keycode == 'D':
				oledExp.clear()
                                oledExp.write("System reseting...")
                                time.sleep(5)
                                os.execl(sys.executable, sys.executable, * sys.argv)   #for resetting the program
                            elif keycode == 'A':
				f = open('confdata.txt', 'r') 
				lines = f.readlines() 
				SiteID = lines[0].rstrip('\n') 
				MonitoringID= lines[1].rstrip('\n') 
				AnalyzerID= lines[2].rstrip('\n') 
				ParameterID= lines[3].rstrip('\n')
				oledExp.clear()
                                oledExp.setCursor(0, 0)
                                oledExp.write(SiteID)
				oledExp.setCursor(1,0)
				oledExp.write(MonitoringID)
				oledExp.setCursor(2,0)                                 
				oledExp.write(AnalyzerID)
				oledExp.setCursor(3,0)                                 
				oledExp.write(ParameterID)
                                time.sleep(5)
                                oledExp.clear()
                            else:
				oledExp.clear()
                                oledExp.setCursor(0,0)
                                oledExp.write("Press 'D' for Reset")
				oledExp.setCursor(1,0)
				oledExp.write("'A' for userData")
				time.sleep(5)
				oledExp.clear()
            lastvalues = copy.deepcopy(values)
Ejemplo n.º 5
0
def endLight():
    for pin in GPIO_PINS:
        omega_gpio.closepin(pin)
Ejemplo n.º 6
0
    if (lightOn == True):
        cyclesOn = cyclesOn + 1

    if (cyclesOn >= LIGHT_ON_SECONDS):
        setLight(0)
        cyclesOn = 0
        lightOn = False

    if (refreshCounter >= refreshRate):

        refreshCounter = 0

        goal, lastScore, refreshRate = redlite.goal(game, teamType, lastScore)

        if (goal):
            setLight(1)
            lightOn = True

    else:
        refreshCounter = refreshCounter + 1

    if (refreshRate == 0):
        break

    time.sleep(1)

# End of Main Loop

# Shutdown
omega_gpio.closepin(GPIO_PIN)
Ejemplo n.º 7
0
]

values = [
    ["0", "0", "0", "0"],
    ["0", "0", "0", "0"],
    ["0", "0", "0", "0"],
    ["0", "0", "0", "0"],
    ["0", "0", "0", "0"],
]

lastvalues = copy.deepcopy(values)

# close before open if used
for pin in a:
    try:
        omega_gpio.closepin(pin)
    except:
        e = 1  # dummy command :-)

# pin init
for pin in r:
    omega_gpio.initpin(pin, 'out')

for pin in c:
    omega_gpio.initpin(pin, 'in')

while True:
    now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    rpos = 0
    for rpin in r:
        omega_gpio.setoutput(r[0], 0)