Exemplo n.º 1
0
    def set_source_brightness_contrast(self, _=None):
        """Load a gamma curve to help adjusting brightness and contrast on a source device"""
        gamma = GammaCurve()
        gamma.set_input_level(HDMIInputLevel.Enhanced)
        gamma.bmax = 100
        gamma.brefwhite = 100
        gamma.bsoftclip = 100
        gamma.end_slope = 0
        gamma.highlight = (Highlight.BTB | Highlight.B | Highlight.NB |
                           Highlight.NW | Highlight.W | Highlight.WTW)
        gamma.eotf = eotf.eotf_gamma_2_2

        print('\nDisplay a test pattern where you can clearly identify black and white')
        input('Press enter when ready load test gamma curve: ')
        saved_input_level = None
        try:
            with JVCCommand() as jvc:
                saved_input_level = jvc.get(Command.HDMIInputLevel)
                if saved_input_level != HDMIInputLevel.Enhanced:
                    print('Changing input level from {} to Enhanced'.format(saved_input_level.name))
                    jvc.set(Command.HDMIInputLevel, HDMIInputLevel.Enhanced)
                gamma.write_jvc(jvc, verify=self.verify)
                jvc.set(Command.Contrast, 0)
                jvc.set(Command.Brightness, 0)

            print('Adjust contrast and brightness on your source so black and white turn green')
            input('Press enter when done: ')
        finally:
            if saved_input_level:
                with JVCCommand() as jvc:
                    if saved_input_level != jvc.get(Command.HDMIInputLevel):
                        print('Changing input level from Enhanced to {}'.format(
                            saved_input_level.name))
                        jvc.set(Command.HDMIInputLevel, saved_input_level)
            self.gamma.write(verify=self.verify)
Exemplo n.º 2
0
    def hdr_contrast_menu(self, _=None, gamma_table_loaded=False):
        """Adjust brightness of reference white by using contrast control on projector"""
        print('After loading a gamma table, use the contrast control on the projector to\n'
              'increase or decrease the brightness of the picture. Large adjustments distorts\n'
              'the gamma curve, so you may have to repeat this step until you only need small\n'
              'adustments\n'
              'When done, leave the contrast at 0')
        while True:
            with JVCCommand() as jvc:
                if gamma_table_loaded:
                    contrast = jvc.get(Command.Contrast)
                    print('Contrast', contrast)
                    if contrast == 0:
                        jvc.set(Command.Remote, RemoteCode.Back)
                        break

                    self.contrast_to_brefwhite(contrast)

                print('Please wait while loading gamma table')
                try:
                    jvc.set(Command.Remote, RemoteCode.Back)
                    self.gamma.write_jvc(jvc, verify=self.verify)
                    jvc.set(Command.Contrast, 0)
                    gamma_table_loaded = True
                    jvc.set(Command.Remote, RemoteCode.PictureAdjust)
                except Exception as err:
                    print('Failed to load gamma table', err)
                    ret = input('Press enter to retry or enter "a" to abort: ')
                    if ret == 'a':
                        return
                    continue
            input('Gamma table ready. Make your adjustments and press enter when ready: ')
Exemplo n.º 3
0
    def setup_hdr(self, _):
        """HDR setup helper"""
        try:
            with JVCCommand() as jvc:
                try:
                    model = jvc.get(Command.Model)
                    print('Found projector model:', model.name)
                except ValueError:
                    if not strtobool(input('Unknown projector model.\n'
                                           'Ignore and continue (y/n)? ')):
                        raise
                while True:
                    power_state = jvc.get(Command.Power)
                    if power_state != PowerState.LampOn:
                        print('Make sure projector is powered on and ready. Current state is:',
                              power_state.name)
                        res = input('Press enter to retry '
                                    '(or enter "on" to send power on command): ')
                        if res == 'on':
                            if jvc.get(Command.Power) == PowerState.StandBy:
                                jvc.set(Command.Power, PowerState.LampOn)
                            else:
                                print('Not in StandBy, try again')
                        continue
                    input_level = jvc.get(Command.HDMIInputLevel)
                    break
                while True:
                    print('Set "Picture Mode" to the User mode you want to program for HDR')
                    print('Set "Gamma" to "Custom 1", "Custom 2" or "Custom 3"')
                    input('Press enter when ready: ')
                    user_mode = jvc.get(Command.PictureMode)
                    gamma_table = jvc.get(Command.GammaTable)
                    if user_mode not in {PictureMode.User1, PictureMode.User2,
                                         PictureMode.User3, PictureMode.User4,
                                         PictureMode.User5, PictureMode.User6}:
                        print('Invalid "Picture Mode":', user_mode.name)
                        continue
                    if gamma_table not in {GammaTable.Custom1, GammaTable.Custom2,
                                           GammaTable.Custom3}:
                        print('Invalid "Gamma":', gamma_table.name)
                        continue
                    gamma_correction = jvc.get(Command.GammaCorrection)
                    if gamma_correction != GammaCorrection.Import:
                        print('Switching {} from {} to {}'.format(
                            gamma_table.name, gamma_correction.name, GammaCorrection.Import.name))
                        jvc.set(Command.GammaCorrection, GammaCorrection.Import)
                    print('Selected', user_mode.name, gamma_table.name, gamma_correction.name)
                    break

            self.gamma.conf_load(GAMMA_HDR_DEFAULT)
            self.gamma.set_input_level(input_level)

            self.set_source_brightness_contrast()
            self.hdr_contrast_menu()

        except CommandNack as err:
            print('Nack', err)
Exemplo n.º 4
0
def load_gamma(*newgamma):
    if len(newgamma) == 1:
        newgamma = newgamma * 3
    assert len(newgamma) == 3
    with JVCCommand(print_all=False) as jvc:
        try:
            print('Picture mode:', jvc.get_picture_mode())
            old_gamma_table = jvc.get_gamma_table()
            print('Gamma Table:', old_gamma_table)
            assert old_gamma_table in {GammaTable.Custom1,
                                       GammaTable.Custom2,
                                       GammaTable.Custom3}, \
                'Selected gamma table, %s, is not a custom gamma table' % old_gamma_table
            gamma_correction = jvc.get_gamma_correction()
            assert gamma_correction is GammaCorrection.Import, \
                'Correction value for %s is not set to import, %s' % (old_gamma_table, gamma_correction)

            jvc.set_gamma(Command.gammared, newgamma[0])
            jvc.set_gamma(Command.gammagreen, newgamma[1])
            jvc.set_gamma(Command.gammablue, newgamma[2])
        except CommandNack as err:
            print('Nack', err)
Exemplo n.º 5
0
def test_read_gamma():
    """JVC gamma test"""
    gamma_tables = []
    with JVCCommand(print_all=False) as jvc:
        old_picture_mode = jvc.get_picture_mode()
        print('Old Picture mode:', old_picture_mode)
        try:
            jvc.set_picture_mode(PictureMode.User6)
            print('New Picture mode:', jvc.get_picture_mode())
            old_gamma_table = jvc.get_gamma_table()
            print('Gamma Table:', old_gamma_table)
            assert old_gamma_table in {GammaTable.Custom1,
                                       GammaTable.Custom2,
                                       GammaTable.Custom3}
            gamma_correction = jvc.get_gamma_correction()
            assert gamma_correction is GammaCorrection.Import

            try:
                for gamma_table in [GammaTable.Custom1,
                                    GammaTable.Custom2,
                                    GammaTable.Custom3]:
                    jvc.set_gamma_table(gamma_table)
                    gamma_correction = jvc.get_gamma_correction()
                    assert gamma_correction is GammaCorrection.Import
                    gamma_red = jvc.get_gamma(Command.gammared)
                    gamma_green = jvc.get_gamma(Command.gammagreen)
                    gamma_blue = jvc.get_gamma(Command.gammablue)
                    gamma_tables.append((gamma_red, gamma_green, gamma_blue))
                    plot(gamma_red, gamma_green, gamma_blue)
            finally:
                jvc.set_gamma_table(old_gamma_table)
        except CommandNack as err:
            print('Nack', err)
        finally:
            jvc.set_picture_mode(old_picture_mode)
            print('Restored Picture mode:', jvc.get_picture_mode())
    return gamma_tables
Exemplo n.º 6
0
 def read(self):
     """Connect to projector and read gamma table"""
     with JVCCommand() as jvc:
         self.read_jvc(jvc)
Exemplo n.º 7
0
 def write(self, verify=False):
     """Connect to projector and write gamma table"""
     with JVCCommand() as jvc:
         self.write_jvc(jvc, verify=verify)