Esempio n. 1
0
    def instance_arduino_code(self, ad):
        ad.setup.add_call(Arduino.pinMode(self.signal_pin, Arduino.OUTPUT))

        ad.loop.add_call(
            self.cycletime.set(self.basic_board_module.current_time -
                               self.last_cycle),
            if_(
                self.cycletime > self.full_cycle,
                (
                    self.cycletime.set(0),
                    self.last_cycle.set(self.basic_board_module.current_time),
                ),
            ),
            if_(
                self.duty_cycle == 0,
                Arduino.digitalWrite(self.signal_pin, Arduino.HIGH),
            ),
            elseif_(
                self.duty_cycle == 100,
                Arduino.digitalWrite(self.signal_pin, Arduino.LOW),
            ),
            elseif_(
                self.cycletime < self.full_cycle *
                ((self.duty_cycle.cast(float_) / self.duty_cycle.maximum)),
                Arduino.digitalWrite(self.signal_pin, Arduino.LOW),
            ),
            else_(Arduino.digitalWrite(self.signal_pin, Arduino.HIGH)),
        )

        self.signal_pin.arduino_setter.add_call(
            Arduino.pinMode(self.signal_pin, Arduino.OUTPUT))
Esempio n. 2
0
 def instance_arduino_code(self, ad):
     ad.setup.add_call(Arduino.pinMode(self.relay_pin, Arduino.OUTPUT))
     ad.loop.add_call(
         if_(self.active, Arduino.digitalWrite(self.relay_pin, Arduino.LOW)),
         else_(Arduino.digitalWrite(self.relay_pin, Arduino.HIGH)),
     )
     self.relay_pin.arduino_setter.add_call(
         Arduino.pinMode(self.relay_pin, Arduino.OUTPUT)
     )
Esempio n. 3
0
    def instance_arduino_code(self, ad):
        ad.setup.add_call(Arduino.pinMode(self.relay_pin, Arduino.OUTPUT))

        ad.loop.add_call(
            self.cycletime.set(self.basic_board_module.current_time - self.last_cycle),
            if_(self.cycletime > self.full_cycle, self.cycletime.set(0)),
            if_(
                self.cycletime > self.full_cycle * self.duty_cycle,
                Arduino.digitalWrite(self.relay_pin, Arduino.HIGH),
            ),
            else_(Arduino.digitalWrite(self.relay_pin, Arduino.HIGH)),
        )

        self.relay_pin.arduino_setter.add_call(
            Arduino.pinMode(self.relay_pin, Arduino.OUTPUT)
        )
Esempio n. 4
0
    def module_arduino_code(cls, board, arduino_code_creator):
        cls.deactivate_pin.add_call(
            if_(
                cls.active_cs_pin > 0,
                code=(
                    Arduino.digitalWrite(cls.active_cs_pin, Arduino.HIGH),
                    cls.active_cs_pin.set(0),
                ),
            )
        )

        cls.activate_pin.add_call(
            if_(cls.active_cs_pin == cls.activate_pin.arg1, return_()),
            if_(cls.active_cs_pin > 0, cls.deactivate_pin()),
            Arduino.pinMode(cls.activate_pin.arg1, Arduino.OUTPUT),
            cls.active_cs_pin.set(cls.activate_pin.arg1),
            Arduino.digitalWrite(cls.active_cs_pin, Arduino.LOW),
        )
Esempio n. 5
0
 def add_arduino_code(self, ad):
     ad.setup.add_call(Arduino.pinMode(self.relay_pin, Arduino.OUTPUT))
     ad.loop.add_call(Arduino.digitalWrite(self.relay_pin, self.open))
     self.relay_pin.arduino_setter.add_call(
         Arduino.pinMode(self.relay_pin, Arduino.OUTPUT))