paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [5652] Light -> Module


From: Christophe De Wagter
Subject: [paparazzi-commits] [5652] Light -> Module
Date: Tue, 24 Aug 2010 11:46:08 +0000

Revision: 5652
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5652
Author:   dewagter
Date:     2010-08-24 11:46:07 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
Light -> Module

Modified Paths:
--------------
    paparazzi3/trunk/conf/airframes/AirborneCodeReorg/LisaFw.xml
    paparazzi3/trunk/conf/settings/light.xml
    paparazzi3/trunk/sw/airborne/main_ap.c

Added Paths:
-----------
    paparazzi3/trunk/conf/modules/light.xml
    paparazzi3/trunk/sw/airborne/modules/light/
    paparazzi3/trunk/sw/airborne/modules/light/light.c
    paparazzi3/trunk/sw/airborne/modules/light/light.h

Removed Paths:
-------------
    paparazzi3/trunk/sw/airborne/light.c
    paparazzi3/trunk/sw/airborne/light.h

Modified: paparazzi3/trunk/conf/airframes/AirborneCodeReorg/LisaFw.xml
===================================================================
--- paparazzi3/trunk/conf/airframes/AirborneCodeReorg/LisaFw.xml        
2010-08-24 11:08:22 UTC (rev 5651)
+++ paparazzi3/trunk/conf/airframes/AirborneCodeReorg/LisaFw.xml        
2010-08-24 11:46:07 UTC (rev 5652)
@@ -159,9 +159,12 @@
        <define name="HOME_RADIUS" value="100" unit="m"/>
   </section>
 
+  <modules>
+    <load name="light.xml"/>
+  </modules>
+
   <firmware name="fixedwing">
     <target name="ap"                  board="lisa_l_1.0"      
processor="stm32" >
-      <param name="FLASH_MODE"                 value="IAP" />
       <define name="AGR_CLIMB" />
       <define name="ALT_KALMAN" />
       <define name="STM32" />          <!-- Temporary Hack -->
@@ -173,7 +176,7 @@
     <!-- Communication -->
     <subsystem name="telemetry"        type="transparent">
       <param name="MODEM_UART_NR"      value="2"/>
-      <param name="MODEM_BAUD"                 value="B9600"/>
+      <param name="MODEM_BAUD"                 value="B57600"/>
     </subsystem>
 
     <!-- Actuators -->

Added: paparazzi3/trunk/conf/modules/light.xml
===================================================================
--- paparazzi3/trunk/conf/modules/light.xml                             (rev 0)
+++ paparazzi3/trunk/conf/modules/light.xml     2010-08-24 11:46:07 UTC (rev 
5652)
@@ -0,0 +1,19 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<module name="light">
+  <header>
+    <file name="light.h"/>
+  </header>
+  <init fun="init_light()"/>
+  <periodic fun="periodic_light()" period="0.05" autorun="TRUE"/>
+  <makefile>
+    <flag name="LIGHT_LED_STROBE" value="3"/>
+    <flag name="LIGHT_LED_NAV" value="4"/>
+
+    <flag name="STROBE_LIGHT_MODE_DEFAULT" value="5"/>
+    <flag name="NAV_LIGHT_MODE_DEFAULT" value="4"/>
+
+    <file name="light.c"/>
+  </makefile>
+</module>
+

Modified: paparazzi3/trunk/conf/settings/light.xml
===================================================================
--- paparazzi3/trunk/conf/settings/light.xml    2010-08-24 11:08:22 UTC (rev 
5651)
+++ paparazzi3/trunk/conf/settings/light.xml    2010-08-24 11:46:07 UTC (rev 
5652)
@@ -3,11 +3,11 @@
 <settings>
     <dl_settings NAME="lights control">
        <dl_settings NAME="lights">
-          <dl_setting module="light" var="light_duration_1" min="0" max="61" 
step="1">
-            <strip_button name="CamOn" icon="on.png" value="15"/>
+          <dl_setting module="autopilot" var="strobe_light_mode" min="0" 
max="6" step="1">
+            <strip_button name="CamOn" icon="on.png" value="1"/>
             <strip_button name="CamOff" icon="off.png" value="0"/>
          </dl_setting>
-          <dl_setting module="light" var="light_duration_2" min="0" max="61" 
step="1"/>
+          <dl_setting var="nav_light_mode" min="0" max="4" step="1"/>
        </dl_settings>
     </dl_settings>
 </settings>

Deleted: paparazzi3/trunk/sw/airborne/light.c
===================================================================
--- paparazzi3/trunk/sw/airborne/light.c        2010-08-24 11:08:22 UTC (rev 
5651)
+++ paparazzi3/trunk/sw/airborne/light.c        2010-08-24 11:46:07 UTC (rev 
5652)
@@ -1,4 +0,0 @@
-#include "light.h"
-
-uint8_t light_duration_1;
-uint8_t light_duration_2;

Deleted: paparazzi3/trunk/sw/airborne/light.h
===================================================================
--- paparazzi3/trunk/sw/airborne/light.h        2010-08-24 11:08:22 UTC (rev 
5651)
+++ paparazzi3/trunk/sw/airborne/light.h        2010-08-24 11:46:07 UTC (rev 
5652)
@@ -1,58 +0,0 @@
-#ifndef LIGHT_H
-#define LIGHT_H
-
-#ifdef USE_LIGHT
-
-#include <inttypes.h>
-
-#ifdef LIGHT_PIN_1
-#error "LIGHT_PIN_1 is now LIGHT_LED_1"
-#endif
-
-/** 0 =< <= 61 . 0 == off, 61 == always on */
-extern uint8_t light_duration_1;
-extern uint8_t light_duration_2;
-
-#ifdef LIGHT_LED_1
-#define LightPeriodicTask1(_1Hz) { \
-  if (_1Hz < light_duration_1) { \
-    LED_OFF(LIGHT_LED_1) \
-  } else \
-    LED_ON(LIGHT_LED_1) \
-}
-#else /* LIGHT_LED_1 */
-#define LightPeriodicTask1(_1Hz) {}
-#endif /* LIGHT_LED_1 */
-
-
-#ifdef LIGHT_LED_2
-#define LightPeriodicTask2(_1Hz) { \
-  if (_1Hz < light_duration_2) { \
-    LED_OFF(LIGHT_LED_2) \
-  } else \
-    LED_ON(LIGHT_LED_2) \
-}
-#else /* LIGHT_LED_1 */
-#define LightPeriodicTask2(_1Hz) {}
-#endif /* LIGHT_LED_1 */
-
-#ifndef LIGHT_DURATION_INITIAL
-#define LIGHT_DURATION_INITIAL 0
-#endif
-
-#define LightInit() { \
-  light_duration_1 = LIGHT_DURATION_INITIAL; \
-  light_duration_2 = LIGHT_DURATION_INITIAL; \
-}
-
-
-/* Called at 60Hz
-   Argument is a counter which goes from 0 to 59 */
-#define LightPeriodicTask(_1Hz) { \
-  LightPeriodicTask1(_1Hz); \
-  LightPeriodicTask2(_1Hz); \
-}
-
-#endif // USE_LIGHT
-
-#endif // LIGHT_H

Modified: paparazzi3/trunk/sw/airborne/main_ap.c
===================================================================
--- paparazzi3/trunk/sw/airborne/main_ap.c      2010-08-24 11:08:22 UTC (rev 
5651)
+++ paparazzi3/trunk/sw/airborne/main_ap.c      2010-08-24 11:46:07 UTC (rev 
5652)
@@ -59,7 +59,6 @@
 #else
 #include "gpio.h"
 #endif
-#include "light.h"
 
 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
 #include "rc_settings.h"
@@ -496,10 +495,6 @@
     break;
   }
 
-#ifdef USE_LIGHT
-  LightPeriodicTask(_1Hz);
-#endif
-
   switch(_4Hz) {
   case 0:
     estimator_propagate_state();
@@ -843,10 +838,6 @@
 
   power_switch = FALSE;
 
-#ifdef USE_LIGHT
-  LightInit();
-#endif
-
 #ifdef TRIGGER_EXT
   trig_ext_init();
 #endif

Added: paparazzi3/trunk/sw/airborne/modules/light/light.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/light/light.c                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/light/light.c  2010-08-24 11:46:07 UTC 
(rev 5652)
@@ -0,0 +1,154 @@
+/*
+ * $Id: demo_module.c 3079 2009-03-11 16:55:42Z gautier $
+ *  
+ * Copyright (C) 2009  Gautier Hattenberger
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA. 
+ *
+ */
+
+#include "light.h"
+#include "led.h"
+
+uint8_t strobe_light_mode;
+uint8_t nav_light_mode;
+
+#ifndef STROBE_LIGHT_MODE_DEFAULT
+#define STROBE_LIGHT_MODE_DEFAULT 5
+#endif
+
+#ifndef NAV_LIGHT_MODE_DEFAULT
+#define NAV_LIGHT_MODE_DEFAULT 4
+#endif
+
+
+void init_light(void) {
+  // this part is already done by led_init in fact
+  LED_INIT(LIGHT_LED_STROBE);
+  LED_OFF(LIGHT_LED_STROBE);
+#ifdef LIGHT_LED_NAV
+  LED_INIT(LIGHT_LED_NAV);
+  LED_OFF(LIGHT_LED_NAV);
+  strobe_light_mode = STROBE_LIGHT_MODE_DEFAULT;
+  nav_light_mode = NAV_LIGHT_MODE_DEFAULT;
+#endif
+}
+
+void periodic_light(void) 
+{
+  static uint8_t counter = 0;
+#ifdef LIGHT_LED_NAV
+  static uint8_t counter_nav = 0;
+#endif
+
+  switch (strobe_light_mode)
+  {
+    default:   // Always off
+       LED_OFF(LIGHT_LED_STROBE);
+       break;
+    case 1:    // Always on
+       LED_ON(LIGHT_LED_STROBE);
+       break;
+    case 2:    // Blink
+    case 3:
+    case 4:
+       if (counter == (strobe_light_mode*5 - 4))
+       {
+               LED_OFF(LIGHT_LED_STROBE);
+       }
+       else if (counter >= 20)
+       {
+               LED_ON(LIGHT_LED_STROBE);
+               counter = 0;
+       }
+       break;
+     case 5:   // Complex Blinking
+       if (counter == 3)
+       {
+               LED_OFF(LIGHT_LED_STROBE);
+       }
+       else if (counter == 4)
+       {
+               LED_ON(LIGHT_LED_STROBE);
+       }
+       else if (counter == 6)
+       {
+               LED_OFF(LIGHT_LED_STROBE);
+       }
+       else if (counter == 7)
+       {
+               LED_ON(LIGHT_LED_STROBE);
+       }
+       else if (counter == 8)
+       {
+               LED_OFF(LIGHT_LED_STROBE);
+       }
+       else if (counter >= 25)
+       {
+               LED_ON(LIGHT_LED_STROBE);
+               counter = 0;
+       }
+       break;
+     case 6:
+       if (counter <= 18)
+       {
+               if ((counter % 2) == 0)
+               {
+                 LED_ON(LIGHT_LED_STROBE);
+               }
+                else
+               {
+                 LED_OFF(LIGHT_LED_STROBE);
+               }
+       }
+       else if (counter == 35)
+       {
+               counter = 0;
+       }
+       break;
+  }
+
+#ifdef LIGHT_LED_NAV
+  switch (nav_light_mode)
+  {
+    default:   // Always off
+       LED_OFF(LIGHT_LED_NAV);
+       break;
+    case 1:    // Always on
+       LED_ON(LIGHT_LED_NAV);
+       break;
+    case 2:    // Blink
+    case 3:
+    case 4:
+       if (counter_nav == (nav_light_mode*5 - 4))
+       {
+               LED_OFF(LIGHT_LED_NAV);
+       }
+       else if (counter_nav >= 20)
+       {
+               LED_ON(LIGHT_LED_NAV);
+               counter_nav = 0;
+       }
+       break;
+  }
+  counter_nav++;
+#endif
+
+  counter++;
+}
+

Added: paparazzi3/trunk/sw/airborne/modules/light/light.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/light/light.h                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/light/light.h  2010-08-24 11:46:07 UTC 
(rev 5652)
@@ -0,0 +1,45 @@
+/*
+ * $Id: demo_module.h 3079 2009-03-11 16:55:42Z gautier $
+ *  
+ * Copyright (C) 2009  Gautier Hattenberger
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA. 
+ *
+ */
+
+/** \file demo_module.h
+ * 
+ * demo module with blinking LEDs
+ */
+
+#ifndef LIGHT_MODULE_H
+#define LIGHT_MODULE_H
+
+#include <inttypes.h>
+
+#ifndef LIGHT_LED_STROBE
+#define LIGHT_LED_STROBE 2
+#endif
+
+extern uint8_t strobe_light_mode;
+extern uint8_t nav_light_mode;
+
+void init_light(void);
+void periodic_light(void);
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]