va_end(args);
}
+void decide_set(int n){
+ switch (n){
+ case 1:
+ LL_GPIO_SetOutputPin(MEGGY1_GPIO_Port, MEGGY1_Pin);
+ break;
+ case 2:
+ LL_GPIO_SetOutputPin(MEGGY2_GPIO_Port, MEGGY2_Pin);
+ break;
+ case 3:
+ LL_GPIO_SetOutputPin(MEGGY3_GPIO_Port, MEGGY3_Pin);
+ break;
+ case 0:
+ LL_GPIO_SetOutputPin(MEGGY4_GPIO_Port, MEGGY4_Pin);
+ break;
+ }
+}
+
+void decide_reset(int n){
+ switch (n){
+ case 1:
+ LL_GPIO_ResetOutputPin(MEGGY1_GPIO_Port, MEGGY1_Pin);
+ break;
+ case 2:
+ LL_GPIO_ResetOutputPin(MEGGY2_GPIO_Port, MEGGY2_Pin);
+ break;
+ case 3:
+ LL_GPIO_ResetOutputPin(MEGGY3_GPIO_Port, MEGGY3_Pin);
+ break;
+ case 0:
+ LL_GPIO_ResetOutputPin(MEGGY4_GPIO_Port, MEGGY4_Pin);
+ break;
+ }
+}
+
+byte recognize(int n){
+ if (n<150) return 0;
+ else return 1;
+}
+
void run_test(void)
{
uint cnt = 0;
+ uint cnt2 = 0;
+ static const char mtree[]="**ETIANMSURWDKGOHVF*L*PJBXCYZQ**";
+ int letter=1;
for (;;)
{
- debug_printf(">>> %d\n", cnt);
- cnt++;
LL_GPIO_SetOutputPin(LD2_GPIO_Port, LD2_Pin);
- LL_GPIO_SetOutputPin(MEGGY1_GPIO_Port, MEGGY1_Pin);
- LL_GPIO_SetOutputPin(MEGGY2_GPIO_Port, MEGGY2_Pin);
- LL_GPIO_SetOutputPin(MEGGY3_GPIO_Port, MEGGY3_Pin);
- if (LL_GPIO_IsInputPinSet(BLUE_BUTTON_GPIO_Port, BLUE_BUTTON_Pin))
- LL_GPIO_SetOutputPin(MEGGY4_GPIO_Port, MEGGY4_Pin);
- LL_mDelay(100);
+ cnt=0;
+ while (!LL_GPIO_IsInputPinSet(BLUE_BUTTON_GPIO_Port, BLUE_BUTTON_Pin)){
+ cnt++;
+ LL_mDelay(1);
+ }
LL_GPIO_ResetOutputPin(LD2_GPIO_Port, LD2_Pin);
- LL_GPIO_ResetOutputPin(MEGGY1_GPIO_Port, MEGGY1_Pin);
- LL_GPIO_ResetOutputPin(MEGGY2_GPIO_Port, MEGGY2_Pin);
- LL_GPIO_ResetOutputPin(MEGGY3_GPIO_Port, MEGGY3_Pin);
- LL_GPIO_ResetOutputPin(MEGGY4_GPIO_Port, MEGGY4_Pin);
- LL_mDelay(100);
+ // debug_printf(">>> %d\n", cnt);
+ letter=(letter<<1)+recognize(cnt);
+ cnt=0;
+ while (LL_GPIO_IsInputPinSet(BLUE_BUTTON_GPIO_Port, BLUE_BUTTON_Pin)){
+ cnt++;
+ LL_mDelay(1);
+ if (cnt==150) {
+ debug_putc(mtree[letter]);
+ letter=1;
+ }
+ if (cnt==1500) debug_putc(' ');
+ if (cnt==4000) debug_putc('\n');
+ }
+
+ cnt2++;
+ for (int i=0;i<4;i++){
+ if (cnt2&(1<<i)) decide_set((i+1)%4);
+ else decide_reset((i+1)%4);
+ }
}
}