element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
element14's The Ben Heck Show
  • Challenges & Projects
  • element14 presents
  • element14's The Ben Heck Show
  • More
  • Cancel
element14's The Ben Heck Show
Forum Basic pocket computer display modification
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join element14's The Ben Heck Show to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 32 replies
  • Subscribers 35 subscribers
  • Views 5717 views
  • Users 0 members are here
  • pc
  • build
  • code
  • pocket
  • display
  • ben_heck
  • basic
Related

Basic pocket computer display modification

ryan27968
ryan27968 over 12 years ago

Hi ben. I was watching old versions of your show and was wondering what is involved in changing the code for your basic pocket computer to work on a 20 by 4 display instead of a 16 by 4. I have tried messing around with the code but with no luck. Thanks in advance.

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 11 years ago in reply to Former Member +1
    WARNING! I DO NOT HAVE ANY HARDWARE TO TEST THIS WITH! THIS MAY STILL BE BROKEN! tl;dr Now that that's out of the way, here's a (potentially) fixed copy of the script: https://gist.github.com/zanothis…
Parents
  • ryan27968
    ryan27968 over 12 years ago

    original? what do you mean?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • benheck
    benheck over 12 years ago in reply to ryan27968

    These files.

    Attachments:
    1273.pocker_BASIC.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ryan27968
    ryan27968 over 12 years ago in reply to benheck

    this is the same code that i originally used, but it still does not work. this is written for a 16 by 4  not a 20 by 4.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • rhyse302
    rhyse302 over 12 years ago in reply to ryan27968

    Did you use the 4 bit monitor?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • benheck
    benheck over 12 years ago in reply to ryan27968

    Ah, you probably need to re-arrange screen memory so it doesn't overflow the lines.

     

    Look through the code for instances of 16, or multiples thereof.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • benheck
    benheck over 12 years ago in reply to ryan27968

    Ah, you probably need to re-arrange screen memory so it doesn't overflow the lines.

     

    Look through the code for instances of 16, or multiples thereof.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Former Member
    Former Member over 12 years ago in reply to benheck

    crossposted to a new thead

     

    I am too having problems getting my 20*4 screen (https://www.sparkfun.com/products/9568) working. I tried changing anything I could imagine having anything to do with the number of  columns in the lcdChar (), doFrame () and setup () routines. Do you know which lines exactly must be changed in order to get a clean output?

    thanks.

    ___________

    Edit (13.8.);

    I got it PARTLY working! THE 4 RIGHTMOST CHARS IN THE FIRST LINE ARE STILL MISSING AND DISPLAYED AT THE BEGINNING OF THE THIRD LINE. Anyone got help? For anyone who wants to know how, I changed the following lines in Tinybasic_2.ino (you find it here: http://www.element14.com/community/thread/25177?start=14&tstart=9)

    Line Nr.From (original code)To (modified code)
    23int screenMem[72];int screenMem[76];
    1481if (cursorX < 16) {if (cursorX < 20) {
    1489if (cursorX == 16 or c == 10) {if (cursorX == 20 or c == 10) {
    1491for (int xg = 0 ; xg < 16 ; xg++) {for (int xg = 0 ; xg < 20 ; xg++) {
    1494screenMem[40 + xg] = screenMem[20 + xg];screenMem[40 + xg] = screenMem[16 + xg];
    1495screenMem[16 + xg] = screenMem[56 + xg];screenMem[20 + xg] = screenMem[56 + xg];
    1503doFrame(56);doFrame(60);
    1535lcd.begin(16, 4);lcd.begin(20, 4);
    1537for (int xg = 0 ; xg < 72 ; xg++) {for (int xg = 0 ; xg < 76 ; xg++) {
    1543doFrame(56);doFrame(60);
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    WARNING! I DO NOT HAVE ANY HARDWARE TO TEST THIS WITH! THIS MAY STILL BE BROKEN!

     

    tl;dr

    Now that that's out of the way, here's a (potentially) fixed copy of the script:

    https://gist.github.com/zanothis/9167288

     

    I had to make the fixes using only the code and the algorithm contained therein. The lcdChar function had a few things mixed up.

    The original used the following:

    for (int xg = 0 ; xg < 16 ; xg++) {

    screenMem[0 + xg] = screenMem[40 + xg];

    screenMem[40 + xg] = screenMem[16 + xg];

    screenMem[16 + xg] = screenMem[56 + xg];

    screenMem[56 + xg] = 32;

    }

     

    This seems to be trying to handle the interlaced copy of the display lines. The problem is that 40 is valid for a 20x4 display, while the 16 would be useful for a 16x4 display, and the 56 is useful in neither.

    If you need to, picture the 1-dimensional array as it will be displayed where the number values are the array indexes (16x4 used, though the same applies to 20x4):

    0 ... 15

    32 ... 47

    16 ... 31

    48 ... 63

     

    The algorithm should be written as follows:

    for (int xg = 0 ; xg < 16 ; xg++) {

    screenMem[0 + xg] = screenMem[32 + xg];

    screenMem[32 + xg] = screenMem[16 + xg];

    screenMem[16 + xg] = screenMem[48 + xg];

    screenMem[48 + xg] = 32;

    }

     

    Then screenMem only needs to have a size of 64.

     

    There are also several places that call doFrame(56) that should actually be doFrame(64). Line 1471 is an exception and should be:

    doFrame(48 + cursorX);

     

    Once those changes are made, changing to any other size is as easy as changing all the 16s to 20s, the 32s to 40s, the 48s to 60s and 64s to 80s in the case of a 20x4 display.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • benheck
    benheck over 11 years ago in reply to Former Member

    I didn't realize there was so much interest in this!

     

    My original code was quite the kludgy hack (which is common when you only have a few weeks)

     

    BASICally, the interpreter is meant to output via serial. I followed the chain down to a single serial print char, and rewrote that part to instead fill that data to "screen memory"

     

    The trick is once a Hitachi 44780 goes past 2 lines the lines aren't numbered sequentially (they are interlaced)

     

    On top of this, for the display to coarse scroll, it needs to keep track of the data.

     

    A more elegant solution would allow you to set constants of DIisplay Size, so it would know the width of lines.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • josephchrzempiec
    josephchrzempiec over 10 years ago in reply to benheck

    Hello Ben i been following your videos for some time now and i must say you are doing a awesome job man. I know a lot of hard work  that i not  show in the videos. i just recently developing a pocket pc using arduino. and i looked at your coding and you did a awesome job thank you. i have a hard time coding or hardware of things or to even get started my self but watching your videos it help me a lot thank you.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • muessigb
    muessigb over 10 years ago in reply to benheck

    Your project is great.

    I am still working on it, but for some reason the LCD is still not working.

    I already developed a driver (based on the work on Cliffleblog) for the Chatpad, but the LCD is just not working.

    Here are some photos of the LCD and the project components.

    The mega will later be replaced by a single ATmega328p and the blue LCD is going to be replaced by a green one (HD44780, 20x4 aswell).

     

    imageimage

     

    I hope anybody, including Ben, whose show I really like and follow since years, can help me solving the LCD problem.

    I am using the code from github that was posted earlier here in this thread.

     

    Greetings, Muessigb

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube