Author Topic: Command languaje for tiny microcontrollers  (Read 54796 times)

0 Members and 1 Guest are viewing this topic.

Online nctnico

  • Super Contributor
  • ***
  • Posts: 30365
  • Country: nl
    • NCT Developments
Re: Command languaje for tiny microcontrollers
« Reply #25 on: October 09, 2022, 07:30:00 pm »
If your goal is to make a well tested code, why not developing in С but on a linux/mac/windows, and abstract/stub the hardware calls.
Basically, write a unit test in C, stubbing the HW, and when it is well tested, your C code is ready to be moved to the uC.
That is the most sensible thing to do indeed. Avoid debugging software on a microcontroller as much as possible. I wrote an ISDN protocol stack that way using Borland C under MS-DOS.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #26 on: October 09, 2022, 07:39:48 pm »
If your goal is to make a well tested code, why not developing in С but on a linux/mac/windows, and abstract/stub the hardware calls.
Basically, write a unit test in C, stubbing the HW, and when it is well tested, your C code is ready to be moved to the uC.
That is the most sensible thing to do indeed. Avoid debugging software on a microcontroller as much as possible. I wrote an ISDN protocol stack that way using Borland C under MS-DOS.

Yup. I triumphantly reinvented that 40 years ago, for a Z80 with an ICE, and PDP-11 running Microsoft's decent operating system: Xenix. [1]

The boundary was events generated by the hardware in one direction, actions in the other, and an FSM using cooperative scheduling running under Xenix or bare Z80 as appropriate.

But where that isn't possible, hardware testing using Forth is a decent alternative.

[1] The observant will realise that depressingly little has changed. Z80 <-> atmega328, ICE <-> JTAG, Xenix <-> Linux. Sigh.
« Last Edit: October 09, 2022, 07:57:24 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17830
  • Country: fr
Re: Command languaje for tiny microcontrollers
« Reply #27 on: October 09, 2022, 07:47:17 pm »
If your goal is to make a well tested code, why not developing in С but on a linux/mac/windows, and abstract/stub the hardware calls.
Basically, write a unit test in C, stubbing the HW, and when it is well tested, your C code is ready to be moved to the uC.
That is the most sensible thing to do indeed. Avoid debugging software on a microcontroller as much as possible. I wrote an ISDN protocol stack that way using Borland C under MS-DOS.

I always recommend that, especially for non-trivial parts of the code, like particular processing, algorithms, etc.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4668
  • Country: us
Re: Command languaje for tiny microcontrollers
« Reply #28 on: October 09, 2022, 09:41:37 pm »
Quote
An interpreted language allows us to program and test with the microcontroller faster than with compiled languages
I'm not sure that's true any more.  The whole cross-compile/simulate/burn process has gotten pretty quick and convenient, and the PC-side tools are much more capable than any embedded interpreter editing capabilities, which is a pretty big advantage once your programs get past "trivial" in complexity.


Quote
but there are not many options to choose from.
I think for interpreted languages capable of running on a 32k/2k microcontroller, you're pretty much stuck with Forth-like languages, or BASIC-like languages.  There are a lot of choices for either one, depending on ... I dunno what.  I've used AMForth (which hasn't been mentioned yet - That makes at least four?) on Arduino hardware.

Interpreters are able to optimize particular operations that you may be interested in.  Remember "The BASIC Stamp"?  It ran god-awful slow (by todays standards.  About 1000 lines/s), but could do 9600bps async Serial output on any pin, and had a bunch of other low-level commands (not "standard BASIC") that made it useful for all sorts of things.

I've seen tiny LISP, too.  Hah hah!
 

Offline florian-x

  • Contributor
  • Posts: 12
  • Country: fr
Re: Command languaje for tiny microcontrollers
« Reply #29 on: October 09, 2022, 09:51:48 pm »
Tasmota project uses Berry language in their esp32 build: https://github.com/berry-lang/berry. I plan to have a close look at it (some time...).
 
The following users thanked this post: spostma

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #30 on: October 09, 2022, 11:53:26 pm »
If your goal is to make a well tested code, why not developing in С but on a linux/mac/windows, and abstract/stub the hardware calls.
Basically, write a unit test in C, stubbing the HW, and when it is well tested, your C code is ready to be moved to the uC.
Exactly.

I myself put each one of them in their own directory, with a small README file describing it, and file it away for later reuse.  If it contains math, I drop LibreOffice .odt and .pdf there too (although I really should use LaTeX and have a small scriptlet for quick viewing.. it's been too long since I used proper LaTeX; MathJax comes closest nowadays).

I do that for all key parts, including unit testing new algorithm implementations and verifying an approach works, for both systems stuff and embedded/microcontroller stuff.  Not only does it reduce my cognitive load (because once tested and marked so, I don't need to worry about the details), but coming back to the same thing later on, you can quickly get back on track (given the README and math), and can discover new stuff.  The last time I did that was just a couple days ago, wrt. indexing binary search trees I posted in the Fun for nerds thread.

For the really complicated stuff, like user interfaces for microcontroller stuff, I actually write a test harness (in Linux) that implements roughly the interfaces provided by the microcontroller hardware.  One useful trick is to run a Gtk+ user interface in the main thread, with its actions modifying variables atomically (using GCC __atomic builtins), and interrupts simulated using thread-targeted POSIX realtime signals (SIGRTMIN+0 to SIGRTMAX) –– they're not; they're just called that, and are just queued unlike ordinary Unix signals –– sent via pthread_sigqueue().  You can use a single signal handler and dispatcher that verifies the signal came from the process itself (siginfo->pid is enforced by the kernel), and use the payload value to indicate the "interrupt".  For the UI, I like to use the GtkBuilder .UI interface, so you can use an external XML .ui file to describe the user interface and buttons, editable in e.g. Glade in WYSIWYG manner.  Makes for a rather effective rapid development environment.

(Signal delivery will interrupt whatever else that thread is running, just like interrupts do on real hardware.  Technically, POSIX says that of the standard C library, only async-signal safe functions can be used in signal handlers, but for a microcontroller simulated environment this is not a big deal, because there usually isn't much of standard C library available anyway.)
« Last Edit: October 09, 2022, 11:57:15 pm by Nominal Animal »
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1917
  • Country: se
Re: Command languaje for tiny microcontrollers
« Reply #31 on: October 10, 2022, 08:01:58 am »
Code: [Select]
: BLK 1 5 OUT 0 5 OUT ;
: FBK 0 FOR BLK NXT ;
100 FBK

Now it really works. It has a cycle time of 150us (6660Hz). Not too fast. Similar to TinyBASIC
Ah, I was wondering why you first attempt did not work: nanoForth is not a complete FORTH, it has some limitations, 3 letters words being one.
Which does not learn from the past: a common practice (not ANSI compliant) was saving only the first 3-5 characters of a word, and its 'real' length - of course there will be conflicts, but they are usually quite less than expected - quit an improvement from the user side, with minimal memory penalty.

As for the speed, they are paying the penalty of token threaded code.
Indirect or direct threading implementations are usually much more efficient, at the cost of being non-portable.

The code size is also quite large - probably due to C++ use plus token threading, which needs a more complex VM: a direct or indirect threading FORTH would just need an inner interpreter (the execution engine, a handful of assembler instructions) and an outer interpreter (the user facing part, parsing and dictionary, most of it can be written in FORTH itself).
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #32 on: October 10, 2022, 10:45:48 am »
Code: [Select]
: BLK 1 5 OUT 0 5 OUT ;
: FBK 0 FOR BLK NXT ;
100 FBK

Now it really works. It has a cycle time of 150us (6660Hz). Not too fast. Similar to TinyBASIC
Ah, I was wondering why you first attempt did not work: nanoForth is not a complete FORTH, it has some limitations, 3 letters words being one.
Which does not learn from the past: a common practice (not ANSI compliant) was saving only the first 3-5 characters of a word, and its 'real' length - of course there will be conflicts, but they are usually quite less than expected - quit an improvement from the user side, with minimal memory penalty.

Based on that description the original code should work, as BLK and BLKS have the same initial three characters but differ in length.

Perhaps it is only using the first three characters and not the length. That would make sense if the 4th byte was the assigned token, and you can only have 256 words defined in the entire program, including built in ones.

I wonder how they distinguish between machine code words, token words in ROM, and token words in RAM. Perhaps just numeric token ranges, since the former two are fixed at system compile time. AVR can't run machine code from RAM, so more can't be added at runtime, words added by the user at runtime can only be token threaded and in RAM.

On an ATMega328 16 bits is enough for either a RAM (byte) address or ROM (word) address. True even on a Mega 1280, but not 2560 (RAM ok, but ROM is too big).
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1917
  • Country: se
Re: Command languaje for tiny microcontrollers
« Reply #33 on: October 10, 2022, 04:26:40 pm »
Based on that description the original code should work, as BLK and BLKS have the same initial three characters but differ in length.

Perhaps it is only using the first three characters and not the length. That would make sense if the 4th byte was the assigned token, and you can only have 256 words defined in the entire program, including built in ones.
Yep,that's what I meant: nanoFORTH is not learning from the past history of resource constrained FORTHs.
I did not dig too much into it to say how it handles its threading.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1473
  • Country: es
    • Picuino
Re: Command languaje for tiny microcontrollers
« Reply #34 on: October 10, 2022, 05:18:06 pm »
Another solution could be to make a command interpreter on the PC.
Or simply a language (Lua, Python, interpreted C) that sends instruction codes over the serial port. At 115200 baud it could send 5760 instructions per second with 1 byte argument, faster than most interpreters.

On the microcontroller side, you can simply program a loop that reads the command received by the UART and executes it by calling the corresponding function.

It would be fast, flexible, occupies little memory and you can make the program as large as you want on the PC, with no memory limitation.
 

Offline paf

  • Regular Contributor
  • *
  • Posts: 96
Re: Command languaje for tiny microcontrollers
« Reply #35 on: October 10, 2022, 06:05:32 pm »
Another solution could be to make a command interpreter on the PC.
Or simply a language (Lua, Python, interpreted C) that sends instruction codes over the serial port. At 115200 baud it could send 5760 instructions per second with 1 byte argument, faster than most interpreters.

On the microcontroller side, you can simply program a loop that reads the command received by the UART and executes it by calling the corresponding function.

It would be fast, flexible, occupies little memory and you can make the program as large as you want on the PC, with no memory limitation.

That already exists (at least in Forth) and is called a Tethered Forth.
More Info:
https://dl.acm.org/doi/pdf/10.1145/122089.122091
https://pages.cs.wisc.edu/~bolo/shipyard/3ins4th.html

   
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1473
  • Country: es
    • Picuino
Re: Command languaje for tiny microcontrollers
« Reply #36 on: October 10, 2022, 06:35:04 pm »
Great development!!
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 17288
  • Country: de
Re: Command languaje for tiny microcontrollers
« Reply #37 on: October 10, 2022, 08:54:37 pm »
Writing a program for an interpreter may be marginally faster than for a compiler. However with modern PCs and the small µC programms the cross compiler is quite fast unless there is something very wrong set up.

The big drawback of interpretet code is that it usually misses many of the error checks / warnings that a compiler can do. A Python program may fail with a syntax error when handling a rare case.
One could consider a different langish than C  (e.g. maybe ADA or a Pascal variant), but no real advantage in not using a complier as an extra checking instance and giving a little more speed.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17830
  • Country: fr
Re: Command languaje for tiny microcontrollers
« Reply #38 on: October 10, 2022, 09:03:25 pm »
Yeah. The real question here is to ask oneself: why do I need an interpreted language on a MCU? And from there would come possible solutions. If you don't have an answer to this question ("just because" doesn't count), this is kind of pointless to answer.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Command languaje for tiny microcontrollers
« Reply #39 on: October 10, 2022, 09:53:52 pm »
The real question here is to ask oneself: why do I need an interpreted language on a MCU?

Right. For me interpreter language for tiny, thus low cost MCU does not make any sense - because low cost means optimization of code size out of your mind. Using interpreter would be cardinal sin in such case. Thou.. during prototyping when one is not sure about logic/physics/etc of final product or product is deemed to be customized over time like science equipment - he could consider to take powerful enough MCU, put interpreter on it - so engineers/scientists or just customers can rapidly tune/change design without help from pro coders.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #40 on: October 10, 2022, 10:54:29 pm »
For case insensitive languages with ASCII alphanumeric identifiers (that begin with a letter), there are 34,658 identifiers up to three characters long, 1,247,714 up to 4 characters long, and 44,917,730 up to 5 characters long.  The initial character takes 4.70 bits, and each succeeding character 5.17 bits.  You can fit any one- or two-character identifier in ten bits, or any three-character one in just over 15 bits.  Up to four characters fit in 21 bits, five in 26 bits, and six in under 31 bits.

If identifiers are case-sensitive, start with a letter, and contain letters, digits, underscore, and one other character (say '.'), the identifiers are basically base-64 digits (except the initial digit is limited to first 52 or 54 values, as digits cannot start an identifier).  Each character then takes exactly 6 bits, so one can fit four of these in a 24-bit word, or five in a 30-bit word.

This kind of perfect hashing is useful, because it is bijective.  Instead of storing the script as text, one can tokenize it as it is read, and convert tokens back to string if a listing is desired.  This is what old BASIC versions usually did, to save memory.

I personally like to use DJB2 Xor hash instead, because it is trivial, but has few collisions among ASCII alphanumeric strings.  It does mean that there might be more than one string corresponding to each identifier, so I recommend against using it for cases when the user can add new identifiers (like variables).



When you have a microcontroller that reads in new values for state variables from an UART, then the UART receive interrupt can be a simple state machine, that in the state variable name phase just hashes the name; and in the assignment or lookup phase, does a binary search into a sorted array of hashes, with each hash corresponding to a type and a pointer in RAM.  This naturally leads to a command mini-language where each identifier is followed by the command character (= for assignment, ? for query), followed by optional value, followed by end of command character (usually newline).  The array of hashes+types+RAM-pointers can reside in ROM/Flash, and for N entries, 3+⌈log2N⌉ lookups are enough to locate the correct entry, if any.

With GCC and Clang, one can use the section attributes to collect such entries from each compilation unit to a single section at link time.  One then does need to do a custom fixup pass, extracting the section from the target object file, sorting the entries for binary searching, and write the section back.  Extraction and reinsertion is trivial with objcopy (which is part of the development tools used with GCC or Clang), but you do need to sort the binary data (extracted into a separate file, containing only the binary data) yourself using a helper script or program.  Such a fixup pass is also useful for detecting if identifier hashes collide; the sorter does not need to even know the hash algorithm used.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #41 on: October 11, 2022, 12:35:20 am »
For case insensitive languages with ASCII alphanumeric identifiers (that begin with a letter) ... you can fit ... any three-character one in just over 15 bits

Reinventing DEC's RAD50?

There is a reason 6.3 was a popular format for file names.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #42 on: October 11, 2022, 01:44:32 am »
For case insensitive languages with ASCII alphanumeric identifiers (that begin with a letter) ... you can fit ... any three-character one in just over 15 bits
Reinventing DEC's RAD50?

There is a reason 6.3 was a popular format for file names.
Not reinventing, just describing!

The key in my post was that if one has a perfect hash function, or a hash function with only acceptable collisions, then a microcontroller firmware that accepts assignments and responds to queries of named variables does not need an input buffer at all; and that encoding schemes like DEC RADIX-50, and the inverses of Base64 and Base85, can be considered perfect hash functions.  Interpreters can use the perfect (bijective) hashes of the keywords as tokens, too.

One variant of Base32 I've used consists of uniquely identificable letters and digits: 0OQDo, 1Il, 2Zz, 3, 4A, 5Ss, 6Gb, 7, 8B, 9gq, a, Cc, Dd, Ee, Ff, Hh, i, Jj, Kk, L, Mm, Nn, Pp, Rr, Tt, Uu, Vv, Ww, Xx, Yy, dot or decimal point, and leading blank or non-leading underscore.  This uses 5 bits per character, so a 6-character identifier fits in 30 bits nicely.  In a microcontroller, you use a 128-byte array in ROM/Flash to map incoming characters to identifiers, and if you keep only the last 6 characters, you just shift the current hash left by 5 bits and add the next identifier character in the identifier parsing stage.  (If you want to keep only the 6 first characters, only add the current identifier character if the current hash is less than 2²⁵.)
I used it for identifiers like VOL.1, with the express intent that typos like v0l.I and VQI.l are acceptable forms for the same identifier.  Whether you consider it a perfect hash function or an imperfect one is up to discussion, but I consider it perfect hashing with multiple acceptable input forms.
If I recall correctly, HP originally used something like this with 7+ -segment LED displays: so, I definitely didn't invent this either!  :)
« Last Edit: October 11, 2022, 01:47:43 am by Nominal Animal »
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6102
  • Country: gb
  • Doing electronics since the 1960s...
Re: Command languaje for tiny microcontrollers
« Reply #43 on: October 11, 2022, 11:23:56 am »
In 1991 I developed a product which had a Tiny Basic. A few k of code, Z80 asm. Integer only, but usable for byte processing. The same product also has a fairly full Pascal compiler, written in Z80 asm ~1975 and licensed to me for that product; most people ended up using that since it was far faster and better. It took up ~20k. I also implemented a Wordstar compatible editor. All this runs with a VT100 terminal :) And 30 years later it still sells. Most were actually programmed in C, using a compiler on a PC.

You should be able to find a full Basic in C. More or less everybody can use that straight away.

AFAIK Python (C source) is about 50k of ARM32 code and needs another 50k of RAM. Some love Python and the rest don't want it :)

The Q to ask is what is the value of being able to plug in a dumb terminal (there is no such thing; you would have to use a laptop running Teraterm or some such) and write/edit source code in the target. It has a certain intellectual appeal but nowadays it is limited.

Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #44 on: October 11, 2022, 03:34:58 pm »
The Q to ask is what is the value of being able to plug in a dumb terminal (there is no such thing; you would have to use a laptop running Teraterm or some such) and write/edit source code in the target. It has a certain intellectual appeal but nowadays it is limited.

You don't need a PC.

This $36.90 device has a 320x240 colour display (24x40 of 7x9 font with 1 pixel gaps), 192 KB RAM, 4 MB flash, 120 MHz Cortex 4MF, WIFI and Bluetooth, SD card, 40 pin GPIO (Pi compatible), SPI, I2C, I2S, ADC, DAC, PWM, UART, 5-way switch, 3 buttons, accelerometer, light sensor, IR transmitter, microphone, speaker. All in a nice case.

Interface it to a BT keyboard and load appropriate software and it's a literal terminal.

https://www.seeedstudio.com/Wio-Terminal-p-4509.html
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1917
  • Country: se
Re: Command languaje for tiny microcontrollers
« Reply #45 on: October 11, 2022, 03:45:56 pm »
You don't need a PC.
Just a magnifying glass, at 2.4"  :-DD

But apart from the use as a terminal, interesting dev board.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #46 on: October 11, 2022, 06:47:46 pm »
One can always take one of the Linux single-board computers like Orange Pi Lite, compile a monolithic kernel that does not require an initrd to boot, and replace the userspace with a dedicated terminal application.  For eye candy, compile Qt5 for framebuffer and OpenGL ES 2.0, and you get full resolution accelerated graphics with antialiasing, including nice fast font rendering.  This way, you can get boot times down to seconds on many SBCs.

I've got a couple of Linux minilaptops (Acer Aspire One A110L and Asus Eee PC) that I might convert to that use.  Any netbook or laptop with sufficient Linux support works fine for this.  They could be fast enough for use as X11 terminals over Ethernet, too, although their resolution is typically 1024×600 to 1366×768, maybe down to 800×480 on the Eee PC; I'd need to check the version.  The BIOS part of their boot sequence is quite slow, though.

The userspace integration work begins at the init system.  Systemd is slow and resource-hungry, and not needed in appliance use.  You can write an init script that starts needed services in sequence where necessary, and the rest in parallel, to minimize boot time.  (If you want Ethernet or WiFi, or device detection on plug-in, you do need a few service daemons running.)  It's interesting stuff, too; perfect for someone interested in embedded appliance development as a proof of concept or portfolio example.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #47 on: October 11, 2022, 09:15:50 pm »
You don't need a PC.
Just a magnifying glass, at 2.4"  :-DD

167 PPI. That's the same as my 17" MacBookPro (pre "retina") on which I run 9 pt Monaco / ProFont / Ubuntu Mono no problems.
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1917
  • Country: se
Re: Command languaje for tiny microcontrollers
« Reply #48 on: October 11, 2022, 10:04:32 pm »
167 PPI. That's the same as my 17" MacBookPro (pre "retina") on which I run 9 pt Monaco / ProFont / Ubuntu Mono no problems.
So you are telling me that a pixel drawn 9/167x25.4 = 1.37 mm height (and that's for the tallest letters, the x height is about half!)  font is legible in an useful way.

To this I there's only one reasonable answer: I'm green with envy for your eyesight.

AFAIK, the 17" Macbook Pro has a 1920x1200 resolution, that puts it more in the 133 ppi range; in any case, a correctly rendered 9 points font will be about 3.2 mm independent of screen resolution.

A 9 pixels font will instead be 1.72 mm, still awfully small, but 25% larger, and overall better especially considering the difference in quality of the panels.

The original "bitmapped 9pt" was designed for the original Mac, that had about 72 ppi, i.e. 1 pixel = 1 point.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #49 on: October 11, 2022, 10:56:44 pm »
167 PPI. That's the same as my 17" MacBookPro (pre "retina") on which I run 9 pt Monaco / ProFont / Ubuntu Mono no problems.
Sure, but 9pt is 21 pixels tall at 167 PPI  (1 pt = 1"/72 = 0.352778 mm).

At 167 PPI, an 8px × 9px font is 1.22mm×1.37mm or 3.9 pt, and 8 px × 10 px font is 1.22mm×1.53mm or 4.3 pt.  These give you a 40×26 or 40×24 character display on a 320×240 pixel display module.

I do believe the smallest size considered legible in newspapers is one Agate, or 5.5 pt, or about 1"/13 ≃ 1.95mm.  (This size being the full line height, just like when considering fixed-width or variable-width but fixed-height bitmap fonts.)
« Last Edit: October 11, 2022, 11:01:01 pm by Nominal Animal »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->