Alexandre Lemay / Mbed 2 deprecated APP1_s5_A17

Dependencies:   mbed MMA8452

Afficheur.cpp

Committer:
ThierryLeonard
Date:
2017-09-05
Revision:
8:5124be43c963
Parent:
6:909e7877d915
Parent:
7:b1b4db3eedb4
Child:
9:b9ac1d914762

File content as of revision 8:5124be43c963:



#include "Afficheur.h"
#ifdef USESPI
    Afficheur::Afficheur():afficheur(p5,p6,p7),chipSelect(p8)
    {
        afficheur.format(8,0);
        afficheur.frequency(50000);
        chipSelect = 0;
    }
#else
    Afficheur::Afficheur():afficheur(),chipSelect(p8)
    {
        chipSelect = 1;
    }
#endif
    void Afficheur::write(char* characters,int length ) 
    {
        
        Serial pc(USBTX, USBRX);
        pc.printf("1");
        static char buf[20];
        pc.printf("2");
        resetDisplay();
        pc.printf("3");
        afficheur.write(characters,length,buf,20);
        pc.printf("4");
        showDot(expo);    
    }
    void Afficheur::write(char ch)
    {
        char buf[1];
        afficheur.write(&ch,1,buf,1);
    }
    void Afficheur::resetDisplay()
    {
        char buf[1];
        afficheur.write("v",1,buf,1);
    }
    void Afficheur::showDot(int expo)
    {
        char command[2] = {'w',expo};
        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);
    }