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

OLED/Display clang-format style fixes #637

Merged
merged 1 commit into from
Sep 20, 2024
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
119 changes: 63 additions & 56 deletions src/dev/oled_ssd1327.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace daisy
{

/**
* 4 Wire SPI Transport for SSD1327 OLED display devices
*/
Expand Down Expand Up @@ -103,56 +102,58 @@ class SSD1327Driver
color_ = 0x0f;
transport_.Init(config.transport_config);

transport_.SendCommand(0x15); // set column address
transport_.SendCommand(0x00); // start column 0
transport_.SendCommand(0x3f); // end column 63*2 (two pixels / byte)
transport_.SendCommand(0x15); // set column address
transport_.SendCommand(0x00); // start column 0
transport_.SendCommand(0x3f); // end column 63*2 (two pixels / byte)

transport_.SendCommand(0x75); // set row address
transport_.SendCommand(0x00); // start row 0
transport_.SendCommand(0x7f); // end row 127
transport_.SendCommand(0x75); // set row address
transport_.SendCommand(0x00); // start row 0
transport_.SendCommand(0x7f); // end row 127

transport_.SendCommand(0x81); // set contrast control
transport_.SendCommand(0x81); // set contrast control
transport_.SendCommand(0x80);

transport_.SendCommand(0xa0); // Set Re-map (0x51)
transport_.SendCommand(0x51); // Column Address Remapping, COM Remapping, Splitting of Odd / Even COM Signals
transport_.SendCommand(0xa0); // Set Re-map (0x51)
transport_.SendCommand(
0x51); // Column Address Remapping, COM Remapping, Splitting of Odd / Even COM Signals

transport_.SendCommand(0xa1); // start line
transport_.SendCommand(0xa1); // start line
transport_.SendCommand(0x00);

transport_.SendCommand(0xa2); // display offset
transport_.SendCommand(0xa2); // display offset
transport_.SendCommand(0x00);

transport_.SendCommand(0xa4); // normal display
transport_.SendCommand(0xa8); // set multiplex ratio
transport_.SendCommand(0xa4); // normal display
transport_.SendCommand(0xa8); // set multiplex ratio
transport_.SendCommand(0x7f);

transport_.SendCommand(0xb1); // set phase length
transport_.SendCommand(0xb1); // set phase length
transport_.SendCommand(0xf1);

transport_.SendCommand(0xb3); // set dclk
transport_.SendCommand(0x00); // 80Hz:0xc1 / 90Hz:0xe1 / 100Hz:0x00 / 110Hz:0x30 / 120Hz:0x50 / 130Hz:0x70
transport_.SendCommand(0xb3); // set dclk
transport_.SendCommand(
0x00); // 80Hz:0xc1 / 90Hz:0xe1 / 100Hz:0x00 / 110Hz:0x30 / 120Hz:0x50 / 130Hz:0x70

transport_.SendCommand(0xab); // Function Selection A
transport_.SendCommand(0xab); // Function Selection A
transport_.SendCommand(0x01);

transport_.SendCommand(0xb6); // set phase length
transport_.SendCommand(0xb6); // set phase length
transport_.SendCommand(0x0f);

transport_.SendCommand(0xbe); // Set VCOMH
transport_.SendCommand(0xbe); // Set VCOMH
transport_.SendCommand(0x0f);

transport_.SendCommand(0xbc); // Set Pre-charge voltage
transport_.SendCommand(0xbc); // Set Pre-charge voltage
transport_.SendCommand(0x08);

transport_.SendCommand(0xd5); // Function Selection B
transport_.SendCommand(0x62); // Enable second pre-charge
transport_.SendCommand(0xd5); // Function Selection B
transport_.SendCommand(0x62); // Enable second pre-charge

transport_.SendCommand(0xfd); // unlock command
transport_.SendCommand(0xfd); // unlock command
transport_.SendCommand(0x12);

System::Delay(200); // wait 200ms
transport_.SendCommand(0xaf); // turn on display
System::Delay(200); // wait 200ms
transport_.SendCommand(0xaf); // turn on display
Fill(false);
};

Expand All @@ -161,30 +162,38 @@ class SSD1327Driver

void DrawPixel(uint_fast8_t x, uint_fast8_t y, bool on)
{
uint8_t pixel;
uint32_t line = width/2;
uint8_t pixel;
uint32_t line = width / 2;

if ((x >= width) || (y >= height))
if((x >= width) || (y >= height))
return;

if (on) {
pixel = buffer_[y * line + (x / 2)];
if (x % 2) {
pixel &= 0xf0;
pixel |= color_;
} else {
pixel &= 0x0f;
pixel |= color_ << 4;
}
if(on)
{
pixel = buffer_[y * line + (x / 2)];
if(x % 2)
{
pixel &= 0xf0;
pixel |= color_;
}
else
{
pixel &= 0x0f;
pixel |= color_ << 4;
}
buffer_[y * line + (x / 2)] = pixel;
}
else {
pixel = buffer_[y * line + (x / 2)];
if (x % 2) {
pixel &= 0xf0;
} else {
pixel &= 0x0f;
}
else
{
pixel = buffer_[y * line + (x / 2)];
if(x % 2)
{
pixel &= 0xf0;
}
else
{
pixel &= 0x0f;
}
buffer_[y * line + (x / 2)] = pixel;
}
};
Expand All @@ -198,36 +207,34 @@ class SSD1327Driver
};

/**
* Update the display
* Update the display
*/
void Update()
{
transport_.SendCommand(0x15); // column
transport_.SendCommand(0x15); // column
transport_.SendCommand(0x00);
transport_.SendCommand((width/2)-1);
transport_.SendCommand((width / 2) - 1);

transport_.SendCommand(0x75); // row
transport_.SendCommand(0x75); // row
transport_.SendCommand(0x00);
transport_.SendCommand(height-1);
transport_.SendCommand(height - 1);

//write data
transport_.SendData(buffer_, 8192);
};

void Set_Color(uint8_t in_col)
{
color_ = in_col & 0x0f;
};
void Set_Color(uint8_t in_col) { color_ = in_col & 0x0f; };

protected:
Transport transport_;
uint8_t buffer_[width/2 * height];
uint8_t buffer_[width / 2 * height];
uint8_t color_;
};

/**
* A driver for the SSD1327 128x128 OLED displays connected via 4 wire SPI
*/
using SSD13274WireSpi128x128Driver = daisy::SSD1327Driver<128, 128, SSD13274WireSpiTransport>;
using SSD13274WireSpi128x128Driver
= daisy::SSD1327Driver<128, 128, SSD13274WireSpiTransport>;

}; // namespace daisy
Loading
Loading