大季 矢花
/
MB2019_main_alltimes
aa
Communication/Controller/Mu/Mu.cpp@0:669ef71cba68, 2018-09-08 (annotated)
- Committer:
- t_yamamoto
- Date:
- Sat Sep 08 06:05:22 2018 +0000
- Revision:
- 0:669ef71cba68
- Child:
- 1:b1219d8ca117
???????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:669ef71cba68 | 1 | #include "Mu.h" |
t_yamamoto | 0:669ef71cba68 | 2 | |
t_yamamoto | 0:669ef71cba68 | 3 | namespace MU { |
t_yamamoto | 0:669ef71cba68 | 4 | Serial MuUart(MU_TX, MU_RX); |
t_yamamoto | 0:669ef71cba68 | 5 | |
t_yamamoto | 0:669ef71cba68 | 6 | namespace { |
t_yamamoto | 0:669ef71cba68 | 7 | char Group[][4] = {"01", "02", "03", "04"}; |
t_yamamoto | 0:669ef71cba68 | 8 | char Channel[][4] = {"08", "14", "1F", "2E"}; |
t_yamamoto | 0:669ef71cba68 | 9 | char DI[][4] = {"10", "20", "40", "80"}; |
t_yamamoto | 0:669ef71cba68 | 10 | char EI[][4] = {"01", "02", "04", "08"}; |
t_yamamoto | 0:669ef71cba68 | 11 | } |
t_yamamoto | 0:669ef71cba68 | 12 | |
t_yamamoto | 0:669ef71cba68 | 13 | void Mu::SendCommand(char *command, char *value, uint8_t valueLength) { |
t_yamamoto | 0:669ef71cba68 | 14 | MuUart.putc('@'); |
t_yamamoto | 0:669ef71cba68 | 15 | MuUart.putc(command[0]); |
t_yamamoto | 0:669ef71cba68 | 16 | MuUart.putc(command[1]); |
t_yamamoto | 0:669ef71cba68 | 17 | while(valueLength--) { |
t_yamamoto | 0:669ef71cba68 | 18 | MuUart.putc(*value); |
t_yamamoto | 0:669ef71cba68 | 19 | value++; |
t_yamamoto | 0:669ef71cba68 | 20 | } |
t_yamamoto | 0:669ef71cba68 | 21 | MuUart.putc('\r'); |
t_yamamoto | 0:669ef71cba68 | 22 | MuUart.putc('\n'); |
t_yamamoto | 0:669ef71cba68 | 23 | } |
t_yamamoto | 0:669ef71cba68 | 24 | |
t_yamamoto | 0:669ef71cba68 | 25 | void Mu::Initialize(uint8_t select) { |
t_yamamoto | 0:669ef71cba68 | 26 | MuUart.baud(19200); |
t_yamamoto | 0:669ef71cba68 | 27 | |
t_yamamoto | 0:669ef71cba68 | 28 | Mu::SendCommand("GI",Group[select],2); |
t_yamamoto | 0:669ef71cba68 | 29 | Mu::SendCommand("CH",Channel[select],2); |
t_yamamoto | 0:669ef71cba68 | 30 | Mu::SendCommand("DI",DI[select],2); |
t_yamamoto | 0:669ef71cba68 | 31 | Mu::SendCommand("EI",EI[select],2); |
t_yamamoto | 0:669ef71cba68 | 32 | } |
t_yamamoto | 0:669ef71cba68 | 33 | } |