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

Proof of concept for configurable OLED display support (#166) #326

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/daisy_field.cpp
Expand Up @@ -125,10 +125,14 @@ void DaisyField::Init(bool boost)
keyboard_sr_.Init(keyboard_cfg);

// OLED
dsy_gpio_pin oled_pins[OledDisplay::NUM_PINS];
oled_pins[OledDisplay::DATA_COMMAND] = seed.GetPin(PIN_OLED_CMD);
oled_pins[OledDisplay::RESET] = {DSY_GPIOX, 0}; // Not a real pin...
display.Init(oled_pins);
OledDisplay<SSD130x4WireSpi128x64Driver>::Config display_config;

display_config.driver_config.transport_config.pin_config.dc
= seed.GetPin(PIN_OLED_CMD);
display_config.driver_config.transport_config.pin_config.reset
= {DSY_GPIOX, 0}; // Not a real pin...

display.Init(display_config);

// LEDs
// 2x PCA9685 addresses 0x00, and 0x02
Expand Down Expand Up @@ -354,9 +358,9 @@ void DaisyField::VegasMode()
led_driver.SetLed(led_grp_b[idx], 1.0f - key_bright);
led_driver.SetLed(led_grp_c[idx], key_bright);
// OLED moves a bar across the screen
uint32_t bar_x = (now >> 4) % SSD1309_WIDTH;
uint32_t bar_x = (now >> 4) % display.Width();
display.Fill(false);
for(size_t i = 0; i < SSD1309_HEIGHT; i++)
for(size_t i = 0; i < display.Height(); i++)
{
display.DrawPixel(bar_x, i, true);
}
Expand Down
17 changes: 9 additions & 8 deletions src/daisy_field.h
Expand Up @@ -2,6 +2,7 @@
#ifndef DSY_FIELD_BSP_H
#define DSY_FIELD_BSP_H /**< & */
#include "daisy_seed.h"
#include "dev/oled_ssd130x.h"

/**
@brief Hardware defines and helpers for daisy field platform.
Expand Down Expand Up @@ -209,14 +210,14 @@ class DaisyField
**/
void VegasMode();

DaisySeed seed;
OledDisplay display;
dsy_gpio gate_out;
GateIn gate_in;
LedDriverPca9685<2, true> led_driver;
Switch sw[SW_LAST];
AnalogControl knob[KNOB_LAST];
AnalogControl cv[CV_LAST];
DaisySeed seed;
OledDisplay<SSD130x4WireSpi128x64Driver> display;
dsy_gpio gate_out;
GateIn gate_in;
LedDriverPca9685<2, true> led_driver;
Switch sw[SW_LAST];
AnalogControl knob[KNOB_LAST];
AnalogControl cv[CV_LAST];

private:
ShiftRegister4021<2> keyboard_sr_; /**< Two 4021s daisy-chained. */
Expand Down
16 changes: 10 additions & 6 deletions src/daisy_patch.cpp
Expand Up @@ -144,9 +144,9 @@ void DaisyPatch::DisplayControls(bool invert)
float v;
size_t dest;
curx = (barspacing * i + 1) + (barwidth * i);
cury = SSD1309_HEIGHT;
cury = display.Height();
v = GetKnobValue(static_cast<DaisyPatch::Ctrl>(i));
dest = (v * SSD1309_HEIGHT);
dest = (v * display.Height());
for(size_t j = dest; j > 0; j--)
{
for(size_t k = 0; k < barwidth; k++)
Expand Down Expand Up @@ -233,10 +233,14 @@ void DaisyPatch::InitControls()

void DaisyPatch::InitDisplay()
{
dsy_gpio_pin pincfg[OledDisplay::NUM_PINS];
pincfg[OledDisplay::DATA_COMMAND] = seed.GetPin(PIN_OLED_DC);
pincfg[OledDisplay::RESET] = seed.GetPin(PIN_OLED_RESET);
display.Init(pincfg);
OledDisplay<SSD130x4WireSpi128x64Driver>::Config display_config;

display_config.driver_config.transport_config.pin_config.dc
= seed.GetPin(PIN_OLED_DC);
display_config.driver_config.transport_config.pin_config.reset
= seed.GetPin(PIN_OLED_RESET);

display.Init(display_config);
}

void DaisyPatch::InitMidi()
Expand Down
13 changes: 7 additions & 6 deletions src/daisy_patch.h
Expand Up @@ -2,6 +2,7 @@
#ifndef DSY_PATCH_BSP_H
#define DSY_PATCH_BSP_H
#include "daisy_seed.h"
#include "dev/oled_ssd130x.h"

namespace daisy
{
Expand Down Expand Up @@ -113,12 +114,12 @@ class DaisyPatch
/* These are exposed for the user to access and manipulate directly
Helper functions above provide easier access to much of what they are capable of.
*/
DaisySeed seed; /**< Seed object */
Encoder encoder; /**< Encoder object */
AnalogControl controls[CTRL_LAST]; /**< Array of controls*/
GateIn gate_input[GATE_IN_LAST]; /**< Gate inputs */
MidiHandler midi; /**< Handles midi*/
OledDisplay display; /**< & */
DaisySeed seed; /**< Seed object */
Encoder encoder; /**< Encoder object */
AnalogControl controls[CTRL_LAST]; /**< Array of controls*/
GateIn gate_input[GATE_IN_LAST]; /**< Gate inputs */
MidiHandler midi; /**< Handles midi*/
OledDisplay<SSD130x4WireSpi128x64Driver> display; /**< & */

// TODO: Add class for Gate output
dsy_gpio gate_output; /**< & */
Expand Down