void FCDevice::writeFirmwareConfiguration(const Value &config) { /* * Send a device configuration settings packet, using values based on a JSON * configuration. */ if (!config.IsObject()) { std::clog << "Firmware configuration is not a JSON object\n"; return; } const Value &led = config["led"]; const Value &dither = config["dither"]; const Value &interpolate = config["interpolate"]; if (!(led.IsTrue() || led.IsFalse() || led.IsNull())) { std::clog << "LED configuration must be true (always on), false (always off), or null (default).\n"; } mFirmwareConfig.data[0] = (led.IsNull() ? 0 : CFLAG_NO_ACTIVITY_LED) | (led.IsTrue() ? CFLAG_LED_CONTROL : 0) | (dither.IsFalse() ? CFLAG_NO_DITHERING : 0) | (interpolate.IsFalse() ? CFLAG_NO_INTERPOLATION : 0) ; writeFirmwareConfiguration(); }
void FCDevice::writeMessage(Document &msg) { /* * Dispatch a device-specific JSON command. * * This can be used to send frames or settings directly to one device, * bypassing the mapping we use for Open Pixel Control clients. This isn't * intended to be the fast path for regular applications, but it can be used * by configuration tools that need to operate regardless of the mapping setup. */ const char *type = msg["type"].GetString(); if (!strcmp(type, "device_options")) { /* * TODO: Eventually this should turn into the same thing as * loadConfiguration() and it shouldn't be device-specific, * but for now most of fcserver assumes the configuration is static. */ writeFirmwareConfiguration(msg["options"]); return; } if (!strcmp(type, "device_pixels")) { // Write raw pixels, without any mapping writeDevicePixels(msg); return; } // Chain to default handler USBDevice::writeMessage(msg); }
void FCDevice::loadConfiguration(const Value &config) { mConfigMap = findConfigMap(config); // Initial firmware configuration from our device options writeFirmwareConfiguration(config); }
void FCDevice::opcSetFirmwareConfiguration(const OPCSink::Message &msg) { /* * Raw firmware configuration packet */ memcpy(mFirmwareConfig.data, msg.data + 4, std::min<size_t>(sizeof mFirmwareConfig.data, msg.length() - 4)); writeFirmwareConfiguration(); }
void FCDevice::configureDevice(const Value &config) { /* * Send a device configuration settings packet, using the default values in our * JSON config file. This can be overridden over OPC later on. */ const Value &led = config["led"]; if (!(led.IsTrue() || led.IsFalse() || led.IsNull())) { std::clog << "LED configuration must be true (always on), false (always off), or null (default).\n"; } mFirmwareConfig.data[0] = (led.IsNull() ? 0 : CFLAG_NO_ACTIVITY_LED) | (led.IsTrue() ? CFLAG_LED_CONTROL : 0) ; writeFirmwareConfiguration(); }