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
|
master_t masterConfig; // master config struct with data independent from profiles
|
||||||
profile_t *currentProfile;
|
profile_t *currentProfile;
|
||||||
|
|
||||||
|
static uint8_t currentControlRateProfileIndex = 0;
|
||||||
controlRateConfig_t *currentControlRateProfile;
|
controlRateConfig_t *currentControlRateProfile;
|
||||||
|
|
||||||
static const uint8_t EEPROM_CONF_VERSION = 84;
|
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)
|
static void setProfile(uint8_t profileIndex)
|
||||||
{
|
{
|
||||||
currentProfile = &masterConfig.profile[profileIndex];
|
currentProfile = &masterConfig.profile[profileIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t currentControlRateProfileIndex = 0;
|
|
||||||
|
|
||||||
uint8_t getCurrentControlRateProfile(void)
|
uint8_t getCurrentControlRateProfile(void)
|
||||||
{
|
{
|
||||||
return currentControlRateProfileIndex;
|
return currentControlRateProfileIndex;
|
||||||
|
|
|
@ -57,6 +57,8 @@ void readEEPROMAndNotify(void);
|
||||||
void writeEEPROM();
|
void writeEEPROM();
|
||||||
void ensureEEPROMContainsValidData(void);
|
void ensureEEPROMContainsValidData(void);
|
||||||
void saveConfigAndNotify(void);
|
void saveConfigAndNotify(void);
|
||||||
|
|
||||||
|
uint8_t getCurrentProfile(void);
|
||||||
void changeProfile(uint8_t profileIndex);
|
void changeProfile(uint8_t profileIndex);
|
||||||
|
|
||||||
uint8_t getCurrentControlRateProfile(void);
|
uint8_t getCurrentControlRateProfile(void);
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
|
|
||||||
#include "config/runtime_config.h"
|
#include "config/runtime_config.h"
|
||||||
|
|
||||||
|
#include "config/config.h"
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#define MILLISECONDS_IN_A_SECOND (1000 * 1000)
|
#define MILLISECONDS_IN_A_SECOND (1000 * 1000)
|
||||||
|
@ -64,6 +66,7 @@ typedef enum {
|
||||||
PAGE_BATTERY,
|
PAGE_BATTERY,
|
||||||
PAGE_SENSORS,
|
PAGE_SENSORS,
|
||||||
PAGE_RX,
|
PAGE_RX,
|
||||||
|
PAGE_PROFILE,
|
||||||
} pageId_e;
|
} pageId_e;
|
||||||
|
|
||||||
const char* pageTitles[] = {
|
const char* pageTitles[] = {
|
||||||
|
@ -71,12 +74,14 @@ const char* pageTitles[] = {
|
||||||
"ARMED",
|
"ARMED",
|
||||||
"BATTERY",
|
"BATTERY",
|
||||||
"SENSORS",
|
"SENSORS",
|
||||||
"RX"
|
"RX",
|
||||||
|
"PROFILE"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PAGE_COUNT (PAGE_RX + 1)
|
#define PAGE_COUNT (PAGE_RX + 1)
|
||||||
|
|
||||||
const uint8_t cyclePageIds[] = {
|
const uint8_t cyclePageIds[] = {
|
||||||
|
PAGE_PROFILE,
|
||||||
PAGE_BATTERY,
|
PAGE_BATTERY,
|
||||||
PAGE_SENSORS,
|
PAGE_SENSORS,
|
||||||
PAGE_RX
|
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)
|
void showBatteryPage(void)
|
||||||
{
|
{
|
||||||
tfp_sprintf(lineBuffer, "Volts: %d.%d, Cells: %d", vbat / 10, vbat % 10, batteryCellCount);
|
tfp_sprintf(lineBuffer, "Volts: %d.%d, Cells: %d", vbat / 10, vbat % 10, batteryCellCount);
|
||||||
|
@ -310,6 +326,9 @@ void updateDisplay(void)
|
||||||
case PAGE_RX:
|
case PAGE_RX:
|
||||||
showRxPage();
|
showRxPage();
|
||||||
break;
|
break;
|
||||||
|
case PAGE_PROFILE:
|
||||||
|
showProfilePage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!armedState) {
|
if (!armedState) {
|
||||||
updateTicker();
|
updateTicker();
|
||||||
|
@ -337,6 +356,7 @@ void displaySetNextPageChangeAt(uint32_t futureMicros) {
|
||||||
|
|
||||||
void displayEnablePageCycling(void) {
|
void displayEnablePageCycling(void) {
|
||||||
pageState.pageFlags |= PAGE_STATE_FLAG_CYCLE_ENABLED;
|
pageState.pageFlags |= PAGE_STATE_FLAG_CYCLE_ENABLED;
|
||||||
|
pageState.cycleIndex = CYCLE_PAGE_ID_COUNT - 1; // start at first page
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayDisablePageCycling(void) {
|
void displayDisablePageCycling(void) {
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ static void cliProfile(char *cmdline)
|
||||||
|
|
||||||
len = strlen(cmdline);
|
len = strlen(cmdline);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
printf("profile %d\r\n", masterConfig.current_profile_index);
|
printf("profile %d\r\n", getCurrentProfile());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
i = atoi(cmdline);
|
i = atoi(cmdline);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue