RT-USB-9AXIS-00
modeSelect.c
[詳解]
1 
15 #include "modeSelect.h"
16 
17 #include "LPC13xx.h"
18 #include "core_cm3.h"
19 #include "type.h"
20 
21 #include "UserInterface.h"
22 #include "SystemTickTimer.h"
23 #include "debug.h"
24 #include "usbTransmission.h"
25 
26 //動作モード毎の処理
27 #include "mode_calibOmega.h"
28 #include "mode_calibAccXY.h"
29 #include "mode_calibAccZ.h"
30 #include "mode_calibMag.h"
31 #include "mode_viewAllData.h"
32 #include "mode_viewEEPROMData.h"
33 #include "mode_clearOffset.h"
34 #include "mode_outputSelect.h"
35 
36 static void modeSelectInfo(void)
37 {
38 
39  myPrintfUSB("############ mode select ################\n");
40  myPrintfUSB("++++++++++++++++++++++++++++++++\n");
41  myPrintfUSB(" Choose the mode .\n");
42  myPrintfUSB(" Short press SW: mode change \n");
43  myPrintfUSB(" Long press SW: enter \n");
44  myPrintfUSB("++++++++++++++++++++++++++++++++\n");
45  myPrintfUSB(" 0 output this info. :Green LED OFF \n");
46  myPrintfUSB(" 1 calib Omega mode :Green LED ON \n");
47  myPrintfUSB(" 2 calib ACCXY mode :flashing Green LED 0.5Hz \n");
48  myPrintfUSB(" 3 calib ACCZ mode :flashing Green LED 1Hz \n");
49  myPrintfUSB(" 4 calib Mag mode :flashing Green LED 2Hz \n");
50  myPrintfUSB(" 5 viewAllData mode :flashing Green LED 4Hz \n");
51  myPrintfUSB(" 6 viewEEPROMData mode :flashing Green LED 8Hz \n");
52  myPrintfUSB(" 7 clear offset mode :flashing Green LED 16Hz \n");
53  myPrintfUSB(" 8 output mode select mode :flashing Green LED 32Hz \n");
54 }
55 
56 void modeSelect(void)
57 {
58  uint8_t md_select = 0;
59  uint32_t sw_count_max = 0;
60  modeSelectInfo();
61 
62  while(1)
63  {
64  wait1msec(1);
65  if( getSWcount() > 0 ) //SWでモード選択
66  {
67  while(getSWcount() != 0 )
68  {
69  sw_count_max = getSWcount();
70  wait1msec(1);
71  if(sw_count_max >3000) break;
72  };
73  //スイッチ短押し
74  if(sw_count_max <3000)
75  {
76  md_select++;
77  md_select = md_select % 9;
78  myPrintfUSB("\t md_select = %d \n ",md_select);
79  switch(md_select){
80  case 0: turnGreenLED(0);
81  modeSelectInfo();
82  break;
83  case 1: turnGreenLED(1);
84  break;
85  case 2: flashGreenLED(1000,1000);
86  break;
87  case 3: flashGreenLED(500,500);
88  break;
89  case 4: flashGreenLED(250,250);
90  break;
91  case 5: flashGreenLED(125,125);
92  break;
93  case 6: flashGreenLED(63,62);
94  break;
95  case 7: flashGreenLED(32,31);
96  break;
97  case 8: flashGreenLED(16,16);
98  break;
99  }
100  }
101  else //スイッチ長押し
102  {
103  break;
104  }
105  }
106  }//end while
107 
108  myPrintfUSB("\t enter\n");
109  flashGreenLED(20,80);
110  wait1msec(3000);
111  turnGreenLED(0);
112 
113 
114  switch(md_select){
115  case 0:
116  break;
117  case 1: mode_calibOmega();
118  break;
119  case 2: mode_calibAccXY();
120  break;
121  case 3: mode_calibAccZ();
122  break;
123  case 4: mode_calibMag();
124  break;
125  case 5: mode_viewAllData();
126  break;
127  case 6: mode_viewEEPROMData();
128  break;
129  case 7: mode_clearOffset();
130  break;
131  case 8: mode_outputSelect();
132  break;
133  }
134 
135  flashGreenLED(160,40);
136  wait1msec(3000);
137  turnGreenLED(0);
138 }
139 
140 
uint16_t getSWcount(void)
Definition: UserInterface.c:78
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
LED,SW,電源電圧の監視等の機能の実装
void flashGreenLED(uint16_t on_count, uint16_t off_count)
void turnGreenLED(uint8_t state)