mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Merge branch 'dev' into epr-pinecil-og
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Author: Ralim
|
||||
*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "OperatingModeUtilities.h"
|
||||
#include "settingsGUI.hpp"
|
||||
#include "task.h"
|
||||
#include <Buttons.hpp>
|
||||
|
||||
@@ -93,23 +93,7 @@ const uint8_t WarningBlock24[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x0C, 0x02, 0xF1, 0xF1, 0xF1, 0x02, 0x0C, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC0, 0xB0, 0x8C, 0x83, 0x80, 0x80, 0x80, 0x80, 0xB3, 0xB3, 0xB3, 0x80, 0x80, 0x80, 0x80, 0x83, 0x8C, 0xB0, 0xC0, 0x00, 0x00};
|
||||
|
||||
#if defined(MODEL_TS100) + defined(MODEL_Pinecil) > 0
|
||||
const uint8_t buttonA[] = {
|
||||
// width = 42
|
||||
// height = 16
|
||||
0x00, 0x00, 0x00, 0x00, 0xe0, 0x18, 0x04, 0x02, 0x02, 0x01, 0x81, 0x49, 0x31, 0x01, 0xc1, 0x25, 0x19, 0x01, 0xc1, 0x25, 0x19, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x18, 0x20, 0x40, 0x40, 0x80, 0x89, 0x8a, 0x88, 0x94,
|
||||
0x8c, 0x94, 0xae, 0x80, 0xbe, 0x8e, 0xa6, 0x8e, 0xa6, 0x8e, 0xa6, 0x8e, 0xa6, 0x8a, 0xa6, 0x8a, 0xa6, 0x8a, 0xa6, 0x8a, 0x46, 0x4a, 0x22, 0x18, 0x07, 0x00, 0x00, 0x00};
|
||||
|
||||
const uint8_t disconnectedTip[] = {
|
||||
// width = 42
|
||||
// height = 16
|
||||
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xc0, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xcc, 0x9c, 0x38, 0x70, 0xe0, 0xc0, 0x80, 0x20, 0x70, 0x38, 0x1c, 0xcc, 0x40,
|
||||
0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0x60, 0xe0, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x05, 0x00, 0x07, 0x01, 0x04, 0x01, 0x04, 0x01,
|
||||
0x04, 0x31, 0x38, 0x1c, 0x0e, 0x04, 0x01, 0x03, 0x07, 0x0e, 0x1c, 0x39, 0x30, 0x01, 0x03, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x04, 0x09, 0x0f, 0x00};
|
||||
#endif
|
||||
|
||||
#if defined(MODEL_Pinecilv2) >= 1
|
||||
#if defined(MODEL_TS100) + defined(MODEL_Pinecil) + defined(MODEL_Pinecilv2) > 0
|
||||
const uint8_t buttonA[] = {
|
||||
// width = 42
|
||||
// height = 16
|
||||
|
||||
@@ -178,14 +178,9 @@ void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle) {
|
||||
fontWidth = 12;
|
||||
break;
|
||||
}
|
||||
for (uint32_t i = 0; i < FontSectionsCount; i++) {
|
||||
const auto §ion = FontSections[i];
|
||||
if (charCode >= section.symbol_start && charCode < section.symbol_end) {
|
||||
currentFont = fontStyle == FontStyle::SMALL ? section.font06_start_ptr : section.font12_start_ptr;
|
||||
index = charCode - section.symbol_start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
currentFont = fontStyle == FontStyle::SMALL ? FontSectionInfo.font06_start_ptr : FontSectionInfo.font12_start_ptr;
|
||||
index = charCode - 2;
|
||||
break;
|
||||
}
|
||||
const uint8_t *charPointer = currentFont + ((fontWidth * (fontHeight / 8)) * index);
|
||||
@@ -361,13 +356,18 @@ void OLED::setRotation(bool leftHanded) {
|
||||
OLED_Setup_Array[9].val = 0xA0;
|
||||
}
|
||||
I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, OLED_Setup_Array, sizeof(OLED_Setup_Array) / sizeof(OLED_Setup_Array[0]));
|
||||
|
||||
osDelay(TICKS_10MS);
|
||||
inLeftHandedMode = leftHanded;
|
||||
|
||||
screenBuffer[5] = inLeftHandedMode ? 0 : 32; // display is shifted by 32 in left handed
|
||||
// mode as driver ram is 128 wide
|
||||
screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; // End address of the ram segment we are writing to (96 wide)
|
||||
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
|
||||
// Force a screen refresh
|
||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
||||
osDelay(TICKS_10MS);
|
||||
checkDisplayBufferChecksum();
|
||||
}
|
||||
|
||||
void OLED::setBrightness(uint8_t contrast) {
|
||||
@@ -384,6 +384,10 @@ void OLED::setInverseDisplay(bool inverse) {
|
||||
// print a string to the current cursor location
|
||||
void OLED::print(const char *const str, FontStyle fontStyle) {
|
||||
const uint8_t *next = reinterpret_cast<const uint8_t *>(str);
|
||||
if (next[0] == 0x01) {
|
||||
fontStyle = FontStyle::LARGE;
|
||||
next++;
|
||||
}
|
||||
while (next[0]) {
|
||||
uint16_t index;
|
||||
if (next[0] <= 0xF0) {
|
||||
@@ -425,7 +429,7 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
|
||||
// Stop 1 short so that we dont blank entire number if its zero
|
||||
for (int i = 0; i < (places - 1); i++) {
|
||||
if (buffer[i] == 2) {
|
||||
buffer[i] = SymbolSpace[0];
|
||||
buffer[i] = LargeSymbolSpace[0];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -474,14 +478,14 @@ void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, boo
|
||||
|
||||
void OLED::debugNumber(int32_t val, FontStyle fontStyle) {
|
||||
if (abs(val) > 99999) {
|
||||
OLED::print(SymbolSpace, fontStyle); // out of bounds
|
||||
OLED::print(LargeSymbolSpace, fontStyle); // out of bounds
|
||||
return;
|
||||
}
|
||||
if (val >= 0) {
|
||||
OLED::print(SymbolSpace, fontStyle);
|
||||
OLED::print(LargeSymbolSpace, fontStyle);
|
||||
OLED::printNumber(val, 5, fontStyle);
|
||||
} else {
|
||||
OLED::print(SymbolMinus, fontStyle);
|
||||
OLED::print(LargeSymbolMinus, fontStyle);
|
||||
OLED::printNumber(-val, 5, fontStyle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,13 +51,9 @@ public:
|
||||
static bool isInitDone();
|
||||
// Draw the buffer out to the LCD if any content has changed.
|
||||
static void refresh() {
|
||||
uint32_t hash = 0;
|
||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||
for (int i = 0; i < len; i++) {
|
||||
hash += (i * screenBuffer[i]);
|
||||
}
|
||||
if (hash != displayChecksum) {
|
||||
displayChecksum = hash;
|
||||
|
||||
if (checkDisplayBufferChecksum()) {
|
||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
||||
// DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
|
||||
// or we need to goto double buffering
|
||||
@@ -118,6 +114,17 @@ public:
|
||||
static void transitionScrollDown();
|
||||
|
||||
private:
|
||||
static bool checkDisplayBufferChecksum(){
|
||||
uint32_t hash = 0;
|
||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||
for (int i = 0; i < len; i++) {
|
||||
hash += (i * screenBuffer[i]);
|
||||
}
|
||||
|
||||
bool result = hash!=displayChecksum;
|
||||
displayChecksum= hash;
|
||||
return result;
|
||||
}
|
||||
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
|
||||
static void setFramebuffer(uint8_t *buffer);
|
||||
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||
|
||||
@@ -152,7 +152,7 @@ bool parseCapabilitiesArray(const uint8_t numCaps, uint8_t *bestIndex, uint16_t
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && (((lastCapabilities[i] & PD_APDO_TYPE) == PD_APDO_TYPE_PPS))) {
|
||||
} else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && (((lastCapabilities[i] & PD_APDO_TYPE) == PD_APDO_TYPE_PPS)) && getSettingValue(SettingsOptions::PDVpdoEnabled)) {
|
||||
// If this is a PPS slot, calculate the max voltage in the PPS range that can we be used and maintain
|
||||
uint16_t max_voltage = PD_PAV2MV(PD_APDO_PPS_MAX_VOLTAGE_GET(lastCapabilities[i]));
|
||||
// uint16_t min_voltage = PD_PAV2MV(PD_APDO_PPS_MIN_VOLTAGE_GET(lastCapabilities[i]));
|
||||
@@ -179,7 +179,7 @@ bool parseCapabilitiesArray(const uint8_t numCaps, uint8_t *bestIndex, uint16_t
|
||||
}
|
||||
}
|
||||
#ifdef POW_EPR
|
||||
else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && (((lastCapabilities[i] & PD_APDO_TYPE) == PD_APDO_TYPE_AVS))) {
|
||||
else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && (((lastCapabilities[i] & PD_APDO_TYPE) == PD_APDO_TYPE_AVS)) && getSettingValue(SettingsOptions::PDVpdoEnabled)) {
|
||||
uint16_t max_voltage = PD_PAV2MV(PD_APDO_AVS_MAX_VOLTAGE_GET(lastCapabilities[i]));
|
||||
uint8_t max_wattage = PD_APDO_AVS_MAX_POWER_GET(lastCapabilities[i]);
|
||||
|
||||
@@ -374,4 +374,4 @@ void pdbs_dpm_get_sink_capability(pd_msg *cap, const bool isPD3) {
|
||||
// cap->hdr = hdr_template | PD_MSGTYPE_SINK_CAPABILITIES | PD_NUMOBJ(numobj);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Submodule source/Core/Drivers/usb-pd updated: 2b59d05b2f...feef71016c
Reference in New Issue
Block a user