ReflowController/Software/sketch_hardware_test/sketch_hardware_test.ino

56 lines
1003 B
C++

#include <Arduino.h>
#include <U8g2lib.h>
#include <Encoder.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
Encoder rotEncoder(2, 3);
const int buzzer = 5;
void setup(void) {
Serial.begin(9600);
Serial.println("Hardware Test:");
pinMode(buzzer, OUTPUT);
u8g2.begin();
Serial.println("Buzzer Test");
tone(buzzer, 1000, 5000);
Serial.println("Buzzer Test");
delay(1000);
Serial.println("Buzzer Test 2");
delay(1000);
Serial.println("Buzzer Test 3");
}
long EncPos = 0;
void loop(void) {
long newEncPos;
newEncPos = rotEncoder.read();
if (newEncPos != EncPos) {
Serial.print("Encoder position = ");
Serial.print(newEncPos);
Serial.println();
EncPos = newEncPos;
}
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,24,"Hello World!");
} while ( u8g2.nextPage() );
//delay(1000);
}