Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: LiquidMenu library not working with teensy

  1. #1

    LiquidMenu library not working with teensy

    Hi all I'm working on a project that will have a menu using an LCD screen with the LiquidCrystal.h library. I want to use a library called LiquidMenu.h because it looks easier to wrap my brain around then the other menu libraries I looked at. When I try to upload an example code to my teensy 3.6 i get the following errors:
    Code:
    In file included from C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\examples\A_hello_menu\A_hello_menu.ino:43:0:
    
    C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\src/LiquidMenu.h:58:102: note: #pragma message: LiquidMenu: Configured for Parallel. Edit 'LiquidMenu_config.h' file to change it.
    
     #pragma message ("LiquidMenu: Configured for Parallel. Edit 'LiquidMenu_config.h' file to change it.")
    
                                                                                                          ^
    
    In file included from D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Stream.h:24:0,
    
                     from D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/HardwareSerial.h:252,
    
                     from D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:46,
    
                     from C:\Users\cfredisdead\AppData\Local\Temp\arduino_build_300981\pch\Arduino.h:6:
    
    D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:49:14: error: expected identifier before numeric constant
    
     #define BYTE 0
    
                  ^
    
    C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\src/LiquidMenu.h:75:16: note: in expansion of macro 'BYTE'
    
       UINT8_T = 9, BYTE = 9,
    
                    ^
    
    D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:49:14: error: expected '}' before numeric constant
    
     #define BYTE 0
    
                  ^
    
    C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\src/LiquidMenu.h:75:16: note: in expansion of macro 'BYTE'
    
       UINT8_T = 9, BYTE = 9,
    
                    ^
    
    D:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:49:14: error: expected unqualified-id before numeric constant
    
     #define BYTE 0
    
                  ^
    
    C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\src/LiquidMenu.h:75:16: note: in expansion of macro 'BYTE'
    
       UINT8_T = 9, BYTE = 9,
    
                    ^
    
    In file included from C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\examples\A_hello_menu\A_hello_menu.ino:43:0:
    
    C:\Users\cfredisdead\Documents\Arduino\libraries\LiquidMenu-master\src/LiquidMenu.h:86:1: error: expected declaration before '}' token
    
     };
    
     ^
    
    Multiple libraries were found for "LiquidCrystal.h"
     Used: D:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LiquidCrystal
     Not used: D:\Program Files (x86)\Arduino\libraries\LiquidCrystal
    Error compiling for board Teensy 3.6.
    Here's the example sketch im trying to upload to the teensy:

    Code:
    /*
     * LiquidMenu library - hello_menu.ino
     *
     * This is the get started example demonstrating how to create
     * a menu of two screens with dynamically changing information.
     *
     * The first screen shows some static text. The second screen
     * shows the reading of analog pin A1. To display a changing
     * variable on the LCD, simply put the variable in the LiquidLine
     * constructor. In this case the LiquidLine object is "analogReading_ine"
     * and the variable is "analogReading". This line is on the second
     * screen. The value of the analog pin is read every second and if
     * it has changed the display is updated with the new value. The
     * menu cycles through its two screens every five seconds.
     *
     * The circuit:
     * https://github.com/VasilKalchev/LiquidMenu/blob/master/examples/A_hello_menu/hello_menu.png
     * - LCD RS pin to Arduino pin 12
     * - LCD E pin to Arduino pin 11
     * - LCD D4 pin to Arduino pin 5
     * - LCD D5 pin to Arduino pin 4
     * - LCD D6 pin to Arduino pin 3
     * - LCD D7 pin to Arduino pin 2
     * - LCD R/W pin to ground
     * - LCD VSS pin to ground
     * - LCD VCC pin to  5V
     * - 10k ohm potentiometer: ends to 5V and ground, wiper to LCD V0
     * - 150 ohm resistor from 5V to LCD Anode
     * - LCD Cathode to ground
     * - ----
     * - some analog input to Arduino pin A1 (unconnected also works)
     *
     * Created July 24, 2016
     * by Vasil Kalchev
     *
     * https://github.com/VasilKalchev/LiquidMenu
     *
     */
    
    // The LCD library
    #include <LiquidCrystal.h>
    // The menu wrapper library
    #include <LiquidMenu.h>
    
    // Pin mapping for the display:
    const byte LCD_RS = 12;
    const byte LCD_E = 11;
    const byte LCD_D4 = 5;
    const byte LCD_D5 = 4;
    const byte LCD_D6 = 3;
    const byte LCD_D7 = 2;
    //LCD R/W pin to ground
    //10K potentiometer wiper to VO
    LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
    
    /*
     * Variable 'analogReading' is later configured to
     * be printed on the display. 'lastAnalogReading'
     * is used to check if the variable has changed.
     */
    const byte analogPin = A1;
    unsigned short analogReading = 0;
    unsigned short lastAnalogReading = 0;
    
    /*
     * Variables used for periodic execution of code. The first one is the period
     * in milliseconds and the second one is the last time the code executed.
     */
    unsigned int period_check = 1000;
    unsigned long lastMs_check = 0;
    
    unsigned int period_nextScreen = 5000;
    unsigned long lastMs_nextScreen = 0;
    
    /*
     * LiquidLine objects represent a single line of text and/or variables
     * on the display. The first two parameters are the column and row from
     * which the line starts, the rest of the parameters are the text and/or
     * variables that will be printed on the display. They can be up to four.
     */
    // Here the line is set to column 1, row 0 and will print the passed
    // string and the passed variable.
    LiquidLine welcome_line1(1, 0, "LiquidMenu ", LIQUIDMENU_VERSION);
    // Here the column is 3, the row is 1 and the string is "Hello Menu".
    LiquidLine welcome_line2(3, 1, "Hello Menu");
    
    /*
     * LiquidScreen objects represent a single screen. A screen is made of
     * one or more LiquidLine objects. Up to four LiquidLine objects can
     * be inserted from here, but more can be added later in setup() using
     * welcome_screen.add_line(someLine_object);.
     */
    // Here the LiquidLine objects are the two objects from above.
    LiquidScreen welcome_screen(welcome_line1, welcome_line2);
    
    // Here there is not only a text string but also a changing integer variable.
    LiquidLine analogReading_line(0, 0, "Analog: ", analogReading);
    LiquidScreen secondary_screen(analogReading_line);
    
    /*
     * The LiquidMenu object combines the LiquidScreen objects to form the
     * menu. Here it is only instantiated and the screens are added later
     * using menu.add_screen(someScreen_object);. This object is used to
     * control the menu, for example: menu.next_screen(), menu.switch_focus()...
     */
    LiquidMenu menu(lcd);
    
    
    void setup() {
      Serial.begin(250000);
    
      pinMode(analogPin, INPUT);
    
      lcd.begin(16, 2);
    
      // This is the method used to add a screen object to the menu.
      menu.add_screen(welcome_screen);
      menu.add_screen(secondary_screen);
    }
    
    void loop() {
      // Periodic reading of the analog pin.
      if (millis() - lastMs_check > period_check) {
        lastMs_check = millis();
        analogReading = analogRead(analogPin);
        /*
         * Check if the analog value have changed
         * and update the display if it has.
         */
        if (analogReading != lastAnalogReading) {
          lastAnalogReading = analogReading;
          menu.update();
        }
      }
    
      // Periodic switching to the next screen.
      if (millis() - lastMs_nextScreen > period_nextScreen) {
        lastMs_nextScreen = millis();
        menu.next_screen();
      }
    }
    And here's a link to the github library. https://github.com/VaSe7u/LiquidMenu

    Any insights would be greatly appreciated.

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,001
    I experienced a similar conflict with the BYTE define in teensy3/Print.h, see
    https://forum.pjrc.com/threads/28505...l=1#post182121

    Maybe in library src/LiquidMenu.h change BYTE = 9, to XBYTE = 9,
    With that change, your sketch compiles for me, but that change might break something else... or not.
    Last edited by manitou; 08-26-2018 at 12:05 AM.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Hmmm... maybe it's *finally* time to remove BYTE?

    It was widely used as part of Arduino's Print class, before Arduino 1.0.

  4. #4
    Maybe in library src/LiquidMenu.h change BYTE = 9, to XBYTE = 9,
    With that change, your sketch compiles for me, but that change might break something else... or not.
    Thanks for the help manituo. That seems to have done it! I have some code working now, properly updating the screen with some buttons.

    and thanks Paul as always for your awesome audio library and all the work that goes into keeping the teensy up to date and compatible.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,805
    Only "12 matches across 6 files" of 'BYTE' in my Teensy tree - most are just comments or legacy dupes:
    Code:
    Searching 2897 files for "\WBYTE\W" (regex, case sensitive)
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\keywords.txt:
       53  beginRepeating	KEYWORD2
       54  
       55: # removed by Arduino 1.0, but still in Teensyduino
       56: BYTE	LITERAL1
       57  
       58  # Arduino constants
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\cores\teensy\Print.h:
       33  #define BIN 2
       34  
       35: // BYTE was defined in very old versions of Arduino
       36  // maybe this now causes more trouble than it's worth?
       37: #ifndef BYTE
       38: #define BYTE 0
       39  #endif
       40  
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\cores\teensy3\Print.cpp:
      256  
      257  	// TODO: make these checks as inline, since base is
      258: 	// almost always a constant.  base = 0 (BYTE) should
      259  	// inline as a call directly to write()
      260  	if (base == 0) {
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\cores\teensy3\Print.h:
       44  #define BIN 2
       45  
       46: // BYTE was defined in very old versions of Arduino
       47  // maybe this now causes more trouble than it's worth?
       48: #ifndef BYTE
       49: #define BYTE 0
       50  #endif
       51  
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\libraries\Metro\examples\serialInterval\serialInterval.pde:
       15      for (int i = 0; i < 6; i++ ) {
       16        Serial.print (analogRead( i) );
       17:       Serial.print(32,BYTE);
       18      }
       19      // Terminate message with a linefeed and a carriage return
       20:     Serial.print(13,BYTE);
       21:     Serial.print(10,BYTE);
       22    }
       23  }
    
    T:\arduino_1.8.5_142_TYC\hardware\teensy\avr\libraries\openGLCD\build\doc\doxygen\doxfiles\GLCD_API.dox:
       70  GLCD.print(integer, OCT) ; // print the octal value of the integer
       71  GLCD.print(integer, BIN) ; // print the binary value of the integer
       72: GLCD.print(integer, BYTE); // print the ASCII character represented by the integer 
       73  GLCD.print(float);         // print a floating point number using two decimal places
       74  GLCD.print(float, digits); // print a floating point number using the given number of digits after the decimal point
    
    12 matches across 6 files

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Wow, looks like the GLCD and Metro libraries really are still using BYTE, even after all these years it's been gone from official Arduino boards!

  7. #7
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,001
    Quote Originally Posted by PaulStoffregen View Post
    Hmmm... maybe it's *finally* time to remove BYTE?

    It was widely used as part of Arduino's Print class, before Arduino 1.0.
    The sketch compiles fine for UNO or DUE or dragonfly ..., so it seems to be a Teensyduino problem.

    And if you try to use Serial.print(x,BYTE) on UNO you get an error
    Code:
    scopetest:51: error: The 'BYTE' keyword is no longer supported.
    As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
    Please use Serial.write() instead.
    Last edited by manitou; 08-26-2018 at 11:44 AM.

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    I've removed BYTE.

    https://github.com/PaulStoffregen/co...03b46cf88700d2

    Arduino had this many years ago and I've kept it around for backwards compatibility. But it's obviously causing more trouble than ancient Arduino compatibility is worth.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •