Go Down

Topic: Rotary Encoder, Button, and LCD User interface with Menu (Read 10014 times) previous topic - next topic

Do you by any chance have an example that uses the LiquidCrystal.h library and an LCD without a shift register?
Changes

Defines.h
Code: [Select]
#define NUM_LCD_ROWS 4
#define NUM_LCD_COLS 20


REBLDisplay.h
Code: [Select]
#include "REBLDisplay.h"

#ifdef USING_SERIAL
extern HardwareSerial Serial;
#endif

LiquidCrystal *LCD;

uint8_t redPin;
uint8_t greenPin;
uint8_t bluePin;


char lineBuffer[NUM_LCD_ROWS][NUM_LCD_COLS + 1]; // Leave an extra space for terminating null

color_vars current_color;

boolean cursorActive = false;
uint8_t cursorRow;
uint8_t cursorCol;

void initLCD(uint8_t aRsPin, uint8_t aEnablePin, uint8_t aD1, uint8_t aD2, uint8_t aD3, uint8_t aD4) {

#ifdef USING_SERIAL
   Serial.begin(19200);
#else
   LCD = new LiquidCrystal(aRsPin, aEnablePin, aD1, aD2, aD3, aD4);
   LCD->begin(NUM_LCD_COLS, NUM_LCD_ROWS);
   LCD->noCursor();
   LCD->clear();

#endif
}

REBL_UI_Example

Code: [Select]
#include <LiquidCrystal>
Code: [Select]
#define ENCODER_INTERRUPT_PIN 2 // MUST keep pin 2.
#define ENCODER_B_PIN A0
#define BUTTON_PIN A1
#define LCD_ENABLE_PIN 13
#define LCD_RS_PIN 12
#define HEART_BEAT_PIN A15
//#define LCD_BLUE A0
//#define LCD_GREEN A2
//#define LCD_RED A4
#define LCD_D1 5    // New ↓
#define LCD_D2 4
#define LCD_D3 3
#define LCD_D4 7
const int contrast = 20;    // min. PWM value

void setup() [Replace everything in the curly braces.]
Code: [Select]
initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4); // New
  initInterface(BUTTON_PIN, ENCODER_INTERRUPT_PIN, ENCODER_B_PIN);
  reblMenu.setCurrentMenu(&menuList);
  pinMode(8,HIGH);  // LCD pin 15: backlight (anode)
//  pinMode(11,OUTPUT);
//  analogWrite(11,700);
  analogWrite(6,contrast); // PWM~ pins: 3,5,(6),9,10,11. LCD pin 3: Vo (supply for LCD driver)
// Turn on LCD Backlight:
//    lcd.setLED1Pin(1);


Or you can try out the above from this link: github.com/adamaero/REBL_UI

It finally works. The schematic is for the Mega 2560. But it only shows up on half of the LCD (2x16 instead of 4x20). So I think something in "REBLDisplay.cpp" around line 85ish and down would be the change...

Davey_Rance

#16
Sep 24, 2018, 01:28 pm Last Edit: Sep 24, 2018, 01:37 pm by Davey_Rance
Good morning all i hope that someone can assist me.

I have been trying to get this to compile and work on an adafruit M0 Express board and there were 3 errors. I believe that i have them all resolved but hope this helps someone else.

Steps i did to create the error was clone the repository from https://github.com/adamaero/REBL_UI, Set my board to be adafruit M0 Express and click on verify.

Error 1:
C:\Users\Davey\Documents\Arduino\libraries\REBL_UI\REBLInterface.cpp:28:7: error: cannot convert 'volatile uint32_t* {aka volatile long unsigned int*}' to 'volatile byte* {aka volatile unsigned char*}' in assignment

  bReg = portInputRegister(digitalPinToPort(aBPin));

Fix:
Update line 28 to be:  bReg =  (unsigned char*) portInputRegister(digitalPinToPort(aBPin));

Error 2:
REBLInterface.cpp:61:7: error: 'cli' was not declared in this scope
Fix:
replace cli(); with noInterrupts(); on line 61

Error 3:
REBLInterface.cpp:64:7: error: 'sei' was not declared in this scope
Fix:
replace sei(); with interrupts(); on line 64

Thanks and have a great day.

Delta_G

The code here wasn't written for that board.  I don't have one of those M0.  So you're going to have to use this as an example to write code for that board.  Or find some other code that does go with that board.  This was all written for AVR Arduino like UNO and Mega. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

tdot79

Hi guys I know this is an older thread but has anyone been able to get this UI to work with an I2C LCD?

I'm a noob and can't seem to figure out what to change.  

My LCD works using the hd44780.h base class by Bill Perry along with the hd44780ioClass/hd44780_I2Cexp.h for the I2C expander on the LCD.

I appreciate any help you can give me.

Go Up