]> mj.ucw.cz Git - home-hw.git/commitdiff
Aircon: Simulating the old interface from test-opencm3
authorMartin Mares <mj@ucw.cz>
Tue, 16 Jul 2019 16:08:50 +0000 (18:08 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 16 Jul 2019 16:08:50 +0000 (18:08 +0200)
aircon/main.c

index 13f23a25f5f3296071f8f936246c723a41d29154..12d2345a3cb0eaf04b2074008f3a85e8807fe3c1 100644 (file)
@@ -151,15 +151,15 @@ static void pwm_init(void)
        timer_set_period(TIM4, T4_CYCLE - 1);
 
        // 50% PWM for the IR LED
-       //timer_set_oc_mode(TIM4, TIM_OC2, TIM_OCM_FORCE_HIGH); // will be TIM_OCM_PWM1 when transmitting
-       timer_set_oc_mode(TIM4, TIM_OC2, TIM_OCM_PWM1); // FIXME
+       timer_set_oc_mode(TIM4, TIM_OC2, TIM_OCM_FORCE_HIGH);   // will be TIM_OCM_PWM1 when transmitting
+       // timer_set_oc_mode(TIM4, TIM_OC2, TIM_OCM_PWM1);      // FIXME
        timer_set_oc_value(TIM4, TIM_OC2, T4_CYCLE / 2);
        timer_set_oc_polarity_high(TIM4, TIM_OC2);
        timer_enable_oc_output(TIM4, TIM_OC2);
 
        // PWM for controlling fan
        timer_set_oc_mode(TIM4, TIM_OC1, TIM_OCM_PWM1);
-       timer_set_oc_value(TIM4, TIM_OC1, T4_CYCLE * 20 / 256);
+       timer_set_oc_value(TIM4, TIM_OC1, 0);
        timer_set_oc_polarity_high(TIM4, TIM_OC1);
        timer_enable_oc_output(TIM4, TIM_OC1);
 
@@ -179,8 +179,6 @@ int main(void)
        ds_init();
        modbus_init();
 
-       gpio_clear(GPIOB, GPIO0);
-
 #if 0
        for (;;) {
                debug_led_toggle();
@@ -201,17 +199,16 @@ int main(void)
                debug_led_toggle();
                delay_ms(100);
                ds_step();
-#if 0
                if (usart_get_flag(USART1, USART_SR_RXNE)) {
                        uint ch = usart_recv(USART1);
                        if (ch == 'B') {
                                bypass_active = 1;
                                gpio_set(GPIOC, GPIO15);        // opto-coupler
-                               gpio_clear(GPIOC, GPIO14);      // LED
+                               gpio_clear(GPIOB, GPIO0);       // LED
                        } else if (ch == 'b') {
                                bypass_active = 0;
                                gpio_clear(GPIOC, GPIO15);      // opto-coupler
-                               gpio_set(GPIOC, GPIO14);        // LED
+                               gpio_set(GPIOB, GPIO0);         // LED
                        } else if (ch >= '0' && ch <= '9') {
                                pwm = 3*(ch - '0') + 1;
                                /*
@@ -229,10 +226,9 @@ int main(void)
                                 *
                                 *      % = pwm*4.389 - 12.723
                                 */
-                               timer_set_oc_value(TIM4, TIM_OC1, pwm);
+                               timer_set_oc_value(TIM4, TIM_OC1, T4_CYCLE * pwm / 256);
                        }
                }
-#endif
                if (cycles++ >= 50) {
                        cycles = 0;
                        show_temperature();