#garfield Logs
Apr 06 2025
#garfield Calendar
12:16 AM rue_mohr: ok, but for converter?
12:31 AM rue_mohr: I like that a single 18650 is enough power for most things
12:31 AM rue_mohr: trying to manage the charge/discharge of a battery sucks, but you cant complain much without being told to just use a disposable battery
07:50 AM rue_mohr: cat asks for out COMES BACK WITH A MOUSE AND DROPS IT IN THE HOUSE, ALIVE.
07:51 AM * rue_mohr catches and evicts mouse
01:00 PM aandrew: hahahahaha
02:16 PM rue_mohr: ok
02:16 PM rue_mohr: I got it working, kinda
02:16 PM rue_mohr: I can draw a set of lines in librecad, import them to inkscape, save it as HPGL, and convert it to TEK4010 drawing sequences
02:17 PM rue_mohr: but I need to re-work the way the units are done in the middle
02:22 PM rue_mohr: tom
02:22 PM rue_mohr: hey
02:22 PM rue_mohr: still driving?
02:23 PM Tom_L: you reverse programed your cat
02:23 PM rue_mohr: heh
02:24 PM rue_mohr: I'm starting to be convinced they brought in that rat
02:24 PM rue_mohr: pretty big tho
02:24 PM Tom_L: middle of the gulf
02:24 PM rue_mohr: of mexico!
02:25 PM rue_mohr: a bit wet to drive out there isn't it?
02:26 PM Tom_L: No
02:26 PM Tom_L: Of america!!!!
02:26 PM rue_mohr: oh where is that? I'v never heard of it before!
02:28 PM Tom_L: South of you somewhere
02:29 PM rue_mohr: a warmer places
02:29 PM Tom_L: there was snow today back home
02:30 PM Tom_L: 75F here
02:30 PM rue_mohr: !?
02:30 PM rue_mohr: wow
02:30 PM rue_mohr: we have a moderate amount of rain
02:36 PM Tom_L: surprised the bits float as good as they do in the middle of the gulf
03:52 PM polprog: the cat just brought you the mouse as a gift
03:52 PM polprog: they do that
03:52 PM polprog: he caught it for you
03:57 PM rue_mohr: he didn't bring it to me
03:57 PM rue_mohr: just released it in the house
03:57 PM rue_mohr: and when I said !!!!! MOUSE!
03:57 PM rue_mohr: he just sat there will it ran round
03:58 PM rue_mohr: FFF****er
03:58 PM rue_mohr: hey
03:58 PM rue_mohr: I can make a dxf, convert it to hpgl with inkscape, and convert it to tek4010 escape drawing codes
03:58 PM polprog: nice
03:59 PM rue_mohr: if I had a spaceship 3d vector set, I could project it and run an rotating animation...
03:59 PM rue_mohr: like in 3d
03:59 PM rue_mohr: BUT
04:00 PM rue_mohr: polprog, why this is cool, is because the escape sequence can come from a microcontroller!!!
04:00 PM polprog: ohhh
04:01 PM polprog: right, you can just run picocom in xterm and have it switch to tek mode
04:01 PM polprog: damn
04:01 PM polprog: thats genius actually
04:01 PM rue_mohr: I'm going to use it to draw some gauges from the micro to the PC terminal
04:01 PM rue_mohr: / Encode a coordinate pair in Tektronix 4010 format
04:01 PM rue_mohr: void EncodePoint(int x, int y) {
04:01 PM rue_mohr: x = Limit(x, 0, 1023);
04:01 PM rue_mohr: y = Limit(y, 0, 767);
04:01 PM rue_mohr: printf("%c",((y >> 5) + 0x20));
04:01 PM rue_mohr: printf("%c",((y & 31) + 0x60));
04:01 PM rue_mohr: printf("%c",((x >> 5) + 0x20));
04:01 PM rue_mohr: printf("%c",((x & 31) + 0x40));
04:01 PM rue_mohr: }
04:02 PM rue_mohr: / change TEK4010 mode
04:02 PM rue_mohr: const char VT_4010_MODE[] = "\x1B[?38h";
04:02 PM rue_mohr: const char VT_100_MODE[] = "\x1B[?38l";
04:02 PM rue_mohr: const char VT_4010_STARTPATH[] = "\x1D";
04:02 PM rue_mohr: const char VT_4010_ALPHA[] = "\x1F";
04:02 PM rue_mohr: const char VT_4010_SHOWCURSOR[] = "\x1B\x1A";
04:02 PM rue_mohr: const char VT_4010_REQUESTPOS[] = "\x1B\x05";
04:02 PM rue_mohr: const char VT_4010_GIN[] = "\x1B[?38h";
04:02 PM rue_mohr: const char VT_4010_ERASE[] = "\x1B\x0C";
04:05 PM polprog: then you should make a micro with a TFT that reads tek4010 codes and draws them
04:05 PM rue_mohr: it animates fast too, clearing and redrawing at 2ms is ok
04:05 PM rue_mohr: hah, rather just use the PC
04:21 PM rue_mohr: I need to come up with an encoded position offset function
04:50 PM polprog: nice
05:58 PM rue_mohr: polprog, cat this in xterm! :]
05:58 PM rue_mohr: http://ruemohr.org/%7Eircjunk/programming/foo.esc
05:58 PM rue_mohr: it should draw ok
05:59 PM rue_mohr: on the apple IIe, there used to be vector drawing things
05:59 PM rue_mohr: and this is really reminding me of it
05:59 PM rue_mohr: but I cant scale/rotate :/
05:59 PM rue_mohr: and the sequences dont just have encoding for 'pick up pen and restart over here'
06:00 PM rue_mohr: 00000000 1b 5b 3f 33 38 68 1b 0c 1d 24 7f 24 58 24 7f 25 |.[?38h...$.$X$.%|
06:00 PM rue_mohr: 00000010 47 1d 25 7f 24 50 25 7f 25 4f 1d 26 7f 24 58 26 |G.%.$P%.%O.&.$X&|
06:00 PM rue_mohr: 00000020 7f 25 47 1d 27 7f 24 50 27 7f 25 4f 1d 28 7f 24 |.%G.'.$P'.%O.(.$|
06:01 PM rue_mohr: the second 1b 0c 1d starts a new line
06:01 PM rue_mohr: er, no, thats screen erase...
06:01 PM rue_mohr: uh
06:01 PM rue_mohr: oh, the 1d is the start new line
06:03 PM rue_mohr: all the co-ordinate bytes are higher than 0x20
06:03 PM rue_mohr: gee it would be fun to have someone to hack with
06:05 PM rue_mohr: my idea is to save the text stream on the controller, and have it be able to xy offset it during streaming
06:05 PM rue_mohr: but
06:05 PM rue_mohr: I'm not sure it saves work
06:05 PM rue_mohr: every xy point is 4 bytes
06:05 PM rue_mohr: which means I need a state machine that does all the work anyhow
06:05 PM rue_mohr: or
06:05 PM rue_mohr: or does it
06:05 PM rue_mohr: if I'm offsetting a whole sprite, I only need to calc the offset once
06:07 PM rue_mohr: so, I start in a pass-mode wait for 1D, then go into a 4 byte fsm modify mode untill the next byte is less than 0x20
06:07 PM rue_mohr: suppose I should make sprite strings and try it
06:09 PM polprog: rue_mohr: yeah, its pretty cool!
06:09 PM polprog: draws OK!
06:09 PM rue_mohr: hah neat
06:09 PM polprog: gotta go to sleep
06:09 PM rue_mohr: any line-only inkscape stuff can be converted
06:09 PM rue_mohr: no curve support
06:10 PM polprog: cool
06:10 PM aandrew: rue_mohr> I can make a dxf, convert it to hpgl with inkscape, and convert it to tek4010 escape drawing codes
06:11 PM rue_mohr: yea, so any entry point into inkscape is ok, but again, no curve support
06:11 PM aandrew: not enough steps. I think you should convert it to a PDF, do the OCR on any text and then create vector commands to draw it
06:11 PM rue_mohr: hah
06:12 PM aandrew: I kind of need to see the result, is this a vector CRT or something?
06:12 PM rue_mohr: tektronix 4010
06:13 PM rue_mohr: they support it in xterm
06:59 PM rue_mohr: ah, cool, becasue the sprite is just a string, I can have one pointer that is loaded with whatever sprite I want
07:06 PM rue_mohr: loadSprite(temp, Guage);
07:06 PM rue_mohr:
07:06 PM rue_mohr: printf("%s", temp);
07:06 PM rue_mohr:
07:06 PM rue_mohr: offsetSprite(temp, 128, 0);
07:06 PM rue_mohr: printf("%s", temp);
07:06 PM rue_mohr:
07:06 PM rue_mohr: offsetSprite(temp, 128, 0);
07:06 PM rue_mohr: printf("%s", temp);
07:06 PM rue_mohr: OH YEA!
07:07 PM rue_mohr: I'm slightly going the wrong direction this is aimed at PC code, but I'm not too far off course yet
07:12 PM rue_mohr: https://paste.debian.net/1367921/
08:14 PM rue_mohr: arg
08:14 PM rue_mohr: I got the offset all wrong, but
08:15 PM rue_mohr: its evil cause you dont know if your going to have a carry till its too late
08:15 PM rue_mohr: because you get the high bits first
08:15 PM rue_mohr: so I have to buffer
08:16 PM rue_mohr: ugh
08:32 PM rue_mohr: thats a lot more processing than I wanted
08:39 PM rue_mohr: void offsetSprite(unsigned char *s, int x, int y) {
08:39 PM rue_mohr: uint8_t state = 0;
08:39 PM rue_mohr: int ix, iy;
08:39 PM rue_mohr: for(;*s;s++){
08:39 PM rue_mohr: if(0) {
08:39 PM rue_mohr: } else if (*s == 0x1d) {
08:39 PM rue_mohr: state = 1;
08:39 PM rue_mohr: } else if (state == 1) { // we will grab all 4 bytes reconstruct and modify >ugh<
08:39 PM rue_mohr: if (*s >= 0x20) {
08:39 PM rue_mohr: iy = (((*(s++)) & 0x1F)<<5) + ((*(s++)) & 0x1F) + y;
08:39 PM rue_mohr: ix = (((*(s++)) & 0x1F)<<5) + ((*(s)) & 0x1F) + x;
08:39 PM rue_mohr: s-=3;
08:39 PM rue_mohr: *(s) = ((iy >> 5) + 0x20); // keeping these in order cause they will be couts.
08:39 PM rue_mohr: *(++s) = ((iy & 31) + 0x60);
08:39 PM rue_mohr: *(++s) = ((ix >> 5) + 0x20);
08:39 PM rue_mohr: *(++s) = ((ix & 31) + 0x40);
08:39 PM rue_mohr: } else {
08:39 PM rue_mohr: state = 0;
08:39 PM rue_mohr: }
08:39 PM rue_mohr: }
08:39 PM rue_mohr: }
08:39 PM rue_mohr: }
08:42 PM rue_mohr: thats a lot of work for a little micro
08:42 PM rue_mohr: I'm not sure if its just better to have the values as a 16 bit array
08:42 PM rue_mohr: but it would need flags for pen up and down
08:42 PM rue_mohr: tho the co-ords are only 10 bit
08:43 PM rue_mohr: *hmmm*
08:43 PM rue_mohr: I was trying to avoid an intermediate format
08:49 PM rue_mohr: ok
08:50 PM rue_mohr: so, in round 2, I could have a program dump the hpgl as an array of 16 bit XY pairs, with the high bit set if its the start of a new path
08:51 PM rue_mohr: then the output routine can offset them and reformat them as it goes thru
08:51 PM rue_mohr: which will take 50% less code, cause I wont have to decompress the points to offset them
08:52 PM rue_mohr: as 16 bit values, I might be able to play some bit tricks to speed up encoding
08:52 PM rue_mohr: 7pm
08:52 PM rue_mohr: about 2 hours
10:58 PM rue_mohr: https://paste.debian.net/1367943/
10:58 PM rue_mohr: getting there
11:10 PM rue_mohr: hahah, I could use a joystick to rotate a cube
11:11 PM rue_mohr: I really need something better than a cube tho, whats easy to export a 3d line list from...
11:28 PM aandrew: just use the OpenGL teapot
11:28 PM aandrew: that's what I used when I needed an object :-)
11:43 PM rue_mohr: no, it has to be something cooler, like a tai fighter