Livt packages

Eccelerators.Matrix

Version 1.0.1

Reusable RGB matrix drawing, color conversion, animation pacing, and HUB75 display components for Livt.

Published files (48)

tests/MatrixRendererPacingTest.lvt

namespace Eccelerators.Matrix.Tests

using Eccelerators.Matrix

/**
 * Verify presentation deadlines include rendering time in a 50 MHz context.
 */
@Test
@Context(ClockFrequency = 50MHz)
component MatrixRendererPacingTest
{
	// Owned renderer and drawing dependencies, accessed through one interface client.
	renderer: MatrixRenderer<100us>
	client: RendererClient
	display: MemoryDisplay
	bitmap: DisplayTestBitmap
	converter: IdentityColorConverter

	// Independent context-edge observation.
	cycles: uint

	/**
	 * Construct a paced renderer and immediate-presentation display.
	 */
	new()
	{
		this.renderer = new MatrixRenderer<100us>()
		this.client = new RendererClient()
		this.display = new MemoryDisplay()
		this.bitmap = new DisplayTestBitmap()
		this.converter = new IdentityColorConverter()
	}

	/**
	 * Observe elapsed time independently of rendering calls.
	 */
	process Count()
	{
		state {
			this.cycles++
		}
	}

	/**
	 * Check initial waiting and periodic presentation without an added drawing delay.
	 */
	@Test
	fn PresentsAtContinuousDeadlines()
	{
		assert this.client.Show(this.renderer, this.display, this.bitmap, this.converter)
		assert this.cycles >= 5000
		assert this.cycles < 5500
		var before = this.cycles
		assert this.client.Show(this.renderer, this.display, this.bitmap, this.converter)
		assert this.cycles - before >= 4500
		assert this.cycles - before < 5500
		assert this.display.presentations == 2
		assert this.display.Pixel(0, 0) == (0xFF0000 as logic[24])
	}
}