Alexandre Lemay
/
APP1_s5_A17
PARTYYYY
Revision 2:3576839565ae, committed 2017-09-04
- Comitter:
- ThierryLeonard
- Date:
- Mon Sep 04 22:57:54 2017 +0000
- Parent:
- 1:ad54e8b7ac20
- Child:
- 5:70db90b673b9
- Commit message:
- Afficheur Spi
Changed in this revision
--- a/Accelerometre.cpp Mon Sep 04 20:00:30 2017 +0000 +++ b/Accelerometre.cpp Mon Sep 04 22:57:54 2017 +0000 @@ -1,6 +1,6 @@ #include "Accelerometre.h" - +/* int Accelerometre::readSingleByte(int regis){ @@ -17,4 +17,4 @@ pc.printf("value is %d\n", c); pc.printf("end\n"); return c; - } \ No newline at end of file + }*/ \ No newline at end of file
--- a/Accelerometre.h Mon Sep 04 20:00:30 2017 +0000 +++ b/Accelerometre.h Mon Sep 04 22:57:54 2017 +0000 @@ -1,9 +1,9 @@ #include "mbed.h" - +/* class Accelerometre{ int readSingleByte(int regist); - }; - \ No newline at end of file + } + */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Afficheur.cpp Mon Sep 04 22:57:54 2017 +0000 @@ -0,0 +1,39 @@ + + +#include "Afficheur.h" + + Afficheur::Afficheur():afficheur(p5,p6,p7),chipSelect(p8) + { + afficheur.format(8,0); + afficheur.frequency(50000); + chipSelect = 0; + } + + void Afficheur::write(char* characters,int length ) + { + static char buf[20]; + resetDisplay(); + afficheur.write(characters,length,buf,20); + } + void Afficheur::write(char ch) + { + static char buf[1]; + afficheur.write(&ch,1,buf,1); + } + void Afficheur::resetDisplay() + { + char buf[1]; + afficheur.write("v",1,buf,1); + } + void Afficheur::showDot() + { + char command[2] = {'w',2}; + char buf[2]; + afficheur.write(command,2,buf, 2); + } + void Afficheur::hideDot() + { + char command[2] = {'w',0}; + char buf[2]; + afficheur.write(command,2,buf, 2); + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Afficheur.h Mon Sep 04 22:57:54 2017 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +#define USESPI + +class Afficheur +{ +public: + Afficheur(); + + void write(char* characters,int length ); + void write(char ch); + void resetDisplay(); + void showDot(); + void hideDot(); + + private: + #ifdef USESPI + SPI afficheur; + #endif + #ifdef USEUART + UARTAfficheur afficheur; + #endif + DigitalOut chipSelect; +}; \ No newline at end of file
--- a/maint.cpp Mon Sep 04 20:00:30 2017 +0000 +++ b/maint.cpp Mon Sep 04 22:57:54 2017 +0000 @@ -1,45 +1,21 @@ #include "mbed.h" +#include "Afficheur.h" + +#define USESPI -class Afficheur -{ - Afficheur() - { - afficheur.format(8,0); - afficheur.frequency(50000); - p8 = 1; - } - - void write(char characters[4], bool dot ) - { - - char rx; - - pin =0; - afficheur.write - afficheur.write(characters,4,rx,4); - pin =1; +Serial pc(USBTX, USBRX); // tx, rx + +Afficheur afficheur; + +int main() { + while(1) + { + if(pc.readable()) + { + afficheur.write(pc.getc()); + } } - static SPI afficheur(p5,p6,p7); - static DigitalOut chipSelect(p8); } - -DigitalOut pin(p8); - -Serial pc(USBTX, USBRX); // tx, rx - -int main() { - - while(1) - { - char rx[50]; - if(pc.readable()) { - pin = 0; - afficheur.write("1234",4,rx,50); - pin = 1; - wait(1); - } - } -}