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

Thread: Serial "Dumb" Terminal

  1. #1

    Serial "Dumb" Terminal

    I'm trying to make a dumb terminal using a PS/2 keyboard, basic microcontroller, and small display. Currently I'm working with a Teensy 3.2 and the Adafruit 3.5" TFT 320x480 display with HX8357D. I'm using PlatformIO in Code - OSS, building the project for the Arduino framework.

    Currently have the keyboard working, and incoming text is displaying nicely except that I don't know how to make it scroll vertically (unless I want to wait a few seconds every refresh). I'm using SPI to drive the display now, but I'm not opposed to using the 8-bit interface for speed.

    I've spent a lot of time searching the net and looking at Adafruit's documentation and some header files, but I've not made any progress on this for weeks. It's so easy to get this running and use functionality shown in examples, but I feel like as soon as I need to step outside what has been prepped, I drop straight off into the deep end. I'm happy to do the research, but I just need some direction because I'm spinning my wheels right now, wasting a lot of time.

    Much thanks in advance for any help!

  2. #2
    Senior Member
    Join Date
    Aug 2019
    Location
    Melbourne Australia
    Posts
    251

  3. #3
    I had not seen that, no. Most of my searching has been prior to that being posted, so maybe xxxajk's ears had been ringing .

    I've added the fbcon and IntervalTimer2 repos under my .pio/libdeps/Teensy directory, and have included fbcon.h in my main.cpp, but it won't build for lack of header cuchar. I am finding this header in my system's C++ 11 include folder, and within the RISC-V toolchain, but not for Arduino nor Teensy.

    The build output follows:
    Code:
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy31.html
    PLATFORM: Teensy (4.13.1) > Teensy 3.1 / 3.2
    HARDWARE: MK20DX256 72MHz, 64KB RAM, 256KB Flash
    DEBUG: Current (jlink) External (jlink)
    PACKAGES: 
     - framework-arduinoteensy 1.154.0 (1.54) 
     - toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 111 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <U8g2> 2.28.8
    |   |-- <SPI> 1.0
    |   |-- <Wire> 1.0
    |-- <fbcon>
    |   |-- <IntervalClassTimer2>
    |-- <IntervalClassTimer2>
    |-- <SPI> 1.0
    |-- <Wire> 1.0
    Building in release mode
    Compiling .pio/build/Teensy/src/main.cpp.o
    Compiling .pio/build/Teensy/lib426/SPI/SPI.cpp.o
    Compiling .pio/build/Teensy/libd76/Wire/Wire.cpp.o
    Compiling .pio/build/Teensy/libd76/Wire/WireIMXRT.cpp.o
    Compiling .pio/build/Teensy/libd76/Wire/WireKinetis.cpp.o
    Compiling .pio/build/Teensy/libd76/Wire/utility/twi.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/U8g2lib.cpp.o
    Compiling .pio/build/Teensy/libbdf/U8g2/U8x8lib.cpp.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_bitmap.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_box.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_buffer.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_circle.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_cleardisplay.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_d_memory.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_d_setup.c.o
    src/main.cpp: In function 'void loop()':
    src/main.cpp:40:59: warning: operation on 'posBufHeadSerial1' may be undefined [-Wsequence-point]
             posBufHeadSerial1 = ++posBufHeadSerial1 % SIZE_BUF;
                                                               ^
    src/main.cpp:51:59: warning: operation on 'posBufTailSerial1' may be undefined [-Wsequence-point]
             posBufTailSerial1 = ++posBufTailSerial1 % SIZE_BUF;
                                                               ^
    src/main.cpp:57:57: warning: operation on 'posBufHeadSerial' may be undefined [-Wsequence-point]
             posBufHeadSerial = ++posBufHeadSerial % SIZE_BUF;
                                                             ^
    src/main.cpp:61:57: warning: operation on 'posBufTailSerial' may be undefined [-Wsequence-point]
             posBufTailSerial = ++posBufTailSerial % SIZE_BUF;
                                                             ^
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_font.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_fonts.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_hvline.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_input_value.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_intersection.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_kerning.c.o
    Archiving .pio/build/Teensy/libd76/libWire.a
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_line.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_ll_hvline.c.o
    Indexing .pio/build/Teensy/libd76/libWire.a
    Archiving .pio/build/Teensy/lib426/libSPI.a
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_message.c.o
    Indexing .pio/build/Teensy/lib426/libSPI.a
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_polygon.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_selection_list.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8g2_setup.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8log.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8log_u8g2.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8log_u8x8.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_8x8.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_byte.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_cad.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_capture.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_a2printer.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_il3820_296x128.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ist3020.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ist7920.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ks0108.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_lc7981.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ld7032_60x32.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ls013b7dh03.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_max7219.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_pcd8544_84x48.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_pcf8812.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_pcf8814_hx1230.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sbn1661.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sed1330.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sh1106_64x32.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sh1106_72x40.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sh1107.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sh1108.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_sh1122.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1305.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_128x32.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_128x64_noname.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_2040x16.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_48x64.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_64x32.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_64x48.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_72x40.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1306_96x16.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1309.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1316.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1317.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1318.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1322.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1325.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1326.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1327.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1329.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1606_172x72.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_ssd1607_200x200.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7511.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st75256.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7528.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st75320.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7565.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7567.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7586s_erc240160.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7586s_s028hn118a.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7588.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_st7920.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_t6963.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1601.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1604.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1608.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1610.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1611.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1617.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1638.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1701_dogs102.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_d_uc1701_mini12864.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_debounce.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_display.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_fonts.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_gpio.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_input_value.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_message.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_selection_list.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_setup.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_string.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_u16toa.c.o
    Compiling .pio/build/Teensy/libbdf/U8g2/clib/u8x8_u8toa.c.o
    Compiling .pio/build/Teensy/libe12/IntervalClassTimer2/IntervalClassTimer2.cpp.o
    Compiling .pio/build/Teensy/libe12/IntervalClassTimer2/IntervalTimer2.cpp.o
    Compiling .pio/build/Teensy/libe12/IntervalClassTimer2/nbproject/private/c_standard_headers_indexer.c.o
    Compiling .pio/build/Teensy/libe12/IntervalClassTimer2/nbproject/private/cpp_standard_headers_indexer.cpp.o
    Compiling .pio/build/Teensy/lib20b/fbcon/fbcon.cpp.o
    Compiling .pio/build/Teensy/lib20b/fbcon/nbproject/private/c_standard_headers_indexer.c.o
    Compiling .pio/build/Teensy/lib20b/fbcon/nbproject/private/cpp_standard_headers_indexer.cpp.o
    Compiling .pio/build/Teensy/FrameworkArduino/AudioStream.cpp.o
    Compiling .pio/build/Teensy/FrameworkArduino/CrashReport.cpp.o
    Compiling .pio/build/Teensy/FrameworkArduino/DMAChannel.cpp.o
    Compiling .pio/build/Teensy/FrameworkArduino/EventResponder.cpp.o
    In file included from /home/agifford/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1/backward/strstream:50:0,
                     from .pio/libdeps/Teensy/IntervalClassTimer2/nbproject/private/cpp_standard_headers_indexer.cpp:87:
    /home/agifford/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
     #warning \
      ^
    .pio/libdeps/Teensy/IntervalClassTimer2/nbproject/private/cpp_standard_headers_indexer.cpp:104:93: fatal error: cuchar: No such file or directory
    compilation terminated.
    *** [.pio/build/Teensy/libe12/IntervalClassTimer2/nbproject/private/cpp_standard_headers_indexer.cpp.o] Error 1
    Compiling .pio/build/Teensy/FrameworkArduino/HardwareSerial.cpp.o
    In file included from /home/agifford/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1/backward/strstream:50:0,
                     from .pio/libdeps/Teensy/fbcon/nbproject/private/cpp_standard_headers_indexer.cpp:87:
    /home/agifford/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
     #warning \
      ^
    .pio/libdeps/Teensy/fbcon/nbproject/private/cpp_standard_headers_indexer.cpp:104:93: fatal error: cuchar: No such file or directory
    compilation terminated.
    *** [.pio/build/Teensy/lib20b/fbcon/nbproject/private/cpp_standard_headers_indexer.cpp.o] Error 1
    At this point, I don't think my code matters, but here it is anyway:
    Code:
    #include <Arduino.h>
    #include <SPI.h>
    #include <Wire.h>
    #include <fbcon.h>
    
    #define TFT_CS 10
    #define TFT_DC 9
    #define TFT_RST 8
    
    #define SIZE_BUF 1024
    
    uint8_t bufSerial[SIZE_BUF];
    uint16_t posBufHeadSerial;
    uint16_t posBufTailSerial;
    
    uint8_t bufSerial1[SIZE_BUF];
    uint16_t posBufHeadSerial1;
    uint16_t posBufTailSerial1;
    
    char hexByte[3];
    bool printHex = false;
    
    void setup() {
        delay(3000);
        Serial.begin(115200);
        Serial.println("Started serial.");
        Serial1.begin(115200);
        Serial.println("Started serial 1.");
    
        posBufHeadSerial = 0;
        posBufTailSerial = 0;
        posBufHeadSerial1 = 0;
        posBufTailSerial1 = 0;
    }
    
    void loop() {
        // Read serial from connected system
        if (Serial1.available()) {
            bufSerial1[posBufHeadSerial1] = Serial1.read();
            posBufHeadSerial1 = ++posBufHeadSerial1 % SIZE_BUF;
        }
        if (posBufHeadSerial1 != posBufTailSerial1) {
            if (printHex) {
                sprintf(hexByte, "%02x", bufSerial1[posBufTailSerial1]);
                Serial.print(hexByte);
            }
            else {
                Serial.print((char)bufSerial1[posBufTailSerial1]);
            }
            //tft.print((char)bufSerial1[posBufTailSerial1]);
            posBufTailSerial1 = ++posBufTailSerial1 % SIZE_BUF;
        }
    
        // Read serial from USB connection
        if (Serial.available()) {
            bufSerial[posBufHeadSerial] = Serial.read();
            posBufHeadSerial = ++posBufHeadSerial % SIZE_BUF;
        }
        if (posBufHeadSerial != posBufTailSerial) {
            Serial1.print((char)bufSerial[posBufTailSerial]);
            posBufTailSerial = ++posBufTailSerial % SIZE_BUF;
        }
    }
    Thanks again for your time!
    Last edited by SiliconBadger; 10-06-2021 at 07:36 AM.

  4. #4
    Don't laugh, but I have that same display and I actually use the ILI9341_t3 driver. This driver is faster, more capable, has much better font support, etc. You should only have to reset the following.

    #define ILI9341_TFTWIDTH 320
    #define ILI9341_TFTHEIGHT 480

    This is very weird, I know. I actually comment these #defines out, and pass the width and height as parameters during object creation, so I can use this lib for my 2.8" and 3.5" displays.

    Because that display seems to not have SPI for touch, I still use the TouchScreen lib.
    TouchScreen Touch = TouchScreen(XP, YP, XM, YM, 300);

    Kris

  5. #5
    Thanks, Kris! I'd considered that, based on the discussion over here. In the end, I don't think either the HX8357 library nor the ILI9341 library have the scrolling and other cursor control functionality built in like the fbcon project, which would be ideal for me.

  6. #6
    The ILI9341_t3 library has a scroll feature

    void setScroll(uint16_t offset);

    I use it in a splash screen like this.

    Display.fillScreen(C_BLACK);
    Display.fillScreenVGradient(0x000E, 0x0000);
    delay(500);
    for (int i = 0; i < 320; i += 2) {
    Display.setTextColor(C_RED, C_BLACK);
    Display.setFont(ArialBlack_40);
    Display.setCursor(11, 40);
    Display.print(F("Canon 7D"));

    Display.setTextColor(C_WHITE, C_BLACK);
    Display.setFont(Arial_20);
    Display.setCursor(30, 120);
    Display.print(F("Microphone Monitor"));

    Display.setFont(Arial_16);
    Display.setCursor(40, 180);
    Display.print(F("v 2.5 Kasprzak (c)"));
    Display.setScroll(i);
    }


    working example can be seen at the 0:05 and 7:49 time mark

    https://www.youtube.com/watch?v=tCUUaf6nYE8


    not sure if this helps.

  7. #7
    Very well done video, Kris, and that's a slick project you have there. I have a lot of large gaps in my knowledge and not much experience with microcontroller projects, so I may be missing some options that are really obvious to others here. For the scrolling you demonstrate, it's a static image being scrolled across the screen. I'm not sure how to translate that approach to work for my need, where the text is going to be changing constantly as old lines scroll up off the top of the screen, and new lines are added at the bottom.

    My only attempt was to read from serial into a buffer of text lines, and each time a line had to scroll off screen, I sent the entire new buffer contents to the display using the print() function of the display library. This was incredibly slow, as in multiple seconds for a full screen refresh. I don't know any other way to send text to the display. This is where it seemed like the fbcon project MatrixRat referenced would be exactly what I need.

    I suppose that scrolling functionality you showed could be the answer, if I have it scroll the display contents up by the height of a text line, and then just write my new text at the bottom. But I'm pretty sure the docs for the Adafruit library mentioned it supports horizontal scrolling, but not vertical scrolling.

    Thanks very much for the excellent video and code excerpt, and I'll check out the docs for the ILI9341_t3 library to see if it supports vertical scroll.

  8. #8

    Assistance with fbcon

    After checking datasheets for both the ILI9341 and HX8357D, and finding more details in forums, it seems there is no built-in support for vertical scrolling of display content when using a landscape presentation.

    As a result, I'd really like to pursue using the fbcon code referenced by MatrixRat, but I'm not sure what to do about the error I'm getting trying to compile (missing include file cuchar). I thought it made more sense to keep my questions about that in this thread, but should I instead post my issue, or a link to this thread, over in the fbcon thread?

  9. #9
    I found the issue. There was no reason for the file causing the error (cpp_standard_headers_indexer.cpp) to be compiled, but PlatformIO was trying because it's a cpp file under the library directories I copied in. Deleting the nbproject directory from both the fbcon and IntervalClassTimer2 directories solved the problem and the charmap example is now running, albeit for a different display size than I'm running. I'll play with it more later and see how things go.

    Thanks to everyone who responded

Posting Permissions

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