#include <TinyWireM.h>
#include <Tiny4kOLED.h>
void splash() {
oled.clear();
oled.setCursor(15, 1);
oled.print(F("ALG & DIGI input"));
oled.setCursor(22, 3);
oled.print(F("For USP Lasers"));
oled.setCursor(15, 7);
oled.print(F("IPG-J M.Nakajima"));
}
void prepareDisplay() {
// unsigned int i, k;
// unsigned char ch[5];
// oled.clear();
// oled.begin();
// oled.setCursor(20, 1);
// oled.print(F("ATtiny85+SSD1306"));
// oled.setCursor(3, 2);
// oled.print(F("temperature|humidity"));
// oled.bitmap(105, 4, 110, 7, img_thermometer);
// oled.setCursor(57, 4);
// oled.print(F("24.0C"));
// oled.setCursor(57, 5);
// oled.print(F("40.0%"));
// oled.bitmap(10, 5, 17, 2, img_heart_small);
}
void setup() {
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);
oled.clear();
// oled.setFont(FONT8X16);
oled.on();
}
void loop() {
int a = analogRead(A3);
int d = analogRead(A2);
oled.setCursor(10, 0);
oled.print(F("Analog input:"));
oled.setCursor(10, 2);
float v1 = a / 1023.0 * 10.0;
oled.print(v1);
oled.setCursor(40, 2);
oled.print(F("V"));
oled.setCursor(10, 4);
oled.print(F("Digital input:"));
oled.setCursor(10, 6);
float v2 = d / 1023.0 * 5.0;
int duty = int(a / 1023.0 * 255.0);
if (duty < 25) {
duty = 1;
}
oled.print(v2);
oled.setCursor(40, 6);
oled.print(F("V"));
oled.setCursor(50, 6);
oled.print(F("->"));
oled.setCursor(70, 6);
oled.print(float(duty) / 255.0 * 100.0);
oled.setCursor(100, 6);
oled.print(F("%"));
analogWrite(1, duty);
}