Suga koubou
/
dali_sample
DALI send/recv library see: https://os.mbed.com/users/okini3939/code/DALI/
main.cpp
- Committer:
- okini3939
- Date:
- 2020-07-22
- Revision:
- 0:306a7e28f64a
- Child:
- 1:b5145c7213be
File content as of revision 0:306a7e28f64a:
#include "mbed.h" #include "DALI.h" #define DALI_ADDRESS 1 Serial pc(USBTX, USBRX); DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4); DALI dali(p22, p21); // tx, rx int main() { pc.baud(115200); pc.printf("DALI sample\r\n"); led1 = 1; for (;;) { if (dali.readable()) { int f, d, v; led3 = 1; dali.read((enum DALI::DALI_FRAME*)&f, &d, &v); pc.printf("dali f=%d d=%d v=%d\r\n", f, d, v); } if (pc.readable()) { char c = pc.getc(); led4 = 1; if (c >= '0' && c <= '9') { dali.write(DALI::DALI_FORWARD_SHORT_DAP, DALI_ADDRESS, (c - '0') * 20); } else if (c == ' ') { dali.write(DALI::DALI_FORWARD_SHORT_DAP, DALI_ADDRESS, 255); } else if (c == 'a') { dali.write(DALI::DALI_FORWARD_SHORT_IAP, DALI_ADDRESS, 0x00); // OFF } else if (c == 'b') { dali.write(DALI::DALI_FORWARD_SHORT_IAP, DALI_ADDRESS, 0x05); // RECALL_MAX_LEVEL } else if (c == 'c') { dali.write(DALI::DALI_FORWARD_SHORT_IAP, DALI_ADDRESS, 0x90); // QUERY_STATUS } } wait_ms(50); led2 = ! led2; led3 = led4 = 0; } }