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

ER-CON30HT orientation adjustment #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions include/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define OLED_BUFSIZE (OLED_WIDTH * OLED_HEIGHT / 8)

#define OLED_CONTRAST_DEFAULT (0x7f)
#define OLED_CONTRAST_GOOD (0xcf)
#define OLED_CONTRAST_MAX (0xff)

#define OLED_CHAR_SPACE 1

Expand Down
33 changes: 25 additions & 8 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,22 @@
#define OLED_INVERTDISPLAY 0xA7
#define OLED_DISPLAYOFF 0xAE
#define OLED_DISPLAYON 0xAF
#define OLED_SETDISPLAYOFFSET 0xD3
#define OLED_SETDISPLAYCLOCKDIV 0xD5
#define OLED_SETDISPLAYOFFSET 0xD3
#define OLED_SETCOMPINS 0xDA
#define OLED_SETVCOMDESELECT 0xDB
#define OLED_SETVCOMDESELECT 0xDB
#define OLED_SETDFOSC 0xD5
#define OLED_SETPRECHARGE 0xD9
#define OLED_SETMULTIPLEX 0xA8
#define OLED_SETSTARTLINE 0x40
#define OLED_MEMORYMODE 0x20
#define OLED_CHARGEPUMP 0x8D
#define OLED_SETCOMREMAP 0xC8
#define OLED_SETSEGREMAP 0xA1

// NORM and FLIP/SWAP rotates the display orientation
#define OLED_SETCOMNORM 0xC0
#define OLED_SETCOMFLIP 0xC8
#define OLED_SETSEGNORM 0xA0
#define OLED_SETSEGSWAP 0xA1

#define OLED_SPI_BASE SPI1
#define OLED_DC_PORT GPIOB
Expand Down Expand Up @@ -129,10 +134,22 @@ void oledSetContrast(uint8_t level) {
void oled_setup() {

static uint8_t initCommands[] = {
OLED_MEMORYMODE, 0x00, // Horizontal Addressing Mode
OLED_CHARGEPUMP, 0x14, // enable charge pump
OLED_SETCONTRAST, OLED_CONTRAST_DEFAULT,
OLED_DISPLAYON };
OLED_DISPLAYOFF,
OLED_SETDISPLAYCLOCKDIV, 0x80,
OLED_SETMULTIPLEX, 0x7F,
OLED_SETDISPLAYOFFSET, 0x00,
OLED_SETSTARTLINE | 0x00,
OLED_CHARGEPUMP, 0x14,
OLED_MEMORYMODE, 0x00,
OLED_SETSEGSWAP,
OLED_SETCOMFLIP,
OLED_SETCOMPINS, 0x12,
OLED_SETCONTRAST, OLED_CONTRAST_GOOD,
OLED_SETPRECHARGE, 0xF1,
OLED_SETVCOMDESELECT, 0x40,
OLED_DISPLAYRESUME,
OLED_NORMALDISPLAY,
OLED_DISPLAYON };

/*
* Function | CS# | D/C# | D0 = SCLK | D1 = SDIN
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ static void showQrAddress(void) {
if (!drawQrCode(uri)) {
oledDrawStringCenter(28, "QR CODE FAILED");
} else {
oledSetContrast(OLED_CONTRAST_QR);
// Seems to not be needed?
//oledSetContrast(OLED_CONTRAST_QR);
}
showLeftButtonLabel("Address");
oledRefresh();
Expand All @@ -110,7 +111,6 @@ static void showAddress(void) {
p = q; // where we stopped
}
showRightButtonLabel("QR");
oledSetContrast(OLED_CONTRAST_DEFAULT); // because we may be coming from the QR code
oledRefresh();
rightButton.pressed = showQrAddress;
leftButton.pressed = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static const struct usb_device_descriptor dev = {
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.bMaxPacketSize0 = USB_MPS,
.idVendor = 0xF055,
.idVendor = 0x1209,
.idProduct = 0xC0DA,
.bcdDevice = 0x0200,
.iManufacturer = USB_STRING_MANUFACTURER,
Expand Down