#include <Tiny4kOLED.h>
#define Vert_PIN A0
#define Horz_PIN A1
void splash() {
oled.clear();
oled.setCursor(15, 1);
oled.print(F("ATtiny85+SSD1306"));
oled.setCursor(30, 3);
oled.print(F("Thumbstick"));
oled.setCursor(20, 7);
oled.print(F("Christian Scott"));
}
void prepareDisplay() {
oled.clear();
oled.begin();
oled.setCursor(2, 2);
oled.print(F("Horizontal | Vertical"));
oled.setCursor(25, 4);
oled.print(F("0"));
oled.setCursor(95, 4);
oled.print(F("0"));
}
void setup() {
pinMode(Vert_PIN, INPUT);
pinMode(Horz_PIN, INPUT);
map(analogRead(Horz_PIN), 512, 1023, -100, 100);
map(analogRead(Vert_PIN), 512, 1023, -100, 100);
oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br);
// Two fonts are supplied with this library, FONT8X16 and FONT6X8
oled.setFont(FONT6X8);
// To clear all the memory
oled.clear();
oled.on();
splash();
delay(3000);
prepareDisplay();
}
int xpos[2] = {64, 32};
void loop() {
// put your main code here, to run repeatedly:
int horz_val = map(analogRead(Horz_PIN), 0, 1023, -100, 100);
int vert_val = map(analogRead(Vert_PIN), 0, 1023, -100, 100);
map(horz_val, 512, 1023, -100, 100);
map(vert_val, 512, 1023, -100, 100);
oled.setCursor(25, 4);
oled.print(horz_val);
oled.print(" ");
oled.setCursor(95, 4);
oled.print(vert_val);
oled.print(" ");
delay(100);
}