Esempio n. 1
0
int main(void)
{
    analogvalue_t delay;

    setup();
    setup_timer0();

    // setup_int0();

    // display_off(&display);
    setup_timer2();

    analog_init(&delay);
    potentiometer_read(&delay);

    display_set(&display, delay.v);
    display_on(&display, 1);

    /* if ((PIND & _BV(PIN_SW1)) == 0) */
    /*     pin = PIN_LED_RED; */

    for (;;) {
        if ((PIND & _BV(PIN_BUTTON2)) == 0) {
            PORTB &= _BV(PIN_LED);
        } else {
            PORTB |= _BV(PIN_LED);
        }



/*
        if ((PIND & _BV(PIN_SW1)) == 0) {
            long tmax = 1000L * delay.v;
            while (micros() - t0 < tmax)
                ;
            PORTD |= _BV(pin);
        } else {
            PORTD &= ~_BV(pin);
            enable_int0();
        }

        if ((PIND & _BV(PIN_SW2)) == 0) {
            settle_on_low(&PIND, PIN_SW2);
            loop_until_bit_is_set(PIND, PIN_SW2);
            display_toggle(&display);
        }
*/

        potentiometer_read(&delay);
        if (delay.v != display.value) {
            display_set(&display, delay.v);
        }
    }

    return 0;
}
Esempio n. 2
0
// diagonal line down and up
void demo_pixel_set() {
    // Lines with line algorithm
    // diagonal line down and up
    display_clear();
    for (int x = 0; x < 128; x++) {
        if (x < 64) {
            display_set(x, x);
        } else {
            display_set(x, 127 - x);
        }
    }

    display_refresh();
    _delay_ms(1000);
}
Esempio n. 3
0
int do_display (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	int i;

	/* Clear display */
	display_set(DISPLAY_CLEAR | DISPLAY_HOME);

	if (argc < 2)
		return (0);

	for (i = 1; i < argc; i++) {
		char *p = argv[i];

		if (i > 1) { /* Insert a space between strings */
			display_putc(' ');
		}

		while ((*p)) {
#ifdef DEBUG_DISP
			putc(*p);
#endif
			display_putc(*p++);
		}
	}

#ifdef DEBUG_DISP
	putc('\n');
#endif

	return (0);
}
Esempio n. 4
0
video_canvas_t *video_canvas_create(video_canvas_t *canvas, 
		unsigned int *width, unsigned int *height, int mapped)
{
	static int vicii_setup=0;

	display_width=320;

	canvas->depth=8;
	canvas->width=320;
	canvas->height=240;

	video_canvas_set_palette(canvas, canvas->palette);

	if (vicii_setup_delay==1)
	{
		if (!vicii_setup) canvas->width=0;
		vicii_setup=1;
	}

	tvout_pal=1;
	if(gp2x_memregs[0x2800>>1]&0x100) {
		tvout=1;
		hwscaling=1;
		if(gp2x_memregs[0x2818>>1]==239) tvout_pal=0;
		printf("\n0x2818=%d\n", gp2x_memregs[0x2818>>1]);
		display_set();
	}

	current_canvas=canvas;
	return canvas;
}
Esempio n. 5
0
void main(void) {
    uint16_t i;
    char usb_char, err;
    const char init_msg[] = {'I', 'N', 'I', 'T'};
    //extern FILE *stdout = _H_USER; // redirect stdout to USB

    init();
    storage_init();

    display_cnt = 0;
    volume_tick = 0;
    chan_tick = 0;
    usb_tick = 0;
    ir_tick = 0;
    ir_speedup = 20;
    dac_lock_tick = 0;

    display_set_alt(0x00, 0x00, 0x00);
    display_set(0x00, 0x00, 1);
    ir_receiver_init();


    err = relay_boards_init(); // as side-effect: determine board Type and Id
    amp_state_init();
    set_relays(0x00, 0x00, 0x00, 0x00);

    display_oled_init();
    if (has_oled_display) {
        display_oled_chars( 0, 0, 5, "hello");
        display_set_alt(DIGIT_D, 0x00, 3);
    }
    else if (err)
        display_set_alt(DIGIT_E, 0x01, 3);

    // Globally enable interrupts
#ifdef UseIPEN
    INTCONbits.GIEH = 1;
    INTCONbits.GIEL = 1;
#else
    INTCONbits.PEIE = 1;
    INTCONbits.GIE = 1;
#endif

    // (re-)launch USB activity
    prev_usb_bus_sense = 0;
    usb_write(init_msg, (uint8_t) 4);

    // The above 'set_relays' enabled the power relay for the analog supply.
#ifdef __DEBUG
    power_tick = 0;
#else
    power_tick = 120;
#endif

    // Set a timer to later undo the mute and activate last volume setting.
    // wait some time for stabilization before enabling all other interrupts
    while (power_tick > 0)
        ; // gets decreased on timer interrupts, 183Hz

    

    // power==0 now, from amp_state_init().
    // incr power now quickly to 1, and later to 2.
    power_incr = 1;

    INTCON3bits.INT1IF = 0;
    INTCON3bits.INT1IE = 1;
    INTCON3bits.INT2IF = 0;
    INTCON3bits.INT2IE = 1;
    INTCON3bits.INT3IF = 0;
    INTCON3bits.INT3IE = 1;

    // Check if a DAC is present in this Relaixed, if so initialize.
    // This check was delayed to allow DAC power-up, otherwise its i2c interface stays in reset
    dac_init();

    while (1) {
        if (volume_incr)
            volume_update();

        if (balance_incr > 1 || balance_incr < -1)
            // suppress a single tick, might have been by accident
            balance_update();

        if (channel_incr)
            channel_update();

        if (power_incr) {
            if (flash_tick != 0 && power_incr < 0) {
                // quickly save recent volume/balance update
                flash_tick = 0;
                flash_volume_channel();
            } else if (power_incr > 0 && power_state() == 0) {
                // if we move power_state from 0 to 1, we surely want to go later to 2
                // For RelaixedPassive: wait somewhat longer for its soft-switch main power
                power_tick = (isRelaixedXLR) ? 500 : 700;
            }

            if (power_incr > 0)
                dac_init(); // check (again) for presence of DAC: it needs time to get out of reset
            power_update();
        }

        if (ir_received_ok) {
            ir_received_ok = 0;
            ir_handle_code();
            if (volume_incr) {
                vol_usb_msg[0] = 'V';
                // when 'volume' keeps pressed, the volume-tick-speed goes up
                if (ir_speedup <= 49)
                    ir_speedup += 4;
            } else {
                vol_usb_msg[0] = 'v';
                ir_speedup = 20;
            }
            byte2hex(vol_usb_msg + 1, ir_tick);
            byte2hex(vol_usb_msg + 3, ir_speedup);

            if (power_incr)
                ir_tick = 100; // increase the default 20 to 100 on power on/off
            else
                flash_tick = 400;

            usb_write(vol_usb_msg, 5);
        }

        if (flash_tick == 1) {
            flash_tick = 0;
            flash_volume_channel();
        }

        if (dac_status() >= DAC_NOLOCK && dac_lock_tick == 0) {
            dac_check_lock();
            dac_lock_tick = 45; // check lock 4x per secnd
        }

        /* some I/O to check repeatedly, for absence of interrupt-on-change */
        check_usb_power(err);
    }
}
Esempio n. 6
0
void main(void)
{
	unsigned int i;
	char usb_char, err;
	const char init_msg[] = {'I', 'N', 'I', 'T'};
	extern FILE *stdout = _H_USER;  // redirect stdout to USB
	
	init();
	
	display_cnt = 0;
    volume_tick = 0;
	chan_tick = 0;
	usb_tick = 0;
    ir_tick = 0;
	display_set( 0x00, 0x00);
	display_set_alt( 0x00, 0x00, 0x00);
	ir_receiver_init();
	storage_init();
	err = relay_boards_init();
	set_relays(0x00, 0x00, 0x00, 0x00, 0x00);
	amp_state_init();

	if (err)
		display_set_alt( DIGIT_E, 0x01, 3);

	// Globally enable interrupts
#ifdef UseIPEN
	INTCONbits.GIEH = 1;
	INTCONbits.GIEL = 1;
#else
	INTCONbits.PEIE = 1;
	INTCONbits.GIE = 1;
#endif

	// (re-)launch USB activity
	prev_usb_bus_sense = 0;
	usb_write( init_msg, (byte)4);

	// The above 'set_relays' enabled the power relay for the analog supply.
	power_tick = 150;

	// Set a timer to later undo the mute and activate last volume setting.
	// wait some time for stabilization before enabling all other interrupts
	while (power_tick > 0)
		; // gets decreased on timer interrupts

	// power==0 now, from amp_state_init().
	// incr power now quickly to 1, and later to 2.
	power_incr = 1;

	INTCON3bits.INT1IF = 0;
	INTCON3bits.INT1IE = 1;
	INTCON3bits.INT2IF = 0;
	INTCON3bits.INT2IE = 1;
	INTCON3bits.INT3IF = 0;
	INTCON3bits.INT3IE = 1;

	while (1)
	{
		if (volume_incr)
			volume_update();

		if (balance_incr > 1 || balance_incr < -1)
			// suppress a single tick, might have been by accident
			balance_update();

		if (channel_incr)
			channel_update();

		if (power_incr)
		{
			if (flash_tick && power_incr < 0)
			{
				// quickly save recent volume/balance update
				flash_tick = 0;
				flash_volume_channel();
			} else if (power_incr > 0 && power_state() == 0)
			{
				// if we move power_state from 0 to 1, we surely want to go later to 2
				power_tick = 500;
			}
			power_update();
		}

		if (ir_received_ok)
		{
			ir_received_ok = 0;
			ir_handle_code();
			if (power_incr)
				ir_tick = 100;
			else
				flash_tick = 400;
		}

		if (flash_tick == 1)
		{
			flash_tick = 0;
			flash_volume_channel();
		}

		/* some I/O to check repeatedly, for absence of interrupt-on-change */
		check_usb_power(err);
	}
}