close-circle
Close
0%
0%

: BACK Be A Compilable Keyboard ;

Forth language and environment for Mickey Board, a custom BLE keyboard PCBA based on nRF51822.

Similar projects worth following
close
Forth language and environment for Mickey Board, a custom BLE keyboard PCBA based on nRF51822.

Due to license limit, the "C" part of the Mickey Board firmware is not opensource. To make it more cusomizable and smart, BACK is coming. It's a STC (subroutine threaded code) forth implementation to make Mickey Board (nRF51822 based BLE keyboard) interactive and compilable with itself and a simple program like notepad. User can define and execute new words just like using a Forth environment on PC, to implement Macro or inquire&modify parameters, without firmware update. The whole environment is inside the keyboard, itself is also the input device and the PC is only an output device,

The BACK is written in assembly and forth-like language. After assembled by GNU as, a hex file will be generated and put together with the Mickey Board firmware.

Add a hash filed in the diction header to speed up "find" process. The assembly part's hash fields are calculated by an elisp function.

Currently, some "words" work in Keil simulation environment and it has not been tested on the board.

View all 6 components

  • Editor & some tests

    Thumb211/06/2017 at 14:47 0 comments

    Fixed some editor bugs. "记事本” is Notepad in Chinese. 

    BACK could be in every keyboard, because almost all keyboards have a backspace :) 

  • BACK in Mickey Board works

    Thumb211/02/2017 at 00:54 0 comments

    BACK is ported to Mickey Board on 1st, Nov.

    Basically, it works! User can interact with Mickey Board in a program like Notepad in Windows. Mickey Board itself is the input device and the PC is the output device. All the functions in simulation environment as showed in previous logs should work, bug not fully tested yet. 

    // However, due to the C part output function's faultiness, something "emitted" might be missing.  

    -> This bug is almost fixed.

  • Implemented an editor to support defining word

    Thumb210/27/2017 at 00:41 0 comments

    The input buffer will be emptied after "enter" is pressed. Therefore, to support defining new words, the codes in input buffer need to be moved into user code area. The "interpreter"  will interpret the codes in the user code area when new word is added.

    Adding a new word has been implemented. Editing an old word is to be implemented.

  • Interaction implmented in simulation environment

    Thumb210/11/2017 at 13:34 0 comments

    The demo runs with UART simulation under Keil simulation environment. Word definition is not supported yet ( ":" needs modification to copy the code from input buffer to source code area). 

    Code can be found in https://github.com/thumb2/back/.

  • Codes for simulation and Mickey Board are merged

    Thumb209/18/2017 at 14:15 0 comments

    Codes for simulation and Mickey Board are merged into one repo: https://github.com/thumb2/back

    The C code on Mickey Board is event based, and blocking is not allowed. Therefore, the forth code is organized into a thread which is never blocked. 

    The simulation code can output something via UART (Keil's uart window). And the Mickey Board code is still under development.

  • BACK on Mickey Board

    Thumb207/13/2017 at 02:21 0 comments

    The BACK was running on real Mickey Board on July 11th. According to the debug tool, the interpreter and compiler worked properly. However, it was not fully tested due to the lack of input/output functions. The source code can be found here: https://github.com/thumb2/back

  • 2017-5-24

    Thumb205/24/2017 at 07:18 0 comments

    Added a project on Hackaday.io . Before that, interpreter, compiler, and some words like "if then else begin until while repeat ." " are implemented and tested in the Keil simulation environment.

View all 7 project logs

  • 1
    Environment setup

    For the simulation version (proj_sim in github repo), Keil free version (4kB limited) and gcc toolchain are need.    

    For the hardware version (proj_mb in github repo), GNU assembler and make tool are needed, (Ubuntu 16.04 is used but not mandatory, sudo apt-get install build-essential).

    To calculate the hash value of a word name in assembly code, there are two elisp functions that can be used in Emacs.

  • 2
    For Mickey Board (some links are in Chinese only)

    1) Buy a Mickey Board (https://item.taobao.com/item.htm?spm=a230r.1.14.1.1ff67ad2Sr20a7&id=546117969332&ns=1&abbucket=20#detail), switches, case and so on, assemble them into a Keyboard. The assembly method can refer to GH60.

    2) Generate keyboard layout file using TKG (https://tkg.btsmartshield.com/)

    3) Generate BACK hex, run make under the proj_mb,back.hex can be found under proj_mb/_build

    4) Generate firmware zip by uploading the layout binary code and back.hex, upload the firmware with nRF Connect App on iOS or Android.

  • 3
    For simulation (may be broken in recent version as we don't test for simulation)

    Open the Keil project in proj_sim, Ctrl+F5 to start debug session. 

    Input/output would be In the UART window.

View all 3 instructions

Enjoy this project?

Share

Discussions

Thomas wrote 11/07/2017 at 20:30 point

That's a really nice idea! I guess that it could also be implemented as something that can go between an ordinary keyboard and a computer. Your project is more fun, though :-)

  Are you sure? yes | no

Thumb2 wrote 11/08/2017 at 00:47 point

Thank you for the comment! The first comment I received here. Forth is an amazing language, however, few people nowadays know it. Probably its light-weight and flexibility caused this result, as it might be hard for large project and collaboration. No matter what, Forther can still benefit from it. Hope that Forth could be BACK :)

  Are you sure? yes | no

Thomas wrote 11/08/2017 at 06:21 point

Forth is amazing, "it's bigger on the inside". 


It's also an old cultural thing, related to ALGOL vs. LISP (A: powerful but finite vs. L: simple but unlimited). I take it for a fact that changing cultures is the hardest thing in humanity. Of course, it's possible to do large projects with Forth but the A culture is dominant, and has generated many many subcultures (e.g. Pascal, BASIC, C, C++, Java, C#, Python ...). There are some L cultures, that live "inside" the A societies (e.g. Smalltalk, JavaScript. Clojure).

This said, your examples for the usefulness of a reflective, concatenative language inside a keyboard reaches a lot of A people. They look at it like at an exotic fruit in the supermarket they see for the first time in their life, and it's almost like they understand for a fracture of a second that the world is bigger than the mega-city they're living in. Some might be tempted to buy a plane ticket. Some, and merely tempted, not really doing it. Of course, you can try and offer them a blue pill (or a taste of the blue exotic fruit ;-).

  Are you sure? yes | no

Thumb2 wrote 11/09/2017 at 01:50 point

All those who get into it say so. Doctor Who is one of my favorite TV program.

For me, Forth is the best language for bootstrap of a CPU with brand new instruction set (the best alien language?), however, it's not quite friendly to human (as the A languages you mentioned). In China, we learn a little classical Chinese, that used not nowadays but in ancient times. I can hardly understand  an article in classical Chinese even though I know each character in it, as the characters' meaning and usage changed over time.  Due to the resource limitation, the meaning/behavior of a Forth word might be different in different implementations (especially for embedded systems) , and I have to read each word if I want to understand a Forth implementation, even though the number is not very large.

I don't know many computer languages. C is my "native" language and Forth is my first foreign language (except C-like languages). Sometimes I feel that C dominates my brain, in other words, I often think about a problem in C. So I'm not sure if the BACK is pure/true Forth, and I even don't know what is a pure/true Forth, or it's just a philosophy not a language? For example, are the different implementations just some different libraries in Forth (like C libraries, written in C, but if you want to know how to use them, you must learn something beyond C), or different dialects of Forth (In China, there are lots of dialects, and people may not understand each other in different dialects. Someone told me the difference between some Chinese dialects might be larger than English & French)? People may not understand each other even though they both speak "Forth". I know there are some standards, but I'm afraid lots of Forth implementations don't comply with them. Maybe we can implement an abstraction layer, and all Forth programs can run on it (perhaps it's the standard itself). However, sometimes we can't due to the resource limitation. Maybe I'm too greedy. 

Few (and few) people in China know/use Forth, so it's hard for me to discuss with a Forther (as my English is not very good). Chinese dominates my brain like C, so it's hard for me to made myself clear in English (or maybe just Chinglish).

  Are you sure? yes | no

Thomas wrote 11/09/2017 at 20:15 point

> For me, Forth is the best language for bootstrap of a CPU with brand new instruction set (the best alien language?)

That's especially true for an STC Forth (if the instruction set allows it)

> however, it's not quite friendly to human (as the A languages you mentioned).

That depends on the human. I've learned to know one person who has trouble with A languages (Like yoda we speak.  Hmmmmmm.)

> Due to the resource limitation, the meaning/behavior of a Forth word might be different in different implementations (especially for embedded systems)

There are standards one can use, and modern µC-Forth systems do a pretty job at it (e.g. NoForth, AmForth, Mecrisp...). Forth systems the predate ANS-Forth are different, and many dialects exist. Sometimes a platform is too limited for some of the ANS concepts

> , and I have to read each word if I want to understand a Forth implementation, even though the number is not very large.

That's also a problem of L languages, I guess.

> I don't know many computer languages. C is my "native" language and Forth is my first foreign language (except C-like languages). Sometimes I feel that C dominates my brain, in other words, I often think about a problem in C. So I'm not sure if the BACK is pure/true Forth,

I had a discussion about whether it's possible to learn Forth by writing a Forth. It's a bit the same as learning languages from radio news only. One has to "live" in a language to understand all aspects/

> and I even don't know what is a pure/true Forth, or it's just a philosophy not a language?

Some would say that the philosophy is more important than the language. The ANS-Forth people think the language is more important (because L should be more like A).

> Someone told me the difference between some Chinese dialects might be larger than English & French)?

> People may not understand each other even though they both speak "Forth".

That's also a problem of L languages, I guess: how can you communicate in a language that no one else speaks?  "Unlimited" is both an asset and a curse.

> I know there are some standards, but I'm afraid lots of Forth implementations don't comply with them. Maybe we can implement an abstraction layer, and all Forth programs can run on it (perhaps it's the standard itself). However, sometimes we can't due to the resource limitation. Maybe I'm too greedy.

That doesn't always work: if the basics are different then the whole structure will also be different. Some things in standard Forth also assume that the dictionary is in RAM memory, which is often not possible in embedded systems

> Few (and few) people in China know/use Forth, so it's hard for me to discuss with a Forther (as my English is not very good). Chinese dominates my brain like C, so it's hard for me to made myself clear in English (or maybe just Chinglish).

Nah, your English is perfect for communication, and there are many ESL speakers in the world. Congrats for mastering a foreign language this good!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates