programme de tournesol photovoltaique pour le cours d'interface

Dependencies:   BSP_DISCO_F746NG

Committer:
legrandpaul
Date:
Mon Jun 21 16:19:41 2021 +0000
Revision:
0:6d4f8bd2994a
programme d'interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
legrandpaul 0:6d4f8bd2994a 1 /*
legrandpaul 0:6d4f8bd2994a 2 * Library for the IUT de Cachan's orientable solar pannel
legrandpaul 0:6d4f8bd2994a 3 *
legrandpaul 0:6d4f8bd2994a 4 * Works with DISCO-F7446NG
legrandpaul 0:6d4f8bd2994a 5 *
legrandpaul 0:6d4f8bd2994a 6 * Copyright (C) Paul Legrand
legrandpaul 0:6d4f8bd2994a 7 *
legrandpaul 0:6d4f8bd2994a 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
legrandpaul 0:6d4f8bd2994a 9 * of this software and associated documnetation files (the "Software"), to deal
legrandpaul 0:6d4f8bd2994a 10 * in the Software without restriction, including without limitation the rights
legrandpaul 0:6d4f8bd2994a 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
legrandpaul 0:6d4f8bd2994a 12 * copies of the Software, and to permit persons to whom the Software is
legrandpaul 0:6d4f8bd2994a 13 * furished to do so, subject to the following conditions:
legrandpaul 0:6d4f8bd2994a 14 *
legrandpaul 0:6d4f8bd2994a 15 * The above copyright notice and this permission notice shall be included in
legrandpaul 0:6d4f8bd2994a 16 * all copies or substantial portions of the Software.
legrandpaul 0:6d4f8bd2994a 17 *
legrandpaul 0:6d4f8bd2994a 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
legrandpaul 0:6d4f8bd2994a 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
legrandpaul 0:6d4f8bd2994a 20 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
legrandpaul 0:6d4f8bd2994a 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
legrandpaul 0:6d4f8bd2994a 22 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
legrandpaul 0:6d4f8bd2994a 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
legrandpaul 0:6d4f8bd2994a 24 * THE SOFTWARE.
legrandpaul 0:6d4f8bd2994a 25 */
legrandpaul 0:6d4f8bd2994a 26
legrandpaul 0:6d4f8bd2994a 27 #include "SolarPannel.h"
legrandpaul 0:6d4f8bd2994a 28
legrandpaul 0:6d4f8bd2994a 29 /*-----------------I/O declaration-----------------*/
legrandpaul 0:6d4f8bd2994a 30
legrandpaul 0:6d4f8bd2994a 31
legrandpaul 0:6d4f8bd2994a 32 void SOLAR_PANNEL::fctErrorFlag (bool flag){}
legrandpaul 0:6d4f8bd2994a 33
legrandpaul 0:6d4f8bd2994a 34 void SOLAR_PANNEL::fctCodeurA(int *angle){
legrandpaul 0:6d4f8bd2994a 35 if(*angle != 179){
legrandpaul 0:6d4f8bd2994a 36 *angle++;
legrandpaul 0:6d4f8bd2994a 37 }
legrandpaul 0:6d4f8bd2994a 38 else *angle = 0;
legrandpaul 0:6d4f8bd2994a 39 }
legrandpaul 0:6d4f8bd2994a 40
legrandpaul 0:6d4f8bd2994a 41 void SOLAR_PANNEL::fctCodeurB (int *angle){
legrandpaul 0:6d4f8bd2994a 42 if(*angle != 1){
legrandpaul 0:6d4f8bd2994a 43 *angle--;
legrandpaul 0:6d4f8bd2994a 44 }
legrandpaul 0:6d4f8bd2994a 45 else *angle = 180;
legrandpaul 0:6d4f8bd2994a 46 }
legrandpaul 0:6d4f8bd2994a 47
legrandpaul 0:6d4f8bd2994a 48 void SOLAR_PANNEL::rotate (bool dir, double vit){
legrandpaul 0:6d4f8bd2994a 49 if(dir == LEFT){
legrandpaul 0:6d4f8bd2994a 50 pwm2->write(0);
legrandpaul 0:6d4f8bd2994a 51 pwm1->write(vit);
legrandpaul 0:6d4f8bd2994a 52 }
legrandpaul 0:6d4f8bd2994a 53
legrandpaul 0:6d4f8bd2994a 54 else if (dir == RIGHT){
legrandpaul 0:6d4f8bd2994a 55 pwm1->write(0);
legrandpaul 0:6d4f8bd2994a 56 pwm2->write(vit);
legrandpaul 0:6d4f8bd2994a 57 }
legrandpaul 0:6d4f8bd2994a 58 }
legrandpaul 0:6d4f8bd2994a 59
legrandpaul 0:6d4f8bd2994a 60 void SOLAR_PANNEL::stop (void){
legrandpaul 0:6d4f8bd2994a 61 pwm1->write(0);
legrandpaul 0:6d4f8bd2994a 62 pwm2->write(0);
legrandpaul 0:6d4f8bd2994a 63 }
legrandpaul 0:6d4f8bd2994a 64
legrandpaul 0:6d4f8bd2994a 65 double SOLAR_PANNEL::getLsensor (void){
legrandpaul 0:6d4f8bd2994a 66 return capteur_G->read();
legrandpaul 0:6d4f8bd2994a 67 }
legrandpaul 0:6d4f8bd2994a 68
legrandpaul 0:6d4f8bd2994a 69 double SOLAR_PANNEL::getRsensor (void){
legrandpaul 0:6d4f8bd2994a 70 return capteur_D->read();
legrandpaul 0:6d4f8bd2994a 71 }
legrandpaul 0:6d4f8bd2994a 72
legrandpaul 0:6d4f8bd2994a 73 double SOLAR_PANNEL::getDelta (void){
legrandpaul 0:6d4f8bd2994a 74 return (capteur_G->read() - capteur_D->read());
legrandpaul 0:6d4f8bd2994a 75 }