RepRapDiscount Full Graphic control with LiquidCrystal library March 06, 2021 05:45AM |
Registered: 3 years ago Posts: 6 |
#include LiquidCrystal.h //LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5, LCD_PINS_D6, LCD_PINS_D7); LiquidCrystal lcd(16, 23, 17, 25, 27, 29);
void setup() { lcd.begin(LCD_WIDTH, LCD_HEIGHT); Serial.begin(9600); lcd.clear(); lcd.print("Hello"); // lcd.setCursor(4, 1); lcd.print("Initializing"); delay(5000); //WAIT FOR STABILLIZATION pinMode(BEEPER,OUTPUT); digitalWrite(BEEPER,HIGH); delay(100); digitalWrite(BEEPER,LOW); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 06, 2021 08:00AM |
Admin Registered: 13 years ago Posts: 6,995 |
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 07, 2021 06:33AM |
Registered: 3 years ago Posts: 6 |
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 08, 2021 05:31AM |
Registered: 3 years ago Posts: 6 |
Quote
Dust
see [github.com] for an example arduino sketch using RAMPS and REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
// SPI Com: SCK = en = 23, MOSI = rw = 17, CS = di = 16 U8GLIB_ST7920_128X64_1X u8g(23, 17, 16);
U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 16, /* reset=*/ 17); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 08, 2021 06:08AM |
Admin Registered: 13 years ago Posts: 6,995 |
void loop() { // Read the encoder and update encoderPos encoder0PinNow = digitalRead(BTN_EN1); if ((encoder0PinALast == LOW) && (encoder0PinNow == HIGH)) { if (digitalRead(BTN_EN2) == LOW) { encoderPos++; } else { encoderPos--; } } encoder0PinALast = encoder0PinNow;
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 08, 2021 06:28AM |
Admin Registered: 13 years ago Posts: 6,995 |
Re: RepRapDiscount Full Graphic control with LiquidCrystal library March 08, 2021 08:51AM |
Registered: 3 years ago Posts: 6 |
Quote
Dust
That example uses a rotary encoder.
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
BTN_EN1 is left rotation,
BTN_EN2 is right rotation
BTN_ENC is pressing encoder in.
the code enve says this
void loop() { // Read the encoder and update encoderPos encoder0PinNow = digitalRead(BTN_EN1); if ((encoder0PinALast == LOW) && (encoder0PinNow == HIGH)) { if (digitalRead(BTN_EN2) == LOW) { encoderPos++; } else { encoderPos--; } } encoder0PinALast = encoder0PinNow;
#include #include #include // SPI Com: SCK = en = 23, MOSI = rw = 17, CS = di = 16 U8GLIB_ST7920_128X64_1X u8g(23, 17, 16); #define BTN_EN1 31 // Left Rotation #define BTN_EN2 33 // Right Rotation #define BTN_ENC 35 // Pressing Encoder In. //int selectionButton = 31, selectionButtonState, selectionButtonLastState = 0, cntSelectionButtonPressed = 1, cntSelectionButtonPressed2ForMenu2 = 0; //A1 //int menuButton = 33 , menuButtonState, menuButtonLastState = 0; // A0 //int scrollDownButton = 35 , scrollDownButtonState, scrollDownButtonLastState = 0; //A3 //boolean mainMenu = false; int LastscrollRight = 0; int LastscrollLeft = 0; int caseNum = 1; boolean LastpushButton = false; int scrollRight = 0; int scrollLeft = 0; int pushButton = 0; int encoderPos = 1; //Current encoder position int encoder0PinALast; //Used to decode rotory encoder, last value int encoder0PinNow; //Used to decode rotory encoder, current value char posStr[4]; //Char array to store encoderPos as a string char tmp_string[16]; void setup() { pinMode(BTN_EN1, INPUT); // Set BTN_EN1 as an unput, half of the encoder digitalWrite(BTN_EN1, HIGH); // turn on pullup resistors pinMode(BTN_EN2, INPUT); // Set BTN_EN2 as an unput, second half of the encoder digitalWrite(BTN_EN2, HIGH); // turn on pullup resistors pinMode(BTN_ENC, INPUT); // Set BTN_ENC as an unput, encoder button digitalWrite(BTN_ENC, HIGH); // turn on pullup resistors u8g.setFont(u8g_font_helvR08); //Set the font for the display u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. } void loop() { Serial.begin(9600); scrollRight = digitalRead(BTN_EN2); scrollLeft = digitalRead(BTN_EN1); pushButton = digitalRead(BTN_ENC); // Read the encoder and update encoderPos encoder0PinNow = digitalRead(BTN_EN2); if ((encoder0PinALast == HIGH) && (encoder0PinNow == LOW)) { if (digitalRead(BTN_EN2) == LOW) { encoderPos++; } else { encoderPos--; } if (encoderPos > 3 or encoderPos < 0){ encoderPos = 1; } } encoder0PinALast = encoder0PinNow; // Serial.println(scrollRight); Serial.println(encoderPos); // Serial.println(pushButton); u8g.firstPage(); do{ MainMenu(); }while(u8g.nextPage()); } void MainMenu(){ switch(encoderPos) { case 1: u8g.setFont(u8g_font_6x13); u8g.setPrintPos(15,15); u8g.print("> A"); u8g.setPrintPos(15,25); u8g.print(" B"); u8g.setPrintPos(15,35); u8g.print(" C"); break; case 2: u8g.setFont(u8g_font_6x13); u8g.setPrintPos(15,15); u8g.print(" A"); u8g.setPrintPos(15,25); u8g.print("> B"); u8g.setPrintPos(15,35); u8g.print(" C"); break; break; case 3: u8g.setFont(u8g_font_6x13); u8g.setPrintPos(15,15); u8g.print(" A"); u8g.setPrintPos(15,25); u8g.print(" B"); u8g.setPrintPos(15,35); u8g.print("> C"); break; } }