TEK 4010/4014 Vector Graphics terminal DEMO

Post your cool example code here.
User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Sun Jul 23, 2017 10:44 am

@Roger: Thanks!
The next improvements could be:
1. introducing ie Tekplotv and Tekploth - vertical and horizontal lines with short addressing
2. Tekbox with short addressing
4. introducing the 12bit mode
5. when talking "a perfect library" - the most difficult part would be to create a mechanism for a redraw of the the dynamic information on the Tek screen by overwriting it by the background ink color and printing the new one.
It is basically easy with a couple of values, but when you draw a lot of strings, arrays (in form of lines/dots/sprites), you have to memorize all the "old_values", and when they change and need to be print out you have to rewrite their picture with the old_value (with background ink color) on the exact same place and print the new value with the actual ink color on the exact same place..
And it is not only a single action like Serial.print or Tekplot(), but it could be a process - ie. to redraw a "spectrum", "waves", small picture..
Not easy..
There is a workaround of course - you can Tekcls() and draw a new complete picture with new values, it is fast enough for most apps.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Sun Jul 23, 2017 12:08 pm

Another demo you may try or add to the library.
Attachments
TEK4014_DEMO.rar
(35.66 KiB) Downloaded 9 times
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6907
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Sun Jul 23, 2017 11:10 pm

That demo worked OK for me.

I just put the library files into a folder inside the libraries folder

I wonder if there should be a function to display the text. I know that Serial.print and serial.println work fine, but it seems strange to not need a TEK specific command to do this

I may just add tek.print and tek.println which just call serial.print and serial.println

Also I think it may be useful to pass the serial port to the library as its hard coded to "Serial"

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 8:24 am

I may just add tek.print and tek.println which just call serial.print and serial.println
Yes, that is ok.
There is one issue with Serial.print - it cannot print the scientific notation - like: -3.45E-6.
So we have to use something instead, which can do..

PS: the Tek terminal, when in alpha mode (Tekalpha()), works like a standard "char based terminal".
The font size parameter (Tekfont(), see our defines in lib) determines its lines/chars volume:

large - 35 lines of 74 characters
normal - 38 lines of 81 characters
small - 58 lines of 121 characters
smallest - 64 lines of 133 characters

The actual font type used could be set in Tek's Setup->Font.
The color emulation and the background color could be set in Tek's Setup -> Window.
Last edited by Pito on Mon Jul 24, 2017 10:06 am, edited 7 times in total.
Pukao Hats Cleaning Services Ltd.

ChrisMicro
Posts: 296
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by ChrisMicro » Mon Jul 24, 2017 8:42 am

I may just add tek.print and tek.println which just call serial.print and serial.println
I did this here.
So all Adafruit-GFX functions use the TEK Terminal as output.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 8:52 am

@Chris: mind the tek terminal is not well suited for drawing filled primitives, as there is not such command afaik..
Adafruit is pixel-oriented, tek is vector oriented with the "draw a line from A,B to C,D" as the only graphics primitive..
Rendering adafruits demos with tek emulation may work, but it will take ages, I would guess :)
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 10:22 am

This is a test of alpha terminal mode.

Code: Select all

// A simple TEK4010/4014 Vector terminal DEMO
// You need TeraTerm or Xterm switched to TEK4010/14 Emulation
//
// Use fast Serial over USB for best experience
//
//  Shows alpha terminal mode
//
// Provided as-is, no warranties of any kind are provided :)
// by Pito 7/2017

#include "Arduino.h"
#include "Tek.h"

TEK tek;

void setup() {
  delay(3000);
  Serial.begin(115200);
}

void loop() {

  uint32_t i;

  tek.Tekcls();

  tek.Tekfont(normal);
  tek.Tekcolor(yellow);
  tek.Tekalpha();
  tek.Teklocate(100, 700);

  for (i = 0; i < 20; i++) {
    Serial.println("Hello World from STM32duino!");
  }

  delay(2000);

  tek.Tekcolor(cyan);
  char* sprite;
  // Type 26 frigate
  sprite = "PAAAAAAAAAAAAAADDBBBDDBBBHHBBBDDBBBHHBBHH";
  tek.Tekgraph(solid);
  for(i=350; i<480; i=i+20){
    for(uint32_t a=300; a<400; a=a+20){
      tek.Teklocate(i, a);
      tek.Teksprite(sprite);
    }
  }

  delay(2000);

  tek.Tekfont(smallest);
  tek.Tekcolor(green);
  tek.Tekalpha();
  tek.Teklocate(100, 300);

  for (i = 0; i < 80; i++) {
    Serial.println("This is a test of Tek Terminal..");
  }

  delay(5000);

}
I would have expected that with the Teklocate(x,y) the "virtual terminal window" stays in the proper "frame", but after println the next line starts at the very left..
A feature or a bug??
Tek Alpha terminal mode.JPG
Tek Alpha terminal mode.JPG (116.81 KiB) Viewed 162 times
Last edited by Pito on Mon Jul 24, 2017 10:54 am, edited 2 times in total.
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6907
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Mon Jul 24, 2017 10:50 am

@pito

We could write some code to turn a scientific notation numbers into a string before sending to serial.print

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 11:01 am

@Roger: here is the float2string code I used to use within our fpu exercise..
I have to double check as there is a davekw7x version floating around which has got a bug.
http://www.stm32duino.com/viewtopic.php ... =60#p26771
This version below shall utilize the single precision FPU when on.
UPDATE: chnged to 7 digits, fair enough for the single precision..

Code: Select all

// ====== float2s(): print out up to 7 digits of input single-precision value
// This version enables single-precision for STM32duino, Teensy 3, etc.
// from double2s version by J.Beale March 2013
// modified from original float2s() posted by davekw7x on December, 2010
// http://arduino.cc/forum/index.php/topic,46931.0.html
// Modded for single precision floats with FPU by Pito 4,7/2017
// No warranties of any kind, provided as-is..

char * float2s(float f)
{
 return float2s(f, 2);
}

char * float2s(float f, unsigned int digits) {
int d;
static char s[26];  // formatted number as string
int index=0;

 // handle sign
 if (f < 0.0f)
 {
   s[index++] = '-';
   f = -f;
 }
 // handle infinite values
 if (isinf(f))
 {
   strcpy(&s[index], "INF");
   return s;
 }
 // handle Not a Number
 if (isnan(f))
 {
   strcpy(&s[index], "NaN");
   return s;
 }

 // max digits
 if (digits > 7) digits = 7;
 int exponent = int(log10f(f));
 float g = f / powf(10.0f, exponent);
 if ((g < 1.0f) && (g != 0.0f))
 {
   g *= 10.0f;
   exponent--;
 }
// if (exponent < -330) {  // lower limit of double-precision on Teensy 3
  if (exponent < -38) { 
   g = 0.0f;
   exponent = 0;
 }
 if (digits < 7) {  // display number rounded at last digit
   g += 0.5f / powf(10.0f,digits);
 }

 d = g;
 sprintf(&s[index++],"%d",d);
 if (digits > 0) sprintf(&s[index++],".");
 for (int i=0;i<digits;i++) {
     g = (g - d) * 10.0f;  // shift one decimal place to the left
     d = int(g);
     sprintf(&s[index++],"%d",d);
 }
 sprintf(&s[index], "e%+d", exponent);
 return s;
} // ===== end float2s()

Code: Select all

// A simple TEK4010/4014 Vector terminal DEMO
// You need TeraTerm or Xterm switched to TEK4010/14 Emulation
//
// Use fast Serial over USB for best experience
//
//  Shows single precision scientific mode
//
// Provided as-is, no warranties of any kind are provided :)
// by Pito 7/2017

#include "Arduino.h"
#include "Tek.h"

char * float2s(float f);
char * float2s(float f, unsigned int digits);

TEK tek;

void setup() {
  delay(3000);
  Serial.begin(115200);
}

void loop() {

  uint32_t i;

  tek.Tekcls();

  tek.Tekcolor(cyan);
  char* sprite;
  // Type 26 frigate
  sprite = "PAAAAAAAAAAAAAADDBBBDDBBBHHBBBDDBBBHHBBHH";
  tek.Tekgraph(solid);
  for (i = 350; i < 480; i = i + 20) {
    for (uint32_t a = 300; a < 400; a = a + 20) {
      tek.Teklocate(i, a);
      tek.Teksprite(sprite);
    }
  }

  delay(2000);

  tek.Tekfont(smallest);
  tek.Tekcolor(green);
  tek.Tekalpha();
  tek.Teklocate(0, 700);

  float x = -3.141592e+38f;

  for (i = 0; i < 75; i++) {
    Serial.print("X= ");
    x = x / 10.0f;
    // Serial.println(float2s(x, 3));
    Serial.println(float2s(x, 7));
  }

  delay(5000);

}

// ====== float2s(): print out up to 7 digits of input single-precision value
// This version enables single-precision for STM32duino, Teensy 3, etc.
// from double2s version by J.Beale March 2013
// modified from original float2s() posted by davekw7x on December, 2010
// http://arduino.cc/forum/index.php/topic,46931.0.html
// Modded for single precision floats with FPU by Pito 4,7/2017
// No warranties of any kind, provided as-is..

char * float2s(float f)
{
 return float2s(f, 2);
}

char * float2s(float f, unsigned int digits) {
int d;
static char s[26];  // formatted number as string
int index=0;

 // handle sign
 if (f < 0.0f)
 {
   s[index++] = '-';
   f = -f;
 }
 // handle infinite values
 if (isinf(f))
 {
   strcpy(&s[index], "INF");
   return s;
 }
 // handle Not a Number
 if (isnan(f))
 {
   strcpy(&s[index], "NaN");
   return s;
 }

 // max digits
 if (digits > 7) digits = 7;
 int exponent = int(log10f(f));
 float g = f / powf(10.0f, exponent);
 if ((g < 1.0f) && (g != 0.0f))
 {
   g *= 10.0f;
   exponent--;
 }
// if (exponent < -330) {  // lower limit of double-precision on Teensy 3
  if (exponent < -38) {
   g = 0.0f;
   exponent = 0;
 }
 if (digits < 7) {  // display number rounded at last digit
   g += 0.5f / powf(10.0f,digits);
 }

 d = g;
 sprintf(&s[index++],"%d",d);
 if (digits > 0) sprintf(&s[index++],".");
 for (int i=0;i<digits;i++) {
     g = (g - d) * 10.0f;  // shift one decimal place to the left
     d = int(g);
     sprintf(&s[index++],"%d",d);
 }
 sprintf(&s[index], "e%+d", exponent);
 return s;
} // ===== end float2s()
Tek scifi float.JPG
Tek scifi float.JPG (57.4 KiB) Viewed 147 times
Tek scifi float 3digits.JPG
Tek scifi float 3digits.JPG (48.54 KiB) Viewed 137 times
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 3:52 pm

In this 25y+ old newsgroup board
ftp://invisible-island.net/shuford/term ... x_news.txt
I found some info on the GIN mode and mouse coordinates:

Code: Select all

There are 2 modes of reading the GIN co-ordinates, interactive and
non-interactive.

Interactive mode: the Xhair cursor is displayed, the operator moves it
to the required position and then presses a key (NOT the return key!).
A sequence of bytes is sent to the computeras follows:

The ASCII value of the key pressed e.g. D
HiX byte - 01 followed by the 5 most significant X bits
LoX byte - 01 followed by the 5 least significant X bits
HiY byte - 01 followed by the 5 most significant Y bits
LoY byte - 01 followed by the 5 least significant Y bits

This sequence is followed by the termination character(s) as set by
a jumper set on the TC2 card within the terminal. The most common
setting is to send the CR character.

To recreate the X and Y values:

X=(32*(HiX-32))+(LoX-32)
Y=(32*(HiY-32))+(LoY-32)

In non-interactive mode the computer sends <ESC><ENQ>. The sequence
returned is as above, except that the keycode is replaced by a status
byte, this gives information as to whether the terminal is in Alpha,
Graphics or GIN mode. I cannot at the moment remember which bit does
what.
I've seen somewhere the mouse buttons send 3 codes (left, mid, right), but I cannot find that again..

Also mentioned there:
https://ftp.gnu.org/gnu/plotutils/plotutils-2.6.tar.gz - various plot utilities related to tek as well
http://aminet.net/package/misc/fish/fish-0165 - includes plot2tek utility (from unix plot format to tek format)

And, finally :D , I've downloaded the TeraTerm's source code and briefly read the tek sources:
1. it has also a "Marker" mode with 11 types of markers (marker, alpha, graphics, vector modes)
2. it can do 15 colors
3. it can do 11 line styles
4. it can do 12bit mode
5. the incremental mode (sprites) are in 4points steps, not 6
6. it returns mouse positions as above, plus/minus :)
etc..
Last edited by Pito on Mon Jul 24, 2017 5:07 pm, edited 6 times in total.
Pukao Hats Cleaning Services Ltd.

Post Reply