Compare commits

...

3 Commits

Author SHA1 Message Date
Sascha Nitsch 8a5f798780 fixed missing macro execution on rotary 2022-03-22 03:44:10 +01:00
Sascha Nitsch 9337d28e75 fixed height calculation 2022-03-22 03:43:49 +01:00
Sascha Nitsch 46ee10990a fixed text output, added some sanity checks 2022-03-22 03:43:08 +01:00
2 changed files with 7 additions and 2 deletions

View File

@ -396,6 +396,9 @@ void CimditProfile::rotaryAction(uint8_t num, int8_t delta) {
} }
showActivate(); showActivate();
break; break;
case MACRO_PRESS:
scanOrExecuteMacro(m_mappedRotary[i].m_value, true);
break;
default: default:
break; break;
} }
@ -443,7 +446,7 @@ void CimditProfile::showActivate() {
w = w >> 1; w = w >> 1;
h = 8; h = 8;
} }
display.setCursor((SCREEN_WIDTH - w) >> 1, (SCREEN_HEIGHT >> 1) + ((SCREEN_HEIGHT - h)>> 1)); display.setCursor((SCREEN_WIDTH - w) >> 1, SCREEN_HEIGHT- h);
display.write(m_profiles[m_selectingProfile]); display.write(m_profiles[m_selectingProfile]);
display.write("?"); display.write("?");
display.display(); display.display();

View File

@ -93,6 +93,7 @@ bool CimditSSD1306::begin() {
} }
void CimditSSD1306::drawPixel(uint8_t x, uint8_t y, bool state) { void CimditSSD1306::drawPixel(uint8_t x, uint8_t y, bool state) {
if (x >= m_width || y >= m_height) return;
if (state) { if (state) {
m_buffer[x + (y >> 3) * m_width] |= (1 << (y & 7)); m_buffer[x + (y >> 3) * m_width] |= (1 << (y & 7));
} else { } else {
@ -105,6 +106,7 @@ void CimditSSD1306::clearDisplay(void) {
} }
void CimditSSD1306::drawFastHLine(uint8_t x, uint8_t y, uint8_t w, bool state) { void CimditSSD1306::drawFastHLine(uint8_t x, uint8_t y, uint8_t w, bool state) {
if ((x + w) >= m_width || (y >= m_height)) return;
uint8_t *pBuf = m_buffer + (y / 8) * m_width + x; uint8_t *pBuf = m_buffer + (y / 8) * m_width + x;
uint8_t mask = 1 << (y & 7); uint8_t mask = 1 << (y & 7);
if (state) { if (state) {
@ -237,7 +239,7 @@ void CimditSSD1306::setTextSize(uint8_t sX, uint8_t sY) {
} }
size_t CimditSSD1306::write(uint8_t c) { size_t CimditSSD1306::write(uint8_t c) {
if (c == '\n' || m_cursorX + m_textsizeX * 6) { // a newline or text oveflow if (c == '\n' || (m_cursorX + m_textsizeX * 6 > m_width)) { // a newline or text oveflow
m_cursorX = 0; // set X to zero m_cursorX = 0; // set X to zero
m_cursorY += m_textsizeY * 8; // go down one line m_cursorY += m_textsizeY * 8; // go down one line
} else if (c == '\r') { // a carriage return } else if (c == '\r') { // a carriage return