Exemplo n.º 1
0
def conway_step():
    for x in range(128):  # loop over x coordinates
        for y in range(32):  # loop over y coordinates
            # count number of neigbours
            num_neighbours = (lcd.get(x - 1, y - 1) + lcd.get(x, y - 1) +
                              lcd.get(x + 1, y - 1) + lcd.get(x - 1, y) +
                              lcd.get(x + 1, y) + lcd.get(x + 1, y + 1) +
                              lcd.get(x, y + 1) + lcd.get(x - 1, y + 1))

            # check if the centre cell is alive or not
            self = lcd.get(x, y)

            # apply the rules of life
            if self and not (2 <= num_neighbours <= 3):
                lcd.reset(x,
                          y)  # not enough, or too many neighbours: cell dies
            elif not self and num_neighbours == 3:
                lcd.set(
                    x, y
                )  # exactly 3 neigbours around an empty cell: cell is born
Exemplo n.º 2
0
def conway_step():
    for x in range(128):        # loop over x coordinates
        for y in range(32):     # loop over y coordinates
            # count number of neigbours
            num_neighbours = (lcd.get(x - 1, y - 1) +
                lcd.get(x, y - 1) +
                lcd.get(x + 1, y - 1) +
                lcd.get(x - 1, y) +
                lcd.get(x + 1, y) +
                lcd.get(x + 1, y + 1) +
                lcd.get(x, y + 1) +
                lcd.get(x - 1, y + 1))

            # check if the centre cell is alive or not
            self = lcd.get(x, y)

            # apply the rules of life
            if self and not (2 <= num_neighbours <= 3):
                lcd.reset(x, y) # not enough, or too many neighbours: cell dies
            elif not self and num_neighbours == 3:
                lcd.set(x, y)   # exactly 3 neigbours around an empty cell: cell is born
Exemplo n.º 3
0
				gps_data(gpsNow, gps_fix_status, ctLong, ctLat, "2014")
				
				#LCD strings
				#sidereal string
				hsid=str(h)
				msid=str(m)
				ssid=str(int(s))
				sidereal_time = "Sidereal: " + hsid.zfill(2) + ":" + msid.zfill(2) + ":" + ssid.zfill(2) + "  "
				#sast string
				Hsast=str(HOURS)
				Msast=str(MINUTES)
				Ssast=str(SECONDS)
				sast_time = "SAST: " + Hsast.zfill(2) + ":" + Msast.zfill(2) + ":" + Ssast.zfill(2) + "      "
								
				if SECONDS ==30: #reset the lcd display every minute to remove display errors
					lcd.reset(fd)
				if SECONDS >=59:
					GPIO.output(arm_pulse, True)
				else:
					GPIO.output(arm_pulse, False)
									
				diff=SECONDS-old_sast
				old_sast=SECONDS
				if diff >= 1 or diff==-59:								#If the time has changed by 1 second update the display
					#======================================================print to LCD display
					lcd.clear(fd) #clear display
					type = True
					lcd.writeString(sast_time, fd)
					try:
						IP = get_ip_address('eth0')
					except: