static long cmsx_RateProfileRead(void) { memcpy(&rateProfile, controlRateProfiles(profileIndex), sizeof(controlRateConfig_t)); cmsx_rateRoll = DEKADEGREES_TO_DEGREES(rateProfile.rates[FD_ROLL]); cmsx_ratePitch = DEKADEGREES_TO_DEGREES(rateProfile.rates[FD_PITCH]); cmsx_rateYaw = DEKADEGREES_TO_DEGREES(rateProfile.rates[FD_YAW]); return 0; }
static void showProfilePage(void) { uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; tfp_sprintf(lineBuffer, "Profile: %d", getCurrentPidProfileIndex()); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); static const char* const axisTitles[3] = {"ROL", "PIT", "YAW"}; const pidProfile_t *pidProfile = currentPidProfile; for (int axis = 0; axis < 3; ++axis) { tfp_sprintf(lineBuffer, "%s P:%3d I:%3d D:%3d", axisTitles[axis], pidProfile->pid[axis].P, pidProfile->pid[axis].I, pidProfile->pid[axis].D ); padLineBuffer(); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); } const uint8_t currentRateProfileIndex = getCurrentControlRateProfileIndex(); tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); const controlRateConfig_t *controlRateConfig = controlRateProfiles(currentRateProfileIndex); tfp_sprintf(lineBuffer, "RRr:%d PRR:%d YRR:%d", controlRateConfig->rcRates[FD_ROLL], controlRateConfig->rcRates[FD_PITCH], controlRateConfig->rcRates[FD_YAW] ); padLineBuffer(); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); tfp_sprintf(lineBuffer, "RE:%d PE:%d YE:%d", controlRateConfig->rcExpo[FD_ROLL], controlRateConfig->rcExpo[FD_PITCH], controlRateConfig->rcExpo[FD_YAW] ); padLineBuffer(); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); tfp_sprintf(lineBuffer, "RR:%d PR:%d YR:%d", controlRateConfig->rates[FD_ROLL], controlRateConfig->rates[FD_PITCH], controlRateConfig->rates[FD_YAW] ); padLineBuffer(); i2c_OLED_set_line(bus, rowIndex++); i2c_OLED_send_string(bus, lineBuffer); }
static long cmsx_RateProfileWriteback(const OSD_Entry *self) { UNUSED(self); rateProfile.rates[FD_ROLL] = DEGREES_TO_DEKADEGREES(cmsx_rateRoll); rateProfile.rates[FD_PITCH] = DEGREES_TO_DEKADEGREES(cmsx_ratePitch); rateProfile.rates[FD_YAW] = DEGREES_TO_DEKADEGREES(cmsx_rateYaw); memcpy((controlRateConfig_t *)controlRateProfiles(profileIndex), &rateProfile, sizeof(controlRateConfig_t)); return 0; }
void setControlRateProfile(uint8_t profileIndex) { currentControlRateProfileIndex = profileIndex; currentControlRateProfile = controlRateProfiles(profileIndex); }
controlRateConfig_t *getControlRateConfig(uint8_t profileIndex) { return controlRateProfiles(profileIndex); }
static long cmsx_RateProfileRead(void) { memcpy(&rateProfile, controlRateProfiles(rateProfileIndex), sizeof(controlRateConfig_t)); return 0; }