/*
Simple "Hello World" for SSD1306 OLED
*/
#include "SPI.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "Fonts/FreeMono9pt7b.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int BTN0 = 2;
int BTN1 = 3;
int invDisp = 0;
void drawHorizontalLine(int x, int y, int w, uint16_t color)
{
for(int pixX = x; pixX < x+w; pixX++)
{
display.drawPixel(pixX, y, color);
}
}
void drawVerticalLine(int x, int y, int h, uint16_t color)
{
for(int pixY = y; pixY < y+h; pixY++)
{
display.drawPixel(x, pixY, color);
}
}
void drawRect(int x, int y, int w, int h, uint16_t color)
{
for(int i = x; i < x+w; i++)
{
display.drawPixel(i, y, color);
display.drawPixel(i, y + h - 1, color);
}
for(int i = y; i < y+h; i++)
{
display.drawPixel(x, i, color);
display.drawPixel(x + w - 1, i, color);
}
}
void fillRect(int x, int y, int w, int h, uint16_t color)
{
for(int col = x; col < x+w; col++)
{
for(int row = y; row < y+h-1; row++)
{
display.drawPixel(col, row+1, color);
}
}
}
void drawPedal(int x, int y)
{
//box
fillRect(x, y, 11, 15, WHITE);
//jacks
fillRect(x-1, y+3, 1, 5, WHITE);
fillRect(x+11, y+3, 1, 5, WHITE);
//btns
display.drawPixel(x+1, y+2, BLACK);
display.drawPixel(x+5, y+2, BLACK);
display.drawPixel(x+9, y+2, BLACK);
//switch
drawVerticalLine(x+5, y+9, 3, BLACK);
drawHorizontalLine(x+4, y+10, 3, BLACK);
}
void drawLogo()
{
drawPedal(20, 10);
drawPedal(58, 20);
// FootController
fillRect(20, 44, 88, 20, WHITE);
fillRect(30, 42, 5, 2, WHITE);
fillRect(38, 42, 5, 2, WHITE);
fillRect(57, 42, 5, 2, WHITE);
fillRect(65, 42, 5, 2, WHITE);
fillRect(90, 42, 5, 2, WHITE);
fillRect(98, 42, 5, 2, WHITE);
drawVerticalLine(63, 0, 64, WHITE);
}
void drawMenu()
{
drawHorizontalLine(0, 10, SCREEN_WIDTH, WHITE);
drawHorizontalLine(0, 53, SCREEN_WIDTH, WHITE);
drawVerticalLine(42, 0, 10, WHITE);
drawVerticalLine(87, 0, 10, WHITE);
drawVerticalLine(64, 54, 10, WHITE);
}
void setup()
{
pinMode(BTN1, INPUT_PULLUP);
Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
display.clearDisplay(); // so the adafruit welcome is cleared
display.invertDisplay(true);
drawLogo();
display.display();
delay(2000);
display.invertDisplay(false);
delay(2000);
//display.clearDisplay();
//drawMenu();
//display.display();
//delay(500);
/*
display.clearDisplay();
drawRect(18, 40, 54, 24, WHITE);
fillRect(20, 10, 50, 20, WHITE);
fillRect(21, 11, 48, 18, BLACK);
display.display();
delay(500);*/
/*
//display.clearDisplay();
display.setFont(&FreeMono9pt7b); // no text size needed when using a font
display.setTextColor(WHITE);
display.setCursor(10, 30);
display.println("FOOT_C");
display.display();
*/
}
void loop()
{
invDisp = digitalRead(BTN1);
display.invertDisplay(!invDisp);
}