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 5708 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…
  • 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
  • Former Member
    Former Member over 10 years ago

    Hey i got the same fault on the LCD.

    I also tried to use the newer version of Arduino TinyBasic (0.13) but it fails.

    And i have another big problem. The Layout of my Chatpad is different than that from the example, this means the mapping of the keys dont match. I tried to remap this. This was not as easy as i think but i got it.

    Old Map:

     

     

    const char scanMap[50] = {      // i could output directly idx,

      8,  9, 10, 40, 20, 30, 47,    // but maybe a translation map

    41, 42, 43, 39, 44, 38, 45,    // can prove useful in future.

    31, 32, 33, 35, 34, 36, 37,    // starts from 1...think 0

    21, 22, 23, 25, 24, 26, 27,    // should be reserved for

    11, 12, 13, 15, 14, 16, 17,    // future use

      1,  2,  3,  5,  4,  6,  7,

    28, 18, 19,  0,  0, 29, 46 };

     

     

    const char serialMap[4][49] = { // CHARACTER MAPPING MATRIX for "pure serial mode"

    // normal char press

    {56,  57,  48,  13, 112,  44,   0,

      0,   0,   0,  46,  32, 109,   0,

      0, 121, 120, 118,  99,  98, 110,

    97, 115, 100, 103, 102, 104, 106,

    113, 119, 101, 116, 114, 122, 117,

    49,  50,  51,  53,  52,  54,  55,

    107, 105, 111,   0,   0, 108,   8},

     

     

    // shifted

    {56,  57,  48,  13,  80,  44,   0,

      0,   0,   0,  46,  32,  77,   0,

      0,  89,  88,  86,  67,  66,  78,

    65,  83,  68,  71,  70,  72,  74,

    81,  87,  69,  84,  82,  90,  85,

    49,  50,  51,  53,  52,  54,  55,

    75,  73,  79,   0,   0,  76,   8},

     

     

    // green alt

    {56,  57,  48,  13,  61,  39,   0,

      0,   0,   0,  63,  32,  58,   0,

      0,  60,  62,  45, 126,  42,  59,

      0,   0,   0,   0,   0, 123, 125,

    33,  34, 128,  37,  36,  38,  47,

    49,  50,  51,  53,  52,  54,  55,

    91,  40,  41,   0,   0,  93,   8},

     

     

    // red alt

    {56,  57,  48,  13,  92,  35,   0,

      0,   0,   0,   0,  32,   0,   0,

      0,   0, 124,  95,   0,  43,   0,

      0,   0,   0,   0,   0,  96,   0,

    64,   0,   0,   0,   0,  94,   0,

    49,  50,  51,  53,  52,  54,  55,

      0,   0,   0,   0,   0,   0,   8}

    };  ////////// END OF MAPPING MATRIX

     

     

     

     

     

    I only Map the important Keys. Special Key are not important for this Projekt.

     

    New Map:

    const char scanMap[50] = { // i could output directly idx,

      8, 9, 10, 40, 20, 30, 47, // but maybe a translation map

    41, 42, 43, 39, 44, 38, 45, // can prove useful in future.

    31, 32, 33, 35, 34, 36, 37, // starts from 1...think 0

    21, 22, 23, 25, 24, 26, 27, // should be reserved for

    11, 12, 13, 15, 14, 16, 17, // future use

      1, 2, 3, 5, 4, 6, 7,

    28, 18, 19, 0, 0, 29, 46 };

     

    const char serialMap[4][49] = { // CHARACTER MAPPING MATRIX for "pure serial mode"

    // normal char press

    {56, 57, 48, 13, 112, 44, 0,

      0, 0, 0, 46, 32, 109, 0,

      0, 121, 120, 118, 99, 98, 110,

    97, 115, 100, 103, 102, 104, 106,

    113, 119, 101, 116, 114, 122, 117,

    49, 50, 51, 53, 52, 54, 55,

    107, 105, 111, 0, 0, 108, 8},

     

    // shifted

    {56, 57, 48, 13, 80, 44, 0,

      0, 0, 0, 46, 32, 77, 0,

      0, 89, 88, 86, 67, 66, 78,

    65, 83, 68, 71, 70, 72, 74,

    81, 87, 69, 84, 82, 90, 85,

    49, 50, 51, 53, 52, 54, 55,

    75, 73, 79, 0, 0, 76, 8},

     

    // green alt

    {56, 57, 48, 13, 61, 39, 0,

      0, 0, 0, 63, 32, 58, 0,

      0, 60, 62, 45, 126, 42, 59,

      0, 0, 0, 0, 0, 123, 125,

    33, 34, 128, 37, 36, 38, 47,

    49, 50, 51, 53, 52, 54, 55,

    91, 40, 41, 0, 0, 93, 8},

     

     

    // red alt

    {56, 57, 48, 13, 92, 35, 0,

      0, 0, 0, 0, 32, 0, 0,

      0, 0, 124, 95, 0, 43, 0,

      0, 0, 0, 0, 0, 96, 0,

    64, 0, 0, 0, 0, 94, 0,

    49, 50, 51, 53, 52, 54, 55,

      0, 0, 0, 0, 0, 0, 8}

    }; ////////// END OF MAPPING MATRIX

     

     

    But i dont now how to Compile this sketch. There are many files but i dont now wich i have to use

    It would be very nice if anyone can help me

     

    Greets

    Kaoala

     

    PS: Sry for the bad english

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Hey, if anybody have a Layout of the Chatpad like me:

    image

    he can use this .hex file (https://drive.google.com/file/d/0B5ekX3iu3Pl-RU9Kbm9FNzg3aUE/view?usp=sharing)

    Because the Original Mapping does not fit. If you have any questions, you can write me

     

    Greets Kaoala

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

    I have that mapping. But because of the lack of an PIC Programmer and because my Bus Pirate wasn't able to do anything, I just wrote a driver based of one I found online.

    So I wrote a PS2Keyboard like library for the Arduino. If anybody needs it, just ask. This library works with the original firmware.

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

    Any help on a 16*2 screen? I'm trying to use them up..

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

    Any help on a 16*2 unit??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 6 years ago in reply to ryan27968

    I know it was like 4 years ago since anyone touched this thread but here is my 20x4 code: https://pastebin.com/Wxs2x79A

    Also mine uses a custom button matrix and it basically uses every single pin on the nano image.

    imageimage

    • 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