Ejemplo n.º 1
0
void factory_reset(void)
{
	uint8_t i,j;


	flash_firmware_version = FW_VERSION;
	flash_startupbank=0;
	flash_clipmode=SHOW_CLIPPING;
	flash_trackcomp[0]=1.0;
	flash_trackcomp[1]=1.0;
	flash_trackoffset[0]=0;
	flash_trackoffset[1]=0;
	flash_voltoct_pwm_tracking = 1.0;

	for (i=0;i<FLASH_NUM_parambanks;i++){
		flash_bankstatus[i] 		= 0xFF;
		flash_filter_type[i] 		= MAXQ;
		flash_filter_mode[i] 		= TWOPASS;
		flash_freqblock[i] 			= 0b00000000000000000000;
		flash_cur_colsch[i]			= 0;

		for (j=0;j<NUM_CHANNELS;j++){
			flash_note[i][j]		= j+5;
			flash_scale[i][j]		= 6;
			flash_scale_bank[i][j]  = 0;
			flash_lock[i][j]		= 0;
			flash_q_locked[i][j]	= 0;
			flash_qval[i][j]		= 0;
			flash_freq_nudge[i][j]	= 0;
		}

	}

	set_default_color_scheme(); //copies DEFAULT_COLOR_CH into COLOR_CH
	cur_colsch = 0;

	//copy COLOR_SCH into flash_COLOR_CH
	uint32_t sz=FLASH_SIZE_colschem;
	uint8_t *src;
	uint8_t *dst;
	src = (uint8_t *)COLOR_CH;
	dst = (uint8_t *)flash_COLOR_CH;
	while (sz--) *dst++ = *src++;

	set_default_user_scalebank();

	sz=FLASH_SIZE_user_scalebank;
	src = (uint8_t *)user_scalebank;
	dst = (uint8_t *)flash_user_scalebank;
	while (sz--) *dst++ = *src++;

	set_default_param_values();

	store_params_into_sram(0);

	write_all_params_to_FLASH();

}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: EQ4/SMR
void main(void)
{
	int32_t t_spread;
	uint32_t i;

    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8000);

	LED_ON(LED_RING_OE); //actually turns the LED ring off
	LEDDriver_Init(5);
	for (i=0;i<26;i++)	LEDDriver_setRGBLED(i,0);
	LED_OFF(LED_RING_OE); //actually turns the LED ring on

	flag_update_LED_ring=1;


	init_inouts();
	init_rotary();
	init_envout_pwm();

	ADC1_Init((uint16_t *)adc_buffer);
	ADC3_Init((uint16_t *)potadc_buffer);

	Codec_Init(SAMPLERATE);

	delay();

	set_default_param_values();

	set_default_color_scheme();

	set_default_user_scalebank();

	//overwrite default parameters if a startup bank exists
	cur_param_bank = load_startup_params();

	if (cur_param_bank == 0xFF){
		factory_reset();
		cur_param_bank=0;
	}

	I2S_Block_Init();

	TIM6_Config();
	DAC_Ch1_NoiseConfig();

	spread=(adc_buffer[SPREAD_ADC] >> 8) + 1;

	I2S_Block_PlayRec();

	//update_spread(1);

	while(1){

		check_errors();

		param_read_switches();

		update_ENVOUT_PWM();

		update_LED_ring();

		update_lock_leds();

		t_spread=read_spread();

		if (t_spread!=-1) update_spread(t_spread);

		process_lock_jacks();

		process_lock_buttons();

		param_read_q();

		param_read_freq_nudge();

		param_read_channel_level();

		process_rotary_button();

		process_rotary_rotation();

		if (ui_mode==PLAY)
			check_rotary_pressed_repeatedly();

		if (ui_mode==EDIT_SCALES)
			handle_edit_scale();

		if (ui_mode==EDIT_COLORS)
			handle_edit_colors();

		if (ui_mode==SELECT_PARAMS){
			handle_freqpot_changing_filtermode();
			handle_slider_changing_clipmode();
		}

		if (do_ROTUP){
			do_ROTUP=0;
			rotate_up();
		}


		if (do_ROTDOWN){
			do_ROTDOWN=0;
			rotate_down();
		}

		process_rotateCV();

		process_scaleCV();

	} //end main loop


} //end main()