bool EepromManager::fetchProfile(ProfileConfig& config) { bool ok = hasSettings(); if (ok) eepromAccess.readBlock(&config, pointerOffset(profile), sizeof(ProfileConfig)); return ok; }
bool EepromManager::storeProfile(const ProfileConfig& config) { bool ok = hasSettings(); if (ok) eepromAccess.writeBlock(pointerOffset(profile), &config, sizeof(ProfileConfig)); return ok; }
bool EepromManager::storeDevice(const DeviceConfig& config, uint8_t deviceIndex) { bool ok = (hasSettings() && deviceIndex<EepromFormat::MAX_DEVICES); if (ok) eepromAccess.writeBlock(pointerOffset(devices)+sizeof(DeviceConfig)*deviceIndex, &config, sizeof(DeviceConfig)); return ok; }
bool EepromManager::fetchDevice(DeviceConfig& config, uint8_t deviceIndex) { bool ok = (hasSettings() && deviceIndex<EepromFormat::MAX_DEVICES); if (ok) eepromAccess.readBlock(&config, pointerOffset(devices)+sizeof(DeviceConfig)*deviceIndex, sizeof(DeviceConfig)); return ok; }
bool EepromManager::applySettings() { if (!hasSettings()) return false; // start from a clean state deviceManager.setupUnconfiguredDevices(); logDebug("Applying settings"); // load the one chamber and one beer for now eptr_t pv = pointerOffset(chambers); tempControl.loadConstants(pv+offsetof(ChamberBlock, chamberSettings.cc)); tempControl.loadSettings(pv+offsetof(ChamberBlock, beer[0].cs)); logDebug("Applied settings"); #if BREWPI_TEMP_PROFILE profileControl.loadProfile(); #endif //BREWPI_TEMP_PROFILE DeviceConfig deviceConfig; for (uint8_t index = 0; fetchDevice(deviceConfig, index); index++) { if (deviceManager.isDeviceValid(deviceConfig, deviceConfig, index)) deviceManager.installDevice(deviceConfig); else { clear((uint8_t*)&deviceConfig, sizeof(deviceConfig)); eepromManager.storeDevice(deviceConfig, index); } } return true; }
void Inset::doDispatch(Cursor & cur, FuncRequest &cmd) { switch (cmd.action()) { case LFUN_MOUSE_RELEASE: // if the derived inset did not explicitly handle mouse_release, // we assume we request the settings dialog if (!cur.selection() && cmd.button() == mouse_button::button1 && clickable(cmd.x(), cmd.y()) && hasSettings()) { FuncRequest tmpcmd(LFUN_INSET_SETTINGS); dispatch(cur, tmpcmd); } break; case LFUN_INSET_SETTINGS: if (cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode())) { showInsetDialog(&cur.bv()); cur.dispatched(); } else cur.undispatched(); break; default: cur.noScreenUpdate(); cur.undispatched(); break; } }
bool Inset::getStatus(Cursor &, FuncRequest const & cmd, FuncStatus & flag) const { // LFUN_INSET_APPLY is sent from the dialogs when the data should // be applied. This is either changed to LFUN_INSET_MODIFY (if the // dialog belongs to us) or LFUN_INSET_INSERT (if the dialog does // not belong to us, i. e. the dialog was open, and the user moved // the cursor in our inset) in lyx::getStatus(). // Dialogs::checkStatus() ensures that the dialog is deactivated if // LFUN_INSET_APPLY is disabled. switch (cmd.action()) { case LFUN_INSET_MODIFY: // Allow modification of our data. // This needs to be handled in the doDispatch method of our // instantiatable children. // FIXME: Why don't we let the insets determine whether this // should be enabled or not ? Now we need this check for // the tabular features. (vfr) if (cmd.getArg(0) == "tabular") return false; flag.setEnabled(true); return true; case LFUN_INSET_INSERT: // Don't allow insertion of new insets. // Every inset that wants to allow new insets from open // dialogs needs to override this. flag.setEnabled(false); return true; case LFUN_INSET_SETTINGS: if (cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode())) { bool const enable = hasSettings(); flag.setEnabled(enable); return true; } else { return false; } case LFUN_IN_MATHMACROTEMPLATE: // By default we're not in a MathMacroTemplate inset flag.setEnabled(false); return true; case LFUN_IN_IPA: // By default we're not in an IPA inset flag.setEnabled(false); return true; default: break; } return false; }