コード例 #1
0
    def test_init_display_brightness(self):
        # set one tube
        number_of_tubes_in_display = 1
        display = SmartNixieTubeDisplay(number_of_tubes_in_display,
                                        serial_port_name=self.inputPort)

        display.brightness = 128
        self.assertEqual('$-,N,N,128,000,000,000!',
                         display.generate_command_string())

        # set two tubes
        number_of_tubes_in_display = 2
        tube_display = SmartNixieTubeDisplay(number_of_tubes_in_display,
                                             serial_port_name=self.inputPort)
        display2 = tube_display

        display2.brightness = 128
        self.assertEqual('$-,N,N,128,000,000,000$-,N,N,128,000,000,000!',
                         display2.generate_command_string())

        # set three tubes
        number_of_tubes_in_display = 3
        display3 = SmartNixieTubeDisplay(number_of_tubes_in_display,
                                         serial_port_name=self.inputPort)

        display3.brightness = 128
        self.assertEqual(
            '$-,N,N,128,000,000,000$-,N,N,128,000,000,000$-,N,N,128,000,000,000!',
            display3.generate_command_string())
コード例 #2
0
    def test_init_display_brightness(self):
        # set one tube
        number_of_tubes_in_display = 1
        display = SmartNixieTubeDisplay(number_of_tubes_in_display, serial_port_name=self.inputPort)

        display.brightness = 128
        self.assertEqual('$-,N,N,128,000,000,000!', display.generate_command_string())

        # set two tubes
        number_of_tubes_in_display = 2
        tube_display = SmartNixieTubeDisplay(number_of_tubes_in_display, serial_port_name=self.inputPort)
        display2 = tube_display

        display2.brightness = 128
        self.assertEqual('$-,N,N,128,000,000,000$-,N,N,128,000,000,000!', display2.generate_command_string())

        # set three tubes
        number_of_tubes_in_display = 3
        display3 = SmartNixieTubeDisplay(number_of_tubes_in_display, serial_port_name=self.inputPort)

        display3.brightness = 128
        self.assertEqual('$-,N,N,128,000,000,000$-,N,N,128,000,000,000$-,N,N,128,000,000,000!',
                         display3.generate_command_string())
コード例 #3
0
    PACKAGE_PARENT = '..'
    SCRIPT_DIR = os.path.dirname(
        os.path.realpath(
            os.path.join(os.getcwd(), os.path.expanduser(__file__))))
    sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

    from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay

# set number of tubes in the display
numberOfTubesInDisplay = 3

# instantiate the display -- serial ports tested on Linux and Mac OS X.
display = SmartNixieTubeDisplay(
    numberOfTubesInDisplay,
    '/dev/tty.usbserial-A9QHHRFJ')  # '/dev/tty.usbserial-A9UD9RRV')

# all the properties can be set like this:
display.brightness = 255

for i in range(255):
    display.red = random.randint(0, 255)
    display.green = random.randint(0, 255)
    display.blue = random.randint(0, 255)

    # set the display number
    display.set_display_number(i)  # random.randint(0,999))

    # send the command set to the display
    display.send_command()
コード例 #4
0
    from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay
except ImportError as e:
    import sys
    import os

    PACKAGE_PARENT = '..'
    SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
    sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

    from smartnixietube.SmartNixieTube import SmartNixieTubeDisplay

# set number of tubes in the display
numberOfTubesInDisplay = 3

# instantiate the display -- serial ports tested on Linux and Mac OS X.
display = SmartNixieTubeDisplay(numberOfTubesInDisplay, '/dev/tty.usbserial-A9QHHRFJ')  # '/dev/tty.usbserial-A9UD9RRV')

# all the properties can be set like this:
display.brightness = 255

for i in range(255):
    display.red = random.randint(0, 255)
    display.green = random.randint(0, 255)
    display.blue = random.randint(0, 255)

    # set the display number
    display.set_display_number(i)  # random.randint(0,999))

    # send the command set to the display
    display.send_command()