Changed bus to be a pointer variable
This commit is contained in:
parent
82be9ecd78
commit
c00ffe0427
|
@ -84,7 +84,7 @@ PG_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig,
|
||||||
#define DISPLAY_UPDATE_FREQUENCY (MICROSECONDS_IN_A_SECOND / 5)
|
#define DISPLAY_UPDATE_FREQUENCY (MICROSECONDS_IN_A_SECOND / 5)
|
||||||
#define PAGE_CYCLE_FREQUENCY (MICROSECONDS_IN_A_SECOND * 5)
|
#define PAGE_CYCLE_FREQUENCY (MICROSECONDS_IN_A_SECOND * 5)
|
||||||
|
|
||||||
static busDevice_t bus;
|
static busDevice_t *bus;
|
||||||
|
|
||||||
static uint32_t nextDisplayUpdateAt = 0;
|
static uint32_t nextDisplayUpdateAt = 0;
|
||||||
static bool dashboardPresent = false;
|
static bool dashboardPresent = false;
|
||||||
|
@ -131,12 +131,12 @@ static pageState_t pageState;
|
||||||
|
|
||||||
void resetDisplay(void)
|
void resetDisplay(void)
|
||||||
{
|
{
|
||||||
dashboardPresent = ug2864hsweg01InitI2C(&bus);
|
dashboardPresent = ug2864hsweg01InitI2C(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCDprint(uint8_t i)
|
void LCDprint(uint8_t i)
|
||||||
{
|
{
|
||||||
i2c_OLED_send_char(&bus, i);
|
i2c_OLED_send_char(bus, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void padLineBuffer(void)
|
void padLineBuffer(void)
|
||||||
|
@ -182,8 +182,8 @@ void fillScreenWithCharacters()
|
||||||
{
|
{
|
||||||
for (uint8_t row = 0; row < SCREEN_CHARACTER_ROW_COUNT; row++) {
|
for (uint8_t row = 0; row < SCREEN_CHARACTER_ROW_COUNT; row++) {
|
||||||
for (uint8_t column = 0; column < SCREEN_CHARACTER_COLUMN_COUNT; column++) {
|
for (uint8_t column = 0; column < SCREEN_CHARACTER_COLUMN_COUNT; column++) {
|
||||||
i2c_OLED_set_xy(&bus, column, row);
|
i2c_OLED_set_xy(bus, column, row);
|
||||||
i2c_OLED_send_char(&bus, 'A' + column);
|
i2c_OLED_send_char(bus, 'A' + column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,22 +193,22 @@ void fillScreenWithCharacters()
|
||||||
void updateTicker(void)
|
void updateTicker(void)
|
||||||
{
|
{
|
||||||
static uint8_t tickerIndex = 0;
|
static uint8_t tickerIndex = 0;
|
||||||
i2c_OLED_set_xy(&bus, SCREEN_CHARACTER_COLUMN_COUNT - 1, 0);
|
i2c_OLED_set_xy(bus, SCREEN_CHARACTER_COLUMN_COUNT - 1, 0);
|
||||||
i2c_OLED_send_char(&bus, tickerCharacters[tickerIndex]);
|
i2c_OLED_send_char(bus, tickerCharacters[tickerIndex]);
|
||||||
tickerIndex++;
|
tickerIndex++;
|
||||||
tickerIndex = tickerIndex % TICKER_CHARACTER_COUNT;
|
tickerIndex = tickerIndex % TICKER_CHARACTER_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateRxStatus(void)
|
void updateRxStatus(void)
|
||||||
{
|
{
|
||||||
i2c_OLED_set_xy(&bus, SCREEN_CHARACTER_COLUMN_COUNT - 2, 0);
|
i2c_OLED_set_xy(bus, SCREEN_CHARACTER_COLUMN_COUNT - 2, 0);
|
||||||
char rxStatus = '!';
|
char rxStatus = '!';
|
||||||
if (rxIsReceivingSignal()) {
|
if (rxIsReceivingSignal()) {
|
||||||
rxStatus = 'r';
|
rxStatus = 'r';
|
||||||
} if (rxAreFlightChannelsValid()) {
|
} if (rxAreFlightChannelsValid()) {
|
||||||
rxStatus = 'R';
|
rxStatus = 'R';
|
||||||
}
|
}
|
||||||
i2c_OLED_send_char(&bus, rxStatus);
|
i2c_OLED_send_char(bus, rxStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFailsafeStatus(void)
|
void updateFailsafeStatus(void)
|
||||||
|
@ -234,19 +234,19 @@ void updateFailsafeStatus(void)
|
||||||
failsafeIndicator = 'r';
|
failsafeIndicator = 'r';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i2c_OLED_set_xy(&bus, SCREEN_CHARACTER_COLUMN_COUNT - 3, 0);
|
i2c_OLED_set_xy(bus, SCREEN_CHARACTER_COLUMN_COUNT - 3, 0);
|
||||||
i2c_OLED_send_char(&bus, failsafeIndicator);
|
i2c_OLED_send_char(bus, failsafeIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showTitle()
|
void showTitle()
|
||||||
{
|
{
|
||||||
i2c_OLED_set_line(&bus, 0);
|
i2c_OLED_set_line(bus, 0);
|
||||||
i2c_OLED_send_string(&bus, pageState.page->title);
|
i2c_OLED_send_string(bus, pageState.page->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlePageChange(void)
|
void handlePageChange(void)
|
||||||
{
|
{
|
||||||
i2c_OLED_clear_display_quick(&bus);
|
i2c_OLED_clear_display_quick(bus);
|
||||||
showTitle();
|
showTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ void showRxPage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (uint8_t channelIndex = 0; channelIndex < rxRuntimeConfig.channelCount && channelIndex < RX_CHANNELS_PER_PAGE_COUNT; channelIndex += 2) {
|
for (uint8_t channelIndex = 0; channelIndex < rxRuntimeConfig.channelCount && channelIndex < RX_CHANNELS_PER_PAGE_COUNT; channelIndex += 2) {
|
||||||
i2c_OLED_set_line(&bus, (channelIndex / 2) + PAGE_TITLE_LINE_COUNT);
|
i2c_OLED_set_line(bus, (channelIndex / 2) + PAGE_TITLE_LINE_COUNT);
|
||||||
|
|
||||||
drawRxChannel(channelIndex, HALF_SCREEN_CHARACTER_COLUMN_COUNT);
|
drawRxChannel(channelIndex, HALF_SCREEN_CHARACTER_COLUMN_COUNT);
|
||||||
|
|
||||||
|
@ -286,11 +286,11 @@ void showWelcomePage(void)
|
||||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "v%s (%s)", FC_VERSION_STRING, shortGitRevision);
|
tfp_sprintf(lineBuffer, "v%s (%s)", FC_VERSION_STRING, shortGitRevision);
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, targetName);
|
i2c_OLED_send_string(bus, targetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showArmedPage(void)
|
void showArmedPage(void)
|
||||||
|
@ -302,8 +302,8 @@ void showProfilePage(void)
|
||||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "Profile: %d", getCurrentPidProfileIndex());
|
tfp_sprintf(lineBuffer, "Profile: %d", getCurrentPidProfileIndex());
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
static const char* const axisTitles[3] = {"ROL", "PIT", "YAW"};
|
static const char* const axisTitles[3] = {"ROL", "PIT", "YAW"};
|
||||||
const pidProfile_t *pidProfile = currentPidProfile;
|
const pidProfile_t *pidProfile = currentPidProfile;
|
||||||
|
@ -315,14 +315,14 @@ void showProfilePage(void)
|
||||||
pidProfile->pid[axis].D
|
pidProfile->pid[axis].D
|
||||||
);
|
);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t currentRateProfileIndex = getCurrentControlRateProfileIndex();
|
const uint8_t currentRateProfileIndex = getCurrentControlRateProfileIndex();
|
||||||
tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex);
|
tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex);
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
const controlRateConfig_t *controlRateConfig = controlRateProfiles(currentRateProfileIndex);
|
const controlRateConfig_t *controlRateConfig = controlRateProfiles(currentRateProfileIndex);
|
||||||
tfp_sprintf(lineBuffer, "RCE: %d, RCR: %d",
|
tfp_sprintf(lineBuffer, "RCE: %d, RCR: %d",
|
||||||
|
@ -330,8 +330,8 @@ void showProfilePage(void)
|
||||||
controlRateConfig->rcRate8
|
controlRateConfig->rcRate8
|
||||||
);
|
);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "RR:%d PR:%d YR:%d",
|
tfp_sprintf(lineBuffer, "RR:%d PR:%d YR:%d",
|
||||||
controlRateConfig->rates[FD_ROLL],
|
controlRateConfig->rates[FD_ROLL],
|
||||||
|
@ -339,8 +339,8 @@ void showProfilePage(void)
|
||||||
controlRateConfig->rates[FD_YAW]
|
controlRateConfig->rates[FD_YAW]
|
||||||
);
|
);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
#define SATELLITE_COUNT (sizeof(GPS_svinfo_cno) / sizeof(GPS_svinfo_cno[0]))
|
#define SATELLITE_COUNT (sizeof(GPS_svinfo_cno) / sizeof(GPS_svinfo_cno[0]))
|
||||||
#define SATELLITE_GRAPH_LEFT_OFFSET ((SCREEN_CHARACTER_COLUMN_COUNT - SATELLITE_COUNT) / 2)
|
#define SATELLITE_GRAPH_LEFT_OFFSET ((SCREEN_CHARACTER_COLUMN_COUNT - SATELLITE_COUNT) / 2)
|
||||||
|
@ -363,77 +363,77 @@ void showGpsPage() {
|
||||||
gpsTicker = gpsTicker % TICKER_CHARACTER_COUNT;
|
gpsTicker = gpsTicker % TICKER_CHARACTER_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_OLED_set_xy(&bus, 0, rowIndex);
|
i2c_OLED_set_xy(bus, 0, rowIndex);
|
||||||
i2c_OLED_send_char(&bus, tickerCharacters[gpsTicker]);
|
i2c_OLED_send_char(bus, tickerCharacters[gpsTicker]);
|
||||||
|
|
||||||
i2c_OLED_set_xy(&bus, MAX(0, SATELLITE_GRAPH_LEFT_OFFSET), rowIndex++);
|
i2c_OLED_set_xy(bus, MAX(0, SATELLITE_GRAPH_LEFT_OFFSET), rowIndex++);
|
||||||
|
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
for (index = 0; index < SATELLITE_COUNT && index < SCREEN_CHARACTER_COLUMN_COUNT; index++) {
|
for (index = 0; index < SATELLITE_COUNT && index < SCREEN_CHARACTER_COLUMN_COUNT; index++) {
|
||||||
uint8_t bargraphOffset = ((uint16_t) GPS_svinfo_cno[index] * VERTICAL_BARGRAPH_CHARACTER_COUNT) / (GPS_DBHZ_MAX - 1);
|
uint8_t bargraphOffset = ((uint16_t) GPS_svinfo_cno[index] * VERTICAL_BARGRAPH_CHARACTER_COUNT) / (GPS_DBHZ_MAX - 1);
|
||||||
bargraphOffset = MIN(bargraphOffset, VERTICAL_BARGRAPH_CHARACTER_COUNT - 1);
|
bargraphOffset = MIN(bargraphOffset, VERTICAL_BARGRAPH_CHARACTER_COUNT - 1);
|
||||||
i2c_OLED_send_char(&bus, VERTICAL_BARGRAPH_ZERO_CHARACTER + bargraphOffset);
|
i2c_OLED_send_char(bus, VERTICAL_BARGRAPH_ZERO_CHARACTER + bargraphOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char fixChar = STATE(GPS_FIX) ? 'Y' : 'N';
|
char fixChar = STATE(GPS_FIX) ? 'Y' : 'N';
|
||||||
tfp_sprintf(lineBuffer, "Sats: %d Fix: %c", gpsSol.numSat, fixChar);
|
tfp_sprintf(lineBuffer, "Sats: %d Fix: %c", gpsSol.numSat, fixChar);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "La/Lo: %d/%d", gpsSol.llh.lat / GPS_DEGREES_DIVIDER, gpsSol.llh.lon / GPS_DEGREES_DIVIDER);
|
tfp_sprintf(lineBuffer, "La/Lo: %d/%d", gpsSol.llh.lat / GPS_DEGREES_DIVIDER, gpsSol.llh.lon / GPS_DEGREES_DIVIDER);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "Spd: %d", gpsSol.groundSpeed);
|
tfp_sprintf(lineBuffer, "Spd: %d", gpsSol.groundSpeed);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex);
|
i2c_OLED_set_line(bus, rowIndex);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "GC: %d", gpsSol.groundCourse);
|
tfp_sprintf(lineBuffer, "GC: %d", gpsSol.groundCourse);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_xy(&bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
i2c_OLED_set_xy(bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "RX: %d", GPS_packetCount);
|
tfp_sprintf(lineBuffer, "RX: %d", GPS_packetCount);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex);
|
i2c_OLED_set_line(bus, rowIndex);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "ERRs: %d", gpsData.errors, gpsData.timeouts);
|
tfp_sprintf(lineBuffer, "ERRs: %d", gpsData.errors, gpsData.timeouts);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_xy(&bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
i2c_OLED_set_xy(bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "Dt: %d", gpsData.lastMessage - gpsData.lastLastMessage);
|
tfp_sprintf(lineBuffer, "Dt: %d", gpsData.lastMessage - gpsData.lastLastMessage);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex);
|
i2c_OLED_set_line(bus, rowIndex);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, "TOs: %d", gpsData.timeouts);
|
tfp_sprintf(lineBuffer, "TOs: %d", gpsData.timeouts);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_xy(&bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
i2c_OLED_set_xy(bus, HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
strncpy(lineBuffer, gpsPacketLog, GPS_PACKET_LOG_ENTRY_COUNT);
|
strncpy(lineBuffer, gpsPacketLog, GPS_PACKET_LOG_ENTRY_COUNT);
|
||||||
padHalfLineBuffer();
|
padHalfLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
#ifdef GPS_PH_DEBUG
|
#ifdef GPS_PH_DEBUG
|
||||||
tfp_sprintf(lineBuffer, "Angles: P:%d R:%d", GPS_angle[PITCH], GPS_angle[ROLL]);
|
tfp_sprintf(lineBuffer, "Angles: P:%d R:%d", GPS_angle[PITCH], GPS_angle[ROLL]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
tfp_sprintf(lineBuffer, "%d %d %d %d", debug[0], debug[1], debug[2], debug[3]);
|
tfp_sprintf(lineBuffer, "%d %d %d %d", debug[0], debug[1], debug[2], debug[3]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -445,11 +445,11 @@ void showBatteryPage(void)
|
||||||
if (batteryConfig()->voltageMeterSource != VOLTAGE_METER_NONE) {
|
if (batteryConfig()->voltageMeterSource != VOLTAGE_METER_NONE) {
|
||||||
tfp_sprintf(lineBuffer, "Volts: %d.%1d Cells: %d", getBatteryVoltage() / 10, getBatteryVoltage() % 10, getBatteryCellCount());
|
tfp_sprintf(lineBuffer, "Volts: %d.%1d Cells: %d", getBatteryVoltage() / 10, getBatteryVoltage() % 10, getBatteryCellCount());
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
uint8_t batteryPercentage = calculateBatteryPercentageRemaining();
|
uint8_t batteryPercentage = calculateBatteryPercentageRemaining();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, batteryPercentage);
|
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, batteryPercentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,11 +458,11 @@ void showBatteryPage(void)
|
||||||
int32_t amperage = getAmperage();
|
int32_t amperage = getAmperage();
|
||||||
tfp_sprintf(lineBuffer, "Amps: %d.%2d mAh: %d", amperage / 100, amperage % 100, getMAhDrawn());
|
tfp_sprintf(lineBuffer, "Amps: %d.%2d mAh: %d", amperage / 100, amperage % 100, getMAhDrawn());
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
uint8_t capacityPercentage = calculateBatteryPercentageRemaining();
|
uint8_t capacityPercentage = calculateBatteryPercentageRemaining();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, capacityPercentage);
|
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, capacityPercentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,36 +472,36 @@ void showSensorsPage(void)
|
||||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||||
static const char *format = "%s %5d %5d %5d";
|
static const char *format = "%s %5d %5d %5d";
|
||||||
|
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, " X Y Z");
|
i2c_OLED_send_string(bus, " X Y Z");
|
||||||
|
|
||||||
if (sensors(SENSOR_ACC)) {
|
if (sensors(SENSOR_ACC)) {
|
||||||
tfp_sprintf(lineBuffer, format, "ACC", acc.accSmooth[X], acc.accSmooth[Y], acc.accSmooth[Z]);
|
tfp_sprintf(lineBuffer, format, "ACC", acc.accSmooth[X], acc.accSmooth[Y], acc.accSmooth[Z]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensors(SENSOR_GYRO)) {
|
if (sensors(SENSOR_GYRO)) {
|
||||||
tfp_sprintf(lineBuffer, format, "GYR", lrintf(gyro.gyroADCf[X]), lrintf(gyro.gyroADCf[Y]), lrintf(gyro.gyroADCf[Z]));
|
tfp_sprintf(lineBuffer, format, "GYR", lrintf(gyro.gyroADCf[X]), lrintf(gyro.gyroADCf[Y]), lrintf(gyro.gyroADCf[Z]));
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
if (sensors(SENSOR_MAG)) {
|
if (sensors(SENSOR_MAG)) {
|
||||||
tfp_sprintf(lineBuffer, format, "MAG", mag.magADC[X], mag.magADC[Y], mag.magADC[Z]);
|
tfp_sprintf(lineBuffer, format, "MAG", mag.magADC[X], mag.magADC[Y], mag.magADC[Z]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tfp_sprintf(lineBuffer, format, "I&H", attitude.values.roll, attitude.values.pitch, DECIDEGREES_TO_DEGREES(attitude.values.yaw));
|
tfp_sprintf(lineBuffer, format, "I&H", attitude.values.roll, attitude.values.pitch, DECIDEGREES_TO_DEGREES(attitude.values.yaw));
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint8_t length;
|
uint8_t length;
|
||||||
|
@ -514,8 +514,8 @@ void showSensorsPage(void)
|
||||||
}
|
}
|
||||||
ftoa(EstG.A[Y], lineBuffer + length);
|
ftoa(EstG.A[Y], lineBuffer + length);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
|
|
||||||
ftoa(EstG.A[Z], lineBuffer);
|
ftoa(EstG.A[Z], lineBuffer);
|
||||||
length = strlen(lineBuffer);
|
length = strlen(lineBuffer);
|
||||||
|
@ -525,8 +525,8 @@ void showSensorsPage(void)
|
||||||
}
|
}
|
||||||
ftoa(smallAngle, lineBuffer + length);
|
ftoa(smallAngle, lineBuffer + length);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -537,8 +537,8 @@ void showTasksPage(void)
|
||||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||||
static const char *format = "%2d%6d%5d%4d%4d";
|
static const char *format = "%2d%6d%5d%4d%4d";
|
||||||
|
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, "Task max avg mx% av%");
|
i2c_OLED_send_string(bus, "Task max avg mx% av%");
|
||||||
cfTaskInfo_t taskInfo;
|
cfTaskInfo_t taskInfo;
|
||||||
for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; ++taskId) {
|
for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; ++taskId) {
|
||||||
getTaskInfo(taskId, &taskInfo);
|
getTaskInfo(taskId, &taskInfo);
|
||||||
|
@ -548,8 +548,8 @@ void showTasksPage(void)
|
||||||
const int averageLoad = (taskInfo.averageExecutionTime * taskFrequency + 5000) / 10000;
|
const int averageLoad = (taskInfo.averageExecutionTime * taskFrequency + 5000) / 10000;
|
||||||
tfp_sprintf(lineBuffer, format, taskId, taskInfo.maxExecutionTime, taskInfo.averageExecutionTime, maxLoad, averageLoad);
|
tfp_sprintf(lineBuffer, format, taskId, taskInfo.maxExecutionTime, taskInfo.averageExecutionTime, maxLoad, averageLoad);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex++);
|
i2c_OLED_set_line(bus, rowIndex++);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
if (rowIndex > SCREEN_CHARACTER_ROW_COUNT) {
|
if (rowIndex > SCREEN_CHARACTER_ROW_COUNT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -565,8 +565,8 @@ void showDebugPage(void)
|
||||||
for (int rowIndex = 0; rowIndex < 4; rowIndex++) {
|
for (int rowIndex = 0; rowIndex < 4; rowIndex++) {
|
||||||
tfp_sprintf(lineBuffer, "%d = %5d", rowIndex, debug[rowIndex]);
|
tfp_sprintf(lineBuffer, "%d = %5d", rowIndex, debug[rowIndex]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(&bus, rowIndex + PAGE_TITLE_LINE_COUNT);
|
i2c_OLED_set_line(bus, rowIndex + PAGE_TITLE_LINE_COUNT);
|
||||||
i2c_OLED_send_string(&bus, lineBuffer);
|
i2c_OLED_send_string(bus, lineBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -676,14 +676,16 @@ void dashboardUpdate(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
void dashboardInit(void)
|
void dashboardInit(void)
|
||||||
{
|
{
|
||||||
bus.i2c.device = I2C_CFG_TO_DEV(dashboardConfig()->device);
|
static busDevice_t dashBoardBus;
|
||||||
bus.i2c.address = dashboardConfig()->address;
|
dashBoardBus.i2c.device = I2C_CFG_TO_DEV(dashboardConfig()->device);
|
||||||
|
dashBoardBus.i2c.address = dashboardConfig()->address;
|
||||||
|
bus = &dashBoardBus;
|
||||||
|
|
||||||
delay(200);
|
delay(200);
|
||||||
resetDisplay();
|
resetDisplay();
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
displayPort = displayPortOledInit(&bus);
|
displayPort = displayPortOledInit(bus);
|
||||||
#if defined(CMS)
|
#if defined(CMS)
|
||||||
if (dashboardPresent) {
|
if (dashboardPresent) {
|
||||||
cmsDisplayPortRegister(displayPort);
|
cmsDisplayPortRegister(displayPort);
|
||||||
|
|
Loading…
Reference in New Issue