//NOTE: ensure those are exactly as on iOS side: MetaWearUnity.swift
    private static string LedColorCode(LedColors forColor)
    {
        switch (forColor)
        {
        case LedColors.ALL:
            return("all");

        case LedColors.BLUE:
            return("blue");

        case LedColors.GREEN:
            return("green");

        case LedColors.RED:
            return("red");

        case LedColors.NONE:
            return("none");

        default:
            return("unspecified");
        }
    }
    public static void StartDeviceLed(DeviceCard device, LedColors color)
    {
#if UNITY_IOS && !UNITY_EDITOR
        ios_turnDeviceLedOn(device.id, LedColorCode(color));
#endif
    }
    public static void StopDeviceLeds(DeviceCard device, LedColors color = LedColors.ALL)
    {
#if UNITY_IOS && !UNITY_EDITOR
        ios_stopDeviceLeds(device.id, LedColorCode(color));
#endif
    }
예제 #4
0
        private void InitializeData()
        {
            // Load color information.  This information was learned using the Color Learn Example.
            colorInformation[LedColors.Black]  = new ColorInformation(new Collection <double>(new double[] { 0, 0, 0, 0.01, 0, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.96, 0 }));
            colorInformation[LedColors.Red]    = new ColorInformation(new Collection <double>(new double[] { 0.08, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.06, 0.61, 0, 0 }));
            colorInformation[LedColors.Orange] = new ColorInformation(new Collection <double>(new double[] { 0, 0, 0.01, 0, 0.22, 0.76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }));
            colorInformation[LedColors.Green]  = new ColorInformation(new Collection <double>(new double[] { 0, 0, 0, 0, 0, 0, 0.16, 0.71, 0.02, 0.06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05 }));

            // Initialize the LED Roi collection.
            ledRois[0]  = new Roi(new Shape[] { new RectangleContour(86, 154, 14, 14) });
            ledRois[1]  = new Roi(new Shape[] { new RectangleContour(136, 153, 14, 14) });
            ledRois[2]  = new Roi(new Shape[] { new RectangleContour(188, 152, 14, 14) });
            ledRois[3]  = new Roi(new Shape[] { new RectangleContour(236, 152, 14, 14) });
            ledRois[4]  = new Roi(new Shape[] { new RectangleContour(87, 194, 14, 14) });
            ledRois[5]  = new Roi(new Shape[] { new RectangleContour(136, 193, 14, 14) });
            ledRois[6]  = new Roi(new Shape[] { new RectangleContour(189, 193, 14, 14) });
            ledRois[7]  = new Roi(new Shape[] { new RectangleContour(236, 194, 14, 14) });
            ledRois[8]  = new Roi(new Shape[] { new RectangleContour(32, 224, 21, 21) });
            ledRois[9]  = new Roi(new Shape[] { new RectangleContour(86, 233, 14, 14) });
            ledRois[10] = new Roi(new Shape[] { new RectangleContour(135, 233, 14, 14) });
            ledRois[11] = new Roi(new Shape[] { new RectangleContour(187, 232, 14, 14) });
            ledRois[12] = new Roi(new Shape[] { new RectangleContour(236, 232, 14, 14) });

            // Initialize the expected patterns array.  This array stores the
            // expected pattern for each image.
            expectedPatterns[0] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[1] = new LedColors[] { LedColors.Red, LedColors.Red, LedColors.Red, LedColors.Red,
                                                    LedColors.Orange, LedColors.Orange, LedColors.Orange, LedColors.Orange,
                                                    LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green };
            expectedPatterns[2] = new LedColors[] { LedColors.Red, LedColors.Red, LedColors.Red, LedColors.Red,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Orange,
                                                    LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green };
            expectedPatterns[3] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green };
            expectedPatterns[4] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[5] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[6] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Black, LedColors.Green, LedColors.Black, LedColors.Black };
            expectedPatterns[7] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Green, LedColors.Black };
            expectedPatterns[8] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Green };
            expectedPatterns[9] = new LedColors[] { LedColors.Black, LedColors.Red, LedColors.Black, LedColors.Black,
                                                    LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                    LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[10] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Red, LedColors.Black,
                                                     LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                     LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[11] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Red,
                                                     LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                     LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black };
            expectedPatterns[12] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Black,
                                                     LedColors.Black, LedColors.Orange, LedColors.Orange, LedColors.Black,
                                                     LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Green };
            expectedPatterns[13] = new LedColors[] { LedColors.Red, LedColors.Black, LedColors.Black, LedColors.Black,
                                                     LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Orange,
                                                     LedColors.Green, LedColors.Black, LedColors.Green, LedColors.Green, LedColors.Black };
            expectedPatterns[14] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Red, LedColors.Red,
                                                     LedColors.Orange, LedColors.Orange, LedColors.Black, LedColors.Black,
                                                     LedColors.Green, LedColors.Black, LedColors.Black, LedColors.Green, LedColors.Green };
            expectedPatterns[15] = new LedColors[] { LedColors.Red, LedColors.Black, LedColors.Black, LedColors.Black,
                                                     LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Orange,
                                                     LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Black };
            expectedPatterns[16] = new LedColors[] { LedColors.Black, LedColors.Black, LedColors.Black, LedColors.Red,
                                                     LedColors.Black, LedColors.Orange, LedColors.Black, LedColors.Orange,
                                                     LedColors.Green, LedColors.Green, LedColors.Green, LedColors.Black, LedColors.Black };
        }