istareatscreens / MychIO

Unity washing machine input manager
3 stars 1 forks source link

Map Adx Led Commands #1

Open istareatscreens opened 1 week ago

istareatscreens commented 1 week ago

Currently the Adx Led device is not mapped, there is a need to write commands for the various light and effects desired for the adx.

Commands are represented as Enums in this enum file: (will be renamed to LedDeviceCommand soon).

namespace MychIO.Device
{
    public enum LedCommand
    {
        ClearAll
    }
}

source: https://github.com/istareatscreens/MychIO/blob/a596661cba4d541f248779030497743804ec474b/Runtime/Device/LedDevice/LedDeviceCommand.cs

You can see I already have a command: ClearAll

Then implementing it into the AdxLedDevice, where each byte[] array in the array is a command to write to the ADX led device.

Right now it connects and clears on startup.

        public static readonly IDictionary<LedCommand, byte[][]> Commands = new Dictionary<LedCommand, byte[][]>
        {
            { LedCommand.ClearAll, new byte[][] {
                    new byte[] {0xE0, 0x11, 0x01, 0x08, 0x32, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C},
                    new byte[] {0xE0, 0x11, 0x01, 0x04, 0x39, 0x00, 0x00, 0x00, 0x4F},
                    new byte[] {0xE0, 0x11, 0x01, 0x01, 0x3C, 0x4F
                  }
                }
            },
        };

source: https://github.com/istareatscreens/MychIO/blob/a596661cba4d541f248779030497743804ec474b/Runtime/Device/LedDevice/AdxLedDevice.cs#L51

Then to run the command (or you can send many at once, currently it is named LedCommand but I will rename it to LedDeviceCommand to be more consistent):

IOManager.Write(DeviceClassification.LedDevice, LedDeviceCommand.ClearAll)

// if you want to send multiple commands in a row you can do this:
IOManager.Write(DeviceClassification.LedDevice, LedDeviceCommand.ClearAll, LedDeviceCommand.B1Red)

source: https://github.com/istareatscreens/MychIO/blob/a596661cba4d541f248779030497743804ec474b/Runtime/IOManager.cs#L136C1-L136C106

Documentation here https://github.com/istareatscreens/MychIO/tree/a596661cba4d541f248779030497743804ec474b?tab=readme-ov-file#writing-to-devices

This should give you info about how the LED works on the adx: https://github.com/Sucareto/Mai2Touch/tree/main

Note the adx LED device is a re-implementation of a 15070 LED controller apparently.

Testing can be facilitated using this project: https://github.com/istareatscreens/MychIODev/tree/master