I have the numbers displays on my vintage crt clock working, now I need to plot lines (Hours,Min,Sec) .
(See pic below)
For the line draw requirement.....
It is basically a two dimensional array of 255 by 255, with X0,Y0 at the top left and X255, Y255 at the bottom right.
My high school/college math skills have faded into the past, so some hints would be appreciated.
So given two points, each defined by an X,Y position, need to plot a straight line.
Example, given x0=23, y0=45 as start point, x1=233, y1=111, plot a line ?
.
EDIT: The crt display does not have blanking enabled (Z axis) at this time, so faint traces can be seen as the beam is moved across the screen.
I would recommned taking the GLCD for the Nokia Display and use this one as the basis of your driver.
I supports text only and graphics - these are two different options.
Then, you get all the capabilities of GLCD - lines, pixels, text etc. etc.
When we write GLCD drivers - we do this. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Anobium, the pixal plot is a lookup table for each number consisting of two bytes per pixal, one for horz position, one for vertical position, each number will uses about 80 bytes. Noy elegant, but works fr now. I may use the number/letter from the GLCD.H after I find it and understand it.
How do I find a listing/description of the various public .H libraries. I have created my own local .H for my LCD.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Want to thank all of you for the help. I have the line drawing software modified to work with my CRT display. I spent several days trying to work out the operating details of this GLCD firmware and I finally have it. It is great how it plots from any point to any other point, perfect for my clock hands as it works in all quadrants.
Yes, I am re-inventing the wheel, since this project is available in kit form, but for me it is a challenge, sort of like a game, with the reward being a personal accomplishment, and educational.
Paul
Below is a test of some lines with the orig point always at the screen center. Refresh is so fast, no visable flicker.
A plot and line in "basic" for 128x64. Change plot.
;
;x1,y1 start line x2,y2 end line
line:
if x1<x2 then:sx="1:dx=x2-x1:else" sx="-1:dx=x1-x2:endif" if="" y1\<y2="" then="" :sy="1:dy=y2-y1:else" sy="-1:dy=y1-y2:endif" dx="">dy then:er=dx:else er=dy:endif
dx=dx+dx:dy=dy+dy:py=y1:px=x1
if dx>dy then
do
;plot
pixel=py And 7
ptr=py And $F8 << 4 Or px @ptr=1<<pixel or="" @ptr="" row="py">>3
hi2cout (0,SSD1306_PAGEADDR)
hi2cout (0,row)
hi2cout (0,7)
hi2cout (0,SSD1306_COLUMNADDR)
hi2cout (0,px)
hi2cout (0,127)
hi2cout (64,@ptr)
;
er=er-dy
if er>32767 then
er=er+dx:py=py+sy
endif
px=px+sx
loop while px<>x2
else
do
;plot
pixel=py And 7
ptr=py And $F8 << 4 Or px @ptr=1<<pixel or="" @ptr="" ;="" screen="" byte="" row="py">>3
hi2cout (0,SSD1306_PAGEADDR)
hi2cout (0,row)
hi2cout (0,7)
hi2cout (0,SSD1306_COLUMNADDR)
hi2cout (0,px)
hi2cout (0,127)
hi2cout (64,@ptr) ;plot pixel on screen
;
er=er-dx
if er>32767 then
er=er+dy:px=px+sx
endif
py=py+sy
loop while py<>y2
endif
return</pixel></pixel></x2>
Last edit: stan cartwright 2017-03-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the numbers displays on my vintage crt clock working, now I need to plot lines (Hours,Min,Sec) .
(See pic below)
For the line draw requirement.....
It is basically a two dimensional array of 255 by 255, with X0,Y0 at the top left and X255, Y255 at the bottom right.
My high school/college math skills have faded into the past, so some hints would be appreciated.
So given two points, each defined by an X,Y position, need to plot a straight line.
Example, given x0=23, y0=45 as start point, x1=233, y1=111, plot a line ?
.
EDIT: The crt display does not have blanking enabled (Z axis) at this time, so faint traces can be seen as the beam is moved across the screen.
..2nd EDIT: Using PIC16F886 at 20 Mhz..
Last edit: Paul Haug 2017-03-24
Wow. Well done.
I would hijack the GLCD routines. This will then work for you.
What is your pixel write routine?
Thinking about this.
I would recommned taking the GLCD for the Nokia Display and use this one as the basis of your driver.
I supports text only and graphics - these are two different options.
Then, you get all the capabilities of GLCD - lines, pixels, text etc. etc.
When we write GLCD drivers - we do this. :-)
You have to calculate the equation:
y-y1 = ((y2-y1)/(x2-x1))(x-x1).
Here is the code to for a line from GLCD.H. You would replace the PSET call - you do not need LineColour as this is optional.
But, if you want Lines, Text (at differerent sizes) etc etc leveraging the existing GLCD would be very simple.
Thanks Anobium, the pixal plot is a lookup table for each number consisting of two bytes per pixal, one for horz position, one for vertical position, each number will uses about 80 bytes. Noy elegant, but works fr now. I may use the number/letter from the GLCD.H after I find it and understand it.
How do I find a listing/description of the various public .H libraries. I have created my own local .H for my LCD.
your 'include' folder of your installation.
Want to thank all of you for the help. I have the line drawing software modified to work with my CRT display. I spent several days trying to work out the operating details of this GLCD firmware and I finally have it. It is great how it plots from any point to any other point, perfect for my clock hands as it works in all quadrants.
Yes, I am re-inventing the wheel, since this project is available in kit form, but for me it is a challenge, sort of like a game, with the reward being a personal accomplishment, and educational.
Paul
Below is a test of some lines with the orig point always at the screen center. Refresh is so fast, no visable flicker.
Last edit: Paul Haug 2017-03-26
Nice
A plot and line in "basic" for 128x64. Change plot.
;
;x1,y1 start line x2,y2 end line
line:
if x1<x2 then:sx="1:dx=x2-x1:else" sx="-1:dx=x1-x2:endif" if="" y1\<y2="" then="" :sy="1:dy=y2-y1:else" sy="-1:dy=y1-y2:endif" dx="">dy then:er=dx:else er=dy:endif dx=dx+dx:dy=dy+dy:py=y1:px=x1 if dx>dy then
do
;plot
pixel=py And 7
ptr=py And $F8 << 4 Or px
@ptr=1<<pixel or="" @ptr="" row="py">>3
hi2cout (0,SSD1306_PAGEADDR)
hi2cout (0,row)
hi2cout (0,7)
hi2cout (0,SSD1306_COLUMNADDR)
hi2cout (0,px)
hi2cout (0,127)
hi2cout (64,@ptr)
;
er=er-dy
if er>32767 then
er=er+dx:py=py+sy
endif
px=px+sx
loop while px<>x2
else
do
;plot
pixel=py And 7
ptr=py And $F8 << 4 Or px
@ptr=1<<pixel or="" @ptr="" ;="" screen="" byte="" row="py">>3
hi2cout (0,SSD1306_PAGEADDR)
hi2cout (0,row)
hi2cout (0,7)
hi2cout (0,SSD1306_COLUMNADDR)
hi2cout (0,px)
hi2cout (0,127)
hi2cout (64,@ptr) ;plot pixel on screen
;
er=er-dx
if er>32767 then
er=er+dy:px=px+sx
endif
py=py+sy
loop while py<>y2
endif
return</pixel></pixel></x2>
Last edit: stan cartwright 2017-03-29
That's not what I pasted but if I edit it is?