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.
Diff: View.cpp
- Revision:
- 0:ded79d89abdf
- Child:
- 1:bb1507f0bb64
diff -r 000000000000 -r ded79d89abdf View.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/View.cpp Fri May 01 05:33:50 2015 +0000 @@ -0,0 +1,99 @@ +#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; + } +} + + + + + +