Merge pull request #1074 from Ralim/ralim/named-power-source
Ralim/named power source
This commit is contained in:
@@ -142,6 +142,14 @@ def get_accel_names_list() -> List[str]:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_power_source_list() -> List[str]:
|
||||||
|
return [
|
||||||
|
"DC",
|
||||||
|
"QC",
|
||||||
|
"PD",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_letter_counts(
|
def get_letter_counts(
|
||||||
defs: dict, lang: dict, build_version: str
|
defs: dict, lang: dict, build_version: str
|
||||||
) -> Tuple[List[str], Dict[str, int]]:
|
) -> Tuple[List[str], Dict[str, int]]:
|
||||||
@@ -202,6 +210,7 @@ def get_letter_counts(
|
|||||||
text_list.append(x[1])
|
text_list.append(x[1])
|
||||||
text_list.extend(get_debug_menu())
|
text_list.extend(get_debug_menu())
|
||||||
text_list.extend(get_accel_names_list())
|
text_list.extend(get_accel_names_list())
|
||||||
|
text_list.extend(get_power_source_list())
|
||||||
|
|
||||||
# collapse all strings down into the composite letters and store totals for these
|
# collapse all strings down into the composite letters and store totals for these
|
||||||
|
|
||||||
@@ -971,6 +980,15 @@ def get_translation_common_text(
|
|||||||
)
|
)
|
||||||
translation_common_text += "};\n\n"
|
translation_common_text += "};\n\n"
|
||||||
|
|
||||||
|
# power source types
|
||||||
|
translation_common_text += "const char* PowerSourceNames[] = {\n"
|
||||||
|
|
||||||
|
for c in get_power_source_list():
|
||||||
|
translation_common_text += (
|
||||||
|
f'\t "{convert_string(symbol_conversion_table, c)}",//{c} \n'
|
||||||
|
)
|
||||||
|
translation_common_text += "};\n\n"
|
||||||
|
|
||||||
return translation_common_text
|
return translation_common_text
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ extern const char *SymbolVersionNumber;
|
|||||||
|
|
||||||
extern const char *DebugMenu[];
|
extern const char *DebugMenu[];
|
||||||
extern const char *AccelTypeNames[];
|
extern const char *AccelTypeNames[];
|
||||||
|
extern const char *PowerSourceNames[];
|
||||||
|
|
||||||
enum class SettingsItemIndex : uint8_t {
|
enum class SettingsItemIndex : uint8_t {
|
||||||
DCInCutoff,
|
DCInCutoff,
|
||||||
|
|||||||
@@ -717,26 +717,29 @@ void showDebugMenu(void) {
|
|||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
// Power negotiation status
|
// Power negotiation status
|
||||||
if (getIsPoweredByDCIN()) {
|
{
|
||||||
OLED::printNumber(0, 1, FontStyle::SMALL);
|
int sourceNumber = 0;
|
||||||
} else {
|
if (getIsPoweredByDCIN()) {
|
||||||
// We are not powered via DC, so want to display the appropriate state for PD or QC
|
sourceNumber = 0;
|
||||||
bool poweredbyPD = false;
|
} else {
|
||||||
|
// We are not powered via DC, so want to display the appropriate state for PD or QC
|
||||||
|
bool poweredbyPD = false;
|
||||||
#ifdef POW_PD
|
#ifdef POW_PD
|
||||||
if (usb_pd_detect()) {
|
if (usb_pd_detect()) {
|
||||||
// We are PD capable
|
// We are PD capable
|
||||||
if (PolicyEngine::pdHasNegotiated()) {
|
if (PolicyEngine::pdHasNegotiated()) {
|
||||||
// We are powered via PD
|
// We are powered via PD
|
||||||
poweredbyPD = true;
|
poweredbyPD = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (poweredbyPD) {
|
||||||
|
sourceNumber = 2;
|
||||||
|
} else {
|
||||||
|
sourceNumber = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
|
||||||
if (poweredbyPD) {
|
|
||||||
OLED::printNumber(2, 1, FontStyle::SMALL);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
OLED::printNumber(1, 1, FontStyle::SMALL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
|
|||||||
Reference in New Issue
Block a user