Последовательное выполнение команд.
Втр, 10/12/2013 - 11:47
vvg10
Offline
Зарегистрирован: 18.04.2013
Не понял, куда-то пропала тема. Спрошу еще раз.
Здравствуйте! Помогите разобраться. Есть набор кнопок и набор команд, которые контроллер выдает при нажатии соответствующей кнопки.
#define cmdPin 7 #define lancPin 11 #define recButton 6 #define zoomOutButton 5 #define zoomInButton 4 #define focusAutoButton 8 #define powerOffButton 9 #define WBSetButton 10 #define focusNearButton 3 #define focusFarButton 2 int cmdRepeatCount; int bitDuration = 104; //Duration of one LANC bit in microseconds. //LANC commands byte 0 + byte 1 //Start-stop video recording boolean REC[] = {LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW, LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH}; //18 33 //Zoom in from slowest to fastest speed boolean ZOOM_IN_0[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW}; //28 00 boolean ZOOM_IN_1[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,LOW,LOW,HIGH,LOW}; //28 02 boolean ZOOM_IN_2[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,LOW,HIGH,LOW,LOW}; //28 04 boolean ZOOM_IN_3[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,LOW,HIGH,HIGH,LOW}; //28 06 boolean ZOOM_IN_4[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,HIGH,LOW,LOW,LOW}; //28 08 boolean ZOOM_IN_5[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,HIGH,LOW,HIGH,LOW}; //28 0A boolean ZOOM_IN_6[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,HIGH,HIGH,LOW,LOW}; //28 0C boolean ZOOM_IN_7[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,LOW}; //28 0E //Zoom out from slowest to fastest speed boolean ZOOM_OUT_0[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,LOW,LOW,LOW,LOW}; //28 10 boolean ZOOM_OUT_1[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,LOW,LOW,HIGH,LOW}; //28 12 boolean ZOOM_OUT_2[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,LOW,HIGH,LOW,LOW}; //28 14 boolean ZOOM_OUT_3[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,LOW,HIGH,HIGH,LOW}; //28 16 boolean ZOOM_OUT_4[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW}; //28 18 boolean ZOOM_OUT_5[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,HIGH,LOW,HIGH,LOW}; //28 1A boolean ZOOM_OUT_6[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,HIGH,HIGH,LOW,LOW}; //28 1C boolean ZOOM_OUT_7[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,LOW}; //28 1E //Focus control. Camera must be switched to manual focus boolean FOCUS_NEAR[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,HIGH,LOW,LOW,LOW,HIGH,HIGH,HIGH}; //28 47 boolean FOCUS_FAR[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,HIGH,LOW,LOW,LOW,HIGH,LOW,HIGH}; //28 45 //Focus Auto/Manual boolean FOCUS_AUTO[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,HIGH,LOW,LOW,LOW,LOW,LOW,HIGH}; //28 41 boolean POWER_OFF[] = {LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW, LOW,HIGH,LOW,HIGH,HIGH,HIGH,HIGH,LOW}; //18 5E boolean MENU[] = {LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW, HIGH,LOW,LOW,HIGH,HIGH,LOW,HIGH,LOW}; //18 9A boolean MENU_DOWN[] = {LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW, HIGH,LOW,LOW,LOW,LOW,HIGH,HIGH,LOW}; //18 86 boolean MENU_RIGHT[] = {LOW,LOW,LOW,HIGH,HIGH,LOW,LOW,LOW, HIGH,HIGH,LOW,LOW,LOW,LOW,HIGH,LOW}; //18 C2 boolean WB_SET[] = {LOW,LOW,HIGH,LOW,HIGH,LOW,LOW,LOW, LOW,HIGH,HIGH,HIGH,LOW,HIGH,HIGH,HIGH}; //28 77 void setup() { pinMode(lancPin, INPUT); //listens to the LANC line pinMode(cmdPin, OUTPUT); //writes to the LANC line pinMode(recButton, INPUT); //start-stop recording button digitalWrite(recButton, HIGH); //turn on an internal pull up resistor pinMode(zoomOutButton, INPUT); digitalWrite(zoomOutButton, HIGH); pinMode(zoomInButton, INPUT); digitalWrite(zoomInButton, HIGH); pinMode(focusNearButton, INPUT); digitalWrite(focusNearButton, HIGH); pinMode(focusFarButton, INPUT); digitalWrite(focusFarButton, HIGH); pinMode(focusAutoButton, INPUT); digitalWrite(focusAutoButton, HIGH); pinMode(powerOffButton, INPUT); digitalWrite(powerOffButton, HIGH); pinMode(WBSetButton, INPUT); digitalWrite(WBSetButton, HIGH); digitalWrite(cmdPin, LOW); //set LANC line to +5V delay(5000); //Wait for camera to power up completly bitDuration = bitDuration - 8; //Writing to the digital port takes about 8 microseconds so only 96 microseconds are left for each bit } void loop() { if (!digitalRead(recButton)) { lancCommand(REC); } if (!digitalRead(zoomOutButton)) { lancCommand(ZOOM_OUT_4); } if (!digitalRead(zoomInButton)) { lancCommand(ZOOM_IN_4); } if (!digitalRead(focusNearButton)) { lancCommand(FOCUS_NEAR); } if (!digitalRead(focusFarButton)) { lancCommand(FOCUS_FAR); } if (!digitalRead(focusAutoButton)) { lancCommand(FOCUS_AUTO); } if (!digitalRead(powerOffButton)) { lancCommand(POWER_OFF); } if (!digitalRead(WBSetButton)) {
Вопрос: как сделать так, чтобы при нажатии WBSetButton последовательно выдавались команды: Menu, Menu_Down, Menu_Down, Menu_Right, WBSet?
- Войдите на сайт для отправки комментариев
Вот код:
Исходя из того что вы решили показывать и что решили не показывать так:
Спасибо большое!