Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[display] Improved SSD1306, Support for SH1106 #627

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,20 +580,21 @@ you specific needs.
<td align="center"><a href="https://modm.io/reference/module/modm-driver-pca9548a">PCA9548A</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-pca9685">PCA9685</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-sh1106">SH1106</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-siemens_s65">SIEMENS-S65</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-siemens_s75">SIEMENS-S75</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-sk6812">SK6812</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-sk9822">SK9822</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-ssd1306">SSD1306</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-stusb4500">STUSB4500</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-stusb4500">STUSB4500</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-sx1276">SX1276</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tcs3414">TCS3414</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tcs3472">TCS3472</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tlc594x">TLC594X</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tmp102">TMP102</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tmp175">TMP175</a></td>
</tr><tr>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-tmp175">TMP175</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-touch2046">TOUCH2046</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-vl53l0">VL53L0</a></td>
<td align="center"><a href="https://modm.io/reference/module/modm-driver-vl6180">VL6180</a></td>
Expand Down
2 changes: 1 addition & 1 deletion src/modm/driver/display/max7219_matrix_horizontal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Max7219MatrixHorizontal<SPI, CS, COLUMNS, ROWS>::update()
// a group of eight pixels horizontal
for (uint8_t col = 0; col < COLUMNS; ++col)
{
buf[--idx] = this->buffer[row * 8 + ledCol][col];
buf[--idx] = this->buffer[col][row * 8 + ledCol];
}
}

Expand Down
75 changes: 75 additions & 0 deletions src/modm/driver/display/sh1106.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2021, Thomas Sommer
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#pragma once

#include "ssd1306.hpp"

namespace modm
{

/**
* SH1106 is said to be 'compatible' with SSD1306. However there's a relevant
* difference: SH1106 does only support MemoryMode::PAGE. This requires a little
* more extensive writeDisplay() routine. We have to alternate between setting
* Page-address and sending page-data instead of sending the whole buffer at
* once like is for SSD1306 in MemoryMode::HORIZONTAL / MemoryMode::VERTICAL
*
* @ingroup modm_driver_sh1106
*/
salkinium marked this conversation as resolved.
Show resolved Hide resolved
template<class I2cMaster, uint8_t Height = 64>
class Sh1106 : public Ssd1306<I2cMaster, Height>
{
public:
Sh1106(uint8_t address = 0x3C) : Ssd1306<I2cMaster, Height>(address) {}

protected:
modm::ResumableResult<void>
startWriteDisplay() override
{
RF_BEGIN();

this->transaction_success = true;

this->commandBuffer[0] = ssd1306::AdressingCommands::HigherColumnStartAddress;
this->commandBuffer[1] = 0x02;

for (page = 0; page < Height / 8; page++)
{
this->commandBuffer[2] = 0xB0 | page;
this->transaction_success &= RF_CALL(this->writeCommands(3));

RF_WAIT_UNTIL(
this->transaction.configureDisplayWrite((uint8_t*)&this->buffer[page], 128));
RF_WAIT_UNTIL(this->startTransaction());
RF_WAIT_WHILE(this->isTransactionRunning());
this->transaction_success &= this->wasTransactionSuccessful();
};

RF_END_RETURN(this->transaction_success);
}

modm::ResumableResult<void>
initializeMemoryMode() override
{
RF_BEGIN();
// Default on Power-up - can be omitted
this->commandBuffer[0] = ssd1306::AdressingCommands::MemoryMode;
this->commandBuffer[1] = ssd1306::MemoryMode::PAGE;
this->transaction_success &= RF_CALL(this->writeCommands(2));
RF_END();
}

private:
size_t page;
};

} // namespace modm
24 changes: 24 additions & 0 deletions src/modm/driver/display/sh1106.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021, Thomas Sommer
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------


def init(module):
module.name = ":driver:sh1106"
module.description = "SH1106 Display"

def prepare(module, options):
module.depends(":driver:ssd1306")
return True

def build(env):
env.outbasepath = "modm/src/modm/driver/display"
env.copy("sh1106.hpp")
Loading