def test_init_display_green(self):
        # set one tube
        number_of_tubes_in_display = 1
        display = SmartNixieTubeDisplay(number_of_tubes_in_display,
                                        serial_port_name=self.inputPort)

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

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

        display2.green = 128
        self.assertEqual('$-,N,N,000,000,128,000$-,N,N,000,000,128,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.green = 128
        self.assertEqual(
            '$-,N,N,000,000,128,000$-,N,N,000,000,128,000$-,N,N,000,000,128,000!',
            display3.generate_command_string())
    def test_init_display_green(self):
        # set one tube
        number_of_tubes_in_display = 1
        display = SmartNixieTubeDisplay(number_of_tubes_in_display, serial_port_name=self.inputPort)

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

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

        display2.green = 128
        self.assertEqual('$-,N,N,000,000,128,000$-,N,N,000,000,128,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.green = 128
        self.assertEqual('$-,N,N,000,000,128,000$-,N,N,000,000,128,000$-,N,N,000,000,128,000!',
                         display3.generate_command_string())
    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()
    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()