static void RADIO_PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[24]; uint8_t val0, val1; CLS1_SendStatusStr((unsigned char*)"Radio", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" state", RadioStateStr(RADIO_AppStatus), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" sniff", RADIO_isSniffing?(unsigned char*)"yes\r\n":(unsigned char*)"no\r\n", io->stdOut); UTIL1_Num8uToStr(buf, sizeof(buf), RADIO_channel); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr((unsigned char*)" channel", buf, io->stdOut); (void)RF1_ReadObserveTxRegister(&val0, &val1); UTIL1_Num8uToStr(buf, sizeof(buf), val0); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" lost, "); UTIL1_strcatNum8u(buf, sizeof(buf), val1); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" retry\r\n"); CLS1_SendStatusStr((unsigned char*)" OBSERVE_TX", buf, io->stdOut); #if 0 /* The RPD status will get reset very fast by another (e.g. WLAN) packet. So this is not really a useful feature :-( */ (void)RF1_ReadReceivedPowerDetector(&val0); /*! \todo only works in RX mode, but somehow this still does not work? */ if (val0&1) { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"1, > -64 dBm\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0, < -64 dBm\r\n"); } CLS1_SendStatusStr((unsigned char*)" RPD", buf, io->stdOut); #endif }
/* ** =================================================================== ** Method : CLS1_SendNum8u (component Shell) ** Description : ** Sends an 8bit unsigned number to the given I/O ** Parameters : ** NAME - DESCRIPTION ** val - number to print ** io - I/O callbacks to be used for printing. ** Returns : Nothing ** =================================================================== */ void CLS1_SendNum8u(uint8_t val, CLS1_StdIO_OutErr_FctType io) { unsigned char buf[sizeof("123")]; UTIL1_Num8uToStr(buf, sizeof(buf), val); CLS1_SendStr(buf, io); }
static void PrintPIDstatus(PID_Config *config, const unsigned char *kindStr, const CLS1_StdIOType *io) { unsigned char buf[48]; unsigned char kindBuf[16]; UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" PID"); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"p: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->pFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" i: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->iFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" d: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->dFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" windup"); UTIL1_Num32sToStr(buf, sizeof(buf), config->iAntiWindup); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" speed"); UTIL1_Num8uToStr(buf, sizeof(buf), config->maxSpeedPercent); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"%\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); }
void DHT11() { byte dht11_dat[5]; byte dht11_in; byte i; // output DHT_SetDir(1); // pull-down i/o pin for 18ms DHT_ClrVal(); WAIT1_Waitms(19); DHT_SetVal(); //pull-up i/o pin for 30ms WAIT1_Waitus(30); //input DHT_SetDir(0); WAIT1_Waitus(30); while(!dht11_in) { dht11_in = DHT_GetVal(); } // if (dht11_in) { // printf("dht11 start condition 1 not met\r\n"); // return; // } WAIT1_Waitus(80);//delayMicroseconds(80); // dht11_in = DHT_GetVal();//dht11_in = PINC & _BV(DHT11_PIN); // if (!dht11_in) { // printf("dht11 start condition 2 not met\r\n"); // return; // } // WAIT1_Waitus(80);//delayMicroseconds(80); // now ready for data reception for (i = 0; i < 5; i++) dht11_dat[i] = read_dht11_dat(); DHT_SetDir(1); DHT_SetVal(); byte dht11_check_sum = dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]; // check check_sum if (dht11_dat[4] != dht11_check_sum) { printf("DHT11 checksum error\r\n"); } printf("Current humdity = "); //printf("%d",dht11_dat[0]); UTIL1_Num8uToStr(strTmp1, sizeof(strTmp1),dht11_dat[0]); UTIL1_Num8uToStr(strTmp2, sizeof(strTmp2),dht11_dat[1]); UTIL1_strcat(strTmp1, sizeof(strTmp1),(byte *)"."); UTIL1_strcat(strTmp1, sizeof(strTmp1),strTmp2); UTIL1_strcat(strTmp1, sizeof(strTmp1),(byte *)"%%\r\n"); //printf((char *)strTmp1); //printf("."); //printf((char *)strTmp2); //printf("%d",dht11_dat[1]); //printf("%%\r\n"); printf((char *)strTmp1); printf("temperature = "); printf("%d",dht11_dat[2]); printf("."); printf("%d",dht11_dat[3]); printf("C \r\n"); // WAIT1_Waitms(2000);//delay(2000); }