Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lcd display emulation for dot-matrix-lcd with pt6520 controllers #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ Z1FIRMWARE = firmware/z1/blink.z1
WISMOTEFIRMWARE = firmware/wismote/blink.wismote
TYNDALLFIRMWARE = firmware/tyndall/blink.tyndall
EXP5438FIRMWARE = firmware/exp5438/testcase-bits.exp5438
LCD122DIPFIRMWARE = firmware/lcd122dip/testcase-lcd.lcd122dip
else
ESBFIRMWARE = ${FIRMWAREFILE}
SKYFIRMWARE = ${FIRMWAREFILE}
Z1FIRMWARE = ${FIRMWAREFILE}
WISMOTEFIRMWARE = ${FIRMWAREFILE}
TYNDALLFIRMWARE = ${FIRMWAREFILE}
EXP5438FIRMWARE = ${FIRMWAREFILE}
LCD122DIPFIRMWARE = ${FIRMWAREFILE}
endif

ifdef MAPFILE
Expand All @@ -81,7 +83,7 @@ TIMERTEST := tests/timertest.firmware
SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc}
BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg images/*.png firmware/*/*.firmware ${SCRIPTS}

PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti wismote} plugin profiler emulink net ui util extutil/highlight extutil/jfreechart}
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti wismote lcd122dip} plugin profiler emulink net ui util extutil/highlight extutil/jfreechart}

SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))}

Expand Down Expand Up @@ -110,6 +112,9 @@ $(JARFILE): $(OBJECTS)
$(JAR) cfm $(JARFILE) JarManifest.txt images/*.jpg -C $(BUILD) .
-@$(RM) JarManifest.txt

%.lcd122dip: jar
java -jar $(JARFILE) -platform=lcd122dip $@ $(ARGS)

%.esb: jar
java -jar $(JARFILE) -platform=esb $@ $(ARGS)

Expand Down Expand Up @@ -145,16 +150,22 @@ runskyprof: compile

runtelos: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)

runz1: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(Z1FIRMWARE) $(MAPARGS) $(ARGS)

runtyndall: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(TYNDALLFIRMWARE) $(MAPARGS) $(ARGS)

runwismote: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(WISMOTEFIRMWARE) $(MAPARGS) $(ARGS)

runexp5438: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(EXP5438FIRMWARE) $(MAPARGS) $(ARGS)

runlcd122dip: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.lcd122dip.LCD122DIPNode $(LCD122DIPFIRMWARE) $(MAPARGS) $(ARGS)

test: cputest

cputest: $(CPUTEST)
Expand Down
Binary file added firmware/lcd122dip/testcase-lcd.lcd122dip
Binary file not shown.
Binary file added images/msp430f149-lcd122dip.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
174 changes: 174 additions & 0 deletions se/sics/mspsim/chip/EA122DIP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <[email protected]>
*
*/

package se.sics.mspsim.chip;

import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.ArrayList;

import se.sics.mspsim.core.Chip;
import se.sics.mspsim.core.IOPort;
import se.sics.mspsim.core.MSP430Core;

public class EA122DIP extends Chip implements PT6520Listener
{
// Controllers
private PT6520 pt6520Left;
private PT6520 pt6520Right;

// Listeners
private ArrayList<EA122DIPListener> displayListeners = new ArrayList<EA122DIPListener>();

/**
* Construct a EA122DIP emulated display
*/
public EA122DIP(MSP430Core cpu, Rectangle position)
{
super("EA122DIP", cpu);

// Create controller for left side
pt6520Left = new PT6520("PT6520Left", cpu, new Rectangle(position.x, position.y, position.width / 2, position.height));
pt6520Left.addListener(this);

// Create controller for right side
pt6520Right = new PT6520("PT6520Right", cpu, new Rectangle(position.x + (position.width / 2), position.y, position.width / 2, position.height));
pt6520Right.addListener(this);
}

public void addListener(EA122DIPListener newListener)
{
// Add to collection
displayListeners.add(newListener);
}

public void removeListener(EA122DIPListener oldListener)
{
// Remove from collection
displayListeners.remove(oldListener);
}

/**
* Notify about display change
*/
private void notifyListener()
{
// Iterate through all listeners
for (EA122DIPListener listener : displayListeners)
{
// Notify for display change
listener.displayChanged();
}
}

/**
* Set data port
*/
public void setDataPort(IOPort port)
{
// Setup controller ports
pt6520Left.setDataPort(port);
pt6520Right.setDataPort(port);
}

/**
* Set read and write pin
*/
public void setReadWritePin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setReadWritePin(port, pin);
pt6520Right.setReadWritePin(port, pin);
}

/**
* Set command pin
*/
public void setCommandPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setCommandPin(port, pin);
pt6520Right.setCommandPin(port, pin);
}

/**
* Set controller one enable pin
*/
public void setEnableLeftPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setEnablePin(port, pin);
}

/**
* Set controller two enable pin
*/
public void setEnableRightPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Right.setEnablePin(port, pin);
}

@Override
public int getConfiguration(int parameter)
{
// TODO Auto-generated method stub
return 0;
}

@Override
public int getModeMax()
{
// TODO Auto-generated method stub
return 0;
}

@Override
public void displayChanged()
{
// Notify display has changed
notifyListener();
}

/**
* Draws buffer image to given graphics
*/
public void drawDisplay(Graphics g)
{
// Get display from controllers
pt6520Left.drawDisplay(g);
pt6520Right.drawDisplay(g);
}
}
44 changes: 44 additions & 0 deletions se/sics/mspsim/chip/EA122DIPListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <[email protected]>
*
*/

package se.sics.mspsim.chip;

public interface EA122DIPListener
{
/**
* Notify listener that display has changed
*/
public void displayChanged();
}
Loading