From 78aab2abeb20593a97e482906a249e05b4fab08a Mon Sep 17 00:00:00 2001 From: Stefan Dastig Date: Sat, 6 Jun 2020 19:44:16 +0200 Subject: [PATCH] Encoder Pinout added, Encoder Test Script working --- Software/Pinout.md | 8 ++-- .../sketch_hardware_test.ino | 41 ++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Software/Pinout.md b/Software/Pinout.md index 8f804cd..3081a20 100644 --- a/Software/Pinout.md +++ b/Software/Pinout.md @@ -17,9 +17,9 @@ |---|--- 1|Not Used 2|Not Used -3|Encoder +3|Encoder 1 4|Not Used -5|Encoder +5|Encoder 2 6|Not Used 7|Not Used 8|Stop Button @@ -30,7 +30,7 @@ |Funktion|Pins |---|--- |Display|SPI (MOSI:11, SCLK:13) + Pin 10 as CS -|Encoder| -|Encoder Button| +|Encoder| Encoder 1 > Pin 2, Encoder 2 > Pin 3 +|Encoder Button| Pin 4 |Beeper| |Stop Button| \ No newline at end of file diff --git a/Software/sketch_hardware_test/sketch_hardware_test.ino b/Software/sketch_hardware_test/sketch_hardware_test.ino index bdb1623..1062d26 100644 --- a/Software/sketch_hardware_test/sketch_hardware_test.ino +++ b/Software/sketch_hardware_test/sketch_hardware_test.ino @@ -1,6 +1,7 @@ #include #include +#include #ifdef U8X8_HAVE_HW_SPI #include @@ -11,38 +12,32 @@ U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); +Encoder rotEncoder(2, 3); + void setup(void) { - - /* U8g2 Project: SSD1306 Test Board */ - //pinMode(10, OUTPUT); - //pinMode(9, OUTPUT); - //digitalWrite(10, 0); - //digitalWrite(9, 0); - - /* U8g2 Project: T6963 Test Board */ - //pinMode(18, OUTPUT); - //digitalWrite(18, 1); - - /* U8g2 Project: KS0108 Test Board */ - //pinMode(16, OUTPUT); - //digitalWrite(16, 0); - - /* U8g2 Project: LC7981 Test Board, connect RW to GND */ - //pinMode(17, OUTPUT); - //digitalWrite(17, 0); - - /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ - //pinMode(6, OUTPUT); - //digitalWrite(6, 0); + Serial.begin(9600); + Serial.println("Hardware Test:"); u8g2.begin(); } +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); -} \ No newline at end of file +}