void AquaTemperatureHelper::loop() { if (!ClockHelper::Instance()->isUpdatedByTimer) { ReadTemperature(); //tempAnalog = analogRead(A0); //currentTempValue = GetTemperatureValue(); if (currentTempValue < minAquaTemp) { isAquaVeryCold = true; isAquaNorm = false; } else if (currentTempValue > maxAquaTemp) { isAquaVeryHeat = true; isAquaNorm = false; } else { isAquaVeryCold = false; isAquaVeryHeat = false; isAquaNorm = true; } } }
int main(){ UartInit(); // timer0Init(); LED = 1; RELAY = 1; // while(1); //* while(1) { str[5]=0x39; //显示C符号 str[1]=tab[TempH/100]; //十位温度 str[2]=tab[(TempH%100)/10]; //十位温度 str[3]=tab[(TempH%100)%10]|0x80; //个位温度,带小数点 str[4]=tab[TempL]; if(flag_get==1) //定时读取当前温度 { temp=ReadTemperature(); if(temp&0x8000) { str[0]=0x40;//负号标志 temp=~temp; // 取反加1 temp +=1; } else str[0]=0; // 0 TempH=temp>>4; TempL=temp&0x0F; TempL=TempL*6/10;//小数近似处理 flag_get=0; } }
uint16_t get_temp() { uint16_t value,t1; ReadTemperature(); t1=high_byte<<8; value=t1+low_byte; return value; }
/** Handle all interrupts (they are classified by usage rate). */ void interrupt(void) { // Screen refresh (Timer 0) if ((intcon.TMR0IE) && (intcon.TMR0IF)) { ScreenRefresh(); intcon.TMR0IF = 0; } // Temperature sampling (Timer 3) if ((pie2.TMR3IE) && (pir2.TMR3IF)) { ReadTemperature(); DisplayStateTemperature(Current_State); // Update displayed temperature (this function is called even if the temperature to display has not changed, but it is simpler this way) pir2.TMR3IF = 0; } // Wake-up timer (Timer 1) if ((pie1.TMR1IE) && (pir1.TMR1IF)) { // Wake up processor and temperature modules ProcessorSetLowPowerMode(0); // Reenable processor full speed prior any other thing TemperatureSetLowPowerMode(0); ReadTemperature(); // Reenable interrupt before returning to low power mode pir1.TMR1IF = 0; // Return to low power mode TemperatureSetLowPowerMode(1); ProcessorSetLowPowerMode(1); } // Button (triggered only when the system is in low power mode) if ((intcon.INT0IE) && (intcon.INT0IF)) { // Reenable processor full speed ProcessorSetLowPowerMode(0); intcon.INT0IF = 0; } }
static int shell_adcalib(int argc, char *argv[]) { int i; i = ReadBatVol(); PrintLog(0, "电池电压: %dmV\n", i); i = ReadTemperature(); PrintLog(0, "当前温度: %d.%dC\n", i/10, i%10); return 0; }
// ------------------------------------------------------------------------- // SUBROUTINE - ReadWet // // 'temp' - The temperature from the DS1820 in F // 'dir' - The wind direction from 0-15 // 'revol' - The wind speed in revolutions per second // // Returns: TRUE, if the reads were successfull and FALSE if they were not. // int ReadWet(int portnum, WeatherStruct *wet, float *temp, int *dir, double *revol) { int ret = TRUE; unsigned long start_count=0, end_count=0, start_time, end_time; float current_temp; // read the current counter // use this reference to calculate wind speed later if (!ReadCounter(portnum, &wet->ds2423[0], 15, &start_count)) { printf("\nError reading counter, verify device present:%d\n", (int)owVerify(portnum, FALSE)); ret = FALSE; } // get a time stamp (mS) start_time = msGettick(); // read the temperature and print in F if (ReadTemperature(portnum, &wet->ds1820[0],¤t_temp)) *temp = current_temp * 9 / 5 + 32; else { printf("\nError reading temperature, verify device present:%d\n", (int)owVerify(portnum, FALSE)); ret = FALSE; } // read the wind direction *dir = TrueDir(portnum, wet); // read the counter again if (!ReadCounter(portnum, &wet->ds2423[0], 15, &end_count)) { printf("Error reading counter, verify device present:%d\n", (int)owVerify(portnum, FALSE)); ret = FALSE; } // get a time stamp (mS) end_time = msGettick(); // calculate the wind speed based on the revolutions per second *revol = (((end_count - start_count) * 1000.0) / (end_time - start_time)) / 2.0; return ret; }
void Sensor_Task(void) { double r, InRs, tmp, adc; WORD chamber = ReadTemperature(ADC_CHAMBER); WORD photodiode = ReadPhotodiode(); WORD index = 0; // save the adc value by high low type chamber_h = (BYTE)(chamber>>8); chamber_l = (BYTE)(chamber); photodiode_h = (BYTE)(photodiode>>8); photodiode_l = (BYTE)(photodiode); // temperature calculation index = (WORD)((chamber/4) * 2.); currentTemp = (float)(pTemp_Chamber[index]) + (float)(pTemp_Chamber[index+1] * 0.1); if( compensation > 0 ){ currentTemp = currentTemp * compensation; } // Checking overheating if( currentTemp >= OVERHEATING_TEMP ){ currentState = STATE_READY; Stop_Task(); currentError = ERROR_OVERHEAT; } // for median filtering temp_buffer[0] = temp_buffer[1]; temp_buffer[1] = temp_buffer[2]; temp_buffer[2] = temp_buffer[3]; temp_buffer[3] = temp_buffer[4]; temp_buffer[4] = currentTemp; memcpy(temp_buffer2, temp_buffer, 5*sizeof(float)); currentTemp = (float)quickSort(temp_buffer2, 5); }
unsigned int get_t(void) { unsigned int t,return_t; unsigned char temp1,temp2; t=ReadTemperature(); if(t&0x8000) { //温度为负 } else { temp1=(unsigned char)(t>>4); temp2=(unsigned char)(t&0x000f); return_t=decimalH[temp2]; temp1%=100; return_t|=(temp1<<8); } return return_t; }
/*FGROUP SHM rc: 0: ok 1: error reading counters Operation: action: read all counters + temperature */ int readCNTS2SHM() { w32 secs, mics; if(shmcnts==NULL) return(1); /* for(ix=0; ix<10; ix++) { shmcnts[ix]=ix; //printf("readCNTS2SHMix:%d\n",ix); }; return(0); */ GetMicSec(&secs, &mics); /* ctpc[CSTART_SPEC+2]= vmer32(L2_ORBIT_READ); readCounters(ctpc, NCOUNTERS, 0); readTVCounters(&ctpc[CSTART_SPEC+3]); //printf("readctpcounters: readCounters ok\n"); ctpc[CSTART_SPEC]= secs; ctpc[CSTART_SPEC+1]= mics; //ctpc[13]= getCounter(1,13); ctpc[CSTART_L1+5]= getCounter(2,5); */ readCounters(shmcnts, LTUNCOUNTERS, 0); // LTU counters shmcnts[temperaturerp]= ReadTemperature(); shmcnts[epochsecsrp]= secs; shmcnts[epochmicsrp]= mics; return(0); }
/********************************** * Function : WORD ReadPhotodiode(void) * This function is overriding for reading photodiode. * The developer use this function very easier. **********************************/ WORD ReadPhotodiode(void) { return ReadTemperature(ADC_PHOTODIODE); }
void main() { float adc_a; float adc_data; int i = 0, k = 0; char send_flag = 0;//1 发送成功 0 重发 // Ds1302Init(); //ds1302初始化函数,更改时间需要用到此函数 inituart(); init_adc(); delayms(1); lcdinit(); charsend("AT+CLTS=1\r\n"); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); while (1) { while (clk_count_last != clk_count) { if (gprs_allow_flag == 1) { delayms(100); gprs_allow_flag = 0; rec_fin = 0; time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200); charsend("AT+CIPSEND=183\r\n"); delayms(100); charsend("POST /data HTTP/1.1\r\nHost:121.40.171.93\r\nContent-Length:87\r\nAuthorization:Basic dGVzdDp0ZXN0\r\n\r\n"); charsend(http_post); } if (gprs_fin_flag == 1&& gprs_fin_flag_2 == 1) { gprs_fin_flag = 0; e_gprs = 0; //互斥访问 charsend("ok2222222222222222"); } if (gprs_fin_flag == 1 && gprs_fin_flag_1 == 1) { gprs_fin_flag = 0; e_gprs = 0; //互斥访问 charsend("ok11111111"); } clk_count_last = clk_count + 1; } clk_count_last = clk_count + 1; clk_count_last = clk_count_last % 600; //datasend( get_ad()); // http_post[54] = (int)chao_data_avg_s % 10 + 48; //传感器数据存在http_post // http_post[53] = (int)chao_data_avg_s / 10 % 10 + 48; // http_post[51] = (int)chao_data_avg_s / 100 % 10 + 48; // http_post[50] = (int)chao_data_avg_s / 100 % 10 + 48; kDisplayListChar(1, 1, myitoa((int)get_ref(),4), 4); kDisplayListChar(1, 2, "13", 6); chao_data[data_count%12] = get_ad(); ///1024* 5 tan_data[data_count%12] = get_ref(); data_count++; data_count=data_count%12; temper = ReadTemperature(); kDisplayListChar(3, 4, strcat(myitoa(temper / 10, 2), "."), 3); kDisplayListChar(5, 4, myitoa(temper % 10, 1), 1); // Ds1302ReadTime(); //时间显示 // time_formchar(time_char); // /******************************************** // adc_data=get_ad(); //这两句是接压力传感器的处理函数 // range=(adc_data-0x00BD)*0.6; // //*********************************************/ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // if (clk_count % 600 % 60 == 0) //每分钟 // { // // split(chao_data, 0, 11); // split(tan_data, 0, 11); // chao_data_avg[data_count_avg%10] = average1(chao_data, 4, 7); // tan_data_avg[data_count_avg%10] = average1(tan_data, 4, 7); // data_count++; // data_count_avg=data_count_avg%10; // // datasend(chao_data_avg[data_count_avg%10]); // } } }
//---------------------------------------------------------------------- // Main Test for DS1920/DS1820 temperature measurement // int main(int argc, char **argv) { float current_temp; int i = 0; int NumDevices=0; int portnum = 0; //---------------------------------------- // Introduction header printf("\n/---------------------------------------------\n"); // printf(" Temperature application DS1920/DS1820 - Version 1.00 \n" // " The following is a test to excersize a DS1920/DS1820.\n" // " Temperature Find and Read from a: \n" // " DS1920/DS1820 (at least 1)\n\n"); printf(" Press any CTRL-C to stop this program.\n\n"); printf(" Output [Serial Number(s) ........ Temp1(F)] \n\n"); // check for required port name if (argc != 2) { printf("1-Wire Net name required on command line!\n" " (example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" " "(Linux DS2480),\"{1,5}\" (Win32 TMEX)\n"); exit(1); } // attempt to acquire the 1-Wire Net if((portnum = owAcquireEx(argv[1])) < 0) { OWERROR_DUMP(stdout); exit(1); } // success printf("Port opened: %s\n",argv[1]); // Find the device(s) NumDevices = FindDevices(portnum, &FamilySN[0], 0x10, MAXDEVICES); if (NumDevices>0) { printf("\n"); printf("Device(s) Found: \n"); for (i = 0; i < NumDevices; i++) { PrintSerialNum(FamilySN[i]); printf("\n"); } printf("\n\n"); // (stops on CTRL-C) do { // read the temperature and print serial number and temperature for (i = 0; i < NumDevices; i++) { if (ReadTemperature(portnum, FamilySN[i],¤t_temp)) { PrintSerialNum(FamilySN[i]); // printf(" %5.1f \n", current_temp * 9 / 5 + 32); printf(" %5.1f \n", current_temp ); // converting temperature from Celsius to Fahrenheit } else printf(" Error reading temperature, verify device present:%d\n", (int)owVerify(portnum, FALSE)); } printf("\n"); } while (!key_abort()); } else printf("\n\n\nERROR, device DS1920/DS1820 not found!\n"); // release the 1-Wire Net owRelease(portnum); printf("Closing port %s.\n", argv[1]); exit(0); return 0; }
/*------------------------------------------------------------- main() */ int main(int argn, char **argv) { int actboards,iab; FILE *bic; TActBoard bds[MAXBOARDS]; bic=fopen("/root/NOTES/boardsincrate","r"); if(bic==NULL) { exit(8); }; signal(SIGBUS, gotsignal); siginterrupt(SIGBUS, 0); /* first fill in bds array: */ actboards=0; while(1) { #define MAXLL 100 int rco; char line[MAXLL]; char *subs; char base[20]; char board[BNL]; subs=fgets(line,MAXLL,bic); if(subs==NULL) break; board[0]='\0'; for(rco=0; rco<BNL; rco++) { if(line[rco]=='=') break; board[rco]=line[rco]; board[rco+1]='\0'; }; if(strcmp(board,"ttcvi")==0) continue; subs= strstr(line,"=0x"); if(subs == NULL) continue; /* bad line */ strncpy(base, &subs[1], 8); base[8]='\0'; strcpy(bds[actboards].name, board); strcpy(bds[actboards].base, base); bds[actboards].temp=0; bds[actboards].crcerror=0; actboards++; }; printf("Start:%s Logmin:%d Logmax:%d Mailmin:%d Mailmax:%d\n",getdatetime(), logged.min, logged.max,mailed.min,mailed.max); for(iab=0; iab<actboards; iab++) { printf("%s ", bds[iab].base); }; printf("\n"); fflush(stdout); fclose(bic); while(1) { int logit; logit=0; /* don't log temperatures */ for(iab=0; iab<actboards; iab++) { int rcc, temp; char blength[]="0x300"; rcc= vmeopen(bds[iab].base, blength); if(rcc>0) { printf("vmeopen error:base:%s rc:%d\n",bds[iab].base,rcc); goto STPCLOSE; }; temp=ReadTemperature(); /* printf("%8s %8s %d\n", bds[iab].name,bds[iab].base , temp); */ bds[iab].temp= temp; if(temp<logged.min || temp>logged.max) logit=1; if(temp<mailed.min || temp>mailed.max) { char msg[200]; sprintf(msg, "%8s %8s %d", bds[iab].name,bds[iab].base , temp); sendmail(msg); }; /* check CRC: */ if((strcmp(bds[iab].name,"ltu")!=0) && (strcmp(bds[iab].name,"l0")!=0) ) { /* only busy, fo at 10.6.2005 */ w32 crc; crc= vmer32(ConfigStatus); if((crc & 0x40) && (bds[iab].crcerror==0)) { char msg[200]; sprintf(msg, "%s %8s %8s temp:%d -CRC ON", getdatetime(),bds[iab].name,bds[iab].base , temp); sendmail(msg); printf("%s\n",msg); bds[iab].crcerror= 1; }; }; if(buserr!=0) { printf("Was buserr\n"); buserr=0; goto STPCLOSE; }; rcc= vmeclose(); if(rcc) { printf("vmeclose error:%d\n",rcc); goto STP; }; if(quit!=0) { printf("quit:%d\n",quit); goto STP; }; }; if(logit==1) { printf("%s ", getdatetime()); for(iab=0; iab<actboards; iab++) { printf("%2d ", bds[iab].temp); }; /* printf("%s",crctxt); */ printf("\n"); fflush(stdout); }; sleep(60); }; STPCLOSE:vmeclose(); STP: ; }
void RunMenu(void) { char cTempChar = 1; // Set to any value other than 0 char zOutputStr[MAX_MEM_SIZE + 3]; // Add space for newline, return and NULL char *ptrOutputStr; eErrorType error = NO_ERROR; static DebugMenuSubType MenuAction = READ_MEMORY; static unsigned int i, Address = 0, Length = 0, Value = 0; static unsigned int Frequency = 0, Voltage = 0; // Read input characters until input buffer is empty while ((cTempChar = SCIReadChar()) != 0) { // Have another character from input buffer if (cTempChar == '\r') { // Enter character. Process input *ptrInputStr = '\0'; // append Null ptrInputStr = zInputStr; // Reset input string SCIWriteString_P(PSTR("\n\r")); // Move cursor to next line // Reset displaying of A/D samples DisplaySamples = 0; // Process entry based on debug menu state switch(MenuState) { case TOP_MENU: if (strcmp(zInputStr, "?") == 0) { // Help screen MenuState = DISPLAY_HELP_MENU1; } else if (strcmp(zInputStr, "ge") == 0) { // Display desired signal parameters // Retrieve signal parameters error = GetError(); SCIWriteString_P(PSTR(" Error = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, error, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); } else if (strcmp(zInputStr, "ce") == 0) { ClearError(); } else if (strcmp(zInputStr, "lcd") == 0) { SCIWriteString_P(PSTR(" Enter character to display (0-9 or a space): ")); MenuState = GET_LCD_CHARACTER; } else if (strcmp(zInputStr, "te") == 0) { // Display temperature int temperature; temperature = ReadTemperature(); SCIWriteString_P(PSTR(" Temperature = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, temperature, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); } else if (strcmp(zInputStr, "dsp") == 0) { // Display desired signal parameters // Retrieve signal parameters Frequency = GET_FREQ_DESIRED(); Voltage = GET_VOLT_DESIRED(); SCIWriteString_P(PSTR(" Desired Frequency = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, Frequency, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); SCIWriteString_P(PSTR(" Desired Voltage = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, Voltage, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); // Retrieve signal parameters Frequency = GET_FREQ_ACTUAL(); Voltage = GET_VOLT_ACTUAL(); SCIWriteString_P(PSTR(" Actual Frequency = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, Frequency, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); SCIWriteString_P(PSTR(" Actual Voltage = ")); ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, Voltage, 10); SCIWriteString(zOutputStr); SCIWriteString_P(PSTR("\n\r")); } else if (strcmp(zInputStr, "msp") == 0) { // Change desired signal parameters SCIWriteString(" Enter desired voltage (100 to 500): "); MenuState = SIGNAL_READ_VOLTAGE; } else if (strcmp(zInputStr, "wv") == 0) { // Change desired signal parameters SCIWriteString(" Enter desired voltage (0 to 1023): "); MenuState = WRITE_D2A; } else if (strcmp(zInputStr, "ds") == 0) { // Display A/D Samples SCIWriteString(" Hit Enter key to terminate\n\r"); DisplaySamples = 1; } else if ((strcmp(zInputStr, "rm") == 0) || (strcmp(zInputStr, "wm") == 0)) { // Memory menu if (strcmp(zInputStr, "rm") == 0) { MenuAction = READ_MEMORY; } else { MenuAction = WRITE_MEMORY; } // Get address SCIWriteString(" Address (0x100 to 0x4FF) = "); MenuState = MEMORY_GET_ADDRESS; } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case GET_LCD_CHARACTER: if (zInputStr[0] != '\0') { // Just skip NULL entries LCDChar = zInputStr[0]; // Now get position SCIWriteString_P(PSTR("\n\r Enter LCD Position(2-7): ")); MenuState = GET_LCD_POSITION; } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case GET_LCD_POSITION: if (zInputStr[0] != '\0') { // Just skip NULL entries LCDPosition = _atoi(zInputStr, 10); // Now get position MenuState = TOP_MENU; } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case WRITE_D2A: if (zInputStr[0] != '\0') { // Just skip NULL entries Voltage = _atoi(zInputStr, 10); if ((Voltage >= 0) && (Voltage <= 1023)) { // Valid voltage. Write to D/A WriteDtoASample(Voltage); } } // Back to top menu MenuState = TOP_MENU; break; case SIGNAL_READ_VOLTAGE: if (zInputStr[0] != '\0') { // Just skip NULL entries Voltage = _atoi(zInputStr, 10); // Now get frequency SCIWriteString_P(PSTR("\n\r Enter desired frequency (40 to 100): ")); MenuState = SIGNAL_READ_FREQUENCY; } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case SIGNAL_READ_FREQUENCY: if (zInputStr[0] != '\0') { // Just skip NULL entries Frequency = _atoi(zInputStr, 10); // Set the parameters if ((error = SetFreq(Frequency)) != NO_ERROR) { SCIWriteString_P(PSTR("\n\r Error setting frequency")); } else { // Set voltage if ((error = SetVolt(Voltage)) != NO_ERROR) { SCIWriteString_P(PSTR("\n\r Error setting voltage")); } } // Back to top menu MenuState = TOP_MENU; } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case MEMORY_GET_ADDRESS: if (zInputStr[0] != '\0') { // Just skip NULL entries Address = _atoi(zInputStr, 16); if ((Address < MIN_MEM_ADDR) || (Address > MAX_MEM_ADDR)) { // Address out of range SCIWriteString_P(PSTR(" Address out of range\n\r")); } else { if (MenuAction == READ_MEMORY) { // Now get length SCIWriteString_P(PSTR(" Length (in hex) = ")); } else { SCIWriteString_P(PSTR(" Value (in hex) = ")); } MenuState = MEMORY_GET_LENGTH; } } else { // No entry // Back to top menu MenuState = TOP_MENU; } break; case MEMORY_GET_LENGTH: if (zInputStr[0] != '\0') { if (MenuAction == READ_MEMORY) { Length = _atoi(zInputStr, 16); // Limit memory to available RAM if ((Address + Length - 1) > MAX_MEM_ADDR) { Length = MAX_MEM_ADDR - Address + 1; } if (Length == 0) { // default to 1 Length = 1; } if (Length > MAX_MEM_SIZE) { Length = MAX_MEM_SIZE; } SCIWriteString_P(PSTR(" Memory =")); for (i = 0; i < Length; ++i) { if ((i % 16) == 0) { SCIWriteString_P(PSTR("\n\r ")); // Display address ptrOutputStr = zOutputStr; _itoa(&ptrOutputStr, Address, 16); SCIWriteString(zOutputStr); SCIWriteString("> "); } ptrOutputStr = zOutputStr; *ptrOutputStr = *(unsigned char *)Address; ++Address; // Convert character to an ASCII string in Hex _itoa(&ptrOutputStr, (int)zOutputStr[0], 16); // Force to be 2 characters long if (strlen(zOutputStr) < 2) { zOutputStr[1] = zOutputStr[0]; zOutputStr[0]= '0'; } zOutputStr[2] = ' '; zOutputStr[3] = '\0'; SCIWriteString(zOutputStr); } SCIWriteString_P(PSTR("\n\r")); } else { // Write memory Value = _atoi(zInputStr, 16); if (Value > 0xFF) { // invalid value SCIWriteString_P(PSTR("Invalid value\n\r")); MenuState = TOP_MENU; } else { SCIWriteString_P(PSTR("Write Mem\n\r")); ptrOutputStr = (char *)Address; *ptrOutputStr = (char)Value; SCIWriteString_P(PSTR("\n\r")); } } // Back to top menu MenuState = TOP_MENU; } break; default: // Erroneous state. Reset to none MenuState = TOP_MENU; break; } // end switch // Reset string pointer. May have been moved during command processing ptrInputStr = zInputStr; if (MenuState == TOP_MENU) { // Display prompt SCIWriteString_P(PSTR("cmd> ")); } } else { // Save new character to input buffer if (ptrInputStr < &zInputStr[MAX_IN_STR_SIZE-2]) { // Buffer is not full *ptrInputStr = cTempChar; *(ptrInputStr+1) = '\0'; // Keep null in string // echo character SCIWriteString(ptrInputStr); ++ptrInputStr; } // else, buffer is full. Ignore characters. } } // End while. All characters processed if (MenuState == DISPLAY_HELP_MENU1) { // Display 1st part of help menu SCIWriteString_P(PSTR(" Commands are:\n\r")); SCIWriteString_P(PSTR(" ge - Display error code\n\r")); MenuState = DISPLAY_HELP_MENU2; } else if (MenuState == DISPLAY_HELP_MENU2) { // Display 2nd part of help menu SCIWriteString_P(PSTR(" ce - Clear current error\n\r")); SCIWriteString_P(PSTR(" lcd - Display LCD character\n\r")); MenuState = DISPLAY_HELP_MENU3; } else if (MenuState == DISPLAY_HELP_MENU3) { // Display 3rd part of help menu SCIWriteString_P(PSTR(" te - Display temperature\n\r")); SCIWriteString_P(PSTR(" wv - Write voltage to D/A\n\r")); MenuState = DISPLAY_HELP_MENU4; } else if (MenuState == DISPLAY_HELP_MENU4) { // Display 4th part of help menu SCIWriteString_P(PSTR(" dsp - Display signal parameters\n\r")); SCIWriteString_P(PSTR(" msp - Change desired signal parameters\n\r")); MenuState = DISPLAY_HELP_MENU5; } else if (MenuState == DISPLAY_HELP_MENU5) { // Display 5th part of help menu SCIWriteString_P(PSTR(" ds - Display A/D samples \n\r")); SCIWriteString_P(PSTR(" rm - Read memory\n\r")); MenuState = DISPLAY_HELP_MENU6; } else if (MenuState == DISPLAY_HELP_MENU6) { // Display 6th part of help menu SCIWriteString_P(PSTR(" wm - Write memory\r")); SCIWriteString_P(PSTR(" ? - Display this help menu\n\r")); MenuState = TOP_MENU; } }
void XShamber::Update(){ AnalogUpdate(); ReadTemperature(); ReadAngle(); }