Store › Forums › Video Experimenter › General Discussion › 2-line serial overlay
Tagged: pollserial tvout print serial
- This topic has 4 replies, 2 voices, and was last updated 7 years, 9 months ago by baldbrad.
-
AuthorPosts
-
March 17, 2017 at 8:22 pm #8843baldbradParticipant
Trying to set up the VE to take serial data from part of our building management system (pi) and display it on our security channel. The idea is room for 2 lines at the bottom of the screen, but we can deal with 1 if necessary.
The issue I’m having is I can get text a line at a time, but it starts at the top of the screen, and if I put the desired XY in the tv.print statement, I get only the first character at that XY.
Here’s my code (modified a bit from SerialNTSC)
I’m not fluent in the Arduino IDE to begin with, and there doesn’t seem to be much documentation on the playing nice with pollserial and tvout..#include <TVout.h> #include <fontALL.h> #include <pollserial.h> #define W 136 #define H 96 TVout tv; pollserial pserial; void setup() { tv.begin(NTSC, W, H); tv.set_hbi_hook(pserial.begin(9600)); initOverlay(); tv.select_font(font6x8); tv.fill(0); } // Initialize ATMega registers for video overlay capability. // Must be called after tv.begin(). void initOverlay() { TCCR1A = 0; // Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin. TCCR1B = _BV(CS10); // Enable input capture interrupt TIMSK1 |= _BV(ICIE1); // Enable external interrupt INT0 on pin 2 with falling edge. EIMSK = _BV(INT0); EICRA = _BV(ISC01); } // Required to reset the scan line when the vertical sync occurs ISR(INT0_vect) { display.scanLine = 0; } void loop() { if (pserial.available()) { tv.print((char)pserial.read()); } }
I’m probably just doing something stupid, but at times, I think it would be nice if there were a pi hat/option o do composite video overlay (I know you can overlay on the pi camera, but that’s not exactly useful)
March 17, 2017 at 10:18 pm #8846MichaelKeymasterTVout has many ways to print. I think you want to set the cursor position first, then use println to print entire lines.
tv.set_cursor(x,y);
March 18, 2017 at 5:46 am #8848baldbradParticipantNope, that didn’t do it. If I put the set_cursor line in void loop() , I only get one letter at the position I want, and if I put it in void setup() I get all characters, but in the same row.
T
E
S
T
instead of TEST…March 18, 2017 at 6:52 am #8851MichaelKeymasterIf you are getting each character on it’s own row, then you must be sending a carriage return or line feed at the end of each transmission. How are you sending the serial data? I have a terminal emulator connected to my Arduino, and by setting the cursor position in setup(), I print the characters at the bottom of the screen and they scroll up. So I type a full string TEST in the terminal then press return, and TEST is printed at the bottom of the screen. Here is the code, which is the same as yours but sets the cursor in setup(). Are you sure you didn’t accidentally change the loop tv.print to tv.println?
#include <TVout.h> #include <fontALL.h> #include <pollserial.h> #define W 136 #define H 96 TVout tv; pollserial pserial; void setup() { tv.begin(NTSC, W, H); tv.set_hbi_hook(pserial.begin(9600)); initOverlay(); tv.select_font(font6x8); tv.fill(0); tv.set_cursor(0, 88); } // Initialize ATMega registers for video overlay capability. // Must be called after tv.begin(). void initOverlay() { TCCR1A = 0; // Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin. TCCR1B = _BV(CS10); // Enable input capture interrupt TIMSK1 |= _BV(ICIE1); // Enable external interrupt INT0 on pin 2 with falling edge. EIMSK = _BV(INT0); EICRA = _BV(ISC01); } // Required to reset the scan line when the vertical sync occurs ISR(INT0_vect) { display.scanLine = 0; } void loop() { if (pserial.available()) { tv.print((char)pserial.read()); } }
March 18, 2017 at 8:43 am #8852baldbradParticipantIt’s working with 1 line for now… I left in the set_cursor line in void Setup(), and changed the tv.println statement back to tv.print
I’m having the pi send 22 spaces and a carriage return before writing the line of data each time it updates.
-
AuthorPosts
- You must be logged in to reply to this topic.