SpinCAD Designer - intermediate classes for SpinCADBlocks

Software questions and issues with the FV-1

Moderator: frank

Post Reply
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

SpinCAD Designer - intermediate classes for SpinCADBlocks

Post by Digital Larry »

Here I'm showing the POTCADBlock, which is an intermediate class extended by each of the actual blocks POT0CADBlock, POT1CADBlock, and POT2CADBlock.

Code: Select all

/* SpinCAD Designer - DSP Development Tool for the Spin FV-1
 * Copyright (C)2013 - Gary Worsham
 * Based on ElmGen by Andrew Kilpatrick
 * 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 	
 */

package com.holycityaudio.SpinCAD.ControlBlocks;

import java.awt.Color;

import com.holycityaudio.SpinCAD.SpinCADBlock;

public class PotCADBlock extends SpinCADBlock{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6291190763689134131L;

	public PotCADBlock(int x, int y) {
		super(x, y);
		// TODO Auto-generated constructor stub
		addControlOutputPin(this);	//	feedback
		setBorderColor(Color.MAGENTA);
	}
}

The PotCADBlock constructor adds a single Control Output pin and sets the block color to magenta. All POTCADBlocks have one Control Output pin and are magenta. Below, I show the POT0CADBlock class which extends the POTCADBlock class.

The constructor here gives the block a name.

The generateCode() method associates the Control Output 1 pin with the POT0 register.

Code: Select all

/* SpinCAD Designer - DSP Development Tool for the Spin FV-1
 * Copyright (C)2013 - Gary Worsham
 * Based on ElmGen by Andrew Kilpatrick
 * 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 	
 */

package com.holycityaudio.SpinCAD.ControlBlocks;

import com.holycityaudio.SpinCAD.fxblocks.basic.SpinFXBlock;

public class Pot0CADBlock extends PotCADBlock{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3427388550727980484L;

	public Pot0CADBlock(int x, int y) {
		super(x, y);
		// TODO Auto-generated constructor stub
		setName("Pot 0");
	}
	
	public void generateCode(SpinFXBlock eP) {
		System.out.println("Pot 0 codegen!");
		this.getPin("Control Output 1").setRegister(POT0);
	}

}
More soon!
Post Reply