2013-03-21 05:42:31 -04:00
|
|
|
#include <stdio.h>
|
2013-03-23 19:46:23 -04:00
|
|
|
#include <stdlib.h>
|
2013-03-21 05:42:31 -04:00
|
|
|
|
|
|
|
#include <irq.h>
|
|
|
|
#include <uart.h>
|
2013-04-14 10:33:00 -04:00
|
|
|
#include <hw/csr.h>
|
|
|
|
#include <hw/flags.h>
|
2013-05-12 15:46:16 -04:00
|
|
|
#include <console.h>
|
2013-03-21 10:32:26 -04:00
|
|
|
|
2013-05-13 09:45:28 -04:00
|
|
|
#include "time.h"
|
2013-05-09 07:41:21 -04:00
|
|
|
#include "dvisampler0.h"
|
|
|
|
#include "dvisampler1.h"
|
2013-03-21 05:42:31 -04:00
|
|
|
|
2013-05-13 09:45:28 -04:00
|
|
|
static int scale_pot(int raw, int range)
|
|
|
|
{
|
|
|
|
int pot_min = 54000;
|
|
|
|
int pot_max = 105400;
|
|
|
|
int scaled;
|
|
|
|
|
|
|
|
scaled = range*(raw - pot_min)/(pot_max - pot_min);
|
|
|
|
if(scaled < 0)
|
|
|
|
scaled = 0;
|
|
|
|
if(scaled > range)
|
|
|
|
scaled = range;
|
|
|
|
return scaled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pots_service(void)
|
|
|
|
{
|
|
|
|
static int last_event;
|
|
|
|
int blackout;
|
|
|
|
int crossfade;
|
|
|
|
|
|
|
|
if(elapsed(&last_event, identifier_frequency_read()/32)) {
|
|
|
|
pots_start_busy_write(1);
|
|
|
|
while(pots_start_busy_read());
|
|
|
|
blackout = scale_pot(pots_res0_read(), 256);
|
|
|
|
crossfade = scale_pot(pots_res1_read(), 255);
|
|
|
|
|
|
|
|
fb_blender_f0_write(crossfade*blackout >> 8);
|
|
|
|
fb_blender_f1_write((255-crossfade)*blackout >> 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fb_service(void)
|
2013-03-21 05:42:31 -04:00
|
|
|
{
|
2013-05-12 15:46:16 -04:00
|
|
|
int c;
|
|
|
|
|
2013-05-13 09:45:28 -04:00
|
|
|
if(readchar_nonblock()) {
|
|
|
|
c = readchar();
|
|
|
|
if(c == '1') {
|
|
|
|
fb_enable_write(1);
|
|
|
|
printf("Framebuffer is ON\n");
|
|
|
|
} else if(c == '0') {
|
|
|
|
fb_enable_write(0);
|
|
|
|
printf("Framebuffer is OFF\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2013-03-21 05:42:31 -04:00
|
|
|
irq_setmask(0);
|
|
|
|
irq_setie(1);
|
|
|
|
uart_init();
|
|
|
|
|
|
|
|
puts("Minimal video mixer software built "__DATE__" "__TIME__"\n");
|
|
|
|
|
2013-05-13 09:45:28 -04:00
|
|
|
time_init();
|
2013-05-09 04:52:43 -04:00
|
|
|
dvisampler0_init_video();
|
2013-05-10 15:03:55 -04:00
|
|
|
dvisampler1_init_video();
|
2013-05-06 03:56:49 -04:00
|
|
|
fb_enable_write(1);
|
2013-05-13 09:45:28 -04:00
|
|
|
|
2013-05-10 15:03:55 -04:00
|
|
|
while(1) {
|
|
|
|
dvisampler0_service();
|
|
|
|
dvisampler1_service();
|
2013-05-13 09:45:28 -04:00
|
|
|
pots_service();
|
|
|
|
fb_service();
|
2013-05-10 15:03:55 -04:00
|
|
|
}
|
2013-03-21 05:42:31 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|