void delegateLedUsb(uint8_t xState){ setLEDState(xState); // Get the state of all LEDs setLEDIndicate(); if(_ledInitState == INIT_LED_INDEX_NOT_INIT){ _ledInitState = INIT_LED_INDEX_INITED; } }
void delegateLedUsb(uint8_t xState){ DBG1(0x3A, (uchar *)&xState, 1); setLEDState(xState); // Get the state of all LEDs setLEDIndicate(); if(_ledInitState == INIT_INDEX_NOT_INIT){ _ledInitState = INIT_INDEX_INITED; } }
void menuHandlerInit(void){ //In order to ensure the LEDs get cleared i8MainMenuState = X_MENU; setLEDAlternateFuncFlag(TRUE); turnOffAllLEDs(); i8MenuChangeFlag = 0; vTaskDelay(500);//Make sure the LED queue gets cleared setLEDState(u8LEDMainMenuMapping[i8MainMenuState], BLINK); setRedLEDs(MAX_BRIGHTNESS); }
void ofxRPiCameraVideoGrabber::applyAllSettings() { setExposurePreset(exposurePreset); setMeteringType(meteringType); setAutoISO(autoISO); setISO(ISO); setAutoShutter(autoShutter); setShutterSpeed(shutterSpeed); setSharpness(sharpness); setContrast(contrast); setBrightness(brightness); setSaturation(saturation); setFrameStabilization(frameStabilization); setWhiteBalance(whiteBalance); setImageFilter(imageFilter); setColorEnhancement(false); //TODO implement setDRE(dreLevel); setSensorCrop(cropRectangle); setDigitalZoom(); setRotation(rotation); setMirror(mirror); setSoftwareSharpening(doDisableSoftwareSharpen); setSoftwareSaturation(doDisableSoftwareSaturation); applyExposure(__func__); //Requires gpio program provided via wiringPi //sudo apt-get install wiringpi ofFile gpioProgram("/usr/bin/gpio"); hasGPIOProgram = gpioProgram.exists(); if(hasGPIOProgram) { LED_PIN = getLEDPin(); stringstream command; command << "gpio export "; command << LED_PIN; command << " out"; if(system(command.str().c_str()) == 0) { //silence compiler warning } LED = true; setLEDState(LED); } }
void MenuStateMachine(void){ uint8_t u8ExitWithoutSavingFlag = TRUE; uint8_t u8MemCommand; static uint32_t u32defaultSettingsInitialValue; static uint8_t u8checkForDefaultSettings = FALSE; uint32_t u32TickCount; //Check to see if the encoder moved if(i8MenuChangeFlag != 0 && i8SubMenuState == SUBMENU_NOT_SELECTED){ changeMainMenuState(); resetBlink(); } //Check to see if the encoder switch is held down for 3 seconds. This is //the mechanism for defaulting the menu. if(u8MenuKeyPressFlag == TRUE){ //Start the timer. u32TickCount = xTaskGetTickCount(); u32defaultSettingsInitialValue = u32TickCount; u8checkForDefaultSettings = TRUE; }else{ //If the switch continues to be held down for 3 seconds, default the settings and exit the menu. if(u8checkForDefaultSettings == TRUE){ if(!READ_ENC_SWITCH){//Switch is held down. //Increment the timer u32TickCount = xTaskGetTickCount(); if((u32TickCount - u32defaultSettingsInitialValue) > DEFAULT_SETTINGS_TIME_LENGTH){ defaultSettings(); u8ExitWithoutSavingFlag = FALSE; u8MenuExitFlag = TRUE; u8checkForDefaultSettings = FALSE; } }else{ u8checkForDefaultSettings = FALSE; } } } switch(i8MainMenuState){ case X_MENU: case Y_MENU: case Z_MENU: //Handle the encoder switch press if(u8MenuKeyPressFlag == TRUE){ u8MenuKeyPressFlag = FALSE; //If no submenu has been selected, enter submenu mode if(i8SubMenuState == SUBMENU_NOT_SELECTED){ i8SubMenuState = RANGE; setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON); setLEDState(u8XYZSubMenuMapping[i8SubMenuState-1], BLINK); } else if(u8ParameterEditModeFlag == FALSE){ //Enter the submenu and modify the parameter u8ParameterEditModeFlag = TRUE; setLEDState(u8XYZSubMenuMapping[i8SubMenuState-1], ON); initializeXYZParameterMode(); } else{ //Lock in the selection and exit the menu. u8ExitWithoutSavingFlag = FALSE; u8MenuExitFlag = TRUE; } } //If it made it this far, then it's changing submenus if(i8MenuChangeFlag != 0){ //If we're not in parameter edit mode if(u8ParameterEditModeFlag == FALSE){ changeXYZSubMenuState(); resetBlink(); } else{ editXYZParameter(i8SubMenuState); } } break; case RECORD_MENU: case OVERDUB_MENU: case PLAYBACK_MENU: //Handle the encoder switch press if(u8MenuKeyPressFlag == TRUE){ u8MenuKeyPressFlag = FALSE; //If no submenu has been selected, enter submenu mode if(i8SubMenuState == SUBMENU_NOT_SELECTED){ i8SubMenuState = SOURCE; setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON); setLEDState(u8PlaySubMenuMapping[i8SubMenuState-1], BLINK); } else if(u8ParameterEditModeFlag == FALSE){ //Enter the submenu and modify the parameter u8ParameterEditModeFlag = TRUE; setLEDState(u8PlaySubMenuMapping[i8SubMenuState-1], ON); initializeRecParameterMode(i8MainMenuState-RECORD_MENU); } else{ //Locking in the change and exiting the menu. u8ExitWithoutSavingFlag = FALSE; u8MenuExitFlag = TRUE; } } //If it made it this far, then it's changing submenus if(i8MenuChangeFlag != 0){ //If we're not in parameter edit mode if(u8ParameterEditModeFlag == FALSE){ changeRecSubMenuState(); resetBlink(); } else{ editRecParameter(i8MainMenuState-RECORD_MENU); } } break; case LOAD_MENU: case STORE_MENU: //Store a sequence /*The first key press enters the mode. The next one issues a store * command*/ if(u8MenuKeyPressFlag == TRUE){ u8MenuKeyPressFlag = FALSE; if(i8MainMenuState == LOAD_MENU){ if(u8LoadModeFlag == FALSE){ //u8LoadModeFlag = TRUE; /*Set the LEDs on for locations which have a stored sequence. Flash the currently selected LED.*/ u8LoadModeFlag = initializeLoadStoreMode(); if(u8LoadModeFlag == 1){ i8SubMenuState = 1; } } else{ //Load the sequence flashLoadSequence(u8LoadStoreParameter); u8LoadModeFlag = FALSE; u8MenuExitFlag = TRUE; } }else{ if(u8StoreModeFlag == FALSE){ //u8StoreModeFlag = TRUE; u8StoreModeFlag = initializeLoadStoreMode(); if(u8StoreModeFlag == 1){ i8SubMenuState = 1; } } else{ //Store the sequence flashStoreSequence(u8LoadStoreParameter, getLengthOfRecording()); u8StoreModeFlag = FALSE; u8MenuExitFlag = TRUE; } } } //Handle the encoder if(u8StoreModeFlag == TRUE || u8LoadModeFlag == TRUE){ if(i8MenuChangeFlag != 0){ editLoadStoreParameter(); } } else{ i8MenuChangeFlag = 0; } break; case EFFECT_MENU: if(u8MenuKeyPressFlag == TRUE){ u8MenuKeyPressFlag = FALSE; if(u8EffectModeFlag == FALSE){ i8SubMenuState = 1; u8EffectModeFlag = TRUE; setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON); initializeEffectMode(); } else{ //Set the effect mode u8EffectModeFlag = FALSE; //Locking in the change and exiting the menu. u8ExitWithoutSavingFlag = FALSE; u8MenuExitFlag = TRUE; } } //Handle the encoder if(u8EffectModeFlag == TRUE){ if(i8MenuChangeFlag != 0){ editEffectParameter(); } } else{ i8MenuChangeFlag = 0; } break; case CLOCK_MENU: if(u8MenuKeyPressFlag == TRUE){ u8MenuKeyPressFlag = FALSE; if(i8SubMenuState == SUBMENU_NOT_SELECTED){ u8ClockModeFlag = TRUE; i8SubMenuState = SYNC; setLEDState(u8LEDMainMenuMapping[i8MainMenuState], ON); setLEDState(u8LEDMainMenuMapping[i8SubMenuState-1], BLINK); } else if(u8ParameterEditModeFlag == FALSE){ //Enter the submenu and modify the parameter u8ParameterEditModeFlag = TRUE; setLEDState(u8LEDMainMenuMapping[i8SubMenuState-1], ON); initializeClockMode(); } else{ //Set the effect mode u8ClockModeFlag = FALSE; //Locking in the change and exiting the menu. u8ExitWithoutSavingFlag = FALSE; u8MenuExitFlag = TRUE; } } //If it made it this far, then it's changing submenus if(i8MenuChangeFlag != 0){ //If we're not in parameter edit mode if(u8ParameterEditModeFlag == FALSE){ changeClockSubMenuState(); resetBlink(); } else{ editClockParameter(); } } break; default: break; } /*When we exit the menu, we have to reset the LIVE PLAY INTERACTION stuff or we could end up in a weird state.*/ if(u8MenuExitFlag == TRUE){ /*If the main switch is pressed, then we exit without saving the change and need to reset the parameter.*/ if(u8ExitWithoutSavingFlag == TRUE){ resetMenuParameter(); } else{ //Write the file table with the stored settings. copyCurrentSettingsToFileTable(0); u8MemCommand = WRITE_FLASH_FILE_TABLE; xQueueSend(xMemInstructionQueue, &u8MemCommand, 0); } resetEncoderLiveInteraction();//Encoder turning needs to be reset to not get spurious changes. i8SubMenuState = SUBMENU_NOT_SELECTED; u8MenuExitFlag = FALSE; setLEDAlternateFuncFlag(FALSE);//LEDs back to indicating position turnOffAllLEDs();//Reset the LEDs state setRedLEDs(HALF_BRIGHTNESS); setMenuModeFlag(FALSE);//Master control knows menu is over u8ParameterEditModeFlag = FALSE; u8LoadModeFlag = FALSE; u8StoreModeFlag = FALSE; } }
static void processRxPs2(void){ // check that every key code for single keys are transmitted if (kbd_flags & FLA_RX_BAD) { // pokud je nastaveny flag spatneho prijmu, zrus ho // pokud flag is set back income withdrawn cli(); kbd_flags &= ~FLA_RX_BAD; sei(); } if ( isReadyForRx() && (keyval==SPLIT || isEmpty())) { // pokud nastaveny flag prijmu bytu, vezmi ho a zanalyzuj // pokud law, the flag setting apart, take it and zanalyzuj rxed = kbd_get_rx_char(); setWaitingRx(false); switch(m_state) { default: switch(rxed) { case 0xEE: /* echo */ // DEBUG_PRINT((" echo \n")); DBG1(0xd0, (uchar *)&rxed, 1); tx_state(0xEE, m_state); return; case 0xF2: /* read id */ // DEBUG_PRINT((" read id \n")); DBG1(0xd1, (uchar *)&rxed, 1); tx_state(0xFA, STA_WAIT_ID); return; case 0xFF: /* reset */ // DEBUG_PRINT((" reset \n")); DBG1(0xd2, (uchar *)&rxed, 1); tx_state(0xFA, STA_WAIT_RESET); return; case 0xFE: /* resend */ // DEBUG_PRINT((" resend \n")); DBG1(0xd3, (uchar *)&rxed, 1); tx_state(lastSent, m_state); return; case 0xF0: /* scan code set */ // DEBUG_PRINT((" scan code set \n")); DBG1(0xd4, (uchar *)&rxed, 1); // 2 tx_state(0xFA, STA_WAIT_SCAN_SET); return; case 0xED: /* led indicators */ // DEBUG_PRINT((" led indicators \n")); DBG1(0xd5, (uchar *)&rxed, 1); // 4 tx_state(0xFA, STA_WAIT_LEDS); return; case 0xF3: // DEBUG_PRINT((" STA_WAIT_AUTOREP \n")); DBG1(0xd6, (uchar *)&rxed, 1); // 3 tx_state(0xFA, STA_WAIT_AUTOREP); return; case 0xF4: // enable // DEBUG_PRINT((" enable \n")); DBG1(0xd7, (uchar *)&rxed, 1); // 5 tx_state(0xFA, STA_NORMAL); initPs2(); return; case 0xF5: // disable // DEBUG_PRINT((" disable \n")); DBG1(0xd8, (uchar *)&rxed, 1); tx_state(0xFA, STA_NORMAL); return; case 0xF6: // Set Default // DEBUG_PRINT((" Set Default \n")); DBG1(0xd9, (uchar *)&rxed, 1); // 1 TYPEMATIC_DELAY=1; TYPEMATIC_REPEAT=5; clear(); tx_state(0xFA, STA_NORMAL); return; default: // DEBUG_PRINT((" default \n")); DBG1(0xda, (uchar *)&rxed, 1); tx_state(0xFA, STA_NORMAL); break; } return; case STA_RXCHAR: // DEBUG_PRINT((" STA_RXCHAR \n")); if (rxed == 0xF5) tx_state(0xFA, STA_NORMAL); else { tx_state(0xFA, STA_RXCHAR); } return; case STA_WAIT_SCAN_SET: // DEBUG_PRINT((" STA_WAIT_SCAN_SET \n")); clear(); tx_state(0xFA, rxed == 0 ? STA_WAIT_SCAN_REPLY : STA_NORMAL); return; case STA_WAIT_AUTOREP: // DEBUG_PRINT((" STA_WAIT_AUTOREP STA_WAIT_AUTOREP \n")); TYPEMATIC_DELAY = (rxed&0b01100000)/0b00100000; temp_a = (rxed&0b00000111); temp_b = (rxed&0b00011000)/(0b000001000); j=1; for(i=0;i<temp_b;i++) { j = j*2; } TYPEMATIC_REPEAT = temp_a*j; tx_state(0xFA, STA_NORMAL); return; case STA_WAIT_LEDS: DBG1(0xdb, (uchar *)&rxed, 1); initPs2(); uint8_t ledstate = 0; // scroll lock if(rxed&0x01) ledstate |= LED_STATE_SCROLL; // num lock if(rxed&0x02) ledstate |= LED_STATE_NUM; // capslock if(rxed&0x04) ledstate |= LED_STATE_CAPS; setLEDState(ledstate); setLEDIndicate(); tx_state(0xFA, STA_NORMAL); return; } } }
void ofxRPiCameraVideoGrabber::toggleLED() { setLEDState(!LED); }