5 #define PAVLINA 1 // settings for my wife's bike
13 #define N_PWMLED_MODES 3
19 void init_log(unsigned char mcusr);
20 void log_set_state(unsigned char val);
22 void log_byte(unsigned char byte);
23 void log_word(uint16_t word);
25 void inline init_log(unsigned char mcusr) { }
26 void inline log_set_state(unsigned char val) { }
27 void inline log_flush() { }
28 void inline log_byte(unsigned char byte) { }
29 void inline log_word(uint16_t word) { }
33 #define PWMLED_ADC_SHIFT 1 /* 1<<1 measurements per single callback */
36 void timer_start_slow_adcs();
37 extern volatile unsigned char adc_is_on;
41 * The real Timer/Counter 1 frequency should not be too close to the
42 * A/D converter frequency (125 kHz). Note that this is not the Top
43 * value of T/C 1, it is shifted by PWM_STEP_SHIFT as described in pwm.c
46 extern volatile unsigned char channels_running;
47 #define PWM_IS_ON(n) (channels_running & (1 << (n)))
48 #define TIMER1_IS_ON() (channels_running)
51 void pwm_off(unsigned char n);
52 void pwm_set(unsigned char n, uint16_t stride);
54 void pwm_disable_if_not_needed();
57 extern volatile uint16_t jiffies;
63 void pwmled_adc(unsigned char n, uint16_t adcval);
64 void pwmled_set_mode(unsigned char n, unsigned char mode);
65 void pwmled_set_brightness(uint16_t brightness);
66 #define PWMLED_BRIGHTNESS(l0_lo, l0_hi, l1, l2_lo, l2_hi) ( \
68 | ((uint16_t)(l0_hi) << 3) \
69 | ((uint16_t)(l1) << 6) \
70 | ((uint16_t)(l2_lo) << 9) \
71 | ((uint16_t)(l2_hi) << 12) \
77 void gpio_set(unsigned char n, unsigned char on);
80 #define AMBIENT_ADC_SHIFT 0 /* 1 measurement per callback */
81 #define N_AMBIENT_ZONES 4
84 void ambient_log_min_max();
85 extern volatile unsigned char ambient_zone, ambient_shadow;
86 void ambient_adc(uint16_t adc_val);
90 unsigned char mode: 5;
91 unsigned char duration_fib: 3;
94 #define PATTERN_END { 0, 0 }
103 #define PWM_PAT(L2, L1, L0) ( \
104 (((L2) & 3) << 3) | \
105 (((L1) & 1) << 2) | \
109 void patterns_next_tick();
110 void led_set_pattern(unsigned char led, pattern_t *pattern);
111 pattern_t *number_pattern(unsigned char num, unsigned char inv);
112 void pattern_reload();
113 void pwmleds_update_mode();
116 #define N_USER_PARAMS 3
119 void timer_check_buttons();
120 void button_adc(uint16_t adcval);
121 unsigned char get_user_param(unsigned char param);
122 unsigned char buttons_wait_for_release();
123 unsigned char buttons_setup_in_progress();
124 pattern_t *buttons_setup_status0_pattern_select();
125 pattern_t *buttons_setup_status1_pattern_select();
130 unsigned char battery_gauge();
133 extern pattern_t on_pattern[];
135 unsigned char any_flag;
137 unsigned char booting : 1;
138 unsigned char braking : 1;
139 unsigned char err_battery : 1;
140 unsigned char err_pwmled0 : 1;
141 unsigned char err_pwmled1 : 1;
142 unsigned char err_pwmled2 : 1;
145 extern volatile err_flags_t err_flags;
150 void toggle_dim_mode();
151 void set_panic_mode();
152 pattern_t *pwmled_pattern_select();
153 pattern_t *status_led_pattern_select();
154 pattern_t *illumination_led_pattern_select();
155 pattern_t *laser_pattern_select();
156 void pwmled_select_brightness();
159 void power_down(unsigned char err);
161 #endif /* !LIGHTS_H__ */