/* Send the corresponding wave signal based on the plug id and the action. */ void sendSequenceByPlugId(uint8_t id, int action) { uint16_t plug_code = 0; plug_code = findPlugCode(id); if(plug_code != 0) { sendSequence(plug_code, action); sendSequence(plug_code, action); sendSequence(plug_code, action); } }
void AdminConnection::processDescribeCommand(InputFrame::Ptr frame) { Logger::getLogger()->debug("doing describe command frame"); if(frame->getDataLength() < 4){ throw FrameException(fec_FrameError); } int numdesc = frame->unpackInt(); if(frame->getDataLength() < 4 + 4 * numdesc){ throw FrameException(fec_FrameError); } sendSequence(frame,numdesc); if(numdesc == 0){ DEBUG("asked for no commands to describe"); throw FrameException( fec_NonExistant, "You didn't ask for any command descriptions, try again"); } for(int i = 0; i < numdesc; i++){ OutputFrame::Ptr of = createFrame(frame); int cmdtype = frame->unpackInt(); CommandManager::getCommandManager()->describeCommand(cmdtype, of); sendFrame(of); } }
////////////////////////////////////////////////////////////////// // Function to perform initial set-up of Accelerometer ////////////////////////////////////////////////////////////////// void initialSetupAccelerometerData() { sendSequence(WRITE_INSTRUCTION, FILTER_CTL_REG, FILTER_CTL_VAL); // Write to Filter Control Reg first sendSequence(WRITE_INSTRUCTION, POWER_CTL_REG, POWER_CTL_VAL); // Write to Power Control Reg -> Measurement mode }
////////////////////////////////////////////////////////////////// // Function to read data from accelerometer via SPI // Sends three bytes to SPI then reads from SPIDAT ////////////////////////////////////////////////////////////////// uint8 readData(uint8 address) { sendSequence(READ_INSTRUCTION, address, GARBAGE_DATA); return pt2SPI->SPIDAT; }
void keypad(void const *argument){ printf("keypad thread entered!\n"); int8_t num = -1; int8_t k = 0;; char ch; // while(1){ // keypad_column_init(); // osDelay(200); // // /*read column*/ // int8_t key_column = readKeyColumn(); // keypad_row_init(); // // /*read row*/ // int8_t key_row = readKeyRow(); // // /*read number*/ // num = read_keypad(key_column, key_row); // if (num != -1) // printf ("%d\n", num); // else{ // ch = read_symble(key_column, key_row); // if (ch != 'e'){ // printf ("%c\n", ch); // } // while (ch != 'D'){ keypad_column_init(); osDelay(250); /*read column*/ int8_t key_column = readKeyColumn(); keypad_row_init(); /*read row*/ int8_t key_row = readKeyRow(); ch = read_keypad(key_column, key_row); if (ch != 'e' ){ // sequence[k] = ch; // printf("sequence[%d]: %c\n", k,sequence[k] ); // k++; //if (ch == 'D'){ sequence[0] = ch; sequence[1] = 'D'; printf ("before sendSequence: %s\n", sequence); LCD_clear_display(); LCD_DISPLAY_UPDATE_POS(0x80, sequence); sendSequence(sequence); //transmit_sequence_thread = osThreadCreate(osThread(transmitSequence), NULL); //} } } // // }