Ejemplo n.º 1
0
def main():
	if len(sys.argv) < 3:
		print("Usage: %s <font.dmd> <text>"%(sys.argv[0]))
		return

	font = dmd.Font(sys.argv[1])
	if not font:
		print("Error loading font")
		return
	text = sys.argv[2]
	
	text_layer = dmd.TextLayer(0, 0, font)
	text_layer.set_text(text)

	proc = pinproc.PinPROC('wpc')
	w = 128
	h = 32
	proc.reset(1)
	
	grouped_layer = dmd.GroupedLayer(w, h, [dmd.FrameLayer(frame=dmd.Frame(w, h)), text_layer])
	
	frame = grouped_layer.next_frame()
	if frame == None:
		print("No frame?")
		return
	for x in range(3): # Send it enough times to get it to show
		proc.dmd_draw(frame)
Ejemplo n.º 2
0
    def connect(self):
        """Connect to the P-ROC.

        Keep trying if it doesn't work the first time.
        """
        self.log.info("Connecting to P-ROC")

        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(self.machine_type)
                self.proc.reset(1)
            except IOError:  # pragma: no cover
                print("Retrying...")
                time.sleep(1)

        version_revision = self.proc.read_data(0x00, 0x01)

        self.revision = version_revision & 0xFFFF
        self.version = (version_revision & 0xFFFF0000) >> 16
        dipswitches = self.proc.read_data(0x00, 0x03)
        self.hardware_version = (dipswitches & 0xF00) >> 8

        self.log.info(
            "Successfully connected to P-ROC/P3-ROC. Firmware Version: %s. Firmware Revision: %s. "
            "Hardware Board ID: %s", self.version, self.revision,
            self.hardware_version)
Ejemplo n.º 3
0
    def connect(self):
        """Connect to the P-ROC.

        Keep trying if it doesn't work the first time.
        """
        self.log.info("Connecting to P-ROC")

        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(self.machine_type)
                self.proc.reset(1)
            except IOError:     # pragma: no cover
                print("Retrying...")
                time.sleep(1)

        version_revision = self.proc.read_data(0x00, 0x01)

        self.revision = version_revision & 0xFFFF
        self.version = (version_revision & 0xFFFF0000) >> 16
        self.machine.create_machine_var("p_roc_version", self.version, persist=False, silent=True)
        '''machine_var: p_roc_version

        desc: Holds the version number of the P-ROC or P3-ROC controller that's
        attached to MPF.
        '''

        self.machine.create_machine_var("p_roc_revision", self.revision, persist=False, silent=True)
        '''machine_var: p_roc_revision

        desc: Holds the revision number of the P-ROC or P3-ROC controller
        that's attached to MPF.
        '''

        self.log.info("Successfully connected to P-ROC/P3-ROC. Revision: %s. Version: %s", self.revision, self.version)
Ejemplo n.º 4
0
    def connect(self):
        """Connect to the P-ROC.

        Keep trying if it doesn't work the first time.
        """
        self.log.info("Connecting to P-ROC")

        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(self.machine_type)
                self.proc.reset(1)
            except IOError:  # pragma: no cover
                print("Retrying...")
                time.sleep(1)

        version_revision = self.proc.read_data(0x00, 0x01)

        self.revision = version_revision & 0xFFFF
        self.version = (version_revision & 0xFFFF0000) >> 16
        dipswitches = self.proc.read_data(0x00, 0x03)
        self.hardware_version = (dipswitches & 0xF00) >> 8
        self.dipswitches = ~dipswitches & 0x3F

        self.log.info(
            "Successfully connected to P-ROC/P3-ROC. Firmware Version: %s. Firmware Revision: %s. "
            "Hardware Board ID: %s", self.version, self.revision,
            self.hardware_version)

        # for unknown reasons we have to postpone this a bit after init
        self.machine.delay.add(100, self._configure_pd_led)
Ejemplo n.º 5
0
 def start_pinproc(self, machine_type, loop):
     """Initialise libpinproc."""
     self.loop = loop
     self.stop_future = asyncio.Future(loop=self.loop)
     while not self.proc:
         try:
             self.proc = pinproc.PinPROC(machine_type)
             self.proc.reset(1)
         except IOError:     # pragma: no cover
             print("Retrying...")
             time.sleep(1)
Ejemplo n.º 6
0
    def start_proc_process(self, machine_type, loop):
        """Run the pinproc communication."""
        self.loop = loop
        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(machine_type)
                self.proc.reset(1)
            except IOError:  # pragma: no cover
                print("Retrying...")
                time.sleep(1)

        self.stop_future = asyncio.Future(loop=self.loop)
        loop.run_until_complete(self.stop_future)
        loop.close()
Ejemplo n.º 7
0
    def connect(self):
        """Connect to the P-ROC.

        Keep trying if it doesn't work the first time.
        """
        self.log.info("Connecting to P-ROC")

        while not self.proc:
            try:
                self.proc = pinproc.PinPROC(self.machine_type)
                self.proc.reset(1)
            except IOError:  # pragma: no cover
                print("Retrying...")
                time.sleep(1)

        self.log.info("Successfully connected to P-ROC/P3-ROC")
Ejemplo n.º 8
0
def main():
	pr = pinproc.PinPROC(machine_type)
	time.sleep(2) # Give P-ROC a second to get going?
	import pygame
	try:
		pygame.init()
		screen = pygame.display.set_mode((128, 32))
		pygame.display.set_caption('P-ROC DMD')
	
		background = pygame.Surface(screen.get_size())
		background = background.convert()
	
		fontSize = 14
		x = 200.0
		while 1:
			background.fill((0, 0, 0))
	
			if pygame.font:
				font = pygame.font.Font(None, fontSize*3)
				text = font.render("This is P-ROC", 1, (150, 150, 150))
				textpos = text.get_rect(center=(x, background.get_height()/2))#(centerx=background.get_width()/2)
				background.blit(text, textpos)
				font = pygame.font.Font(None, fontSize)
				text = font.render("This is P-ROC", 1, (255, 255, 255))
				textpos = text.get_rect(center=(math.cos(time.clock()*5.0)*10.0+background.get_width()/2, math.sin(time.clock()*5.0)*5.0+background.get_height()*0.3))
				background.blit(text, textpos)
				font = pygame.font.Font(None, fontSize*1.5)
				text = font.render("pypinproc", 1, (255, 255, 255))
				textpos = text.get_rect(center=(background.get_width()*0.5, background.get_height()*0.75))
				background.blit(text, textpos)
	
			screen.blit(background, (0,0))
			pygame.display.flip()
	
			surface = pygame.display.get_surface()
			buffer = surface.get_buffer()

			pr.dmd_draw(buffer.raw)
			del buffer
			del surface
			x -= 1
			if x < -200.0:
				x = 200.0
			time.sleep(1/40)
	finally: #except KeyboardInterrupt:
		del pr
Ejemplo n.º 9
0
# This script is intended to be run:
#
#   python -i pypinproctest.py
#
import pinproc
import yaml

machine_type = pinproc.MachineTypeWPC

pr = pinproc.PinPROC(machine_type)
pr.reset(1)


def pulse(n, t=20):
    """docstring for pulse"""
    pr.driver_pulse(pinproc.decode(machine_type, str(n)), t)


del pr
Ejemplo n.º 10
0
    def __init__(self):
        """Initialize platform."""
        self.proc = pinproc.PinPROC(pinproc.normalize_machine_type('pdb'))
        self.proc.reset(1)

        # reset all drivers to off
        for i in range(0, 255):
            state = {'driverNum': i,
                     'outputDriveTime': 0,
                     'polarity': True,
                     'state': False,
                     'waitForFirstTimeSlot': False,
                     'timeslots': 0,
                     'patterOnTime': 0,
                     'patterOffTime': 0,
                     'patterEnable': False,
                     'futureEnable': False}

            self.proc.driver_update_state(state)

        # some magic stuff we don't understand but it has to be this way
        for group_ctr in range(0, 4):
            self.proc.driver_update_group_config(
                group_ctr,
                0,
                group_ctr,
                0,
                0,
                False,
                True,
                True,
                True)

        # enable banks for boards 0-7
        for bank_num in range(0, 16):
            self.proc.driver_update_group_config(
                bank_num + 4,
                0,
                bank_num,
                0,
                0,
                False,
                True,
                True,
                True)

        self.proc.driver_update_global_config(
                                           False,
                                           True,  # Polarity
                                           False,  # N/A
                                           False,  # N/A
                                           1,  # N/A
                                           0,
                                           0,
                                           False,  # Active low rows? No
                                           False,  # N/A
                                           False,  # Stern? No
                                           False,  # Reset watchdog trigger
                                           True,  # Enable watchdog
                                           1000)

        self.proc.driver_update_global_config(
                                           True,
                                           True,  # Polarity
                                           False,  # N/A
                                           False,  # N/A
                                           1,  # N/A
                                           0,
                                           0,
                                           False,  # Active low rows? No
                                           False,  # N/A
                                           False,  # Stern? No
                                           False,  # Reset watchdog trigger
                                           True,  # Enable watchdog
                                           1000)
        self.callbacks = {}     # type: Dict[str:callable]
Ejemplo n.º 11
0
import pinproc

proc = pinproc.PinPROC(pinproc.normalize_machine_type('pdb'))

for switch, state in enumerate(proc.switch_get_states()):

    if not switch % 16:
        print('')
        print('SW-16 Board Address {0}'.format(switch / 16))

    print('Switch {0} State {1}'.format(switch, state))
Ejemplo n.º 12
0
import time
import pinproc

proc = pinproc.PinPROC(1)
proc.reset(1)

for x in range(255):
    proc.switch_update_rule(x, 'closed_nondebounced',
                           {'notifyHost': True, 'reloadActive': False}, [],
                            False)
    proc.switch_update_rule(x, 'open_nondebounced',
                            {'notifyHost': True, 'reloadActive': False}, [],
                            False)

while True:

    for event in proc.get_events():
        print(event)
        event_type = event['type']
        event_value = event['value']

        if event_type == pinproc.EventTypeSwitchClosedDebounced:
            print('+{}'.format(event_value))
        elif event_type == pinproc.EventTypeSwitchOpenDebounced:
            print('-{}'.format(event_value))

    proc.watchdog_tickle()
    proc.flush()
    time.sleep(.01)