Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmamma committed Feb 28, 2023
2 parents 23cb76b + aaf6daf commit 64a93b1
Show file tree
Hide file tree
Showing 177 changed files with 19,090 additions and 8,310 deletions.
27 changes: 27 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
MCL 4.40 25/02/2023

Please install Machinedrum OS X.08 & Monomachine OS X.01 before using MCL 4.40.
Perform the USB DFU firmware procedure to upgrade the USB microcontroller for class compliant USB MIDI.

- Improvements:

Increased GUI responsiveness and framerate.
Grid page rendering speed increased from 14FPS -> 21FPS

Increased SDCard read speed:
SdCard slot read performance increased by 30%

Automated Slot Loading, and Queueing has been overhauled for
robust, predictable behaviour.

- Fixes

Grid Page: Allow length adustment across multiple slots when slot speeds are the
same.

Program Change Advanced mode did not work over USB MIDI

Copy/Paste pattern will now copy/paste MD Master FX.

Bugs related to parameter locks when pasting MD Tracks.

MCL 4.30 12/01/2023

Please install Machinedrum OS X.08 & Monomachine OS X.01 before using MCL 4.30.
Expand Down
131 changes: 17 additions & 114 deletions avr/cores/megacommand/Adafruit_SSD1305_Library/Adafruit_SSD1305.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SPISettings oledspi = SPISettings(16000000, MSBFIRST, SPI_MODE0);
#define _BV(bit) (1 << (bit))
#endif

#include "MCLSd.h"
// a 5x7 font table
extern const uint8_t PROGMEM font[];

Expand Down Expand Up @@ -222,33 +223,13 @@ void Adafruit_SSD1305::fillScreen(uint8_t color) {
}
}

void Adafruit_SSD1305::begin(uint8_t i2caddr) {
_i2caddr = i2caddr;

// set pin directions
if (sclk != -1) {
pinMode(sid, OUTPUT);
pinMode(sclk, OUTPUT);
#ifdef __AVR__
clkport = portOutputRegister(digitalPinToPort(sclk));
clkpinmask = digitalPinToBitMask(sclk);
mosiport = portOutputRegister(digitalPinToPort(sid));
mosipinmask = digitalPinToBitMask(sid);
#endif
} else if (cs != -1) {
// hardware SPI
void Adafruit_SSD1305::begin() {
SD.m_card->setDedicatedSpi(false);
// set pin directions
// hardware SPI
SPI.begin();
} else {
// I2C
Wire.begin();
}

if (cs != -1) {
pinMode(dc, OUTPUT);
pinMode(cs, OUTPUT);
}

if (rst != -1) {
pinMode(rst, OUTPUT);

digitalWrite(rst, HIGH);
Expand All @@ -260,8 +241,6 @@ void Adafruit_SSD1305::begin(uint8_t i2caddr) {
delay(10);
// bring out of reset
digitalWrite(rst, HIGH);
}

#if defined SSD1305_128_32
// Init sequence for 128x32 OLED module
command(SSD1305_DISPLAYOFF); // 0xAE
Expand Down Expand Up @@ -336,6 +315,7 @@ void Adafruit_SSD1305::begin(uint8_t i2caddr) {
#endif

command(SSD1305_DISPLAYON); //--turn on oled panel
SD.m_card->setDedicatedSpi(true);
}

void Adafruit_SSD1305::invertDisplay(uint8_t i) {
Expand All @@ -348,72 +328,48 @@ void Adafruit_SSD1305::invertDisplay(uint8_t i) {

void Adafruit_SSD1305::command(uint8_t c) {

if (cs != -1) {
// SPI of sorts

digitalWrite(cs, HIGH);
digitalWrite(dc, LOW);
delay(1);
if (sclk == -1) {
#ifdef SPI_HAS_TRANSACTION
SPI.beginTransaction(oledspi);
#else
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(ADAFRUIT_SSD1305_SPI);
#endif
}
digitalWrite(cs, LOW);
spixfer(c);
SPI.transfer(c);
digitalWrite(cs, HIGH);

#ifdef SPI_HAS_TRANSACTION
if (sclk == -1)
SPI.endTransaction(); // release the SPI bus
#endif
} else {
// I2C
uint8_t control = 0x00; // Co = 0, D/C = 0
Wire.beginTransmission(_i2caddr);
Wire.write(control);
Wire.write(c);
Wire.endTransmission();
}
}

uint8_t Adafruit_SSD1305::getBuffer(uint16_t i) { return buffer[i]; }
uint8_t* Adafruit_SSD1305::getBuffer() { return buffer; }

void Adafruit_SSD1305::data(uint8_t c) {
if (cs != -1) {
// SPI of sorts
digitalWrite(cs, HIGH);
digitalWrite(dc, HIGH);

if (sclk == -1) {
#ifdef SPI_HAS_TRANSACTION
SPI.beginTransaction(oledspi);
#else
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(ADAFRUIT_SSD1305_SPI);
#endif
}

digitalWrite(cs, LOW);
spixfer(c);
SPI.transfer(c);
digitalWrite(cs, HIGH);

#ifdef SPI_HAS_TRANSACTION
if (sclk == -1)
SPI.endTransaction(); // release the SPI bus
#endif
} else {
// I2C
uint8_t control = 0x40; // Co = 0, D/C = 1
Wire.beginTransmission(_i2caddr);
Wire.write(control);
Wire.write(c);
Wire.endTransmission();
}
}

void Adafruit_SSD1305::textbox(const char *text, const char *text2, uint16_t delay) {
Expand All @@ -440,7 +396,8 @@ void Adafruit_SSD1305::display(void) {
textbox_enabled = false;
}
}

//For dedicated SPI we do this.
SD.m_card->setDedicatedSpi(false);
#ifdef ENABLE_DIAG_LOGGING
if (diag_page.is_active()) {
diag_page.draw();
Expand All @@ -454,62 +411,33 @@ void Adafruit_SSD1305::display(void) {
screen_saver_active = screen_saver;

uint16_t i = 0;

uint8_t *p = buffer;
for (uint8_t page = 0; page < 4; page++) {
command(SSD1305_SETPAGESTART + page);
command(0x00);
command(0x10);

if (cs == -1) {
// save I2C bitrate
#ifdef __AVR__
uint8_t twbrbackup = TWBR;
TWBR = 12; // upgrade to 400KHz!
#endif

// Serial.println(TWBR, DEC);
// Serial.println(TWSR & 0x3, DEC);

// I2C has max 16 bytes per xmision
// send a bunch of data in one xmission
for (uint8_t w = 0; w < 128 / 16; w++) {
Wire.beginTransmission(_i2caddr);
Wire.write(0x40);
for (uint8_t x = 0; x < 16; x++) {
Wire.write(buffer[i++]);
}
Wire.endTransmission();
}

#ifdef __AVR__
TWBR = twbrbackup;
#endif
} else {
// SPI
if (sclk == -1) {
// SPI
#ifdef SPI_HAS_TRANSACTION
SPI.beginTransaction(oledspi);
#else
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(ADAFRUIT_SSD1305_SPI);
#endif
}

digitalWrite(cs, HIGH);
// digitalWrite(cs, HIGH);
digitalWrite(dc, HIGH);
digitalWrite(cs, LOW);

for (uint8_t x = 0; x < 128; x++) {
spixfer(buffer[i++]);
}
SPI.transfer(p,128);
p += 128;

digitalWrite(cs, HIGH);
#ifdef SPI_HAS_TRANSACTION
if (sclk == -1)
SPI.endTransaction(); // release the SPI bus
#endif
}
}
SD.m_card->setDedicatedSpi(true);
display_lock = false;
}

Expand All @@ -518,29 +446,4 @@ void Adafruit_SSD1305::clearDisplay(void) {
memset(buffer, 0, (SSD1305_LCDWIDTH * SSD1305_LCDHEIGHT / 8));
}

void Adafruit_SSD1305::spixfer(uint8_t x) {
if (sclk == -1) {
SPI.transfer(x);
return;
}
// software spi
// Serial.println("Software SPI");

for (uint8_t bit = 0x80; bit; bit >>= 1) {
#if defined(AVR)
*clkport &= ~clkpinmask;
if (x & bit)
*mosiport |= mosipinmask;
else
*mosiport &= ~mosipinmask;
*clkport |= clkpinmask;
#else
digitalWrite(sclk, LOW);
if (x & bit)
digitalWrite(sid, HIGH);
else
digitalWrite(sid, LOW);
digitalWrite(sclk, HIGH);
#endif
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ class Adafruit_SSD1305 : public Adafruit_GFX {
Adafruit_SSD1305(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST) :sid(SID), sclk(SCLK), dc(DC), rst(RST), cs(-1), Adafruit_GFX(SSD1305_LCDWIDTH, SSD1305_LCDHEIGHT) {}

Adafruit_SSD1305(int8_t DC, int8_t RST, int8_t CS) :sid(-1), sclk(-1), dc(DC), rst(RST), cs(CS), Adafruit_GFX(SSD1305_LCDWIDTH, SSD1305_LCDHEIGHT) {}

Adafruit_SSD1305(int8_t RST) :sid(-1), sclk(-1), dc(-1), rst(RST), cs(-1), Adafruit_GFX(SSD1305_LCDWIDTH, SSD1305_LCDHEIGHT) {}


void begin(uint8_t i2caddr = SSD1305_I2C_ADDRESS);
void begin();

void command(uint8_t c);
void data(uint8_t c);

Expand Down
34 changes: 23 additions & 11 deletions avr/cores/megacommand/GUI/GUI.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "GUI.h"
#include "MidiUart.h"
#include "WProgram.h"
#include "Sketch.h"
#include "Pages.h"
#include "Sketch.h"
#include "WProgram.h"

#define SCREEN_SAVER_TIME 5

Expand All @@ -11,9 +11,7 @@
Sketch _defaultSketch((char *)"DFT");

/************************************************/
GuiClass::GuiClass() {
setSketch(&_defaultSketch);
}
GuiClass::GuiClass() { setSketch(&_defaultSketch); }

void GuiClass::setSketch(Sketch *_sketch) {
if (sketch != NULL) {
Expand Down Expand Up @@ -90,7 +88,6 @@ void GuiClass::loop() {
}
}


MidiUartParent::handle_midi_lock = 1;
for (int i = 0; i < tasks.size; i++) {
if (tasks.arr[i] != NULL) {
Expand Down Expand Up @@ -129,12 +126,14 @@ void GuiClass::loop() {
}
}
MidiUartParent::handle_midi_lock = _midi_lock_tmp;

}

void GuiClass::display_lcd() {
void GuiClass::display_lcd() {}

}
#ifdef DEBUGMODE
uint8_t fps = 0;
uint16_t fps_clock = 0;
#endif

void GuiClass::display() {
PageParent *page = NULL;
Expand All @@ -145,6 +144,19 @@ void GuiClass::display() {
page->redisplay = false;
}
}

#ifdef DEBUGMODE
if (fps == 0 && fps_clock == 0) {
fps_clock = slowclock;
}
fps++;
if (clock_diff(fps_clock, slowclock) > 1000) {
DEBUG_PRINT("FPS: ");
DEBUG_PRINTLN(fps);
fps = 0;
fps_clock = slowclock;
}
#endif
#ifdef UART_USB
#ifndef DEBUGMODE
if (display_mirror) {
Expand All @@ -171,8 +183,8 @@ void GuiClass::display() {
MidiUartUSB.m_putc(buf, sizeof(buf));
n = n + 7;
}
MidiUartUSB.m_putc(0xF7);
MidiUartParent::handle_midi_lock = 0;
MidiUartUSB.m_putc(0xF7);
MidiUartParent::handle_midi_lock = 0;
}
#endif
#endif
Expand Down
6 changes: 3 additions & 3 deletions avr/cores/megacommand/MCL/A4Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ bool A4Track::get_track_from_sysex(uint8_t tracknumber) {
}

void A4Track::load_immediate(uint8_t tracknumber, SeqTrack *seq_track) {
store_in_mem(tracknumber);
load_seq_data(seq_track);
}

bool A4Track::store_in_grid(uint8_t column, uint16_t row, SeqTrack *seq_track, uint8_t merge,
bool online) {
bool online, Grid *grid) {

active = A4_TRACK_TYPE;

Expand All @@ -57,7 +56,8 @@ bool A4Track::store_in_grid(uint8_t column, uint16_t row, SeqTrack *seq_track, u
memcpy(&seq_data, ext_track->data(), sizeof(seq_data));
}
#endif
ret = proj.write_grid((uint8_t *)this, sizeof(A4Track), column, row);
ret = write_grid((uint8_t *)(this), len, column, row, grid);

if (!ret) {
return false;
}
Expand Down
Loading

0 comments on commit 64a93b1

Please sign in to comment.