void startAdvancedAsyncDefault(uint8_t pin){ //println_W("Starting advanced async on channel: ");p_int_W(pin); //int mode =GetChannelMode(pin); //getBcsIoDataTable(pin)->PIN.asyncDataPreviousVal=0xffffffff;; int32_t mode =GetChannelMode(pin); if(mode == IS_ANALOG_IN){ float val = GetChanVal( pin) ; configAdvancedAsyncDeadBand(pin,val*1.1,val*0.9); }else{ getBcsIoDataTable(pin)->asyncDataTimer.MsTime=getMs(); getBcsIoDataTable(pin)->asyncDataTimer.setPoint=10; getBcsIoDataTable(pin)->PIN.asyncDataType = NOTEQUAL; } RunEvery(getPinsScheduler( pin)); }
BOOL GetChannelValue(BowlerPacket * Packet){ BOOL ret=FALSE; BYTE pin = Packet->use.data[0]; BYTE mode = GetChannelMode(pin); //int i; UINT16 val=GetChanVal(pin); if(IsAsync(pin)){ //AsynAck(); } Packet->use.head.Method=BOWLER_POST; if ((mode == IS_DC_MOTOR_VEL)||(mode == IS_DC_MOTOR_DIR)||(mode == IS_DO)|| (mode == IS_PWM)|| (mode == IS_SERVO) || (mode == IS_DI) ||(mode == IS_COUNTER_OUTPUT_HOME)||(mode == IS_COUNTER_INPUT_HOME)){ set8bit(Packet, val,1); Packet->use.head.DataLegnth=6; ret = TRUE; }else if ((mode == IS_ANALOG_IN)){ val=GetADC(pin); set16bit(Packet,val,1); Packet->use.head.DataLegnth=7; ret = TRUE; }else if ( (mode == IS_UART_TX) || (mode == IS_UART_RX)){ //Number of bytes in the stream to be sent Packet->use.head.DataLegnth=5; UINT16 numBytes=Get_UART_Byte_CountPassThrough(); if(numBytes>0){ UARTGetArrayPassThrough(Packet->use.data+1,numBytes); //Offset using pointer, rather then shuffeling // for (i=0;i<numBytes;i++){ // Packet->use.data[(numBytes)-i]=Packet->use.data[(numBytes-1)-i]; // } Packet->use.data[0]=17; Packet->use.head.DataLegnth+=numBytes; } return TRUE; }else{ return FALSE; } return ret; }