Tyler Altenhofen / MVC

View.cpp

Committer:
tyleralt
Date:
2015-05-01
Revision:
0:ded79d89abdf
Child:
1:bb1507f0bb64

File content as of revision 0:ded79d89abdf:

#include "mbed.h"
#include <vector>
#define BUFFER_SIZE 16
#define NUMBER_OF_SLICES 360
#include "View.h"
#include "Point.h"
#include "EuclidPoint.h"

//write to arm pins
    DigitalOut pushRegister(p24);
    DigitalOut pushBit(p23);
    
    DigitalOut dataArmOne(p15);
    DigitalOut dataArmTwo(p16);
    DigitalOut dataArmThree(p17);
    DigitalOut dataArmFour(p18);
    DigitalOut dataArmFive(p19);
    DigitalOut dataArmSix(p20);
    DigitalOut dataArmSeven(p21);
    DigitalOut dataArmEight(p22);

View :: View(){
    
    current_slice = 0;

}
void View :: pushData (char bits [16]){
  for (int i = 8; i < 16; i ++){
    dataArmOne = bits [i] & 0x01;
    dataArmTwo = bits [i] & 0x02;
    dataArmThree = bits [i]& 0x04;
    dataArmFour = bits [i]& 0x08;
    dataArmFive = bits [i] & 0x10;
    dataArmSix = bits [i] & 0x20;
    dataArmSeven = bits [i] & 0x40;
    dataArmEight = bits [i] & 0x80;
    
    pushBit = 1;
    pushBit = 0;
  }
  for (int i = 7; i >= 0; i --){
    dataArmOne = bits [i] & 0x01;
    dataArmTwo = bits [i] & 0x02;
    dataArmThree = bits [i]& 0x04;
    dataArmFour = bits [i]& 0x08;
    dataArmFive = bits [i] & 0x10;
    dataArmSix = bits [i] & 0x20;
    dataArmSeven = bits [i] & 0x40;
    dataArmEight = bits [i] & 0x80;
    
    pushBit = 1;
    pushBit = 0;
    }
      
  pushRegister = 1;
  pushRegister = 0;
}


void View:: nextLedPush(){
  if (current_slice < NUMBER_OF_SLICES){
    pushData(slice_data[current_slice]);
    current_slice ++;
  } 
}

void View :: resetCount(void){
    current_slice = 0;
}
void View :: resetDisplay(void){
    for (int i = 0; i < 360; i ++){
        for (int j = 0; j < 16; j++){
            slice_data [i][j] = 0x00;
        }
    }
    slice_data [1][1] = 0xFF;
}
void View :: addPoint(Point pointer){
    int arrSlice = pointer.getArraySlice();
    char c = pointer.getIdentifyingChar();
    int distance = pointer.getPositionDistance();
    slice_data[arrSlice][distance] ^= c;
}

void View :: addEucPoint(EuclidPoint euc){
    Point start = euc.getStartPoint();
    Point end = euc.getEndPoint(); 
    int distance = start.getPositionDistance();
    char c = start.getIdentifyingChar();
    for (int i = start.getArraySlice(); i < end.getArraySlice(); i++){
        slice_data[i][distance] ^= c;
    }
}