public async void LightFx(string ch, byte fx, byte[] param) { if (fx != (byte)PFxLightFx.TURN_OFF) { SetLightFXBrightness(ch, 255); } PFxAction action = new PFxAction(); action.lightOutputMask = PortToMask(ch); action.lightFxId = fx; param = new byte[2]; param[0] = (byte)PFxLightPeriod.PERIOD_1S; param[1] = (byte)PFxLightFactor.FADE_FACTOR_NONE; //FADE_FACTOR_150 for (int i = 0; i < param.Length; i++) { switch (i) { case 0: action.lightParam1 = param[0]; break; case 1: action.lightParam2 = param[1]; break; case 2: action.lightParam3 = param[2]; break; case 3: action.lightParam4 = param[3]; break; case 4: action.lightParam5 = param[4]; break; } } byte[] res = await SendData(action.GetTestActionData()); }
private async void RefreshFileDir() { try { PFxAction action = new PFxAction(); byte[] rx = await SendData(action.GetCmdNumFiles()); fileId.Clear(); fileNames.Clear(); int file_count = rx[4]; for (int i = 0; i < file_count; i++) { byte[] rxDir = await SendData(action.GetCmdGetDirEntry((byte)(i + 1))); int id = rxDir[3]; fileId.Add(id); string name = ""; for (int j = 0; j < 32 && rxDir[24 + j] != 0; j++) { name += (char)rxDir[24 + j]; } fileNames.Add(name); MainBoard.WriteLine("PFx: new file found - " + name + " (id " + id + ")"); } MainBoard.WriteLine(fileId.Count + " files found on PFx"); } catch (Exception ex) { MainBoard.WriteLine("Exception while parsing files: " + ex.Message, Color.Red); } }
public async void SetLightFXBrightness(string port, int brightness) { PFxAction action = new PFxAction(); action.lightOutputMask = PortToMask(port); action.lightFxId = EVT_LIGHTFX_ON_OFF_TOGGLE; action.lightParam4 = brightness > 0 ? EVT_TRANSITION_ON : EVT_TRANSITION_OFF; /*int x = brightness; * if (x > 255) x = 255; * if (x < 0) x = 0;*/ //action.lightFxId = EVT_LIGHTFX_SET_BRIGHT; //action.lightParam1 = (byte)x; await SendData(action.GetTestActionData()); }
public async override void SetMotorSpeed(string port, int speed) { PFxAction action = new PFxAction(); Port portObj = GetPortFromPortId(port); // If we can't find the port, we can't do anything! if (portObj == null) { MainBoard.WriteLine("Could not set Motor Speed to " + speed + " for " + Name + " because no default port are setup", Color.Red); return; } double sf = speed; if (sf > 100.0) { sf = 100.0; } if (sf < -100.0) { sf = -100.0; } sf = (sf / 100.0) * 63.0; portObj.Speed = speed; int si = (int)(Math.Abs(sf)) & EVT_MOTOR_SPEED_HIRES_MASK; si |= EVT_MOTOR_SPEED_HIRES; if (sf < 0.0) { si |= EVT_MOTOR_SPEED_HIRES_REV; } action.motorParam1 = (byte)si; int m = PortToMask(port) & EVT_MOTOR_OUTPUT_MASK; m |= EVT_MOTOR_SET_SPD; action.motorActionId = (byte)m; OnDataUpdated(); await SendData(action.GetTestActionData()); }
async void SoundFx(byte fx, byte[] param, byte fileID) { PFxAction action = new PFxAction(); action.soundFxId = fx; if ((fileID >= 0) && (fileID < 0xFF)) { action.soundFileId = fileID; } for (int i = 0; i < param.Length; i++) { switch (i) { case 0: action.soundParam1 = param[0]; break; case 1: action.soundParam2 = param[1]; break; } } byte[] res = await SendData(action.GetTestActionData()); }