Electro-Tactile Display Stimulation
Fork of Stimulation by
Stimulation.cpp@1:a45c4e14442c, 2016-10-26 (annotated)
- Committer:
- sura0111
- Date:
- Wed Oct 26 09:02:39 2016 +0000
- Revision:
- 1:a45c4e14442c
- Parent:
- 0:609c2f02a156
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sura0111 | 0:609c2f02a156 | 1 | #include "Stimulation.h" |
sura0111 | 0:609c2f02a156 | 2 | #include "mbed.h" |
sura0111 | 0:609c2f02a156 | 3 | #include "DAAD.h" |
sura0111 | 0:609c2f02a156 | 4 | #include "HV507.h" |
sura0111 | 0:609c2f02a156 | 5 | |
sura0111 | 0:609c2f02a156 | 6 | Stimulation::Stimulation() |
sura0111 | 0:609c2f02a156 | 7 | { |
sura0111 | 0:609c2f02a156 | 8 | DAADinit(); |
sura0111 | 1:a45c4e14442c | 9 | hv507Init(1); //initialize one HV507 |
sura0111 | 0:609c2f02a156 | 10 | } |
sura0111 | 0:609c2f02a156 | 11 | void Stimulation::begin() |
sura0111 | 0:609c2f02a156 | 12 | { |
sura0111 | 0:609c2f02a156 | 13 | hv507FastScan(0); |
sura0111 | 0:609c2f02a156 | 14 | } |
sura0111 | 1:a45c4e14442c | 15 | void Stimulation::setOn(unsigned int pin, short volume, unsigned int pulsewidth) |
sura0111 | 0:609c2f02a156 | 16 | { |
sura0111 | 1:a45c4e14442c | 17 | int t= pulsewidth/2; |
sura0111 | 1:a45c4e14442c | 18 | if(pin!=0){ |
sura0111 | 1:a45c4e14442c | 19 | hv507FastScan(pin); |
sura0111 | 1:a45c4e14442c | 20 | } |
sura0111 | 0:609c2f02a156 | 21 | HV507_BL = 1; |
sura0111 | 0:609c2f02a156 | 22 | HV507_LE = 1; |
sura0111 | 0:609c2f02a156 | 23 | HV507_LE = 0; |
sura0111 | 1:a45c4e14442c | 24 | for(int i=0; i<t; i++) AD = DAAD(volume); // Stimulation on |
sura0111 | 1:a45c4e14442c | 25 | //AD = DAAD(volume); |
sura0111 | 0:609c2f02a156 | 26 | } |
sura0111 | 0:609c2f02a156 | 27 | void Stimulation::setOff() |
sura0111 | 0:609c2f02a156 | 28 | { |
sura0111 | 1:a45c4e14442c | 29 | AD = DAAD(0); // Stimulation off |
sura0111 | 0:609c2f02a156 | 30 | HV507_BL = 0; |
sura0111 | 0:609c2f02a156 | 31 | } |
sura0111 | 0:609c2f02a156 | 32 | void Stimulation::end() |
sura0111 | 0:609c2f02a156 | 33 | { |
sura0111 | 0:609c2f02a156 | 34 | hv507Clear(HV507_NUM); //cleaning |
sura0111 | 0:609c2f02a156 | 35 | HV507_LE = 1; |
sura0111 | 0:609c2f02a156 | 36 | HV507_LE = 0; |
sura0111 | 0:609c2f02a156 | 37 | HV507_BL = 0; |
sura0111 | 0:609c2f02a156 | 38 | } |