Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
View.cpp
- Committer:
- tyleralt
- Date:
- 2015-05-01
- Revision:
- 1:bb1507f0bb64
- Parent:
- 0:ded79d89abdf
- Child:
- 2:891b3618be4f
File content as of revision 1:bb1507f0bb64:
#include "mbed.h" #include <vector> #define BUFFER_SIZE 16 #define NUMBER_OF_SLICES 360 #include "View.h" #include "Point.h" #include "EuclidPoint.h" #include <math.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){ int x = euc.x; int y = euc.y; Point pointer = euc.getPoint(); int arrSlice = pointer.getArraySlice(); char c = pointer.getIdentifyingChar(); int distance = pointer.getPositionDistance(); slice_data[arrSlice][distance] |= c; int divider = 1 + ((distance)/ 4); int reach = rint((double)3 / divider); for (int i = 0 ; i < reach; i ++){ slice_data [(arrSlice + i)%360][distance] |= c; slice_data [(arrSlice - i)%360][distance] |= c; } /* int changeDeg = arrSlice; double deg = (double) changeDeg / 57.295; while ( ((sin (deg) * (distance + 1)) - y == 0 && (int) (cos (deg) * (distance + 1)) - x == 0)){ slice_data[change][distance] |= c; changeDeg ++; double deg = (double) changeDeg / 57.295; } changeDeg = arrSlice; deg = (double) changeDeg / 57.295; while ( (int) (sin (deg) * (distance + 1)) - y == 0 && (int) (cos (deg) * (distance + 1)) - x == 0){ slice_data[change][distance] |= c; changeDeg --; double deg = (double) changeDeg / 57.295; } while ( tan(arrSlice / 57.295) == ((double) y / x) || (int) tan(arrSlice / 57.295) == (int) ((double) -y / x)){ slice_data[change][distance] |= c; change ++; } change = arrSlice; //while ((int) (sin(change / 57.295) * distance) == x && (int)(cos (change / 57.295) * distance)== y){ while ( (int) tan(arrSlice / 57.295) == (int) ((double) y / x) || (int) tan(arrSlice / 57.295) == (int) ((double) -y / x)){ slice_data[change][distance] |= c; change --; } */ }