<commit_before>﻿using System;
using System.Drawing;
using Sleddog.Blink1.Interfaces;

namespace Sleddog.Blink1.Commands
{
	internal class ReadPresetQuery : IBlink1Query<Blink1Preset>
	{
		private readonly byte position;

		public ReadPresetQuery(ushort position)
		{
			this.position = Convert.ToByte(position);
		}

		public Blink1Preset ToResponseType(byte[] responseData)
		{
			var color = Color.FromArgb(responseData[2], responseData[3], responseData[4]);
			var duration = TimeSpan.FromMilliseconds(ConvertToMilliseconds(responseData[5], responseData[6]));

			return new Blink1Preset(color, duration);
		}

		private int ConvertToMilliseconds(byte high, byte low)
		{
			return (high + low)*10;
		}

		public byte[] ToHidCommand()
		{
			return new[]
			       {
				       Convert.ToByte(1),
				       (byte) Blink1Commands.ReadPreset,
				       Convert.ToByte(0),
				       Convert.ToByte(0),
				       Convert.ToByte(0),
				       Convert.ToByte(0),
				       Convert.ToByte(0),
				       position
			       };
		}
	}
}<commit_msg>Corrected ReadPreset to use Blink1Duration<commit_after>﻿using System;
using System.Drawing;
using Sleddog.Blink1.Interfaces;

namespace Sleddog.Blink1.Commands
{
    internal class ReadPresetQuery : IBlink1Query<Blink1Preset>
    {
        private readonly byte position;

        public ReadPresetQuery(ushort position)
        {
            this.position = Convert.ToByte(position);
        }

        public Blink1Preset ToResponseType(byte[] responseData)
        {
            var color = Color.FromArgb(responseData[2], responseData[3], responseData[4]);
            var duration = new Blink1Duration(responseData[5], responseData[6]);

            return new Blink1Preset(color, duration);
        }

        public byte[] ToHidCommand()
        {
            return new[]
            {
                Convert.ToByte(1),
                (byte) Blink1Commands.ReadPreset,
                Convert.ToByte(0),
                Convert.ToByte(0),
                Convert.ToByte(0),
                Convert.ToByte(0),
                Convert.ToByte(0),
                position
            };
        }
    }
}
{'fraction_non_alphanumeric': 0.09953703703703703, 'fraction_numerical': 0.018518518518518517, 'mean_word_length': 2.3093415007656968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2486176', 'n_tokens_mistral': 718, 'n_tokens_neox': 636, 'n_words': 118}