programme de tournesol photovoltaique pour le cours d'interface

Dependencies:   BSP_DISCO_F746NG

Revision:
0:6d4f8bd2994a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/solarPanel/solarPannel.cpp	Mon Jun 21 16:19:41 2021 +0000
@@ -0,0 +1,75 @@
+/*
+ *  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.
+ */
+ 
+#include "SolarPannel.h"
+
+    /*-----------------I/O declaration-----------------*/
+
+
+void SOLAR_PANNEL::fctErrorFlag (bool flag){}
+
+void SOLAR_PANNEL::fctCodeurA(int *angle){
+    if(*angle != 179){
+        *angle++;
+    }
+    else *angle = 0;
+}
+
+void SOLAR_PANNEL::fctCodeurB (int *angle){
+    if(*angle != 1){
+        *angle--;
+    }
+    else *angle = 180;
+}
+
+void SOLAR_PANNEL::rotate (bool dir, double vit){
+    if(dir == LEFT){
+        pwm2->write(0);
+        pwm1->write(vit);
+    }
+    
+    else if (dir == RIGHT){
+        pwm1->write(0);
+        pwm2->write(vit);  
+    }
+}
+
+void SOLAR_PANNEL::stop (void){
+    pwm1->write(0);
+    pwm2->write(0);
+}
+
+double SOLAR_PANNEL::getLsensor (void){
+    return capteur_G->read();   
+}
+
+double SOLAR_PANNEL::getRsensor (void){
+    return capteur_D->read();   
+}
+
+double SOLAR_PANNEL::getDelta (void){
+    return (capteur_G->read() - capteur_D->read());
+}