mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Add Profile OLED display page that shows the current profile and rate
profile.
This commit is contained in:
parent
28f9fa629c
commit
ef7f5321da
4 changed files with 31 additions and 4 deletions
|
@ -100,6 +100,8 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es
|
|||
|
||||
master_t masterConfig; // master config struct with data independent from profiles
|
||||
profile_t *currentProfile;
|
||||
|
||||
static uint8_t currentControlRateProfileIndex = 0;
|
||||
controlRateConfig_t *currentControlRateProfile;
|
||||
|
||||
static const uint8_t EEPROM_CONF_VERSION = 84;
|
||||
|
@ -244,13 +246,16 @@ static void resetControlRateConfig(controlRateConfig_t *controlRateConfig) {
|
|||
|
||||
}
|
||||
|
||||
uint8_t getCurrentProfile(void)
|
||||
{
|
||||
return masterConfig.current_profile_index;
|
||||
}
|
||||
|
||||
static void setProfile(uint8_t profileIndex)
|
||||
{
|
||||
currentProfile = &masterConfig.profile[profileIndex];
|
||||
}
|
||||
|
||||
static uint8_t currentControlRateProfileIndex = 0;
|
||||
|
||||
uint8_t getCurrentControlRateProfile(void)
|
||||
{
|
||||
return currentControlRateProfileIndex;
|
||||
|
|
|
@ -57,6 +57,8 @@ void readEEPROMAndNotify(void);
|
|||
void writeEEPROM();
|
||||
void ensureEEPROMContainsValidData(void);
|
||||
void saveConfigAndNotify(void);
|
||||
|
||||
uint8_t getCurrentProfile(void);
|
||||
void changeProfile(uint8_t profileIndex);
|
||||
|
||||
uint8_t getCurrentControlRateProfile(void);
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
#include "display.h"
|
||||
|
||||
#define MILLISECONDS_IN_A_SECOND (1000 * 1000)
|
||||
|
@ -64,6 +66,7 @@ typedef enum {
|
|||
PAGE_BATTERY,
|
||||
PAGE_SENSORS,
|
||||
PAGE_RX,
|
||||
PAGE_PROFILE,
|
||||
} pageId_e;
|
||||
|
||||
const char* pageTitles[] = {
|
||||
|
@ -71,12 +74,14 @@ const char* pageTitles[] = {
|
|||
"ARMED",
|
||||
"BATTERY",
|
||||
"SENSORS",
|
||||
"RX"
|
||||
"RX",
|
||||
"PROFILE"
|
||||
};
|
||||
|
||||
#define PAGE_COUNT (PAGE_RX + 1)
|
||||
|
||||
const uint8_t cyclePageIds[] = {
|
||||
PAGE_PROFILE,
|
||||
PAGE_BATTERY,
|
||||
PAGE_SENSORS,
|
||||
PAGE_RX
|
||||
|
@ -211,6 +216,17 @@ void showArmedPage(void)
|
|||
{
|
||||
}
|
||||
|
||||
void showProfilePage(void)
|
||||
{
|
||||
tfp_sprintf(lineBuffer, "Profile: %d", getCurrentProfile());
|
||||
i2c_OLED_set_line(1);
|
||||
i2c_OLED_send_string(lineBuffer);
|
||||
|
||||
tfp_sprintf(lineBuffer, "Rate profile: %d", getCurrentControlRateProfile());
|
||||
i2c_OLED_set_line(2);
|
||||
i2c_OLED_send_string(lineBuffer);
|
||||
}
|
||||
|
||||
void showBatteryPage(void)
|
||||
{
|
||||
tfp_sprintf(lineBuffer, "Volts: %d.%d, Cells: %d", vbat / 10, vbat % 10, batteryCellCount);
|
||||
|
@ -310,6 +326,9 @@ void updateDisplay(void)
|
|||
case PAGE_RX:
|
||||
showRxPage();
|
||||
break;
|
||||
case PAGE_PROFILE:
|
||||
showProfilePage();
|
||||
break;
|
||||
}
|
||||
if (!armedState) {
|
||||
updateTicker();
|
||||
|
@ -337,6 +356,7 @@ void displaySetNextPageChangeAt(uint32_t futureMicros) {
|
|||
|
||||
void displayEnablePageCycling(void) {
|
||||
pageState.pageFlags |= PAGE_STATE_FLAG_CYCLE_ENABLED;
|
||||
pageState.cycleIndex = CYCLE_PAGE_ID_COUNT - 1; // start at first page
|
||||
}
|
||||
|
||||
void displayDisablePageCycling(void) {
|
||||
|
|
|
@ -1090,7 +1090,7 @@ static void cliProfile(char *cmdline)
|
|||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
printf("profile %d\r\n", masterConfig.current_profile_index);
|
||||
printf("profile %d\r\n", getCurrentProfile());
|
||||
return;
|
||||
} else {
|
||||
i = atoi(cmdline);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue