#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Include manually added font file
#include "FreeSerifBold12pt7b.h"
#include "Picopixel.h"
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1 // No reset pin used
#define OLED_I2C_ADDRESS 0x3C // I2C address of the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
static const unsigned char PROGMEM image_Voltage_bits[] = {0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xc0,0x01,0x80,0x03,0x80,0x07,0x00,0x0f,0xe0,0x01,0xc0,0x03,0x80,0x03,0x00,0x06,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const byte modeSwitch = 10;
void setup() {
Serial.begin(9600);
// Initialize the display with the correct I2C address
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_I2C_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Halt if initialization fails
}
pinMode(modeSwitch, INPUT_PULLUP);
// Clear and display initial content
display.clearDisplay();
display.display();
// Show logo
showLogo();
delay(1800);
// Clear display after logo
display.clearDisplay();
delay(800);
// Show Track
showTrack();
}
void loop() {
// Nothing to do here for this test
MainModeFunc();
enableTrackSeq();
}
// Switching to track seq mode : START
static const unsigned char PROGMEM trackSeqBitmap[] = {0x66,0x66,0x66,0x64,0x00,0x00,0x00,0x00,0x01,0x99,0x99,0x90,0xee,0xee,0xee,0xee,0x00,0x00,0x00,0x00,0x03,0xbb,0xbb,0xb8,0x4c,0xcc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x01,0x33,0x33,0x30};
void enableTrackSeq(){
if(inTrackMode == true && digitalRead(SW8) == LOW){
enableTrackSeqBtnRead();
}
}
void enableTrackSeqBtnRead(){
if(modeSwitch clicked function){
TrackSeqMODE();
}
}
void TrackSeqMODE()
{
onTrackSeq = true;
onSum1 = false;
onSum2 = false;
onSum3 = false;
onSum4 = false;
showTrackSeq();
}
void showTrackSeq(){
display.setTextWrap(false);
display.setTextColor(1);
display.setFont(&FreeSansBoldOblique12pt7b);
display.setCursor(5, 26);
display.print("Track Seq");
display.drawBitmap(25, 9, trackSeqBitmap, 93, 3, SSD1306_WHITE);
display.display();
}
// Switching to track seq mode : END
void MainModeFunc() {
// if button not pressed or switch in position 1
if(digitalRead(modeSwitch) == HIGH)
{
trackMODE();
}
// if button pressed or switch in position 2
else
{
playlistMODE();
}
}
void trackMODE()
{
showTrack();
}
void playlistMODE()
{
showPlaylist();
}
void vyuvu()
{
showTrack();
}
void showLogo() {
display.setTextWrap(false);
display.setTextColor(1);
display.setFont(&FreeSerifBold12pt7b);
display.setCursor(29, 17);
display.print("EZ.FL");
display.fillRect(40, 21, 48, 9, 1);
display.setTextColor(0);
display.setFont(&Picopixel);
display.setCursor(42, 27);
display.print("High Engineer");
display.drawBitmap(57, 0, image_Voltage_bits, 16, 16, SSD1306_WHITE);
display.display();
}
void showTrack() {
display.setTextWrap(false);
display.setTextColor(1);
display.setFont(&FreeSerifBold12pt7b);
display.setCursor(22, 23);
display.print("TRACK");
display.display();
}
void showPlaylist() {
display.setTextWrap(false);
display.setFont(&FreeSerifBold12pt7b);
display.setCursor(4, 23);
display.print("PLAYLIST");
display.display();
}
void showPianoRoll() {
display.setTextWrap(false);
display.setTextColor(1);
display.setFont(&FreeSerifBold12pt7b);
display.setCursor(22, 23);
display.print("TRACK");
display.display();
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1