72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
|
|
#include <Arduino.h>
|
|
#include <U8g2lib.h>
|
|
#include <Encoder.h>
|
|
//#include "Adafruit_MAX31855.h"
|
|
#include "max6675.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(rotation, cs [, reset]) [page buffer, size = 128 bytes]
|
|
//U8G2_ST7920_128X64_2_HW_SPI(rotation, cs [, reset]) [page buffer, size = 256 bytes]
|
|
//U8G2_ST7920_128X64_F_HW_SPI(rotation, cs [, reset]) [full framebuffer, size = 1024 bytes]
|
|
U8G2_ST7920_128X64_2_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
|
|
|
|
Encoder rotEncoder(2, 3);
|
|
|
|
const int buzzer = 5;
|
|
|
|
#define MAXDO 7
|
|
#define MAXCS 8
|
|
#define MAXCLK 9
|
|
|
|
MAX6675 thermocouple(MAXCLK, MAXCS, MAXDO);
|
|
|
|
void setup(void) {
|
|
Serial.begin(9600);
|
|
Serial.println("Hardware Test:");
|
|
|
|
pinMode(buzzer, OUTPUT);
|
|
|
|
u8g2.begin();
|
|
|
|
Serial.println("Buzzer Test");
|
|
tone(buzzer, 8000, 500);
|
|
|
|
Serial.print("C = ");
|
|
Serial.println(thermocouple.readCelsius());
|
|
Serial.print("F = ");
|
|
Serial.println(thermocouple.readFahrenheit());
|
|
}
|
|
|
|
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.drawLine(0,15,128,15);
|
|
u8g2.drawLine(64,16,64,48);
|
|
u8g2.drawLine(0,49,128,49);
|
|
u8g2.setFont(u8g2_font_ncenB10_tr);
|
|
u8g2.drawStr(0,11,"Ready to flow!");
|
|
u8g2.setFont(u8g2_font_ncenB18_tr);
|
|
u8g2.drawStr(0,47,"122°C");
|
|
} while ( u8g2.nextPage() );
|
|
//delay(1000);
|
|
}
|