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@0:ded79d89abdf, 2015-05-01 (annotated)
- Committer:
- tyleralt
- Date:
- Fri May 01 05:33:50 2015 +0000
- Revision:
- 0:ded79d89abdf
- Child:
- 1:bb1507f0bb64
geting Frist crossing and second not working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tyleralt | 0:ded79d89abdf | 1 | #include "mbed.h" |
tyleralt | 0:ded79d89abdf | 2 | #include <vector> |
tyleralt | 0:ded79d89abdf | 3 | #define BUFFER_SIZE 16 |
tyleralt | 0:ded79d89abdf | 4 | #define NUMBER_OF_SLICES 360 |
tyleralt | 0:ded79d89abdf | 5 | #include "View.h" |
tyleralt | 0:ded79d89abdf | 6 | #include "Point.h" |
tyleralt | 0:ded79d89abdf | 7 | #include "EuclidPoint.h" |
tyleralt | 0:ded79d89abdf | 8 | |
tyleralt | 0:ded79d89abdf | 9 | //write to arm pins |
tyleralt | 0:ded79d89abdf | 10 | DigitalOut pushRegister(p24); |
tyleralt | 0:ded79d89abdf | 11 | DigitalOut pushBit(p23); |
tyleralt | 0:ded79d89abdf | 12 | |
tyleralt | 0:ded79d89abdf | 13 | DigitalOut dataArmOne(p15); |
tyleralt | 0:ded79d89abdf | 14 | DigitalOut dataArmTwo(p16); |
tyleralt | 0:ded79d89abdf | 15 | DigitalOut dataArmThree(p17); |
tyleralt | 0:ded79d89abdf | 16 | DigitalOut dataArmFour(p18); |
tyleralt | 0:ded79d89abdf | 17 | DigitalOut dataArmFive(p19); |
tyleralt | 0:ded79d89abdf | 18 | DigitalOut dataArmSix(p20); |
tyleralt | 0:ded79d89abdf | 19 | DigitalOut dataArmSeven(p21); |
tyleralt | 0:ded79d89abdf | 20 | DigitalOut dataArmEight(p22); |
tyleralt | 0:ded79d89abdf | 21 | |
tyleralt | 0:ded79d89abdf | 22 | View :: View(){ |
tyleralt | 0:ded79d89abdf | 23 | |
tyleralt | 0:ded79d89abdf | 24 | current_slice = 0; |
tyleralt | 0:ded79d89abdf | 25 | |
tyleralt | 0:ded79d89abdf | 26 | } |
tyleralt | 0:ded79d89abdf | 27 | void View :: pushData (char bits [16]){ |
tyleralt | 0:ded79d89abdf | 28 | for (int i = 8; i < 16; i ++){ |
tyleralt | 0:ded79d89abdf | 29 | dataArmOne = bits [i] & 0x01; |
tyleralt | 0:ded79d89abdf | 30 | dataArmTwo = bits [i] & 0x02; |
tyleralt | 0:ded79d89abdf | 31 | dataArmThree = bits [i]& 0x04; |
tyleralt | 0:ded79d89abdf | 32 | dataArmFour = bits [i]& 0x08; |
tyleralt | 0:ded79d89abdf | 33 | dataArmFive = bits [i] & 0x10; |
tyleralt | 0:ded79d89abdf | 34 | dataArmSix = bits [i] & 0x20; |
tyleralt | 0:ded79d89abdf | 35 | dataArmSeven = bits [i] & 0x40; |
tyleralt | 0:ded79d89abdf | 36 | dataArmEight = bits [i] & 0x80; |
tyleralt | 0:ded79d89abdf | 37 | |
tyleralt | 0:ded79d89abdf | 38 | pushBit = 1; |
tyleralt | 0:ded79d89abdf | 39 | pushBit = 0; |
tyleralt | 0:ded79d89abdf | 40 | } |
tyleralt | 0:ded79d89abdf | 41 | for (int i = 7; i >= 0; i --){ |
tyleralt | 0:ded79d89abdf | 42 | dataArmOne = bits [i] & 0x01; |
tyleralt | 0:ded79d89abdf | 43 | dataArmTwo = bits [i] & 0x02; |
tyleralt | 0:ded79d89abdf | 44 | dataArmThree = bits [i]& 0x04; |
tyleralt | 0:ded79d89abdf | 45 | dataArmFour = bits [i]& 0x08; |
tyleralt | 0:ded79d89abdf | 46 | dataArmFive = bits [i] & 0x10; |
tyleralt | 0:ded79d89abdf | 47 | dataArmSix = bits [i] & 0x20; |
tyleralt | 0:ded79d89abdf | 48 | dataArmSeven = bits [i] & 0x40; |
tyleralt | 0:ded79d89abdf | 49 | dataArmEight = bits [i] & 0x80; |
tyleralt | 0:ded79d89abdf | 50 | |
tyleralt | 0:ded79d89abdf | 51 | pushBit = 1; |
tyleralt | 0:ded79d89abdf | 52 | pushBit = 0; |
tyleralt | 0:ded79d89abdf | 53 | } |
tyleralt | 0:ded79d89abdf | 54 | |
tyleralt | 0:ded79d89abdf | 55 | pushRegister = 1; |
tyleralt | 0:ded79d89abdf | 56 | pushRegister = 0; |
tyleralt | 0:ded79d89abdf | 57 | } |
tyleralt | 0:ded79d89abdf | 58 | |
tyleralt | 0:ded79d89abdf | 59 | |
tyleralt | 0:ded79d89abdf | 60 | void View:: nextLedPush(){ |
tyleralt | 0:ded79d89abdf | 61 | if (current_slice < NUMBER_OF_SLICES){ |
tyleralt | 0:ded79d89abdf | 62 | pushData(slice_data[current_slice]); |
tyleralt | 0:ded79d89abdf | 63 | current_slice ++; |
tyleralt | 0:ded79d89abdf | 64 | } |
tyleralt | 0:ded79d89abdf | 65 | } |
tyleralt | 0:ded79d89abdf | 66 | |
tyleralt | 0:ded79d89abdf | 67 | void View :: resetCount(void){ |
tyleralt | 0:ded79d89abdf | 68 | current_slice = 0; |
tyleralt | 0:ded79d89abdf | 69 | } |
tyleralt | 0:ded79d89abdf | 70 | void View :: resetDisplay(void){ |
tyleralt | 0:ded79d89abdf | 71 | for (int i = 0; i < 360; i ++){ |
tyleralt | 0:ded79d89abdf | 72 | for (int j = 0; j < 16; j++){ |
tyleralt | 0:ded79d89abdf | 73 | slice_data [i][j] = 0x00; |
tyleralt | 0:ded79d89abdf | 74 | } |
tyleralt | 0:ded79d89abdf | 75 | } |
tyleralt | 0:ded79d89abdf | 76 | slice_data [1][1] = 0xFF; |
tyleralt | 0:ded79d89abdf | 77 | } |
tyleralt | 0:ded79d89abdf | 78 | void View :: addPoint(Point pointer){ |
tyleralt | 0:ded79d89abdf | 79 | int arrSlice = pointer.getArraySlice(); |
tyleralt | 0:ded79d89abdf | 80 | char c = pointer.getIdentifyingChar(); |
tyleralt | 0:ded79d89abdf | 81 | int distance = pointer.getPositionDistance(); |
tyleralt | 0:ded79d89abdf | 82 | slice_data[arrSlice][distance] ^= c; |
tyleralt | 0:ded79d89abdf | 83 | } |
tyleralt | 0:ded79d89abdf | 84 | |
tyleralt | 0:ded79d89abdf | 85 | void View :: addEucPoint(EuclidPoint euc){ |
tyleralt | 0:ded79d89abdf | 86 | Point start = euc.getStartPoint(); |
tyleralt | 0:ded79d89abdf | 87 | Point end = euc.getEndPoint(); |
tyleralt | 0:ded79d89abdf | 88 | int distance = start.getPositionDistance(); |
tyleralt | 0:ded79d89abdf | 89 | char c = start.getIdentifyingChar(); |
tyleralt | 0:ded79d89abdf | 90 | for (int i = start.getArraySlice(); i < end.getArraySlice(); i++){ |
tyleralt | 0:ded79d89abdf | 91 | slice_data[i][distance] ^= c; |
tyleralt | 0:ded79d89abdf | 92 | } |
tyleralt | 0:ded79d89abdf | 93 | } |
tyleralt | 0:ded79d89abdf | 94 | |
tyleralt | 0:ded79d89abdf | 95 | |
tyleralt | 0:ded79d89abdf | 96 | |
tyleralt | 0:ded79d89abdf | 97 | |
tyleralt | 0:ded79d89abdf | 98 | |
tyleralt | 0:ded79d89abdf | 99 |