PIN Commands
Version vom 22. Juni 2009, 15:10 Uhr von Stella (Diskussion | Beiträge) (Die Seite wurde neu angelegt: A simple example, which may show you some features of Control6: <pre> CONTROL_START PIN_INPUT(KEY) PIN_PULLUP(KEY) PIN_OUTPUT(LED) THREAD(nice_gaudi) ...)
A simple example, which may show you some features of Control6:
CONTROL_START PIN_INPUT(KEY) PIN_PULLUP(KEY) PIN_OUTPUT(LED) THREAD(nice_gaudi) TIMER_START(new) PIN_SET(LED); TIMER_WAIT(new, 20) PIN_CLEAR(LED); THREAD_END(nice_gaudi) ON CLOCK_MIN == 5 DO THREAD_RESTART(nice_gaudi) END ON PIN_FALLING(KEY) DO THREAD_RESTART(nice_gaudi) END CONTROL_END
- The typical CONTROL_START, CONTROL_END enclose the Control6 scripts
- the pin commands:
- the names PIN_INPUT and the other PIN_* refers to are the same, which are defined in pinning/*.m4. You also may to add your pins there.
- PIN_INPUT defines the KEY pin as an input pin (DDRx is set correctly)
- PIN_PULLUP enabled the pullup for the KEY pin (PORTx is set correctly)
- PIN_OUTPUT defines the LED pin as an output pin (DDRx is set correctly)
- PIN_FALLING(KEY) is an event, which is always triggered if there is an falling edge on the pin KEY. Corresponding to PIN_FALLING, PIN_RISING does also exists.
- THREAD, THREAD_END define a new thread `nice_gaudi' within this thread there is a timer started ( the first call of TIMER_START creates this timer also, the creation of a timer can also be done with TIMER_NEW). After the timer is started the LED key is enabled.
- The TIMER_WAIT waits, until the created timer has reaced 20 seconds. After that the LED is cleared again. Be aware of the ; at the end of PIN_SET, PIN_CLEAR. This is because this lines are not interpreted with m4, but are plain C code (CPP macros)
- The two ON commands start the thread nice_gaudi either when the clock minute field is 5 ( be aware of the RESTART ) or the KEY pin has an falling edge.