Arduino as PAL video generator, software question
Forum rules
This forum is run by the BATC (British Amateur Television Club), it is service made freely available to all interested parties, please do not abuse this privilege.
Thank you
This forum is run by the BATC (British Amateur Television Club), it is service made freely available to all interested parties, please do not abuse this privilege.
Thank you
Arduino as PAL video generator, software question
Since video consists of sinq pulses, a black level and a white level for white, this can be done with an arduino.
The gate that makes the pulses with a different voltage divider than the gate that makes the white level by means of two resistors. (Bottom sinq: 0V, black 0.3V, white 1V).
The information and the sketch can be found at https://playground.arduino.cc/Main/TVout
With little effort it is possible to find out how, for example, a call or other text can be displayed.
Code:
#include <TVout.h>
TVout TV;
unsigned char x,y;
void setup() {
x=0;
y=0;
TV.start_render(_PAL);
}
void loop() {
TV.print_str(40,16,"PA3CRX");
TV.print_str(50,32,"ATV");
}
However, the characters are relatively small. They are built up in the following way (for example the letter "P"):
Code:
//P
0b11110000,
0b10001000,
0b11110000,
0b10000000,
0b10000000,
0b10000000,
0b00000000,
So it seems a little effort to make large characters for this but I do not know how.
The intention is to equip my portable stations with an Arduino with, for example, the number code that is broadcast during the ATV activities weekends. This code can then be displayed without having to connect (separate) peripherals.
I came across a URL that should make it possible to display a logo, for example. (https://www.open-electronics.org/a-vide ... r-arduino/)
With a tool mentioned herein, for example, in Paint a call or numbers can be converted to Ascii and that could be displayed. This is indeed not a problem. However, I am unable to adjust the sketch in a way that it works.
So my question is whether someone has something like this working (or someone with a knowledgeable interest who is interested in making something like that) and then want to share the information about it.
Thanks in advance,
Chris PA3CRX
The gate that makes the pulses with a different voltage divider than the gate that makes the white level by means of two resistors. (Bottom sinq: 0V, black 0.3V, white 1V).
The information and the sketch can be found at https://playground.arduino.cc/Main/TVout
With little effort it is possible to find out how, for example, a call or other text can be displayed.
Code:
#include <TVout.h>
TVout TV;
unsigned char x,y;
void setup() {
x=0;
y=0;
TV.start_render(_PAL);
}
void loop() {
TV.print_str(40,16,"PA3CRX");
TV.print_str(50,32,"ATV");
}
However, the characters are relatively small. They are built up in the following way (for example the letter "P"):
Code:
//P
0b11110000,
0b10001000,
0b11110000,
0b10000000,
0b10000000,
0b10000000,
0b00000000,
So it seems a little effort to make large characters for this but I do not know how.
The intention is to equip my portable stations with an Arduino with, for example, the number code that is broadcast during the ATV activities weekends. This code can then be displayed without having to connect (separate) peripherals.
I came across a URL that should make it possible to display a logo, for example. (https://www.open-electronics.org/a-vide ... r-arduino/)
With a tool mentioned herein, for example, in Paint a call or numbers can be converted to Ascii and that could be displayed. This is indeed not a problem. However, I am unable to adjust the sketch in a way that it works.
So my question is whether someone has something like this working (or someone with a knowledgeable interest who is interested in making something like that) and then want to share the information about it.
Thanks in advance,
Chris PA3CRX
-
- Posts: 1236
- Joined: Wed Jan 06, 2016 9:46 am
Re: Arduino as PAL video generator, software question
If I remember correctly PICDREAM did something similar. Not complex, but useful. I think its software is in the BATC somewhere. I remember building one 20+ years ago!
Gareth G4XAT
Gareth G4XAT
Re: Arduino as PAL video generator, software question
I still use its successor PICDREAM 2 after getting some PCB made. Its even more useful now i can change messages etc from my cellphone "in the field"
The only issue is (as Noel has experienced) if you feed it 's output into the composite input of the portsdown it gets transmitted with the top 5t0% of the testcard at the bottom of the received image and the bottom 50% of the testcard at the top of the received image. Looks fine directly on a composite monitor though
Dave
G4FRE
The only issue is (as Noel has experienced) if you feed it 's output into the composite input of the portsdown it gets transmitted with the top 5t0% of the testcard at the bottom of the received image and the bottom 50% of the testcard at the top of the received image. Looks fine directly on a composite monitor though
Dave
G4FRE
Re: Arduino as PAL video generator, software question
Thanks for reply and the suggestions.
However, to generate simple video is more easy with Arduino, only the cheap arduino is needed and two resistors (for the video levels). And it is a small thing, could easily be fitted in the housing with the portable (analogue) transmitter.
The only point is I do not have enough knowledge about the sketch to make the characters larger.
Making the matrix with more pixels like cq-tv267 page 32 (Turning back the pages of CQ-TV 78) is not the problem (like the letter ‘P’, as in the example above). But what needs to be changed to make it appear?
Thanks in advance,
Chris PA3CRX
However, to generate simple video is more easy with Arduino, only the cheap arduino is needed and two resistors (for the video levels). And it is a small thing, could easily be fitted in the housing with the portable (analogue) transmitter.
The only point is I do not have enough knowledge about the sketch to make the characters larger.
Making the matrix with more pixels like cq-tv267 page 32 (Turning back the pages of CQ-TV 78) is not the problem (like the letter ‘P’, as in the example above). But what needs to be changed to make it appear?
Thanks in advance,
Chris PA3CRX
Re: Arduino as PAL video generator, software question
Hi Chris,
I was also looking for a such a solution and was working on a chipset from VLSI, but did not had time to complete it yet. On hackaday there is an example:
https://hackaday.io/project/21097-ntscp ... lay-shield
A lot of info about the chip on:
http://www.vsdsp-forum.com/phpbb/viewforum.php?f=14
To generate image and fonts you can use this application:
http://www.eran.io/the-dot-factory-an-l ... generator/
Not sure you can use it with your solution as well.
I'm happy to test as well and see if we can get it to work.
73 Koert PA1KW
I was also looking for a such a solution and was working on a chipset from VLSI, but did not had time to complete it yet. On hackaday there is an example:
https://hackaday.io/project/21097-ntscp ... lay-shield
A lot of info about the chip on:
http://www.vsdsp-forum.com/phpbb/viewforum.php?f=14
To generate image and fonts you can use this application:
http://www.eran.io/the-dot-factory-an-l ... generator/
Not sure you can use it with your solution as well.
I'm happy to test as well and see if we can get it to work.
73 Koert PA1KW
Re: Arduino as PAL video generator, software question
Hi
I have just read your very interesting article in the latest CQ-TV.
You asked a question about changing the size of characters. This is actually quite simple to do:
Using your example ('P')
uint8 p[7] = [//P
0b11110000,
0b10001000,
0b11110000,
0b10000000,
0b10000000,
0b10000000,
0b00000000 ];
We now have a variable p which contains 7 bytes, and each of those bytes has a character line in the highest 5 bits.
What we need to do is step through each byte one bit at a time, read the value there (0 or 1) and put that pixel in the screen buffer at the correct location. If we do this multiple times we can make a character wider.
Repeating the process vertically allows us to also make the character taller.
Once we do that, we need to account for the extra pixel width when writing a string to the screen. Whenever we output one character using your code normally add 5 to the x position to account for the pixels. Now we need to put the next letter 5 x the width away so each subsequent character does not overwrite the previous character.
For a moment, assume we want to put the letter 'P' at the top of the screen, double height and triple width. I will also add the original 'P' so you can see the difference. For clarity, I will also show the pixels as ' ' and '#'.
We don't want to break the existing code so the easiest way to modify the code is to add a new function which is a slightly modified copy of the existing function.
TVout.cpp
TVout.h
Sample usage:
This should display a string at (10, 5), double width, triple height.
Please note that I have not tested this code but if it doesn't work I will happily debug any issues.
I have just read your very interesting article in the latest CQ-TV.
You asked a question about changing the size of characters. This is actually quite simple to do:
Using your example ('P')
uint8 p[7] = [//P
0b11110000,
0b10001000,
0b11110000,
0b10000000,
0b10000000,
0b10000000,
0b00000000 ];
We now have a variable p which contains 7 bytes, and each of those bytes has a character line in the highest 5 bits.
What we need to do is step through each byte one bit at a time, read the value there (0 or 1) and put that pixel in the screen buffer at the correct location. If we do this multiple times we can make a character wider.
Repeating the process vertically allows us to also make the character taller.
Once we do that, we need to account for the extra pixel width when writing a string to the screen. Whenever we output one character using your code normally add 5 to the x position to account for the pixels. Now we need to put the next letter 5 x the width away so each subsequent character does not overwrite the previous character.
For a moment, assume we want to put the letter 'P' at the top of the screen, double height and triple width. I will also add the original 'P' so you can see the difference. For clarity, I will also show the pixels as ' ' and '#'.
Code: Select all
111111111111000 11110 ############ ####
111111111111000 10001 ############ # #
111000000000111 11110 ### ### ####
111000000000111 10000 ### ### #
111111111111000 10000 ############ #
111111111111000 10000 ############ #
111000000000000 00000 ###
111000000000000 ###
111000000000000 ###
111000000000000 ###
111000000000000 ###
111000000000000 ###
000000000000000
000000000000000
TVout.cpp
Code: Select all
/* print a character c at x,y with a scale of scale_x, scale_y
*/
void TVout::print_scaled_char(unsigned char x, unsigned char y, char c, unsigned char scale_x, unsigned char scale_y) {
char i; // i is used to determine which character row we are reading from the EEPROM
char y_pos; // y_pos stores where we will be writing on screen
uint8_t j; // j is the actual byte read from the EEPROM to make up the character line by line. It will contain the horizontal pixels for one line
uint8 rx, ry; // repeat x times, repeat y times
for (i = 0; i < 7; i++) {
j = pgm_read_byte(((uint32_t)(ascii)) + c*7 + i); // we moved this line because we do not want to keep reading the same byte
for(ry = 0; ry < scale_y; ry++) { // loop through each row
y_pos = y + (i * scale_y) + ry; // we need to modify this so the pixels are scaled
for(rx = 0; rx < scale_x; rx++) {
sp(x + rx, y_pos, (j & 0x80)==0x80);
sp(x + rx + (scale_x * 1), y_pos, (j & 0x40)==0x40);
sp(x + rx + (scale_x * 2), y_pos, (j & 0x20)==0x20);
sp(x + rx + (scale_x * 3), y_pos, (j & 0x10)==0x10);
sp(x + rx + (scale_x * 4), y_pos, (j & 0x08)==0x08);
}
}
}
}
/* print a null terminated string at x,y, scaled by scale_x, scale_y
*/
void TVout::print_scaled_str(unsigned char x, unsigned char y, char *str, unsigned char scale_x, unsigned char scale_y) {
if (x >= _RESOLUTION_HORIZONTAL || y >= _RESOLUTION_VERTICAL)
return;
unsigned char font_width = 5, font_height = 7;
for (char i=0; str[i]!=0; i++) {
print_scaled_char(x, y, str[i], scale_x, scale_y);
x += font_width * scale_x;
if(x / font_width >= char_line()) {
x = 0;
y += font_height * scale_y;
if(y >= _RESOLUTION_VERTICAL)
return;
}
}
}
Code: Select all
// macros for readability when selecting mode.
#define _PAL 1
#define _NTSC 0
/*
TVout.cpp contains a brief explanation of each function.
*/
class TVout {
public:
void start_render(unsigned char mode);
void pause_render();
void resume_render();
void clear_screen();
unsigned char horz_res();
unsigned char vert_res();
char char_line();
void delay_frame(unsigned int x);
void set_pixel(unsigned char x, unsigned char y, char c);
unsigned char get_pixel(unsigned char x, unsigned char y);
void draw_line(unsigned char x0, unsigned char y0,
unsigned char x1, unsigned char y1, char c);
void print_char(unsigned char x, unsigned char y, char c);
void print_str(unsigned char x, unsigned char y, char *str);
void print_scaled_char(unsigned char x, unsigned char y, char c,
unsigned char scale_x, unsigned char scale_y);
void print_scaled_str(unsigned char x, unsigned char y, char *str,
unsigned char scale_x, unsigned char scale_y);
};
static void inline sp(unsigned char x, unsigned char y, char c);
#endif
Code: Select all
TV.print_scaled_str(10, 5, "M0ODZ Testing", 2, 3);
Please note that I have not tested this code but if it doesn't work I will happily debug any issues.
Re: Arduino as PAL video generator, software question
I tried the suggestions made by Greg and did not get it working.
Greg digged up his own Arduino to try himself what went wrong.
The article in CQ-TV272 page 21 descibes a working version.
Greg digged up his own Arduino to try himself what went wrong.
The article in CQ-TV272 page 21 descibes a working version.