programme de tournesol photovoltaique pour le cours d'interface

Dependencies:   BSP_DISCO_F746NG

solarPanel/SolarPannel.h

Committer:
legrandpaul
Date:
2021-06-21
Revision:
0:6d4f8bd2994a

File content as of revision 0:6d4f8bd2994a:

/*
 *  Library for the IUT de Cachan's orientable solar pannel
 *
 *  Works with DISCO-F7446NG
 *
 *  Copyright (C) Paul Legrand
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documnetation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to  whom the Software is
 * furished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef _SolarPannel_H__
#define _SolarPannel_H__

#include "mbed.h"

#define PWM_SPEED 0.2
#define LEFT 0
#define RIGHT 1



class SOLAR_PANNEL
{

public:
    /*-----------------I/O declaration-----------------*/
    SOLAR_PANNEL()
    {
        ErrorFlag = new InterruptIn(PF_8);
        codeurA = new InterruptIn(PF_10);
        codeurB = new InterruptIn(PC_7);
        capteur_G = new AnalogIn(PF_7);
        capteur_D = new AnalogIn(PF_6);
        
        pwm1 = new PwmOut(PA_0);
        pwm2 = new PwmOut(PC_6);
    }

    InterruptIn  * ErrorFlag;
    InterruptIn * codeurB;
    InterruptIn * codeurA;

    AnalogIn * capteur_G;
    AnalogIn * capteur_D;

    PwmOut * pwm1;// (PF_6);
    PwmOut * pwm2;// (PC_7);


    void rotate (bool dir, double vit);
    void stop (void);
    double getLsensor (void);
    double getRsensor (void);
    double getDelta (void);

private :

    void fctErrorFlag (bool flag);
    void fctCodeurA(int *angle);
    void fctCodeurB (int *angle);

};

#endif // _SolarPannel_H__ //