TEK 4010/4014 Vector Graphics terminal DEMO

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

TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Fri Jul 14, 2017 6:43 pm

The old style vector graphics terminals are still in use, at least here :)
Here is the TEK 4010/14 you may get at ebay most probably..

https://www.youtube.com/watch?v=IztxeoHhoyM

Have a look at the beautiful way those old vector graphics terminals worked.. 8-)

https://en.wikipedia.org/wiki/Tektronix_4010

To try with vector based graphics at home, and today, you may try the simple Demo below - all you need is a BluePill or something like that and TeraTerm terminal, or something like that.. :)

UPDATE: added printing out the elapsed time, added GIN, added Sprites, added defines for colors, line styles and font sizes

Code: Select all

// A simple TEK4010/4014 Graphics Vector terminal - DEMO
// You need ie. TeraTerm or Xterm switched into TEK4010/14 Emulation
// The current vector's addressing is 1024x1024 (10bit)
//
// Loosely inspired by
// http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdisp.html
// and other related information found on the web
//
// Provided as-is, no warranties of any kind are provided :)
// by Pito 7/2017

#include "Arduino.h"

void setup() {
    delay(3000);  // Wait for USB
    Serial.begin(115200);
    }

void loop() {

  // Draw some primitives on the screen for fun
  // Origin (0,0) is the left bottom corner, y| __x

	uint32_t elapsed = micros();
	
  Tekcls();
  Tekcolor(2);
  Tekgraph(4);
  Tekpoint(100, 100);
  Tekpoint(200, 100);
  Tekpoint(200, 200);
  Tekpoint(100, 200);

  Tekcolor(3);
  for (uint32_t i = 300; i < 500; i = i + 10) {
    Tekline(i, 400, i, 600);
  }

  Tekstyle(0);

  Tekline(300, 300, 500, 500);
  Tekstyle(1);
  Tekline(600, 400, 200, 300);
  Tekstyleb(2);
  Tekcolor(7);
  Tekplot(10, 700);
  Tekplot(500, 30);
  Tekstyle(3);
  Tekline(400, 600, 100, 800);
  Tekcolor(4);
  Tekstyleb(4);
  Tekplot(300, 330);

  Tekalpha();

  Tekfont(1);
  Teklocate(700, 400);
  Tekcolor(6);
  Serial.println("Hello World !!");

  Tekfont(2);
  Tekcolor(1);
  Teklocate(700, 300);
  Serial.println("STM32duino !!");

  Tekfont(0);
  Tekcolor(2);
  Teklocate(500, 200);
  Serial.println("THIS IS A TEST OF TEK4014 !!");

  Tekcolor(1);
  Tekstyle(0);
  Tekbox(300, 200, 600, 600);

  Tekcolor(2);
  Tekstyle(0);
  Tekdot(150, 150);

  uint32_t i;

  for (i = 0; i < 360; i++) {
    float q = i;
    q = 3.141592f * q / 180.0f;
    float r = cosf(q);
    q = sinf(q);
    q = q * 120.0f;
    q = q + 195.0f;
    r = r * 120.0f;
    r = r + 580.0f;
    Tekdot((uint16_t) r, (uint16_t) q);
  }

  Tekcolor(5);

  for (i = 0; i < 360; i++) {
    float q = i;
    q = 3.141592f * q / 180.0f;
    q = sinf(q);
    q = q * 150.0f;
    q = q + 195.0f;
    float r = i + 30.0f;
    Tekdot((uint16_t) r, (uint16_t) q);
  }

  uint32_t a = 450;
  for (i = 1; i < 34; i++) {
    Tekline(0, 450, 1000, a);
    a = a + 10;
  }
  
  Tekalpha();
  Teklocate(400, 100);

  elapsed = micros() - elapsed;
  Serial.print("Elapsed: ");
  Serial.print(elapsed);
  Serial.println(" micros");

  delay(5000);
}

// ********************************************************
// TEK4010/4014 basic 10bit commands library
// For details consult the TEK4010/4014 manual
// Pito 7/2017 for stm32duino
// ********************************************************

// Colors for print, plot, dot
#define black 0
#define red 1
#define green 2
#define yellow 3
#define blue 4
#define magenta 5
#define cyan 6
#define white 7

// Line styles
#define solid 0
#define dotted 1
#define dash_dotted 2
#define short_dashed 3
#define long_dashed 4

// Font sizes
#define large 0
#define normal 1
#define small 2
#define smallest 3

// Clear Tek screen
void Tekcls() {
  Serial.write(0x1B);
  Serial.write(0x0c);
//Serial.write(0x0d);Serial.write(0x0a);
}

// Select a color (0-7)
void Tekcolor(uint8_t color) {
  Serial.write(0x1B);
  Serial.write(0x5b);
  Serial.write(0x33);
  Serial.write(0x30 + color);
  Serial.write(0x6d);
}

// Switch to graphical mode with a line style (0-4)
void Tekgraph(uint8_t style) {
  Serial.write(0x1D);
  Serial.write(0x1B);
  Serial.write(style | 0x60);
}

// Select a font size (0-3) for printing alphanumeric strings
// The actual font type has to be set in the Emulator
void Tekfont(uint8_t fontsize) {
  Serial.write(0x1B);
  Serial.write(0x38 + fontsize);
}

// Normal style lines (0-4)
void Tekstyle(uint8_t style) {
  Serial.write(0x1B);
  Serial.write(0x60 + style);
}

// Bold style lines (??)
void Tekstyleb(uint8_t style) {
  Serial.write(0x1B);
  Serial.write(0x68 + style);
}

// Switch to alphanumeric mode
void Tekalpha() {
  Serial.write(0x1f);
}

// Draw a point as a small cross (??)
void Tekpoint(uint16_t x, uint16_t y) {
  Serial.write(0x1C);  // FS
  Serial.write(0x20 + ((y >> 5) & 0x1F));
  Serial.write(0x60 + ((y) & 0x1F));
  Serial.write(0x20 + ((x >> 5) & 0x1F));
  Serial.write(0x40 + ((x) & 0x1F));
}

// Draw a single dot
void Tekdot(uint16_t x, uint16_t y) {
  Serial.write(0x1D);  // GS
  Serial.write(0x20 + ((y >> 5) & 0x1F));
  Serial.write(0x60 + ((y) & 0x1F));
  Serial.write(0x20 + ((x >> 5) & 0x1F));
  Serial.write(0x40 + ((x) & 0x1F));
  Serial.write(0x40 + ((x) & 0x1F));
}

// Draw a line from (x1, y1) to (x2, y2)
void Tekline(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
  Serial.write(0x1D);  // GS
  Serial.write(0x20 + ((y1 >> 5) & 0x1F));
  Serial.write(0x60 + ((y1) & 0x1F));
  Serial.write(0x20 + ((x1 >> 5) & 0x1F));
  Serial.write(0x40 + ((x1) & 0x1F));
  Serial.write(0x20 + ((y2 >> 5) & 0x1F));
  Serial.write(0x60 + ((y2) & 0x1F));
  Serial.write(0x20 + ((x2 >> 5) & 0x1F));
  Serial.write(0x40 + ((x2) & 0x1F));
}

// Continue with drawing a line to (x1, y1)
void Tekplot(uint16_t x1, uint16_t y1) {
  Serial.write(0x20 + ((y1 >> 5) & 0x1F));
  Serial.write(0x60 + ((y1) & 0x1F));
  Serial.write(0x20 + ((x1 >> 5) & 0x1F));
  Serial.write(0x40 + ((x1) & 0x1F));
}

// Locate a point where to print a string
void Teklocate(uint16_t x1, uint16_t y1) {
  Serial.write(0x1D);  // GS
  Serial.write(0x20 + ((y1 >> 5) & 0x1F));
  Serial.write(0x60 + ((y1) & 0x1F));
  Serial.write(0x20 + ((x1 >> 5) & 0x1F));
  Serial.write(0x40 + ((x1) & 0x1F));
  Tekalpha();
}

// Draw a box with left bottom corner at (bx, by) and top right corner at (tx, ty)
void Tekbox(uint16_t bx, uint16_t by, uint16_t tx, uint16_t ty) {
  Tekline(bx, by, tx, by);
  Tekplot(tx, ty);
  Tekplot(bx, ty);
  Tekplot(bx, by);
}

// Draw small sprites
void Teksprite(char* sprite) {
  Serial.write(0x1E);
  Serial.print(sprite); 
}

// Go to the Graphics-IN mode
void Tekgin() {
  Serial.write(0x1B);
  Serial.write(0x1A);
}
TEK4014 DEMO.jpg
TEK4014 DEMO.jpg (116.04 KiB) Viewed 376 times
The default size of the screen is 1024 x 780, but maybe it could be switched to 4k x 4k (with 12bit vector addressing).
There is a lot of other Tek functionality hidden to me today (ie. you can click with mouse on the Tek screen and it sends back the actual mouse position via serial - like a light pen), thus our talented programmers may take over and create a library, when required.
Last edited by Pito on Tue Jul 18, 2017 11:40 am, edited 30 times in total.
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector terminal DEMO

Post by ChrisMicro » Fri Jul 14, 2017 8:39 pm

Interesting, I didn't know that Teraterm understands TEK4010/4014.
Some time ago I adapted mcurses:
https://github.com/ChrisMicro/mcurses

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

Re: TEK 4010/4014 Vector terminal DEMO

Post by Pito » Sat Jul 15, 2017 9:04 am

Not only TeraTerm understands Tek4010/4014 vector graphics, but "xterm" too.
Linux users may try..
Xterm:
The Tektronix 4014 emulation is also fairly good. It supports 12-bit graphics addressing, scaled to the window size. Four different font sizes and five different lines types are supported.
12bit vector addressing requires small changes in the routines (I currently use 10bits for x and y), but allows you to draw at 4096x4096 large screen.. You can hardly get such a TFT connected to your BluePill soon.. :P
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Sat Jul 15, 2017 12:26 pm

And a .bin for F103 (96kB) with more action on the screen..:)
SerialUSB. Set font to Lucida or Consolas in the Tek window for a better retro look ..
TEK4014_DEMO.rar
(48.92 KiB) Downloaded 6 times
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Sun Jul 16, 2017 7:10 am

Updated above bin with new USB driver. You have to get about 61msecs with first screen.
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by ChrisMicro » Mon Jul 17, 2017 9:12 am

Just for fun I added you TEK-functions to GuiPiitx:
https://github.com/ChrisMicro/GuiPittix ... _wrapper.h
Now the LED blinking example and the number example can drive the TEK-display ( dynamically :D ).
The other examples require a touch-input which I could not achieve with teraterm. It seems when I click on the teraterm window it is not sending back the mouse position.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 17, 2017 10:11 am

In order to get the mouse position, you shall first switch into GIN mode.
Not tested:

Code: Select all

// Go to the Graphics-IN mode
void Tekgin() {
  Serial.write(0x1B);
  Serial.write(0x1A);
}
In the GIN mode you have to get mouse cursor in form of a cross-hair, and when a keyboard button is pressed (or mouse is clicked) it returns the code of the button (1st char) and then 4 chars with the cross-hair position within the Tek window.
Last edited by Pito on Mon Jul 17, 2017 11:13 am, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 17, 2017 11:08 am

With this quick hack you may see you get data off the mouse movements and clicking/pressing buttons in GIN mode:

Code: Select all

  char b0, b1, b2, b3 , b4;
  Tekgin();  // set the Graphics-IN mode
  Teklocate(200, 600);  // from here we want printout results
  while(1) {
    Tekgin();  // GIN mode
    if (Serial.available() > 0) b0 = Serial.read();  // Get pressed buttons/mouse code
    if (Serial.available() > 0) b1 = Serial.read();  // cross hair coordinates
    if (Serial.available() > 0) b2 = Serial.read();  // cross hair coordinates
    if (Serial.available() > 0) b3 = Serial.read();  // cross hair coordinates
    if (Serial.available() > 0) b4 = Serial.read();  // cross hair coordinates
    Tekalpha();  // go to alpha mode
    Tekfont(2);
    Tekcolor(6);
    Serial.print(b0, HEX);Serial.print("   ");  // print out the stuff
    Serial.print(b1, HEX);Serial.print(" ");
    Serial.print(b2, HEX);Serial.print(" ");
    Serial.print(b3, HEX);Serial.print(" ");
    Serial.println(b4, HEX);
    delay(500);
  }
GIN TEK mode.JPG
GIN TEK mode.JPG (77.2 KiB) Viewed 249 times
You have to find the way how to interpret the data :)
Last edited by Pito on Mon Jul 17, 2017 11:40 am, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 17, 2017 11:33 am

There is also an "Incremental plot mode" for drawing smaller "sprites" :P
Not tested.

Code: Select all

// Draw small sprites
void Teksprite(char* sprite) {
  Serial.write(0x1E);
  Serial.print(sprite); 
}
Where the sprite creation is coded within the string by following chars:

Code: Select all

P - beam on
space - beam off
A, B, D, E, F, I, J, H - 45deg vector directions in 6 points displacements, the vector's 
direction like

 F  D  E
B       A
 J  H  I
A string like "PAAAAAADDDDDDBBBBBHHHHHH" will draw a small 36x36 points large box..
Last edited by Pito on Mon Jul 17, 2017 3:30 pm, edited 2 times in total.
Pukao Hats Cleaning Services Ltd.

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

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by ChrisMicro » Mon Jul 17, 2017 2:53 pm

Pito, where did you find the specification?
I found some github resource which could be useful.

Post Reply