]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/lights.h
firmware: buttons-press and pwrdown rework
[bike-lights.git] / firmware / lights.h
index c0daaef6175e74c180dceeef2cc2f4e651d585bb..d0eddd79c4837a56368e6906760e11391ca8ffca 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LIGHTS_H__
 #define LIGHTS_H__ 1
 
-#define N_LEDS 5
+#define N_LEDS 7
 #define N_PWMLEDS 3
 #define N_PWMLED_MODES 4
 
@@ -24,16 +24,21 @@ void inline log_word(uint16_t word) { }
 
 /* adc.c */
 void init_adc();
+void susp_adc();
 void timer_start_adcs();
 
 /* pwm.c */
+#define PWM_MAX 0x1FF
+
 void init_pwm();
+void susp_pwm();
 void pwm_off(unsigned char n);
 void pwm_set(unsigned char n, uint16_t stride);
 
 /* tmr.c */
 extern volatile uint16_t jiffies;
 void init_tmr();
+void susp_tmr();
 
 /* pwmled.c */
 void pwmled_init();
@@ -43,11 +48,10 @@ unsigned char pwmled_needs_adc(unsigned char n);
 unsigned char pwmled_enabled(unsigned char n);
 
 /* gpio.c */
-#define GPIO_LED1 0
-#define GPIO_LED2 1
-
 void gpio_init();
+void susp_gpio();
 void gpio_set(unsigned char n, unsigned char on);
+void gpio_before_poweroff();
 
 /* ambient.c */
 void ambient_init();
@@ -55,16 +59,33 @@ extern volatile unsigned char ambient_zone;
 void ambient_adc(uint16_t adc_val);
 
 /* pattern.c */
+typedef struct {
+       unsigned char mode: 3;
+       unsigned char duration: 5;
+} pattern_t;
+
+#define PATTERN_END { 0, 0 }
+extern pattern_t off_pattern[];
+extern pattern_t on_pattern[];
+
 void pattern_init();
 void patterns_next_tick();
 void led_set_status(unsigned char status);
+void led_set_pattern(unsigned char led, pattern_t *pattern);
 
 /* buttons.c */
+#define MAX_USER_PARAMS 3
 void init_buttons();
 void timer_check_buttons();
+unsigned char get_user_param(unsigned char param);
+
+/* battery.c */
+extern volatile unsigned char battery_100mv;
+void battery_adc();
+void init_battery();
 
-/* init.c */
-void hw_setup();
+/* main.c */
+void power_down();
 
 #endif /* !LIGHTS_H__ */