emulating a OLED display on a VGA and/or a LCD monitor

Post here all questions related to LibMaple core if you can't find a relevant section!
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: emulating a OLED display on a VGA and/or a LCD monitor

Post by feluga »

Timing and synchronizing are always the issue when it comes to TVs, VGA or HDMI signals.
In your project, there may be synching issues that lead to broken images on TV or on VGA.

Check out this project: https://hackaday.com/2018/03/11/fpga-ma ... ore-298278

It's an FPGA open source project that takes OLED SSD1306 SPI signal to VGA.
It was used to take images from an open game console (Arduboy) to display on VGA monitors.

Certainly that's the solution for your project!
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: emulating a OLED display on a VGA and/or a LCD monitor

Post by feluga »

Source Code for the FPGA project: https://github.com/uXeBoy/VGA1306
Discussion about how it is used in the Arduboy project is here: https://community.arduboy.com/t/vga1306 ... a/4851/157

Hardware is based on iCE40 FPGA chip and Olimex has a very affordable development board based on the very same chip of this project: https://www.olimex.com/Products/FPGA/iC ... e-hardware

Github with examples for VGA output in VHDL ==> https://github.com/OLIMEX/iCE40HX1K-EVB

Maybe that's the way to go....
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: emulating a OLED display on a VGA and/or a LCD monitor

Post by Y@@J »

There's no need for a FPGA. The OLED *IS* emulated. I have a working project. I could route a PCB right now. I can move motors, display temperatures, play with the auto-leveling device and so on, just using the emulated display. It even reproduces the marlin glitches (there are some). Less than 200 lines of code. Ran for the last 12 hours without a problem (exept I'll have to synchronize the resets between all the boards).
And no doubt it will be the same with a LCD12864 : just have to purchase one and work with the datasheet ; the only one I have is on the 3D printer, and it will stay where it is : need it.
BigTreeTech did it with a... STM32F103F8 ! (see schematics on their Git). They don't use FPGAs. Just a STM32 reading SPI lines from any 3D printer board configured for a LCD12864. Coded with Cube. It does work on their commercial product, and it does on my breadboards with a 7" LCD. Now want it as a OctoPrint plugin, displayed in a tab, like the webcam, the GCode terminal, and many plugins.
The next step is OctoPrint. The real problems are Python (hate this crap), Linux (have been reluctant to alternative OS's since BSD in the early '90), and getting a working OctoPrint devenv (just started to install a Ubuntu VM, because it is a pain under Windows : epic fail).
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: emulating a OLED display on a VGA and/or a LCD monitor

Post by Y@@J »

Added a timeout functionality in the reveive function. micros() or similar function is not usable with TVOut. TVOut has its own millis(), but its granularity is far too coarse (16 to 20ms depending on NTSC or PAL). A simple counter does it.
(if the STM32 wasn't responding for whatever reason, TVOut was stuck in an infinate loop. Solved.)

Code: Select all

#define BUFFER_SIZE		((WIDTH/8) * HEIGHT) // 1 bit per pixel
#define	TIMEOUT			100

void onStartVBlanking()
{
	PORTB &= ~(1 << 5); // 13 (B-5) LOW : send Request To Send (RTS)
	uint16_t i = 0;
	uint8_t* pBuffer = TV.screen;

	while (i < BUFFER_SIZE)
	{

		// wait for CLK falling
		uint8_t j = 0; // timeout counter
		while (PINC & (1 << 4)) // A4 = C-4
			if (j++ > TIMEOUT) // timeout
				goto end;

		// read value
		//						D3-D6 = MSB				A0-A3 = LSB
		//							D-3-6					C-0-3
		*(pBuffer + i++) = ((PIND & 0b01111000) << 1) | (PINC & 0b00001111);

		// wait for CLK rising
		j = 0;
		while (!(PINC & (1 << 4))) // A4 = C-4
			if (j++ > TIMEOUT) // timeout
				goto end;
	}

end:
	// D13 (B-5) HIGH : RTS HIGH, end of transmission
	PORTB |= 1 << 5;
}
Last edited by Y@@J on Thu Dec 31, 2020 12:12 am, edited 1 time in total.
Y@@J
Posts: 57
Joined: Mon Sep 28, 2020 8:51 pm

Re: emulating a OLED display on a VGA and/or a LCD monitor

Post by Y@@J »

Currently experimenting with another approach : I finally had a look under the RaspBerry Pi hood : drawing directly in the frame buffer ("bare metal programming"). It is interesting because the image of the OLED appears as an overlay, over the underlaying desktop, console, or OctoPrint/Octolapse (OctoPrint is itself in a Chromium browser +- kiosk mode). For now it is just an image of the XMB bitmap previously captured and used for testing). No so difficult.
Wrote a routine for displaying fat pixels (x1 -> x8). Really neat, and the whole 32bit palette can be used !). And no need to learn XWindow :P

Sending parallel data makes no sense. The STM32 second channel will do it. Still to learn how to use a daemonized program), and how to deal with SPI.The GPIO itself sems to be similar to the STM32 :) Should be completed within a couple of days.
DSC_7853.JPG
DSC_7853.JPG (75.47 KiB) Viewed 2864 times
Post Reply

Return to “General discussion”