The Rusty Spike

A Railroad Fan's Website

By

Police Lightbar Sim For Launchpad – Rev 2



Spend some time reworking the core code as well as the storage format for the flashing sequence. Turns out that I was spoiled working with the Arduino boards, which has significantly more memory. I am endeavoring to put multiple flashing sequences into one code binary and switch them with a pushbutton attached to a DI pin on the Launchpad. Installed an old copy of Adobe Premiere and started playing with that as well. Here’s the results:

 

Filmed at 1080p HD this time around to see if I could clear up the image any. Didn’t succeed as much as I would like, so I am thinking the issue is the use of the digital zoom on the camera. Next time, I’ll switch to macro mode and have the camera physically closer to the breadboard and not use digital zoom.

Changes To The Code (Techy stuff)

The old code used two arrays of shorts(16 bit integers) to track the status of each light: meta and steps. Each light entry in the ‘meta’ array contained a current step tracker and a time accumulated on current step tracker, as well as which pin to use and how many steps there were in this light’s flashing sequence.

The second array, ‘steps’, contained an array of Pin Status and ‘Time on this step’ entry. After accumulated time exceeded ‘Time On This Step’ then that light’s step counter was incremented and the next ‘step’ entry was executed. If that step called for the pin to be OFF, then it was turned OFF and vice versa.

Old Code:

/* Configuration array
 * LIGHT, MAX_STEPS, current Steps, elapsed time
 */
static short meta[TOTAL_NUM_LIGHTS][4] = {
  {RED00, 9, 0, 0},
  {RED01, 9, 0, 0},
  {RED02, 7, 0, 0},
  {BLUE00, 7, 0, 0},
  {BLUE01, 5, 0, 0},
  {BLUE02, 5, 0, 0},
  {YELLOW00, 2, 0, 0},
  {YELLOW01, 2, 0, 0}
};
 
/*
 * Light sequencing array
 */
const static int TOTAL_NUM_STEPS = 9;
static short steps[TOTAL_NUM_LIGHTS][TOTAL_NUM_STEPS][2] = {
  { // RED00
	{OFF, 50},
	{ON, 50},
	{OFF, 100},
	{ON, 50},
	{OFF, 100},
	{ON, 50},
	{OFF, 100},
	{ON, 50},
	{OFF, 450}
  }, ....

Going back and re-evaluation those data structures, they are extremely wasteful. (A product of being originally developed on the higher memory Arduino board). Wasteful in the sense that OFF was a single bit but was being stored in a 16 bit container. Pin was a value of 1-8 (3 bits) but was being stored in a 16 bit container. etc etc etc.

So I took another stab at the data structures. (In retrospect, I think I went too far). I created a single array of bytes with the intent that the logic loop would iterate over it reading, jumping, name modifying as needed. Here’s the result:

New Code:

// 3X Strobe
static byte data_01[] =
{
//RED_00
	PORT01, //Port
	RED_00, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100, ....

Approaching the byte array as if I were writing a binary protocol, I used the first five bytes as ‘header’ information: Port and Pin, total number of steps in this sequence, current step, accumulated time on current step.

Following that is the step data. For the sake if compression, I broke the one-byte block into a 1 bit and a 7bit chunk. The 1st bit is the Pin on/off command and the remaining 7 bits is the time on this step.

Now we hit the first snag of my design: 7 bits yields a max value of 128. If I want to keep a pin low for 350ms, I have to use three steps: 125+125+100. Previous design would have called for 4 byte and this one calls for only 3, so its a win. But the cost of saving that one byte is a significant increase in complexity.

Still some room for improvement! Here we go Rev 3…..

 

Rev 2 – Complete Code:

lp4mrr.h:

//
// Launchpad for Model Railroaders (LP4MRR) Library
// COPYRIGHT 2013 Dave Loman
//
// Provided  under a Creative Commons Attribution, Non-Commercial
// Share-Alike,3.0 Unported License
//
// TARGETED TO MSP430 LANUCHPAD W/MSP430G2553 PROCESSOR
//
//
 
#ifndef LP4MRR_H
#define LP4MRR_H
 
typedef char byte;
 
#define INPUT  0x00
#define OUTPUT 0x01
 
#define ON     0x00
#define OFF    0x01
#define TOGGLE 0x02
 
#define PORT01 1
#define PORT02 2
 
void setPinMode(int port, int pin, int mode);
void setP1PinMode(int pin, int mode);
void setP2PinMode(int pin, int mode);
 
void setPinState(int port, int pin, int mode);
void setP1PinState(int pin, int state);
void setP2PinState(int pin, int state);
 
void waitabit(volatile unsigned int cycles);
 
 
#endif //LP4MRR_H

 

lp4mrr.c:

//
// Launchpad for Model Railroaders (LP4MRR) Library
// COPYRIGHT 2013 Dave Loman
//
// Provided  under a Creative Commons Attribution, Non-Commercial
// Share-Alike,3.0 Unported License
//
// TARGETED TO MSP430 LANUCHPAD W/MSP430G2553 PROCESSOR
//
//
 
#include "lp4mrr.h"
#include <msp430.h>
 
void setPinMode(int port, int pin, int mode) {
	if (port == PORT01 )
		setP1PinMode(pin, mode);
	else
		setP2PinMode(pin, mode);
}
void setP1PinMode(int pin, int mode) {
	if (mode == INPUT )
		P1DIR &= ~(0x01 << pin);
	else
		P1DIR |= (0x01 << pin);
}
void setP2PinMode(int pin, int mode) {
	if (mode == INPUT )
		P2DIR &= ~(0x01 << pin);
	else
		P2DIR |= (0x01 << pin);
}
 
 
void setPinState(int port, int pin, int state) {
	if (port == PORT01 )
		setP1PinState(pin, state);
	else
		setP2PinState(pin, state);
}
void setP1PinState(int pin, int state) {
	if (state == OFF )
		P1OUT &= ~(0x01 << pin);
	else if (state == ON )
		P1OUT |= (0x01 << pin);
	else
		P1OUT ^= (0x01 << pin);
}
void setP2PinState(int pin, int state) {
	if (state == OFF )
		P2OUT &= ~(0x01 << pin);
	else if (state == ON )
		P2OUT |= (0x01 << pin);
	else
		P2OUT ^= (0x01 << pin);
}
 
void waitabit(volatile unsigned int cycles) {
	do cycles--;
	while(cycles != 0);
}
 
 
 
int main(void) {
	setup();
 
	int msElapsed = 42;
	for(;;) {
		//TODO: calc elapsed time and pass to loop
		loop(msElapsed);
		waitabit(4000);
	}
 
	return 0;
}

 

main.c:

//
// Police Lightbar Flasher
// COPYRIGHT 2012 Dave Loman
//
// Provided  under a Creative Commons Attribution, Non-Commercial
// Share-Alike,3.0 Unported License
//
// TARGETED TO MSP430 LANUCHPAD W/MSP430G2553 PROCESSOR
//
//
 
#include <msp430.h>
#include "lp4mrr.h"
#include "flashSequences.h"
 
 
 
void setup() {
	WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer
}
 
 
byte pattern = 0;
void loop(int diffT) {
	if (diffT <= 0)  return;
 
	volatile byte port = 0, pin = 0, stepCountIndex = 0, curStepIndex = 0, nextStepIndex = 0, elapsedTimeIndex = 0;
	volatile byte dataStartIndex = 0, stepCmd = 0, timeOnStep = 0;
	volatile short tempTime = 0;
	volatile byte i = 0;
	for (i = 0; i< cnt; ++i) {
		port = data[i++];
		pin = data[i++];
 
		// Setup Pin
		setPinMode(port, pin, OUTPUT);
 
		stepCountIndex = i++;
		curStepIndex = i++;
		elapsedTimeIndex = i++;
 
		// mark begining of data
		dataStartIndex = i;
 
		//accumulate time
		tempTime = data[elapsedTimeIndex] + diffT;
 
		//get time allowed on this step from data;
		timeOnStep = data[dataStartIndex + data[curStepIndex]]  & 0x7F;  //binary: 01 11 11 11
 
		//Check if accumulated time exceeds time on step.
		if (tempTime >= timeOnStep) {
			//Incr step
			data[curStepIndex] += 1;
 
			if (data[curStepIndex] >= data[stepCountIndex])
				data[curStepIndex] = 0;
 
 
			//update temptime
			tempTime -= timeOnStep;
		}
 
		//Deterimine if pin cmd is on or off
		stepCmd    = data[dataStartIndex + data[curStepIndex]]  & 0x80;  //binary: 10 00 00 00
 
		//Set pin state;
		setPinState(port, pin, (stepCmd == STEP_PIN_ON) ? ON : OFF);
 
		//Write back time
		data[elapsedTimeIndex] = tempTime;
 
		//Advance to next light
		i += (data[stepCountIndex] - 1);
 
		//Reset for next pass
		port = 0;
		pin = 0;
		stepCountIndex = 0;
		curStepIndex = 0;
		nextStepIndex = 0;
		elapsedTimeIndex = 0;
		dataStartIndex = 0;
		stepCmd = 0;
		timeOnStep = 0;
		tempTime = 0;
	}
 
	i = 0;
}

 

flashSequences.h:

//
// Police Lightbar Flasher
// COPYRIGHT 2012 Dave Loman
//
// Provided  under a Creative Commons Attribution, Non-Commercial
// Share-Alike,3.0 Unported License
//
// TARGETED TO MSP430 LANUCHPAD W/MSP430G2553 PROCESSOR
//
//
 
#ifndef FLASHSEQUENCES_H
#define FLASHSEQUENCES_H
 
#define RED_00 0 //Port 01
#define RED_01 1 //Port 01
#define RED_02 2 //Port 01
 
#define BLU_00 3 //Port 01
#define BLU_01 4 //Port 01
#define BLU_02 5 //Port 01
 
#define YEL_00 0 //Port 02
#define YEL_01 1 //Port 02
 
#define WHT_00 6 //Port 01
#define WHT_01 7 //Port 01
 
#define STEP_PIN_ON  0x80  //binary: 10 00 00 00
#define STEP_PIN_OFF 0x7F  //binary: 01 11 11 11
 
 
//XXX
// 3X Strobe
static byte len_01 = 160;
static byte data_01[] =
{
//RED_00
	PORT01, //Port
	RED_00, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_00
	PORT01, //Port
	BLU_00, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
//RED_01
	PORT01, //Port
	RED_01, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_01
	PORT01, //Port
	BLU_01, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
 
//RED_02
	PORT01, //Port
	RED_02, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_02
	PORT01, //Port
	BLU_02, //Pin
	14,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
//YEL_00
	PORT02, //Port
	YEL_00, //Pin
	1,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
//YEL_01
	PORT02, //Port
	YEL_01, //Pin
	1,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
 
//WHT_00
	PORT01, //Port
	WHT_00, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
 
//WHT_01
	PORT01, //Port
	WHT_01, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
};
 
 
 
 
 
//XXX
// 2X Strobe
static byte len_02 = 136;
static byte data_02[] =
{
//RED_00
	PORT01, //Port
	RED_00, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_00
	PORT01, //Port
	BLU_00, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
//RED_01
	PORT01, //Port
	RED_01, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_01
	PORT01, //Port
	BLU_01, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
//RED_02
	PORT01, //Port
	RED_02, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
//BLU_02
	PORT01, //Port
	BLU_02, //Pin
	10,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF &  50,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF &  50,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
 
//YEL_00
	PORT02, //Port
	YEL_00, //Pin
	1,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
 
//YEL_01
	PORT02, //Port
	YEL_01, //Pin
	1,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
 
//WHT_00
	PORT01, //Port
	WHT_00, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
 
//WHT_01
	PORT01, //Port
	WHT_01, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
};
 
 
 
//XXX
// Traffic Director, Left
 
static byte cnt = 112;
static byte data[] =
{
//RED_00
	PORT01, //Port
	RED_00, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
//BLU_00
	PORT01, //Port
	BLU_00, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
 
//RED_01
	PORT01, //Port
	RED_01, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
//BLU_01
	PORT01, //Port
	BLU_01, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
 
//RED_02
	PORT01, //Port
	RED_02, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
//BLU_02
	PORT01, //Port
	BLU_02, //Pin
	8,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_OFF & 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
	STEP_PIN_ON  | 127,
 
//WHT_00
	PORT01, //Port
	WHT_00, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
//WHT_01
	PORT01, //Port
	WHT_01, //Pin
	12,  // stepCount;
	0,  // currentStep;
	0,  // elapsedTime;
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
 
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_ON  |  50,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
	STEP_PIN_OFF & 100,
};
 
#endif // FLASHSEQUENCES_H

One Response to Police Lightbar Sim For Launchpad – Rev 2

  1. Toni W Ryan says:

    Dave,
    I may be all wet here, but why does your project eat RAM? The LED sequences are just static tables that you are timing and sending to the output pins. Even the smaller of the two chips in the launchpad has 8K of flash. That should be plenty to hold all your flash sequence tables plus your code. Are you modifying the sequences in some way that I’m not seeing that they need to be in RAM?
    Perplexed,
    Toni

Leave a Reply

Your email address will not be published. Required fields are marked *